Class: FLV::Edit::Processor::Join

Inherits:
Base
  • Object
show all
Defined in:
lib/flv/edit/processor/join.rb

Constant Summary

Constants inherited from Base

Base::ALL_EVENTS, Base::EVENT_TRIGGER, Base::EVENT_TRIGGER_LIST, Base::MAIN_EVENTS

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#absorb, #dispatch_chunk, #dispatch_chunks, #dispatch_instead, #each, #has_next_file?, #initialize, #process_all, #rewind, #stdout, #stop

Constructor Details

This class inherits a constructor from FLV::Edit::Processor::Base

Instance Method Details

#on_header(h) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/flv/edit/processor/join.rb', line 32

def on_header(h)
  if is_first_header = !@delta
    @delta = 0
    @wait_for_keyframe = false
    @last_video_timestamp = 0
  else
    if @last_video_timestamp
      last_interval = @last_video_timestamp - @next_to_last_video_timestamp
      @delta += [@last_video_timestamp + last_interval, @last_timestamp].max
      @wait_for_keyframe = true
    else
      @delta = @last_timestamp
    end
    dispatch_instead(Tag.new(@last_timestamp, evt = Event.new(:onNextSegment, :file => ::File.basename(h.path))))
  end
end

#on_keyframe(tag) ⇒ Object



25
26
27
28
29
30
# File 'lib/flv/edit/processor/join.rb', line 25

def on_keyframe(tag)
  if @wait_for_keyframe
    @wait_for_keyframe = false
    @delta -= tag.timestamp
  end
end

#on_tag(tag) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/flv/edit/processor/join.rb', line 12

def on_tag(tag)
  if @wait_for_keyframe
    absorb
  else
    tag.timestamp += @delta
  end
  @last_timestamp = tag.timestamp
end

#on_video(tag) ⇒ Object



21
22
23
# File 'lib/flv/edit/processor/join.rb', line 21

def on_video(tag)
  @next_to_last_video_timestamp, @last_video_timestamp = @last_video_timestamp, tag.timestamp
end

#process_next_fileObject



8
9
10
# File 'lib/flv/edit/processor/join.rb', line 8

def process_next_file
  dispatch_chunks(@source) while @source.has_next_file?
end