ariblib 0.1.0
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 +13 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/ariblib.gemspec +33 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ariblib.rb +14 -0
- data/lib/ariblib/BitStream.rb +68 -0
- data/lib/ariblib/Descriptor.rb +303 -0
- data/lib/ariblib/EventInformationTable.rb +184 -0
- data/lib/ariblib/ProgramSpecificInformation.rb +318 -0
- data/lib/ariblib/String.rb +325 -0
- data/lib/ariblib/TransportStreamFile.rb +283 -0
- data/lib/ariblib/version.rb +3 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6149d706fd012cbcce5bd14c61c8ba5fc39e6579
|
4
|
+
data.tar.gz: 657e53e9de56faff299e4285a58050eae90b0665
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 91518877edfa842d77bb631907299221b905121be88c8506e7aac7692885253573f0cdcda2922811d83ac33eb8015263f0999ebf7e37f6509eae8710df924726
|
7
|
+
data.tar.gz: 207f9a07dd5eae181e52316c62ecf70cf62618ee211052823b0a74c53e1d8217ac0d8b3b1e183cc8f4711973aecc28be79a79c1c4a16c9211959d41bfe144738
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 nak
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Ariblib
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ariblib`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
TODO: Write usage instructions here
|
8
|
+
|
9
|
+
<!---
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'ariblib'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install ariblib
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
TODO: Write usage instructions here
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nak1114/ariblib. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
39
|
+
-->
|
40
|
+
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
45
|
+
|
data/Rakefile
ADDED
data/ariblib.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ariblib/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ariblib"
|
8
|
+
spec.version = Ariblib::VERSION
|
9
|
+
spec.authors = ["nak1114"]
|
10
|
+
spec.email = ["naktak1114@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Implementation of ARIB STD B10}
|
13
|
+
spec.description = %q{It reads the TS format file , and outputs such as a program information .}
|
14
|
+
spec.homepage = "https://github.com/nak1114/ariblib"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
#if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
#else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
#end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ariblib"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/ariblib.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#! ruby
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
|
4
|
+
require "ariblib/version"
|
5
|
+
require "ariblib/BitStream"
|
6
|
+
require "ariblib/String"
|
7
|
+
require "ariblib/Descriptor"
|
8
|
+
require "ariblib/ProgramSpecificInformation"
|
9
|
+
require "ariblib/EventInformationTable"
|
10
|
+
require "ariblib/TransportStreamFile"
|
11
|
+
|
12
|
+
module Ariblib
|
13
|
+
# Your code goes here...
|
14
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#! ruby
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
|
4
|
+
module Ariblib
|
5
|
+
|
6
|
+
#ビットストリーム
|
7
|
+
class BitStream
|
8
|
+
def initialize(buf)
|
9
|
+
@bitstream_buffer=buf
|
10
|
+
@bitstream_postion=0
|
11
|
+
end
|
12
|
+
def str(byte)
|
13
|
+
ret=@bitstream_buffer.byteslice(@bitstream_postion/8,byte)
|
14
|
+
@bitstream_postion+=byte*8
|
15
|
+
ret
|
16
|
+
end
|
17
|
+
def getc
|
18
|
+
len=@bitstream_postion/8
|
19
|
+
@bitstream_postion+=8
|
20
|
+
ret =@bitstream_buffer.getbyte(len )
|
21
|
+
ret
|
22
|
+
end
|
23
|
+
def gets
|
24
|
+
len=@bitstream_postion/8
|
25
|
+
@bitstream_postion+=8*2
|
26
|
+
ret =@bitstream_buffer.getbyte(len ) << 8
|
27
|
+
ret|=@bitstream_buffer.getbyte(len+1)
|
28
|
+
ret
|
29
|
+
end
|
30
|
+
def get3
|
31
|
+
len=@bitstream_postion/8
|
32
|
+
@bitstream_postion+=8*3
|
33
|
+
ret =@bitstream_buffer.getbyte(len ) << 16
|
34
|
+
ret|=@bitstream_buffer.getbyte(len+1) << 8
|
35
|
+
ret|=@bitstream_buffer.getbyte(len+2)
|
36
|
+
ret
|
37
|
+
end
|
38
|
+
def read(size)
|
39
|
+
pos =@bitstream_postion>>3
|
40
|
+
modd=@bitstream_postion&0x07
|
41
|
+
@bitstream_postion+=size
|
42
|
+
mod =((~(@bitstream_postion)).succ)&0x07
|
43
|
+
poss=((size+modd+7)>>3)
|
44
|
+
tmp=0
|
45
|
+
poss.times do |i|
|
46
|
+
tmp<<=8
|
47
|
+
tmp|=@bitstream_buffer.getbyte(pos+i)
|
48
|
+
end
|
49
|
+
tmpd = (tmp>>mod) & ((1<<size)-1)
|
50
|
+
return tmpd
|
51
|
+
end
|
52
|
+
def lest
|
53
|
+
@bitstream_buffer.size*8-@bitstream_postion
|
54
|
+
end
|
55
|
+
def buf
|
56
|
+
@bitstream_buffer
|
57
|
+
end
|
58
|
+
def buf=(a)
|
59
|
+
@bitstream_buffer=a
|
60
|
+
end
|
61
|
+
def pos
|
62
|
+
@bitstream_postion
|
63
|
+
end
|
64
|
+
def pos=(a)
|
65
|
+
@bitstream_postion=a
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,303 @@
|
|
1
|
+
#! ruby
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
|
4
|
+
module Ariblib
|
5
|
+
#記述子
|
6
|
+
class Descriptor
|
7
|
+
def initialize(h,bs,tag,length)
|
8
|
+
parse(h,bs,tag,length)
|
9
|
+
end
|
10
|
+
def parse(h,bs,tag,descriptor_length)
|
11
|
+
h[:tag] << tag
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class ShortEventDescriptor < Descriptor
|
16
|
+
def parse(h,bs,tag,descriptor_length)
|
17
|
+
|
18
|
+
iso_639_language_code =bs.get3 #24 bslbf
|
19
|
+
event_name_length =bs.getc #8 uimsbf
|
20
|
+
event_name_char =Ariblib::String.new(bs,event_name_length).to_utf8
|
21
|
+
text_length =bs.getc #8 uimsbf
|
22
|
+
text_char =Ariblib::String.new(bs,text_length).to_utf8
|
23
|
+
h[:title]=event_name_char
|
24
|
+
h[:desc ]=text_char
|
25
|
+
end
|
26
|
+
end
|
27
|
+
class ExtendedEventDescriptor < Descriptor
|
28
|
+
def parse(h,bs,tag,descriptor_length)
|
29
|
+
descriptor_number =bs.read 4 #uimsbf
|
30
|
+
last_descriptor_number =bs.read 4 #uimsbf
|
31
|
+
iso_639_language_code =bs.get3 #24 bslbf
|
32
|
+
length_of_items =bs.getc #8 uimsbf
|
33
|
+
len=bs.pos+length_of_items*8
|
34
|
+
while bs.pos < len
|
35
|
+
item_description_length =bs.getc #8 uimsbf
|
36
|
+
item_description_char =Ariblib::String.new(bs,item_description_length).to_utf8
|
37
|
+
item_length =bs.getc #8 uimsbf
|
38
|
+
item_char =bs.str(item_length)
|
39
|
+
if item_description_length==0
|
40
|
+
(h[:verbose_pair].last)[1] += item_char
|
41
|
+
else
|
42
|
+
h[:verbose_pair] << [item_description_char,item_char]
|
43
|
+
end
|
44
|
+
#item_char =Ariblib::String.new(bs,item_length).to_utf8
|
45
|
+
#h[item_description_char]||=[]
|
46
|
+
#h[item_description_char] << item_char
|
47
|
+
#verbose << [item_description_char,item_char]
|
48
|
+
end
|
49
|
+
text_length =bs.getc #8 uimsbf
|
50
|
+
text_char =bs.str(text_length)
|
51
|
+
h[:verbose] += text_char
|
52
|
+
end
|
53
|
+
end
|
54
|
+
class ContentDescriptor < Descriptor
|
55
|
+
def parse(h,bs,tag,descriptor_length)
|
56
|
+
content_nibble_level_1=bs.read 4
|
57
|
+
content_nibble_level_2=bs.read 4
|
58
|
+
bs.pos+=descriptor_length-1
|
59
|
+
h[:content]=[content_nibble_level_1,content_nibble_level_2]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
class ServiceDescriptor < Descriptor
|
63
|
+
def parse(h,bs,tag,descriptor_length)
|
64
|
+
service_type =bs.read 8 #uimsbf
|
65
|
+
service_provider_name_length =bs.read 8 #uimsbf
|
66
|
+
service_provider_name =Ariblib::String.new(bs,service_provider_name_length).to_utf8#bs.str(service_provider_name_length)
|
67
|
+
service_name_length =bs.read 8 #uimsbf
|
68
|
+
service_name =Ariblib::String.new(bs,service_name_length).to_utf8#bs.str(service_name_length)
|
69
|
+
h[:service_type]=service_type
|
70
|
+
h[:service_provider_name]=service_provider_name
|
71
|
+
h[:service_name]=service_name
|
72
|
+
end
|
73
|
+
end
|
74
|
+
class DataContentDescriptor < Descriptor
|
75
|
+
def parse(h,bs,tag,descriptor_length)
|
76
|
+
data_component_id = bs.read 16 #uimsbf
|
77
|
+
entry_component = bs.getc #8 uimsbf
|
78
|
+
selector_length = bs.getc #8 uimsbf
|
79
|
+
selector_byte = bs.str(selector_length)
|
80
|
+
num_of_component_ref = bs.getc #8 uimsbf
|
81
|
+
component_ref = bs.str(num_of_component_ref)
|
82
|
+
|
83
|
+
iso_639_language_code = bs.read 24 #bslbf
|
84
|
+
text_length = bs.getc #8 uimsbf
|
85
|
+
text_char = Ariblib::String.new(bs,text_length).to_utf8
|
86
|
+
h[:data_component]=text_char
|
87
|
+
end
|
88
|
+
end
|
89
|
+
class AudioComponentDescriptor < Descriptor
|
90
|
+
def parse(h,bs,tag,descriptor_length)
|
91
|
+
text_length = descriptor_length - 9#8 uimsbf
|
92
|
+
reserved_future_use = bs.read 4 #bslbf
|
93
|
+
stream_content = bs.read 4 #uimsbf
|
94
|
+
component_type = bs.getc #8 uimsbf
|
95
|
+
component_tag = bs.getc #8 uimsbf
|
96
|
+
stream_type = bs.getc #8 uimsbf
|
97
|
+
simulcast_group_tag = bs.getc #8 bslbf
|
98
|
+
es_multi_lingual_flag = bs.read 1 #bslbf
|
99
|
+
main_component_flag = bs.read 1 #bslbf
|
100
|
+
quality_indicator = bs.read 2 #bslbf
|
101
|
+
sampling_rate = bs.read 3 #uimsbf
|
102
|
+
reserved_future_use = bs.read 1 #bslbf
|
103
|
+
iso_639_language_code = bs.read 24 #bslbf
|
104
|
+
if (es_multi_lingual_flag == 1)
|
105
|
+
iso_639_language_code_2 = bs.read 24 #bslbf
|
106
|
+
text_length-= 3
|
107
|
+
end
|
108
|
+
text_char = Ariblib::String.new(bs,text_length).to_utf8
|
109
|
+
h[:audio_component]=text_char
|
110
|
+
end
|
111
|
+
end
|
112
|
+
class ComponentDescriptor < Descriptor
|
113
|
+
def parse(h,bs,tag,descriptor_length)
|
114
|
+
text_length = descriptor_length - 6#8 uimsbf
|
115
|
+
reserved_future_use = bs.read 4 #bslbf
|
116
|
+
stream_content = bs.read 4 #uimsbf
|
117
|
+
component_type = bs.getc #8 uimsbf
|
118
|
+
component_tag = bs.getc #8 uimsbf
|
119
|
+
iso_639_language_code = bs.read 24 #bslbf
|
120
|
+
text_char = Ariblib::String.new(bs,text_length).to_utf8
|
121
|
+
h[:component]=text_char
|
122
|
+
end
|
123
|
+
end
|
124
|
+
class EventGroupDescriptor < Descriptor
|
125
|
+
def parse(h,bs,tag,descriptor_length)
|
126
|
+
list=[]
|
127
|
+
#event_group_descriptor (){
|
128
|
+
group_type = bs.read 4 #uimsbf
|
129
|
+
event_count = bs.read 4 #uimsbf
|
130
|
+
event_count.times do
|
131
|
+
service_id = bs.read 16 #uimsbf
|
132
|
+
event_id = bs.read 16 #uimsbf
|
133
|
+
list <<[service_id,event_id]
|
134
|
+
end
|
135
|
+
if(group_type == 4 || group_type ==5)
|
136
|
+
len=(descriptor_length-1-event_count*4)/8
|
137
|
+
len.times do
|
138
|
+
original_network_id = bs.read 16 #uimsbf
|
139
|
+
transport_stream_id = bs.read 16 #uimsbf
|
140
|
+
service_id = bs.read 16 #uimsbf
|
141
|
+
event_id = bs.read 16 #uimsbf
|
142
|
+
end
|
143
|
+
else
|
144
|
+
len=(descriptor_length-1-event_count*4)
|
145
|
+
private_data_byte = bs.str len #uimsbf
|
146
|
+
end
|
147
|
+
h[:event_group]=[group_type,list]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
class LogoTransmissionDescriptor < Descriptor
|
151
|
+
def parse(h,bs,tag,descriptor_length)
|
152
|
+
#h[:tag] << :digital_copy_control
|
153
|
+
logo_transmission_type = bs.read 8 #uimsbf
|
154
|
+
if(logo_transmission_type == 0x01)
|
155
|
+
reserved_future_use = bs.read 7 #bslbf
|
156
|
+
logo_id = bs.read 9 #uimsbf
|
157
|
+
reserved_future_use = bs.read 4 #bslbf
|
158
|
+
logo_version = bs.read 12 #uimsbf
|
159
|
+
download_data_id = bs.read 16 #uimsbf
|
160
|
+
h[:logo]=[logo_id,logo_version,download_data_id]
|
161
|
+
elsif(logo_transmission_type == 0x02)
|
162
|
+
reserved_future_use = bs.read 7 #bslbf
|
163
|
+
logo_id = bs.read 9 #uimsbf
|
164
|
+
h[:logo]=[logo_id]
|
165
|
+
elsif(logo_transmission_type == 0x03)
|
166
|
+
len=(descriptor_length-1)
|
167
|
+
logo_char = Ariblib::String.new(bs,len).to_utf8 #uimsbf
|
168
|
+
h[:logo_char]=logo_char
|
169
|
+
else
|
170
|
+
len=(descriptor_length-1)
|
171
|
+
reserved_future_use = bs.str len #bslbf
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
class ServiceGroupDescriptor < Descriptor
|
176
|
+
def parse(h,bs,tag,descriptor_length)
|
177
|
+
h[:tag] << :service_groupe
|
178
|
+
end
|
179
|
+
end
|
180
|
+
class DigitalCopyControlDescriptor < Descriptor
|
181
|
+
def parse(h,bs,tag,descriptor_length)
|
182
|
+
h[:tag] << :digital_copy_control
|
183
|
+
end
|
184
|
+
end
|
185
|
+
class NetworkNameDescriptor < Descriptor
|
186
|
+
def parse(h,bs,tag,descriptor_length)
|
187
|
+
network_name = Ariblib::String.new(bs,descriptor_length).to_utf8 #uimsbf
|
188
|
+
h[:network_name] = network_name
|
189
|
+
end
|
190
|
+
end
|
191
|
+
class TSInformationDescriptor < Descriptor
|
192
|
+
def parse(h,bs,tag,descriptor_length)
|
193
|
+
ret=[]
|
194
|
+
start_pos=bs.pos
|
195
|
+
remote_control_key_id = bs.read 8 #uimsbf
|
196
|
+
length_of_ts_name = bs.read 6 #uimsbf
|
197
|
+
transmission_type_count = bs.read 2 #uimsbf
|
198
|
+
ts_name_char = Ariblib::String.new(bs,length_of_ts_name).to_utf8 #uimsbf
|
199
|
+
transmission_type_count.times do
|
200
|
+
transmission_type_info = bs.read 8 #bslbf
|
201
|
+
num_of_service = bs.read 8 #uimsbf
|
202
|
+
num_of_service.times do
|
203
|
+
service_id = bs.read 16 #uimsbf
|
204
|
+
ret << service_id
|
205
|
+
end
|
206
|
+
end
|
207
|
+
len=descriptor_length-(bs.pos-start_pos)/8
|
208
|
+
#for (l = 0;l< N;l++) {
|
209
|
+
#reserved_future_use 8 bslbf
|
210
|
+
#}
|
211
|
+
h[:TS_remote_key]=remote_control_key_id
|
212
|
+
h[:TS_name]=ts_name_char
|
213
|
+
h[:TS_service]=ret
|
214
|
+
end
|
215
|
+
end
|
216
|
+
class TerrestrialDeliverySystemDescriptor < Descriptor
|
217
|
+
def parse(h,bs,tag,descriptor_length)
|
218
|
+
ret=[]
|
219
|
+
area_code = bs.read 12 #bslbf
|
220
|
+
guard_interval = bs.read 2 #bslbf
|
221
|
+
transmission_mode = bs.read 2 #bslbf
|
222
|
+
len=descriptor_length-2
|
223
|
+
(len/2).times do
|
224
|
+
frequency = bs.read 16 #uimsbf
|
225
|
+
ret << frequency
|
226
|
+
end
|
227
|
+
h[:TDS]=[area_code,transmission_mode,ret]
|
228
|
+
end
|
229
|
+
end
|
230
|
+
class PartialReceptionDescriptor < Descriptor
|
231
|
+
def parse(h,bs,tag,descriptor_length)
|
232
|
+
ret=[]
|
233
|
+
(descriptor_length/2).times do
|
234
|
+
service_id = bs.read 16 #uimsbf
|
235
|
+
ret << service_id
|
236
|
+
end
|
237
|
+
h[:PartialReception]=ret
|
238
|
+
end
|
239
|
+
end
|
240
|
+
class SystemManagementDescriptor < Descriptor
|
241
|
+
def parse(h,bs,tag,descriptor_length)
|
242
|
+
h[:tag] << :system_management
|
243
|
+
#system_management_id 16 uimsbf
|
244
|
+
#for (i=0;i <N;i++){
|
245
|
+
# additional_identification_info 8 uimsbf 不要
|
246
|
+
#}
|
247
|
+
end
|
248
|
+
end
|
249
|
+
class ServiceListDescriptor < Descriptor
|
250
|
+
def parse(h,bs,tag,descriptor_length)
|
251
|
+
ret=[]
|
252
|
+
(descriptor_length/3).times do
|
253
|
+
service_id = bs.read 16 #uimsbf
|
254
|
+
service_type = bs.read 8 #uimsbf
|
255
|
+
ret << [service_id,service_type]
|
256
|
+
end
|
257
|
+
h[:service_list]=ret
|
258
|
+
end
|
259
|
+
end
|
260
|
+
DescriptorTag={
|
261
|
+
0x4D => ShortEventDescriptor, #-----o---o n 0x4D 短形式イベント記述子*2
|
262
|
+
0x4E => ExtendedEventDescriptor, #-----o---o r 0x4E 拡張形式イベント記述子
|
263
|
+
0x54 => ContentDescriptor, #-----o---- r 0x54 コンテント記述子
|
264
|
+
80 => ComponentDescriptor, #-o---o---- r 0x50 コンポーネント記述子
|
265
|
+
196 => AudioComponentDescriptor, #-----o---- r 0xC4 音声コンポーネント記述子
|
266
|
+
0xC7 => DataContentDescriptor, #-----o---- r 0xC7 データコンテンツ記述子
|
267
|
+
214 => EventGroupDescriptor, #-----o---- r 0xD6 イベントグループ記述子
|
268
|
+
#for SDT(地上波)
|
269
|
+
0x48 => ServiceDescriptor, #----o----- n 0x48 サービス記述子*2
|
270
|
+
207 => LogoTransmissionDescriptor,#----o----- r 0xCF ロゴ伝送記述子
|
271
|
+
#for NIT(地上波)
|
272
|
+
0x40 => NetworkNameDescriptor, #--o------- n 0x40* ネットワーク名記述子*2
|
273
|
+
0x41 => ServiceListDescriptor, #--oo---o-- n 0x41* サービスリスト記述子*1
|
274
|
+
0xFA => TerrestrialDeliverySystemDescriptor,#--o------- n 0xFA* 地上分配システム記述子*1
|
275
|
+
0xFE => SystemManagementDescriptor, #-oo------- n 0xFE* システム管理記述子*1
|
276
|
+
224 => ServiceGroupDescriptor, #--o------- r 0xE0 サービスグループ記述子
|
277
|
+
0xCD => TSInformationDescriptor, #--o------- r 0xCD* TS 情報記述子
|
278
|
+
0xFB => PartialReceptionDescriptor, #--o------- j 0xFB* 部分受信記述子*1(ワンセグ)
|
279
|
+
}
|
280
|
+
DescriptorTag.default=Descriptor
|
281
|
+
DescriptorTag.freeze
|
282
|
+
end
|
283
|
+
|
284
|
+
__END__
|
285
|
+
SDT ->
|
286
|
+
->CommonDataTable ->
|
287
|
+
->EIT ->
|
288
|
+
|
289
|
+
NIT -> tpid,onid,*:service_list :TS_name || *:network_name
|
290
|
+
|
291
|
+
|
292
|
+
NIT(事業者情報)
|
293
|
+
id,(tpid,onid),ts_name,remote_key
|
294
|
+
|
295
|
+
SDT(サービス情報)
|
296
|
+
id,(tpid,onid,sid),service_type,service_name,logo_id,logo_name
|
297
|
+
|
298
|
+
EIT(番組情報)
|
299
|
+
id,(tpid,onid,sid,eid),start,fin,title,desc,colspan
|
300
|
+
|
301
|
+
CDT(ロゴ情報)
|
302
|
+
id (logo_id),logo0,1,2,3,4,5
|
303
|
+
|