va_ts/
stream_type.rs

1/// ETSI EN 300 468 V1.15.1 (2016-03)
2/// ISO/IEC 13818-1
3#[derive(Clone, Debug)]
4pub enum StreamType {
5    MPEG1Video,
6    H262,
7    MPEG1Audio, // mp2
8    MPEG2Audio, // mp2
9    MPEG2TabledData,
10    MPEG2PacketizedData, // mp3
11    MHEG,
12    DSMCCInAPacketizedStream,
13    H222AuxiliaryData,
14    DSMCCMultiprotocolEncapsulation,
15    DSMCCUNMessages,
16    DSMCCStreamDescriptors,
17    DSMCCTabledData,
18    ISOIEC138181AuxiliaryData,
19    AAC, // AAC
20    MPEG4H263Video,
21    MPEG4LOAS,
22    MPEG4FlexMux,
23    MPEG4FlexMuxTables,
24    DSMCCSynchronizedDownloadProtocol,
25    PacketizedMetadata,
26    SectionedMetadata,
27    DSMCCDataCarouselMetadata,
28    DSMCCObjectCarouselMetadata,
29    SynchronizedDownloadProtocolMetadata,
30    IPMP,
31    H264,
32    MPEG4RawAudio,
33    MPEG4Text,
34    MPEG4AuxiliaryVideo,
35    SVC,
36    MVC,
37    JPEG2000Video,
38
39    H265,
40
41    ChineseVideoStandard,
42
43    IPMPDRM,
44    H262DES64CBC,
45    AC3,          // AC3
46    SCTESubtitle, // SCTE
47    DolbyTrueHDAudio,
48    AC3DolbyDigitalPlus,
49    DTS8,
50    SCTE35,
51    AC3DolbyDigitalPlus16,
52
53    // 0x00
54    // 0x22
55    // 0x23
56    // 0x25
57    // 0x41
58    // 0x43...0x7E
59    // 0x88...0x8F
60    Reserved(u8),
61
62    Other(u8),
63}
64
65impl From<u8> for StreamType {
66    fn from(d: u8) -> Self {
67        match d {
68            0x01 => StreamType::MPEG1Video,
69            0x02 => StreamType::H262,
70            0x03 => StreamType::MPEG1Audio, // mp2
71            0x04 => StreamType::MPEG2Audio, // mp2
72            0x05 => StreamType::MPEG2TabledData,
73            0x06 => StreamType::MPEG2PacketizedData, // mp3
74            0x07 => StreamType::MHEG,
75            0x08 => StreamType::DSMCCInAPacketizedStream,
76            0x09 => StreamType::H222AuxiliaryData,
77            0x0A => StreamType::DSMCCMultiprotocolEncapsulation,
78            0x0B => StreamType::DSMCCUNMessages,
79            0x0C => StreamType::DSMCCStreamDescriptors,
80            0x0D => StreamType::DSMCCTabledData,
81            0x0E => StreamType::ISOIEC138181AuxiliaryData,
82            0x0F => StreamType::AAC, // AAC
83            0x10 => StreamType::MPEG4H263Video,
84            0x11 => StreamType::MPEG4LOAS,
85            0x12 => StreamType::MPEG4FlexMux,
86            0x13 => StreamType::MPEG4FlexMuxTables,
87            0x14 => StreamType::DSMCCSynchronizedDownloadProtocol,
88            0x15 => StreamType::PacketizedMetadata,
89            0x16 => StreamType::SectionedMetadata,
90            0x17 => StreamType::DSMCCDataCarouselMetadata,
91            0x18 => StreamType::DSMCCObjectCarouselMetadata,
92            0x19 => StreamType::SynchronizedDownloadProtocolMetadata,
93            0x1A => StreamType::IPMP,
94            0x1B => StreamType::H264,
95            0x1C => StreamType::MPEG4RawAudio,
96            0x1D => StreamType::MPEG4Text,
97            0x1E => StreamType::MPEG4AuxiliaryVideo,
98            0x1F => StreamType::SVC,
99            0x20 => StreamType::MVC,
100            0x21 => StreamType::JPEG2000Video,
101
102            0x24 => StreamType::H265,
103
104            0x42 => StreamType::ChineseVideoStandard,
105
106            0x7F => StreamType::IPMPDRM,
107            0x80 => StreamType::H262DES64CBC,
108            0x81 => StreamType::AC3,          // AC3
109            0x82 => StreamType::SCTESubtitle, // SCTE
110            0x83 => StreamType::DolbyTrueHDAudio,
111            0x84 => StreamType::AC3DolbyDigitalPlus,
112            0x85 => StreamType::DTS8,
113            0x86 => StreamType::SCTE35,
114            0x87 => StreamType::AC3DolbyDigitalPlus16,
115
116            0x00 | 0x22 | 0x23 | 0x25 | 0x41 | 0x43..=0x7E | 0x88..=0x8F => StreamType::Reserved(d),
117
118            _ => StreamType::Other(d),
119        }
120    }
121}
122
123impl From<StreamType> for u8 {
124    fn from(st: StreamType) -> u8 {
125        match st {
126            StreamType::MPEG1Video => 0x01,
127            StreamType::H262 => 0x02,
128            StreamType::MPEG1Audio => 0x03,
129            StreamType::MPEG2Audio => 0x04,
130            StreamType::MPEG2TabledData => 0x05,
131            StreamType::MPEG2PacketizedData => 0x06,
132            StreamType::MHEG => 0x07,
133            StreamType::DSMCCInAPacketizedStream => 0x08,
134            StreamType::H222AuxiliaryData => 0x09,
135            StreamType::DSMCCMultiprotocolEncapsulation => 0x0A,
136            StreamType::DSMCCUNMessages => 0x0B,
137            StreamType::DSMCCStreamDescriptors => 0x0C,
138            StreamType::DSMCCTabledData => 0x0D,
139            StreamType::ISOIEC138181AuxiliaryData => 0x0E,
140            StreamType::AAC => 0x0F,
141            StreamType::MPEG4H263Video => 0x10,
142            StreamType::MPEG4LOAS => 0x11,
143            StreamType::MPEG4FlexMux => 0x12,
144            StreamType::MPEG4FlexMuxTables => 0x13,
145            StreamType::DSMCCSynchronizedDownloadProtocol => 0x14,
146            StreamType::PacketizedMetadata => 0x15,
147            StreamType::SectionedMetadata => 0x16,
148            StreamType::DSMCCDataCarouselMetadata => 0x17,
149            StreamType::DSMCCObjectCarouselMetadata => 0x18,
150            StreamType::SynchronizedDownloadProtocolMetadata => 0x19,
151            StreamType::IPMP => 0x1A,
152            StreamType::H264 => 0x1B,
153            StreamType::MPEG4RawAudio => 0x1C,
154            StreamType::MPEG4Text => 0x1D,
155            StreamType::MPEG4AuxiliaryVideo => 0x1E,
156            StreamType::SVC => 0x1F,
157            StreamType::MVC => 0x20,
158            StreamType::JPEG2000Video => 0x21,
159
160            StreamType::H265 => 0x24,
161
162            StreamType::ChineseVideoStandard => 0x42,
163
164            StreamType::IPMPDRM => 0x7F,
165            StreamType::H262DES64CBC => 0x80,
166            StreamType::AC3 => 0x81,
167            StreamType::SCTESubtitle => 0x82,
168            StreamType::DolbyTrueHDAudio => 0x83,
169            StreamType::AC3DolbyDigitalPlus => 0x84,
170            StreamType::DTS8 => 0x85,
171            StreamType::SCTE35 => 0x86,
172            StreamType::AC3DolbyDigitalPlus16 => 0x87,
173
174            StreamType::Reserved(d) => d,
175
176            StreamType::Other(d) => d,
177        }
178    }
179}