m2ts_parser 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/m2ts_parser/appendix/arib_duration.rb +23 -0
- data/lib/m2ts_parser/appendix/arib_string.rb +27 -0
- data/lib/m2ts_parser/appendix/arib_time.rb +46 -0
- data/lib/m2ts_parser/appendix/ca_system_id.rb +34 -0
- data/lib/m2ts_parser/appendix/content_nibble.rb +160 -0
- data/lib/m2ts_parser/appendix/crc32.rb +73 -0
- data/lib/m2ts_parser/application/epg_parse.rb +66 -0
- data/lib/m2ts_parser/application/out.txt +844 -0
- data/lib/m2ts_parser/common.rb +28 -0
- data/lib/m2ts_parser/descriptor.rb +364 -0
- data/lib/m2ts_parser/mpeg_transport_stream.rb +95 -0
- data/lib/m2ts_parser/table.rb +131 -0
- data/lib/m2ts_parser/test.rb +21 -0
- data/lib/m2ts_parser/version.rb +3 -0
- data/lib/m2ts_parser.rb +23 -0
- data/m2ts_parser.gemspec +27 -0
- metadata +121 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module M2TSParser
|
3
|
+
class Code < BinaryParser::TemplateBase
|
4
|
+
def to_s
|
5
|
+
code.to_s
|
6
|
+
end
|
7
|
+
|
8
|
+
def content_description
|
9
|
+
to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
def names
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class LanguageCode < Code
|
18
|
+
Def do
|
19
|
+
data :code, Binary, 24
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class CountryCode < Code
|
24
|
+
Def do
|
25
|
+
data :code, Binary, 24
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,364 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module M2TSParser
|
3
|
+
# 6.2.1 ブーケ名記述子 (Bouquet name descriptor)
|
4
|
+
# ※ bouquet[ブーケ]:放送事業者から1 つのものとして提供されるサービス(編成チャンネル)の集合。
|
5
|
+
class BouquetNameDescriptor < BinaryParser::TemplateBase
|
6
|
+
Def do
|
7
|
+
data :descriptor_tag, UInt, 8
|
8
|
+
data :descriptor_length, UInt, 8
|
9
|
+
data :chars, Appendix::ARIBString, var(:descriptor_length) * 8
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# 6.2.2 CA 識別記述子 (CA identifier descriptor)
|
14
|
+
# ※ Conditional Access (CA) system[限定受信方式]:サービスやイベントの視聴を制御するシステム。
|
15
|
+
# ※ 特定のブーケ、サービス、イベント、あるいはコンポーネントが限定受信システムに関係しているか
|
16
|
+
# どうかを示し、さらに限定受信方式識別(CA_system_id)で限定受信システムの種別を示す。
|
17
|
+
class CAIdentifierDescriptor < BinaryParser::TemplateBase
|
18
|
+
Def do
|
19
|
+
data :descriptor_tag, UInt, 8
|
20
|
+
data :descriptor_length, UInt, 8
|
21
|
+
|
22
|
+
# この16 ビットのフィールドは、CA システムを識別する。
|
23
|
+
# このフィールド値の割当ては、標準化機関の規定による。(付録M 参照)
|
24
|
+
SPEND var(:descriptor_length) * 8, :ca_system_ids, Appendix::CASystemId
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# 6.2.3 コンポーネント記述子 (Component descriptor)
|
29
|
+
# ※ component(エレメンタリーストリーム)[コンポーネント]:イベントを構成する要素。
|
30
|
+
# 例えば、映像、音声、文字、各種データなど。
|
31
|
+
class ComponentDescriptor < BinaryParser::TemplateBase
|
32
|
+
Def do
|
33
|
+
data :descriptor_tag, UInt, 8
|
34
|
+
data :descriptor_length, UInt, 8
|
35
|
+
data :reserved_future_use, UInt, 4
|
36
|
+
data :stream_content, UInt, 4
|
37
|
+
data :component_type, UInt, 8
|
38
|
+
data :component_tag, UInt, 8
|
39
|
+
data :iso_639_language_code, LanguageCode, 24
|
40
|
+
data :text, Appendix::ARIBString, var(:descriptor_length) * 8 - 48
|
41
|
+
end
|
42
|
+
|
43
|
+
# ARIB-STD-B10 第2部 表6-5 「コンポーネント内容とコンポーネント種別」に従う定義
|
44
|
+
ComponentMapping = {
|
45
|
+
0x01 => {
|
46
|
+
0x01 => "映像480i(525i)、アスペクト比4:3",
|
47
|
+
0x02 => "映像480i(525i)、アスペクト比16:9 パンベクトルあり",
|
48
|
+
0x03 => "映像480i(525i)、アスペクト比16:9 パンベクトルなし",
|
49
|
+
0x04 => "映像480i(525i)、アスペクト比 > 16:9",
|
50
|
+
0x91 => "映像2160p、アスペクト比4:3",
|
51
|
+
0x92 => "映像2160p、アスペクト比16:9 パンベクトルあり",
|
52
|
+
0x93 => "映像2160p、アスペクト比16:9 パンベクトルなし",
|
53
|
+
0x94 => "映像2160p、アスペクト比 > 16:9",
|
54
|
+
0xA1 => "映像480p(525p)、アスペクト比4:3",
|
55
|
+
0xA2 => "映像480p(525p)、アスペクト比16:9 パンベクトルあり",
|
56
|
+
0xA3 => "映像480p(525p)、アスペクト比16:9 パンベクトルなし",
|
57
|
+
0xA4 => "映像480p(525p)、アスペクト比 > 16:9",
|
58
|
+
0xB1 => "映像1080i(1125i)、アスペクト比4:3",
|
59
|
+
0xB2 => "映像1080i(1125i)、アスペクト比16:9 パンベクトルあり",
|
60
|
+
0xB3 => "映像1080i(1125i)、アスペクト比16:9 パンベクトルなし",
|
61
|
+
0xB4 => "映像1080i(1125i)、アスペクト比 > 16:9",
|
62
|
+
0xC1 => "映像720p(750p)、アスペクト比4:3",
|
63
|
+
0xC2 => "映像720p(750p)、アスペクト比16:9 パンベクトルあり",
|
64
|
+
0xC3 => "映像720p(750p)、アスペクト比16:9 パンベクトルなし",
|
65
|
+
0xC4 => "映像720p(750p)、アスペクト比 > 16:9",
|
66
|
+
0xD1 => "映像240p アスペクト比4:3",
|
67
|
+
0xD2 => "映像240p アスペクト比16:9 パンベクトルあり",
|
68
|
+
0xD3 => "映像240p アスペクト比16:9 パンベクトルなし",
|
69
|
+
0xD4 => "映像240p アスペクト比 > 16:9",
|
70
|
+
0xE1 => "映像1080p(1125p)、アスペクト比4:3",
|
71
|
+
0xE2 => "映像1080p(1125p)、アスペクト比16:9 パンベクトルあり",
|
72
|
+
0xE3 => "映像1080p(1125p)、アスペクト比16:9 パンベクトルなし",
|
73
|
+
0xE4 => "映像1080p(1125p)、アスペクト比 > 16:9",
|
74
|
+
0xF1 => "映像180p アスペクト比4:3",
|
75
|
+
0xF2 => "映像180p アスペクト比16:9 パンベクトルあり",
|
76
|
+
0xF3 => "映像180p アスペクト比16:9 パンベクトルなし",
|
77
|
+
0xF4 => "映像180p アスペクト比 > 16:9",
|
78
|
+
},
|
79
|
+
0x02 => {
|
80
|
+
0x01 => "音声、1/0モード(シングルモノ)",
|
81
|
+
0x02 => "音声、1/0+1/0モード(デュアルモノ)",
|
82
|
+
0x03 => "音声、2/0モード(ステレオ)",
|
83
|
+
0x04 => "音声、2/1モード",
|
84
|
+
0x05 => "音声、3/0モード",
|
85
|
+
0x06 => "音声、2/2モード",
|
86
|
+
0x07 => "音声、3/1モード",
|
87
|
+
0x08 => "音声、3/2モード",
|
88
|
+
0x09 => "音声、3/2+LFEモード(3/2.1モード*1)",
|
89
|
+
0x0A => "音声、3/3.1モード*1",
|
90
|
+
0x0B => "音声、2/0/0-2/0/2-0.1モード*1",
|
91
|
+
0x0C => "音声、5/2.1モード*1",
|
92
|
+
0x0D => "音声、3/2/2.1モード*1",
|
93
|
+
0x0E => "音声、2/0/0-3/0/2-0.1モード*1",
|
94
|
+
0x0F => "音声、0/2/0-3/0/2-0.1モード*1",
|
95
|
+
0x10 => "音声、2/0/0-3/2/3-0.2モード*1",
|
96
|
+
0x11 => "音声、3/3/3-5/2/3-3/0/0.2モード*1",
|
97
|
+
0x40 => "視覚障害者用音声解説",
|
98
|
+
0x41 => "聴覚障害者用音声",
|
99
|
+
},
|
100
|
+
0x05 => {
|
101
|
+
0x01 => "H.264|MPEG-4 AVC、映像480i(525i)、アスペクト比4:3",
|
102
|
+
0x02 => "H.264|MPEG-4 AVC、映像480i(525i)、アスペクト比16:9 パンベクトルあり",
|
103
|
+
0x03 => "H.264|MPEG-4 AVC、映像480i(525i)、アスペクト比16:9 パンベクトルなし",
|
104
|
+
0x04 => "H.264|MPEG-4 AVC、映像480i(525i)、アスペクト比 > 16:9",
|
105
|
+
0x91 => "H.264|MPEG-4 AVC、映像2160p、アスペクト比4:3",
|
106
|
+
0x92 => "H.264|MPEG-4 AVC、映像2160p、アスペクト比16:9 パンベクトルあり",
|
107
|
+
0x93 => "H.264|MPEG-4 AVC、映像2160p、アスペクト比16:9 パンベクトルなし",
|
108
|
+
0x94 => "H.264|MPEG-4 AVC、映像2160p、アスペクト比 > 16:9",
|
109
|
+
0xA1 => "H.264|MPEG-4 AVC、映像480p(525p)、アスペクト比4:3",
|
110
|
+
0xA2 => "H.264|MPEG-4 AVC、映像480p(525p)、アスペクト比16:9 パンベクトルあり",
|
111
|
+
0xA3 => "H.264|MPEG-4 AVC、映像480p(525p)、アスペクト比16:9 パンベクトルなし",
|
112
|
+
0xA4 => "H.264|MPEG-4 AVC、映像480p(525p)、アスペクト比 > 16:9",
|
113
|
+
0xB1 => "H.264|MPEG-4 AVC、映像1080i(1125i)、アスペクト比4:3",
|
114
|
+
0xB2 => "H.264|MPEG-4 AVC、映像1080i(1125i)、アスペクト比16:9 パンベクトルあり",
|
115
|
+
0xB3 => "H.264|MPEG-4 AVC、映像1080i(1125i)、アスペクト比16:9 パンベクトルなし",
|
116
|
+
0xB4 => "H.264|MPEG-4 AVC、映像1080i(1125i)、アスペクト比 > 16:9",
|
117
|
+
0xC1 => "H.264|MPEG-4 AVC、映像720p(750p)、アスペクト比4:3",
|
118
|
+
0xC2 => "H.264|MPEG-4 AVC、映像720p(750p)、アスペクト比16:9 パンベクトルあり",
|
119
|
+
0xC3 => "H.264|MPEG-4 AVC、映像720p(750p)、アスペクト比16:9 パンベクトルなし",
|
120
|
+
0xC4 => "H.264|MPEG-4 AVC、映像720p(750p)、アスペクト比 > 16:9",
|
121
|
+
0xD1 => "H.264|MPEG-4 AVC、映像240p アスペクト比4:3",
|
122
|
+
0xD2 => "H.264|MPEG-4 AVC、映像240p アスペクト比16:9 パンベクトルあり",
|
123
|
+
0xD3 => "H.264|MPEG-4 AVC、映像240p アスペクト比16:9 パンベクトルなし",
|
124
|
+
0xD4 => "H.264|MPEG-4 AVC、映像240p アスペクト比 > 16:9",
|
125
|
+
0xE1 => "H.264|MPEG-4 AVC、映像1080p(1125p)、アスペクト比4:3",
|
126
|
+
0xE2 => "H.264|MPEG-4 AVC、映像1080p(1125p)、アスペクト比16:9 パンベクトルあり",
|
127
|
+
0xE3 => "H.264|MPEG-4 AVC、映像1080p(1125p)、アスペクト比16:9 パンベクトルなし",
|
128
|
+
0xE4 => "H.264|MPEG-4 AVC、映像1080p(1125p)、アスペクト比 > 16:9",
|
129
|
+
0xF1 => "H.264|MPEG-4 AVC、映像180p アスペクト比4:3",
|
130
|
+
0xF2 => "H.264|MPEG-4 AVC、映像180p アスペクト比16:9 パンベクトルあり",
|
131
|
+
0xF3 => "H.264|MPEG-4 AVC、映像180p アスペクト比16:9 パンベクトルなし",
|
132
|
+
0xF4 => "H.264|MPEG-4 AVC、映像180p アスペクト比 > 16:9",
|
133
|
+
}
|
134
|
+
}
|
135
|
+
ComponentMapping.default = {}
|
136
|
+
|
137
|
+
def component
|
138
|
+
ComponentMapping[stream_content.to_i][component_type.to_i].to_s
|
139
|
+
end
|
140
|
+
|
141
|
+
def content_description
|
142
|
+
component
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# 6.2.4 コンテント記述子 (Content descriptor)
|
147
|
+
class ContentDescriptor < BinaryParser::TemplateBase
|
148
|
+
class ContentNibble < BinaryParser::TemplateBase
|
149
|
+
Def do
|
150
|
+
data :content_nibble_level_1, UInt, 4
|
151
|
+
data :content_nibble_level_2, UInt, 4
|
152
|
+
data :user_nibble1, UInt, 4
|
153
|
+
data :user_nibble2, UInt, 4
|
154
|
+
end
|
155
|
+
|
156
|
+
def genre1
|
157
|
+
Appendix::ContentNibbleMapping[content_nibble_level_1.to_i].first
|
158
|
+
end
|
159
|
+
|
160
|
+
def genre2
|
161
|
+
Appendix::ContentNibbleMapping[content_nibble_level_1.to_i][1][content_nibble_level_2.to_i].to_s
|
162
|
+
end
|
163
|
+
|
164
|
+
def content_description
|
165
|
+
"#{genre1} - #{genre2}"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
Def do
|
170
|
+
data :descriptor_tag, UInt, 8
|
171
|
+
data :descriptor_length, UInt, 8
|
172
|
+
SPEND var(:descriptor_length) * 8, :contents, ContentNibble
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# 6.2.5 国別受信可否記述子 (Country availability descriptor)
|
177
|
+
class CountryAvailabilityDescriptor < BinaryParser::TemplateBase
|
178
|
+
Def do
|
179
|
+
data :descriptor_tag, UInt, 8
|
180
|
+
data :descriptor_length, UInt, 8
|
181
|
+
data :country_availability_flag, UInt, 1
|
182
|
+
data :reserved_future_use, UInt, 7
|
183
|
+
SPEND var(:descriptor_length) * 8 - 8, :country_codes, CountryCode
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# 6.2.6 衛星分配システム記述子 (Satellite delivery system descriptor)
|
188
|
+
class SatelliteDeliverySystemDescriptor < BinaryParser::TemplateBase
|
189
|
+
|
190
|
+
# 表6-9 「偏波」による定義
|
191
|
+
class Polarisation < BinaryParser::TemplateBase
|
192
|
+
PolarisationMapping = {
|
193
|
+
0b00 => "水平",
|
194
|
+
0b01 => "垂直",
|
195
|
+
0b10 => "左旋",
|
196
|
+
0b11 => "右旋",
|
197
|
+
}
|
198
|
+
|
199
|
+
def content_description
|
200
|
+
to_s
|
201
|
+
end
|
202
|
+
|
203
|
+
def to_s
|
204
|
+
PolarisationMapping[to_i].to_s
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# 表6-10 「衛星の変調方式」による定義
|
209
|
+
class Modulation < BinaryParser::TemplateBase
|
210
|
+
ModulationMapping = {
|
211
|
+
0b00000 => "未定義",
|
212
|
+
0b00001 => "QPSK",
|
213
|
+
0b01000 => "広帯域衛星デジタル放送方式(TMCC信号参照)",
|
214
|
+
0b01001 => "2.6GHz帯衛星デジタル音声放送方式(パイロットチャンネル参照)",
|
215
|
+
0b01010 => "高度狭帯域CSデジタル放送方式(フィジカルレイヤヘッダ及びベースバンドヘッダ参照)",
|
216
|
+
0b01011 => "高度広帯域衛星デジタル放送方式(TMCC信号参照)",
|
217
|
+
}
|
218
|
+
|
219
|
+
def content_description
|
220
|
+
to_s
|
221
|
+
end
|
222
|
+
|
223
|
+
def to_s
|
224
|
+
ModulationMapping[to_i].to_s
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
# 表6-11 「FEC(内符号)」による定義
|
229
|
+
class FEC < BinaryParser::TemplateBase
|
230
|
+
FECMapping = {
|
231
|
+
0b0000 => "未定義",
|
232
|
+
0b0001 => "符号化率1/2",
|
233
|
+
0b0010 => "符号化率2/3",
|
234
|
+
0b0011 => "符号化率3/4",
|
235
|
+
0b0100 => "符号化率5/6",
|
236
|
+
0b0101 => "符号化率7/8",
|
237
|
+
0b1000 => "広帯域衛星デジタル放送方式(TMCC信号参照)",
|
238
|
+
0b1001 => "2.6GHz帯衛星デジタル音声放送方式(パイロットチャンネル参照)",
|
239
|
+
0b1010 => "高度狭帯域CSデジタル放送方式(フィジカルレイヤヘッダ参照)",
|
240
|
+
0b1011 => "高度広帯域衛星デジタル放送方式(TMCC信号参照)",
|
241
|
+
0b1111 => "内符号なし",
|
242
|
+
}
|
243
|
+
|
244
|
+
def content_description
|
245
|
+
to_s
|
246
|
+
end
|
247
|
+
|
248
|
+
def to_s
|
249
|
+
FECMapping[to_i].to_s
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
Def do
|
254
|
+
data :descriptor_tag, UInt, 8
|
255
|
+
data :descriptor_length, UInt, 8
|
256
|
+
data :frequency, BCD_f5, 32
|
257
|
+
data :orbital_position, BCD_f1, 16
|
258
|
+
data :west_east_flag, UInt, 1
|
259
|
+
data :polarisation, Polarisation, 2
|
260
|
+
data :modulation, Modulation, 5
|
261
|
+
data :symbol_rate, BCD_f4, 28
|
262
|
+
data :fec_inner, FEC, 4
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# 6.2.7 拡張形式イベント記述子 (Extended event descriptor)
|
267
|
+
class ExtendedEventDescriptor < BinaryParser::TemplateBase
|
268
|
+
Def do
|
269
|
+
data :descriptor_tag, UInt, 8
|
270
|
+
data :descriptor_length, UInt, 8
|
271
|
+
data :descriptor_number, UInt, 4
|
272
|
+
data :last_descriptor_number, UInt, 4
|
273
|
+
data :iso_639_language_code, LanguageCode, 24
|
274
|
+
data :length_of_items, UInt, 8
|
275
|
+
SPEND var(:length_of_items) * 8, :items do
|
276
|
+
data :item_description_length, UInt, 8
|
277
|
+
data :item_description_char, Appendix::ARIBString, var(:item_description_length) * 8
|
278
|
+
data :item_length, UInt, 8
|
279
|
+
data :item_char, Appendix::ARIBString, var(:item_length) * 8
|
280
|
+
end
|
281
|
+
data :text_length, UInt, 8
|
282
|
+
data :text_char, Appendix::ARIBString, var(:text_length) * 8
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
# 6.2.8 リンク記述子 (Linkage descriptor)
|
287
|
+
|
288
|
+
|
289
|
+
# 6.2.9 モザイク記述子 (Mosaic descriptor)
|
290
|
+
|
291
|
+
|
292
|
+
# 6.2.10 NVOD 基準サービス記述子 (Near Video On Demand reference descriptor)
|
293
|
+
|
294
|
+
|
295
|
+
# 6.2.11 ネットワーク名記述子 (Network name descriptor)
|
296
|
+
|
297
|
+
|
298
|
+
# 6.2.12 パレンタルレート記述子 (Parental rating descriptor)
|
299
|
+
|
300
|
+
|
301
|
+
# 6.2.13 サービス記述子 (Service descriptor)
|
302
|
+
# ※ service[編成チャンネル]:放送事業者が編成する、スケジュールの一環として放送可能な番組の連続。
|
303
|
+
|
304
|
+
|
305
|
+
# 6.2.14 サービスリスト記述子 (Service list descriptor)
|
306
|
+
|
307
|
+
|
308
|
+
# 6.2.15 短形式イベント記述子 (Short event descriptor)
|
309
|
+
# ※ event[番組]:同一のサービスに属している開始及び終了時刻が定められた放送データス
|
310
|
+
# トリーム構成要素の集合体で、ニュース、ドラマなど一つの番組を指す。また、運用上の
|
311
|
+
# 必要に応じ、一番組中の一コーナーを指すこともできる。
|
312
|
+
class ShortEventDescriptor < BinaryParser::TemplateBase
|
313
|
+
Def do
|
314
|
+
data :descriptor_tag, UInt, 8
|
315
|
+
data :descriptor_length, UInt, 8
|
316
|
+
data :iso_639_language_code, LanguageCode, 24
|
317
|
+
data :event_name_length, UInt, 8
|
318
|
+
data :event_name, Appendix::ARIBString, var(:event_name_length) * 8
|
319
|
+
data :text_length, UInt, 8
|
320
|
+
data :text, Appendix::ARIBString, var(:text_length) * 8
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
# 6.2.16 ストリーム識別記述子 (Stream identifier descriptor)
|
325
|
+
|
326
|
+
|
327
|
+
# 6.2.17 スタッフ記述子 (Stuffing descriptor)
|
328
|
+
|
329
|
+
|
330
|
+
# 6.2.18 タイムシフトイベント記述子 (Time shifted event descriptor)
|
331
|
+
|
332
|
+
# 6.2.53 データブロードキャスト識別記述子 (data broadcast id descriptor)
|
333
|
+
|
334
|
+
|
335
|
+
# 未定義記述子
|
336
|
+
class UndefinedDescriptor < BinaryParser::TemplateBase
|
337
|
+
Def do
|
338
|
+
data :descriptor_tag, UInt, 8
|
339
|
+
data :descriptor_length, UInt, 8
|
340
|
+
data :entity, Binary, var(:descriptor_length) * 8
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
# 記述子セレクター
|
345
|
+
module Descriptor
|
346
|
+
|
347
|
+
# ARIB STD-B10 第1部 表5-3 「記述子タグ値の割当」による定義
|
348
|
+
DescriptorMapping = {
|
349
|
+
0x46 => BouquetNameDescriptor,
|
350
|
+
0x49 => CountryAvailabilityDescriptor,
|
351
|
+
0x4d => ShortEventDescriptor,
|
352
|
+
0x4e => ExtendedEventDescriptor,
|
353
|
+
0x50 => ComponentDescriptor,
|
354
|
+
0x53 => CAIdentifierDescriptor,
|
355
|
+
0x54 => ContentDescriptor,
|
356
|
+
}
|
357
|
+
DescriptorMapping.default = UndefinedDescriptor
|
358
|
+
|
359
|
+
def self.new(binary, parent_scope=nil)
|
360
|
+
descriptor_tag = binary.sub(:byte_length => 1).to_i
|
361
|
+
return DescriptorMapping[descriptor_tag].new(binary)
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# 2.4.3.1 Transport Stream (Table 2-1)
|
2
|
+
# 2.4.3.2 Transport Stream packet layer (Table 2-2)
|
3
|
+
# 2.4.3.4 Adaptation field (Table 2-6)
|
4
|
+
|
5
|
+
module M2TSParser
|
6
|
+
class MPEGTransportStream < BinaryParser::StreamTemplateBase
|
7
|
+
|
8
|
+
Def(188) do
|
9
|
+
data :sync_byte, UInt, 8
|
10
|
+
data :transport_error_indicator, UInt, 1
|
11
|
+
data :payload_unit_start_indicator, UInt, 1
|
12
|
+
data :transport_priority, UInt, 1
|
13
|
+
data :pid, UInt, 13
|
14
|
+
data :transport_scrambling_control, UInt, 2
|
15
|
+
data :adaptation_field_control, UInt, 2
|
16
|
+
data :continuity_counter, UInt, 4
|
17
|
+
|
18
|
+
IF E{ adaptation_field_control == 0b10 || adaptation_field_control == 0b11 } do
|
19
|
+
data :adaptation_field_length, UInt, 8
|
20
|
+
|
21
|
+
IF E{ adaptation_field_length > 0 } do
|
22
|
+
data :discontinuity_indicator, UInt, 1
|
23
|
+
data :random_access_indicator, UInt, 1
|
24
|
+
data :elementary_stream_priority_indicator, UInt, 1
|
25
|
+
data :pcr_flag, UInt, 1
|
26
|
+
data :opcr_flag, UInt, 1
|
27
|
+
data :splicing_point_flag, UInt, 1
|
28
|
+
data :transport_private_dataa_flag, UInt, 1
|
29
|
+
data :adaptation_field_extension_flag, UInt, 1
|
30
|
+
|
31
|
+
IF E{ pcr_flag == 1 } do
|
32
|
+
data :program_clock_reference_base, UInt, 33
|
33
|
+
data :reserved1, UInt, 6
|
34
|
+
data :program_clock_reference_extension, UInt, 9
|
35
|
+
end
|
36
|
+
|
37
|
+
IF E{ opcr_flag == 1 } do
|
38
|
+
data :original_program_clock_reference_base, UInt, 33
|
39
|
+
data :reserved2, UInt, 6
|
40
|
+
data :original_program_clock_reference_extension, UInt, 9
|
41
|
+
end
|
42
|
+
|
43
|
+
IF E{ splicing_point_flag == 1 } do
|
44
|
+
data :splice_countdown, UInt, 8
|
45
|
+
end
|
46
|
+
|
47
|
+
IF E{ transport_private_data_flag == 1 } do
|
48
|
+
data :transport_private_data_length, UInt, 8
|
49
|
+
data :private_data_bytes, Binary, var(:transport_private_data_length) * 8
|
50
|
+
end
|
51
|
+
|
52
|
+
IF E{ adaptation_field_extension_flag == 1 } do
|
53
|
+
data :adaptation_field_extension_length, UInt, 8
|
54
|
+
data :ltw_flag, UInt, 1
|
55
|
+
data :piecewise_rate_flag, UInt, 1
|
56
|
+
data :seamless_splice_flag, UInt, 1
|
57
|
+
data :reserved3, UInt, 5
|
58
|
+
|
59
|
+
IF E{ ltw_flag == 1 } do
|
60
|
+
data :ltw_valid_flag, UInt, 1
|
61
|
+
data :ltw_offset, UInt, 15
|
62
|
+
end
|
63
|
+
|
64
|
+
IF E{ piecewise_rate_flag == 1 } do
|
65
|
+
data :reserved4, UInt, 2
|
66
|
+
data :piecewise_rate, UInt, 22
|
67
|
+
end
|
68
|
+
|
69
|
+
IF E{ seamless_splice_flag == 1 } do
|
70
|
+
data :splice_type, UInt, 4
|
71
|
+
data :dts_next_au_32_30, UInt, 3
|
72
|
+
data :marker_bit1, UInt, 1
|
73
|
+
data :dts_next_au_29_15, UInt, 15
|
74
|
+
data :marker_bit2, UInt, 1
|
75
|
+
data :dts_next_au_14_0 , UInt, 15
|
76
|
+
data :marker_bit3, UInt, 1
|
77
|
+
end
|
78
|
+
|
79
|
+
data :reserved5, Binary, var(:adaptation_field_extension_length) * 8 - position
|
80
|
+
end
|
81
|
+
|
82
|
+
data :stuffing_bytes, Binary, var(:adaptation_field_length) * 8 - position
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
IF E{ adaptation_field_control == 0b01 || adaptation_field_control == 0b11 } do
|
87
|
+
data :data_bytes, Binary, rest
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def rest?
|
92
|
+
non_proceed_get_next && non_proceed_get_next.sync_byte == 0x47
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|