Module: TranscodingMachine

Defined in:
lib/transcoding_machine.rb,
lib/transcoding_machine/media_format.rb,
lib/transcoding_machine/media_player.rb,
lib/transcoding_machine/server/worker.rb,
lib/transcoding_machine/client/job_queue.rb,
lib/transcoding_machine/server/s3_storage.rb,
lib/transcoding_machine/server/transcoder.rb,
lib/transcoding_machine/client/result_queue.rb,
lib/transcoding_machine/server/file_storage.rb,
lib/transcoding_machine/media_format_criterium.rb,
lib/transcoding_machine/server/ec2_environment.rb,
lib/transcoding_machine/server/media_file_attributes.rb,
lib/transcoding_machine/server/transcoding_event_listener.rb

Defined Under Namespace

Modules: Client, Server Classes: AudioFormat, MediaFormat, MediaFormatCriterium, MediaPlayer, ResultQueue, VideoFormat

Constant Summary collapse

VERSION =
"#{version[:major]}.#{version[:minor]}.#{version[:patch]}"

Class Method Summary collapse

Class Method Details

.load_models_from_hash(models_hash) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/transcoding_machine.rb', line 18

def load_models_from_hash(models_hash)
  models_hash.symbolize_keys!
  media_formats = Hash.new
  models_hash[:media_formats].each do |id, attributes|
    attributes[:id] = id
    attributes.symbolize_keys!
    if attributes[:criteria]
      attributes[:criteria].map! {|c| MediaFormatCriterium.new(:key => c['key'],
                                                               :operator => c['operator'],
                                                               :value => c['value'])}
    end
    case attributes[:type]
    when 'video'
      media_formats[id] = VideoFormat.new(attributes)
    when 'audio'
      media_formats[id] = AudioFormat.new(attributes)
    end
  end
  
  media_players = Hash.new
  models_hash[:media_players].each do |id, attributes|
    attributes[:id] = id
    attributes.symbolize_keys!
    attributes[:formats].map! {|format_id| media_formats[format_id] }
    media_players[id] = MediaPlayer.new(attributes)
  end
  
  [media_players, media_formats.values.sort {|f1, f2| f2.priority <=> f1.priority}]
end

.load_models_from_json(json_string) ⇒ Object



14
15
16
# File 'lib/transcoding_machine.rb', line 14

def load_models_from_json(json_string)
  load_models_from_hash(ActiveSupport::JSON.decode(json_string))
end