Class: Ariblib::ProgramSpecificInformation

Inherits:
Object
  • Object
show all
Defined in:
lib/ariblib/ProgramSpecificInformation.rb

Overview

PSI TSペイロード

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProgramSpecificInformation

Returns a new instance of ProgramSpecificInformation.



9
10
11
12
13
14
15
# File 'lib/ariblib/ProgramSpecificInformation.rb', line 9

def initialize
	@buf=''.force_encoding('ASCII-8BIT')
	@count=nil
	@length=nil
	@contents=[]
	@descriptor_set=DescriptorTag
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



75
76
77
# File 'lib/ariblib/ProgramSpecificInformation.rb', line 75

def contents
  @contents
end

Instance Method Details

#arib_to_utf8(buf) ⇒ Object



50
51
52
# File 'lib/ariblib/ProgramSpecificInformation.rb', line 50

def arib_to_utf8(buf)
			Ariblib::String.new(Ariblib::BitStream.new(buf),buf.length).to_utf8
end

#descriptor(bs, len) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ariblib/ProgramSpecificInformation.rb', line 53

def descriptor(bs,len)
	return nil if len==0
	h={:tag => [],
		:verbose_pair=>[],
		:verbose=>''.force_encoding('ASCII-8BIT'),
	}

	len=bs.pos+len*8
	while bs.pos < len
		descriptor_tag     =bs.getc #8 uimsbf
		descriptor_length  =bs.getc #8 uimsbf
		len2=bs.pos+descriptor_length*8
		@descriptor_set[descriptor_tag].new(h,bs,descriptor_tag,descriptor_length)
		bs.pos=len2
	end
	bs.pos=len
	h[:verbose_pair]=h[:verbose_pair].map{|v|[v[0],arib_to_utf8(v[1])]}
	h[:verbose]=arib_to_utf8(h[:verbose])
	h.delete :verbose_pair if h[:verbose_pair].size==0
	h.delete :verbose if h[:verbose].size==0
	h
end

#init_bufObject



16
17
18
19
# File 'lib/ariblib/ProgramSpecificInformation.rb', line 16

def init_buf
	@buf.clear
	@length=nil
end

#set(ts) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ariblib/ProgramSpecificInformation.rb', line 35

def set(ts)
	@count=nil if ts.continuity_counter != @count
	buf=ts.bs.str(ts.payload_length)

	if ts.payload_unit_start_indicator != 0
		set_buf(ts,buf.byteslice(1,188))

		@count=ts.continuity_counter
		init_buf
		set_buf(ts,buf.byteslice(buf.getbyte(0)+1,188))
	else
		set_buf(ts,buf)
	end
end

#set_buf(ts, buf) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ariblib/ProgramSpecificInformation.rb', line 21

def set_buf(ts,buf)
	return unless @count
	@buf+=buf
	@length=(((@buf.getbyte(1)<<8) | @buf.getbyte(2))&0x0fff)+3 if (@length==nil) && (@buf.length>=3)
	if @buf.length>=@length
		@ts=ts
		tmp =parse_buf 
		@contents << tmp if tmp 
		@count=nil
	else
		@count=(@count+1)&0x0f
	end
end