Class: F4F

Inherits:
Object
  • Object
show all
Defined in:
lib/glued/f4f.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reader) ⇒ F4F

Returns a new instance of F4F.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/glued/f4f.rb', line 6

def initialize(reader)
  @reader = reader
  @boxes = []

  # Scan for boxes in the stream see spec 1.3 F4V box format
  until (@reader.pos >= @reader.size) do
    box = next_box
    @boxes << box
    @reader.pos = box.pos + box.size
  end
end

Instance Attribute Details

#boxesObject (readonly)

Returns the value of attribute boxes.



4
5
6
# File 'lib/glued/f4f.rb', line 4

def boxes
  @boxes
end

Instance Method Details

#next_boxObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/glued/f4f.rb', line 26

def next_box
  pos = @reader.pos
  size = @reader.int32
  type = @reader.fourCC
  size = @reader.int64 if size == 1 #For boxes over 4GB the size is moved here.

  header_size = @reader.pos-pos
  content_size = size - header_size

  F4FHeader.new(pos, size, type, @reader.pos, content_size)
end

#ok?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
# File 'lib/glued/f4f.rb', line 18

def ok?
  # WARNING: There are rumours that "Some moronic servers add wrong
  # boxSize in header causing fragment verification to fail so we
  # have to fix the boxSize before processing the fragment."

  (@boxes[0].type == Bootstrap::AFRA && @boxes[1].type == Bootstrap::MOOF && @boxes[2].type == Bootstrap::MDAT)
end