Class: AviGlitch::Frame
- Inherits:
-
Object
- Object
- AviGlitch::Frame
- Defined in:
- lib/aviglitch/frame.rb
Overview
Frame is the struct of the frame data and meta-data. You can access this class through AviGlitch::Frames. To modify the binary data, operate the data
property.
Constant Summary collapse
- AVIIF_LIST =
0x00000001
- AVIIF_KEYFRAME =
0x00000010
- AVIIF_NO_TIME =
0x00000100
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#flag ⇒ Object
Returns the value of attribute flag.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compares its content.
-
#initialize(data, id, flag) ⇒ Frame
constructor
Creates a new AviGlitch::Frame object.
-
#is?(frame_type) ⇒ Boolean
Returns if it is a frame in
frame_type
. -
#is_audioframe? ⇒ Boolean
Returns if it is an audio frame.
-
#is_deltaframe? ⇒ Boolean
(also: #is_pframe?)
Returns if it is a video frame and also not a key frame.
-
#is_keyframe? ⇒ Boolean
(also: #is_iframe?)
Returns if it is a video frame and also a key frame.
-
#is_videoframe? ⇒ Boolean
Returns if it is a video frame.
Constructor Details
#initialize(data, id, flag) ⇒ Frame
Creates a new AviGlitch::Frame object.
The arguments are:
data
-
just data, without meta-data
id
-
id for the stream number and content type code (like “00dc”)
flag
-
flag that describes the chunk type (taken from idx1)
23 24 25 26 27 |
# File 'lib/aviglitch/frame.rb', line 23 def initialize data, id, flag @data = data @id = id @flag = flag end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
12 13 14 |
# File 'lib/aviglitch/frame.rb', line 12 def data @data end |
#flag ⇒ Object
Returns the value of attribute flag.
12 13 14 |
# File 'lib/aviglitch/frame.rb', line 12 def flag @flag end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/aviglitch/frame.rb', line 12 def id @id end |
Instance Method Details
#==(other) ⇒ Object
Compares its content.
75 76 77 78 79 |
# File 'lib/aviglitch/frame.rb', line 75 def == other self.id == other.id && self.flag == other.flag && self.data == other.data end |
#is?(frame_type) ⇒ Boolean
Returns if it is a frame in frame_type
.
63 64 65 66 67 68 69 70 71 |
# File 'lib/aviglitch/frame.rb', line 63 def is? frame_type return true if frame_type == :all detection = "is_#{frame_type.to_s.sub(/frames$/, 'frame')}?" begin self.send detection rescue NoMethodError => e false end end |
#is_audioframe? ⇒ Boolean
Returns if it is an audio frame.
57 58 59 |
# File 'lib/aviglitch/frame.rb', line 57 def is_audioframe? @id[2, 2] == 'wb' end |
#is_deltaframe? ⇒ Boolean Also known as: is_pframe?
Returns if it is a video frame and also not a key frame.
41 42 43 |
# File 'lib/aviglitch/frame.rb', line 41 def is_deltaframe? is_videoframe? && @flag & AVIIF_KEYFRAME == 0 end |
#is_keyframe? ⇒ Boolean Also known as: is_iframe?
Returns if it is a video frame and also a key frame.
31 32 33 |
# File 'lib/aviglitch/frame.rb', line 31 def is_keyframe? is_videoframe? && @flag & AVIIF_KEYFRAME != 0 end |
#is_videoframe? ⇒ Boolean
Returns if it is a video frame.
51 52 53 |
# File 'lib/aviglitch/frame.rb', line 51 def is_videoframe? @id[2, 2] == 'db' || @id[2, 2] == 'dc' end |