1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/// ETSI EN 300 468 V1.15.1 (2016-03)
/// ISO/IEC 13818-1
#[derive(Clone, Debug)]
pub enum StreamType {
    MPEG1Video,
    H262,
    MPEG1Audio, // mp2
    MPEG2Audio, // mp2
    MPEG2TabledData,
    MPEG2PacketizedData, // mp3
    MHEG,
    DSMCCInAPacketizedStream,
    H222AuxiliaryData,
    DSMCCMultiprotocolEncapsulation,
    DSMCCUNMessages,
    DSMCCStreamDescriptors,
    DSMCCTabledData,
    ISOIEC138181AuxiliaryData,
    AAC, // AAC
    MPEG4H263Video,
    MPEG4LOAS,
    MPEG4FlexMux,
    MPEG4FlexMuxTables,
    DSMCCSynchronizedDownloadProtocol,
    PacketizedMetadata,
    SectionedMetadata,
    DSMCCDataCarouselMetadata,
    DSMCCObjectCarouselMetadata,
    SynchronizedDownloadProtocolMetadata,
    IPMP,
    H264,
    MPEG4RawAudio,
    MPEG4Text,
    MPEG4AuxiliaryVideo,
    SVC,
    MVC,
    JPEG2000Video,

    H265,

    ChineseVideoStandard,

    IPMPDRM,
    H262DES64CBC,
    AC3,          // AC3
    SCTESubtitle, // SCTE
    DolbyTrueHDAudio,
    AC3DolbyDigitalPlus,
    DTS8,
    SCTE35,
    AC3DolbyDigitalPlus16,

    // 0x00
    // 0x22
    // 0x23
    // 0x25
    // 0x41
    // 0x43...0x7E
    // 0x88...0x8F
    Reserved(u8),

    Other(u8),
}

impl From<u8> for StreamType {
    fn from(d: u8) -> Self {
        match d {
            0x01 => StreamType::MPEG1Video,
            0x02 => StreamType::H262,
            0x03 => StreamType::MPEG1Audio, // mp2
            0x04 => StreamType::MPEG2Audio, // mp2
            0x05 => StreamType::MPEG2TabledData,
            0x06 => StreamType::MPEG2PacketizedData, // mp3
            0x07 => StreamType::MHEG,
            0x08 => StreamType::DSMCCInAPacketizedStream,
            0x09 => StreamType::H222AuxiliaryData,
            0x0A => StreamType::DSMCCMultiprotocolEncapsulation,
            0x0B => StreamType::DSMCCUNMessages,
            0x0C => StreamType::DSMCCStreamDescriptors,
            0x0D => StreamType::DSMCCTabledData,
            0x0E => StreamType::ISOIEC138181AuxiliaryData,
            0x0F => StreamType::AAC, // AAC
            0x10 => StreamType::MPEG4H263Video,
            0x11 => StreamType::MPEG4LOAS,
            0x12 => StreamType::MPEG4FlexMux,
            0x13 => StreamType::MPEG4FlexMuxTables,
            0x14 => StreamType::DSMCCSynchronizedDownloadProtocol,
            0x15 => StreamType::PacketizedMetadata,
            0x16 => StreamType::SectionedMetadata,
            0x17 => StreamType::DSMCCDataCarouselMetadata,
            0x18 => StreamType::DSMCCObjectCarouselMetadata,
            0x19 => StreamType::SynchronizedDownloadProtocolMetadata,
            0x1A => StreamType::IPMP,
            0x1B => StreamType::H264,
            0x1C => StreamType::MPEG4RawAudio,
            0x1D => StreamType::MPEG4Text,
            0x1E => StreamType::MPEG4AuxiliaryVideo,
            0x1F => StreamType::SVC,
            0x20 => StreamType::MVC,
            0x21 => StreamType::JPEG2000Video,

            0x24 => StreamType::H265,

            0x42 => StreamType::ChineseVideoStandard,

            0x7F => StreamType::IPMPDRM,
            0x80 => StreamType::H262DES64CBC,
            0x81 => StreamType::AC3,          // AC3
            0x82 => StreamType::SCTESubtitle, // SCTE
            0x83 => StreamType::DolbyTrueHDAudio,
            0x84 => StreamType::AC3DolbyDigitalPlus,
            0x85 => StreamType::DTS8,
            0x86 => StreamType::SCTE35,
            0x87 => StreamType::AC3DolbyDigitalPlus16,

            0x00 | 0x22 | 0x23 | 0x25 | 0x41 | 0x43..=0x7E | 0x88..=0x8F => StreamType::Reserved(d),

            _ => StreamType::Other(d),
        }
    }
}

impl From<StreamType> for u8 {
    fn from(st: StreamType) -> u8 {
        match st {
            StreamType::MPEG1Video => 0x01,
            StreamType::H262 => 0x02,
            StreamType::MPEG1Audio => 0x03,
            StreamType::MPEG2Audio => 0x04,
            StreamType::MPEG2TabledData => 0x05,
            StreamType::MPEG2PacketizedData => 0x06,
            StreamType::MHEG => 0x07,
            StreamType::DSMCCInAPacketizedStream => 0x08,
            StreamType::H222AuxiliaryData => 0x09,
            StreamType::DSMCCMultiprotocolEncapsulation => 0x0A,
            StreamType::DSMCCUNMessages => 0x0B,
            StreamType::DSMCCStreamDescriptors => 0x0C,
            StreamType::DSMCCTabledData => 0x0D,
            StreamType::ISOIEC138181AuxiliaryData => 0x0E,
            StreamType::AAC => 0x0F,
            StreamType::MPEG4H263Video => 0x10,
            StreamType::MPEG4LOAS => 0x11,
            StreamType::MPEG4FlexMux => 0x12,
            StreamType::MPEG4FlexMuxTables => 0x13,
            StreamType::DSMCCSynchronizedDownloadProtocol => 0x14,
            StreamType::PacketizedMetadata => 0x15,
            StreamType::SectionedMetadata => 0x16,
            StreamType::DSMCCDataCarouselMetadata => 0x17,
            StreamType::DSMCCObjectCarouselMetadata => 0x18,
            StreamType::SynchronizedDownloadProtocolMetadata => 0x19,
            StreamType::IPMP => 0x1A,
            StreamType::H264 => 0x1B,
            StreamType::MPEG4RawAudio => 0x1C,
            StreamType::MPEG4Text => 0x1D,
            StreamType::MPEG4AuxiliaryVideo => 0x1E,
            StreamType::SVC => 0x1F,
            StreamType::MVC => 0x20,
            StreamType::JPEG2000Video => 0x21,

            StreamType::H265 => 0x24,

            StreamType::ChineseVideoStandard => 0x42,

            StreamType::IPMPDRM => 0x7F,
            StreamType::H262DES64CBC => 0x80,
            StreamType::AC3 => 0x81,
            StreamType::SCTESubtitle => 0x82,
            StreamType::DolbyTrueHDAudio => 0x83,
            StreamType::AC3DolbyDigitalPlus => 0x84,
            StreamType::DTS8 => 0x85,
            StreamType::SCTE35 => 0x86,
            StreamType::AC3DolbyDigitalPlus16 => 0x87,

            StreamType::Reserved(d) => d,

            StreamType::Other(d) => d,
        }
    }
}