Skip to main content

dvb_subtitle/
lib.rs

1#![doc = include_str!("../README.md")]
2#![no_std]
3#![cfg_attr(docsrs, feature(doc_cfg))]
4#![warn(missing_docs)]
5// Runnable examples, embedded so they render on docs.rs and stay in sync with
6// the actual `examples/*.rs` files (shown, not compiled).
7#![doc = "\n# Examples\n"]
8#![doc = "Two runnable examples ship with this crate (`cargo run -p dvb-subtitle --example <name>`).\n"]
9#![doc = "\n## `parse_segment`\n\n```rust,ignore"]
10#![doc = include_str!("../examples/parse_segment.rs")]
11#![doc = "```\n\n## `parse_full_pes`\n\n```rust,ignore"]
12#![doc = include_str!("../examples/parse_full_pes.rs")]
13#![doc = "```"]
14
15extern crate alloc;
16
17mod any;
18mod error;
19mod pes_data_field;
20mod segments;
21mod traits;
22
23pub use any::AnySegment;
24pub use error::{Error, Result};
25pub use pes_data_field::PesDataField;
26pub use traits::SegmentDef;
27
28/// The `data_identifier` for DVB subtitle streams (0x20).
29pub use pes_data_field::DATA_IDENTIFIER;
30/// The `end_of_PES_data_field_marker` (0xFF).
31pub use pes_data_field::END_OF_PES_MARKER;
32/// The `subtitle_stream_id` identifying a DVB subtitle stream (0x00).
33pub use pes_data_field::SUBTITLE_STREAM_ID;
34/// The sync_byte prefixing each subtitling segmentation (0x0F).
35pub use pes_data_field::SYNC_BYTE;
36
37// Re-export segment types and enums for convenience.
38pub use segments::alternative_clut::{
39    AlternativeClutEntry, AlternativeClutSegment, ClutParameters, DynamicRangeColourGamut,
40    OutputBitDepth,
41};
42pub use segments::clut_definition::{ClutDefinitionSegment, ClutEntry};
43pub use segments::disparity_signalling::{
44    DisparityRegion, DisparityShiftInterval, DisparityShiftUpdateSequence,
45    DisparitySignallingSegment, Subregion,
46};
47pub use segments::display_definition::DisplayDefinitionSegment;
48pub use segments::end_of_display_set::EndOfDisplaySetSegment;
49pub use segments::object_data::{
50    DataType, InterlacedPixelsData, ObjectCodingMethod, ObjectDataPayload, ObjectDataSegment,
51    PixelDataSubBlock, PixelRun, PixelRunIter, ProgressivePixelBlock,
52};
53pub use segments::page_composition::{PageCompositionSegment, PageRegionEntry, PageState};
54pub use segments::region_composition::{
55    ObjectProviderFlag, ObjectType, RegionCompositionSegment, RegionDepth,
56    RegionLevelOfCompatibility, RegionObjectEntry,
57};
58pub use segments::stuffing::StuffingSegment;
59
60// Implement SegmentDef for each type
61impl SegmentDef<'_> for DisplayDefinitionSegment {
62    const SEGMENT_TYPE: u8 = segments::display_definition::SEGMENT_TYPE;
63    const NAME: &'static str = "DISPLAY_DEFINITION";
64}
65
66impl SegmentDef<'_> for PageCompositionSegment {
67    const SEGMENT_TYPE: u8 = segments::page_composition::SEGMENT_TYPE;
68    const NAME: &'static str = "PAGE_COMPOSITION";
69}
70
71impl SegmentDef<'_> for RegionCompositionSegment {
72    const SEGMENT_TYPE: u8 = segments::region_composition::SEGMENT_TYPE;
73    const NAME: &'static str = "REGION_COMPOSITION";
74}
75
76impl SegmentDef<'_> for ClutDefinitionSegment {
77    const SEGMENT_TYPE: u8 = segments::clut_definition::SEGMENT_TYPE;
78    const NAME: &'static str = "CLUT_DEFINITION";
79}
80
81impl<'a> SegmentDef<'a> for ObjectDataSegment<'a> {
82    const SEGMENT_TYPE: u8 = segments::object_data::SEGMENT_TYPE;
83    const NAME: &'static str = "OBJECT_DATA";
84}
85
86impl SegmentDef<'_> for EndOfDisplaySetSegment {
87    const SEGMENT_TYPE: u8 = segments::end_of_display_set::SEGMENT_TYPE;
88    const NAME: &'static str = "END_OF_DISPLAY_SET";
89}
90
91impl SegmentDef<'_> for DisparitySignallingSegment {
92    const SEGMENT_TYPE: u8 = segments::disparity_signalling::SEGMENT_TYPE;
93    const NAME: &'static str = "DISPARITY_SIGNALLING";
94}
95
96impl SegmentDef<'_> for AlternativeClutSegment {
97    const SEGMENT_TYPE: u8 = segments::alternative_clut::SEGMENT_TYPE;
98    const NAME: &'static str = "ALTERNATIVE_CLUT";
99}
100
101impl<'a> SegmentDef<'a> for StuffingSegment<'a> {
102    const SEGMENT_TYPE: u8 = segments::stuffing::SEGMENT_TYPE;
103    const NAME: &'static str = "STUFFING";
104}