Class: FLV::FLVTag
- Inherits:
-
Object
show all
- Defined in:
- lib/flv/tag.rb
Constant Summary
collapse
- AUDIO =
8
- VIDEO =
9
- META =
18
- UNDEFINED =
0
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(stream = nil) ⇒ FLVTag
Returns a new instance of FLVTag.
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/flv/tag.rb', line 43
def initialize(stream = nil)
@tag_type = UNDEFINED
@byte_offset = nil
unless stream.nil?
data_size = stream.read__UI24
@timestamp = stream.read__UI24
stream.read__UI32
@data = stream.read(data_size)
else
@timestamp = 0
@data = ''
end
after_initialize(stream.nil?) if respond_to? :after_initialize
end
|
Instance Attribute Details
#byte_offset ⇒ Object
Returns the value of attribute byte_offset.
39
40
41
|
# File 'lib/flv/tag.rb', line 39
def byte_offset
@byte_offset
end
|
#tag_type ⇒ Object
Returns the value of attribute tag_type.
39
40
41
|
# File 'lib/flv/tag.rb', line 39
def tag_type
@tag_type
end
|
#timestamp ⇒ Object
Returns the value of attribute timestamp.
39
40
41
|
# File 'lib/flv/tag.rb', line 39
def timestamp
@timestamp
end
|
Class Method Details
.type2name(type) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/flv/tag.rb', line 96
def self.type2name(type)
case type
when AUDIO
'audio'
when VIDEO
'video'
when META
'meta'
when UNDEFINED
'undefined'
else
"unknown(#{type})"
end
end
|
Instance Method Details
#data ⇒ Object
68
69
70
|
# File 'lib/flv/tag.rb', line 68
def data
@data
end
|
#data_size ⇒ Object
72
73
74
|
# File 'lib/flv/tag.rb', line 72
def data_size
data.length
end
|
#info ⇒ Object
84
85
86
|
# File 'lib/flv/tag.rb', line 84
def info
"#{name}: timestamp #{timestamp}, size #{size}, data size #{data_size}"
end
|
#inspect ⇒ Object
88
89
90
91
92
93
94
|
# File 'lib/flv/tag.rb', line 88
def inspect
out = ["tag: #{self.class}"]
out << "timestamp: #{@timestamp}"
out << "size: #{size}"
out << "data_size: #{data_size}"
out
end
|
#name ⇒ Object
64
65
66
|
# File 'lib/flv/tag.rb', line 64
def name
'Unknown Tag'
end
|
#serialize(stream) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/flv/tag.rb', line 76
def serialize(stream)
stream.write__UI8 tag_type
stream.write__UI24 data_size
stream.write__UI24 timestamp
stream.write__UI32 0
stream.write__STRING data
end
|
#size ⇒ Object
59
60
61
62
|
# File 'lib/flv/tag.rb', line 59
def size
11 + data_size
end
|