Class: EncodingQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/enigmamachine/encoding_queue.rb

Instance Method Summary collapse

Constructor Details

#initializeEncodingQueue

Adds a periodic timer to the Eventmachine reactor loop and immediately starts looking for unencoded videos.



8
9
10
11
12
# File 'lib/enigmamachine/encoding_queue.rb', line 8

def initialize
  EM.add_periodic_timer(5) {
    encode_next_video
  }
end

Instance Method Details

#encode_next_videoObject

Gets the next unencoded Video from the database and starts encoding its file.



17
18
19
20
21
22
23
24
25
26
# File 'lib/enigmamachine/encoding_queue.rb', line 17

def encode_next_video
  if Video.unencoded.count > 0 && Video.encoding.count < EnigmaMachine.threads
    video = Video.unencoded.first
    begin
      video.encode!
    rescue Exception => ex
      # don't do anything just yet, until we set up logging properly.
    end
  end
end