Skip to main content

dvb_bbframe/
lib.rs

1//! ETSI DVB-S2 / S2X / T2 BBFrame parser + builder.
2//!
3//! Supports both Normal Mode (NM) and High Efficiency Mode (HEM)
4//! per EN 302 755 v1.4.1 §5.1.7.
5//!
6//! Entry points:
7//! - [`header::Bbheader`] — the 10-byte BBHEADER with parse + serialize.
8//! - [`packet::up_iter`] — user packet extraction from the data field.
9//! - [`pump::BbframePump`] — per-PLP BBFrame→inner-TS pump (orchestrates header
10//!   parse + carry-over extraction).
11//! - [`crc::crc8`] — CRC-8 encoder (EN 302 307-1 §5.1.4 / EN 302 755 Annex F).
12//! - [`issy`] — ISSY field parser (EN 302 755 Annex C).
13//!
14//! # Quick start
15//! ```
16//! use dvb_bbframe::header::{Bbheader, Matype, Mode, TsGs, BBHEADER_LEN};
17//!
18//! let hdr = Bbheader {
19//!     matype: Matype { ts_gs: TsGs::Ts, sis: true, ccm: true, issyi: false, npd: false, ext: 0, isi: 0 },
20//!     upl: 1504, sync: 0x47, dfl: 1504, syncd: 0, mode: Mode::Normal, issy_in_header: None,
21//! };
22//! let bytes = hdr.serialize();              // 10-byte BBHEADER
23//! assert_eq!(bytes.len(), BBHEADER_LEN);
24//! assert_eq!(Bbheader::parse(&bytes).unwrap(), hdr); // byte-identical round-trip
25//! ```
26//! For recovering the inner TS carried in a T2-MI stream, see
27//! `dvb_t2mi::inner_ts::InnerTsRecovery`, which drives this header + the
28//! [`packet`] extractor for you.
29//!
30//! # Generic Stream (GSE) handoff
31//!
32//! When `Bbheader::parse` yields `matype.ts_gs == TsGs::Gse`, the data field
33//! carries GSE (Generic Stream Encapsulation) packets (EN 302 307-1 / EN 302 755).
34//! GSE parsing is out of scope for this crate — hand the data field to the
35//! third-party `dvb-gse` crate:
36//!
37//! ```ignore
38//! use dvb_bbframe::header::{Bbheader, TsGs, BBHEADER_LEN};
39//!
40//! let hdr = Bbheader::parse(df_bytes).unwrap();
41//! let data_field = &df_bytes[BBHEADER_LEN..];
42//! match hdr.matype.ts_gs {
43//!     TsGs::Ts => {
44//!         /* TS user packets: dvb_bbframe::packet::up_iter(data_field, &hdr) */
45//!     }
46//!     TsGs::Gse => {
47//!         /* GSE packets: hand `data_field` to the `dvb-gse` crate */
48//!     }
49//!     other => {
50//!         /* GFPS / GCS — generic continuous or packetized */
51//!     }
52//! }
53//! ```
54//!
55//! # RFU policy
56//!
57//! BBFrame `reserved_future_use` bits are **emitted as 1** and
58//! `reserved_zero_future_use` bits as **0**, following the DVB convention.
59//! Parsers accept any value (no rejection on non-zero RFU) for forward
60//! compatibility.
61
62#![warn(missing_docs)]
63#![cfg_attr(not(feature = "std"), no_std)]
64#![cfg_attr(docsrs, feature(doc_cfg))]
65// Runnable examples, embedded so they render on docs.rs and stay in sync with
66// the actual `examples/*.rs` files (shown, not compiled).
67#![doc = "\n# Examples\n"]
68#![doc = "Two runnable examples ship with this crate (`cargo run -p dvb-bbframe --example <name>`).\n"]
69#![doc = "\n## `parse_bbheader`\n\n```rust,ignore"]
70#![doc = include_str!("../examples/parse_bbheader.rs")]
71#![doc = "```\n\n## `walk_capture`\n\n```rust,ignore"]
72#![doc = include_str!("../examples/walk_capture.rs")]
73#![doc = "```"]
74
75extern crate alloc;
76
77pub mod crc;
78pub mod error;
79pub mod header;
80pub mod issy;
81pub mod packet;
82pub mod pump;
83
84pub use error::{Error, Result};