Class: Bitmovin::Job

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Includes:
Helpers
Defined in:
lib/bitmovin/job.rb

Overview

Represents a bitmovin Job

See Also:

Constant Summary collapse

ATTRIBUTES =
%i{
  job_id
  input_id
  output_id
  speed
  encoding_profile_id
  audio_meta_data
  manifest_types
  deinterlace
  extract_closed_captinos
  merge_audio_channel_configs
  duration
  start_time
  created_at
}

Constants included from Helpers

Helpers::S3_BUCKET_IN_URL_REGEX, Helpers::S3_BUCKET_SUBDOMAIN_REGEX, Helpers::S3_OBJECT_KEY_IN_URL_REGEX, Helpers::S3_OBJECT_KEY_SUBDOMAIN_REGEX

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

deep_camelize_keys, deep_underscore_keys, extract_bucket, extract_object_key, prepare_request_json, prepare_response_json

Constructor Details

#initialize(params = {}) ⇒ Job

Returns a new instance of Job.

Parameters:

  • params (Hash) (defaults to: {})

    Job details

Options Hash (params):

  • input_id (Integer)

    Job input id

  • output_id (Integer)

    Job output id

  • encoding_profile_id (Integer)

    Encoding profile id

  • audio_meta_data (Hash)

    Meta data of the audio streams (Only available when using standard as speed setting)

    • :default_stream_id (Integer) - Default stream id of the audio stream

    • :language (String) - Language abbreviation [ISO 639-1]

    • :label (String) - Label of the language field

  • manifest_types (Array<String>)

    Available values: mpd | m3u8

  • extract_closed_captinos (Boolean)

    Extract closed captions from the input file

  • deinterlace (Boolean)

    Create de-interlaced output

  • merge_audio_channel_configs (Hash)

    Merge multiple mono audio input streams to stereo or 5.1 audio streams (Only available when using standard as speed setting)

    • :audio_channels [Array] - Array of mono input streams



52
53
54
# File 'lib/bitmovin/job.rb', line 52

def initialize(params={})
  @details = params
end

Class Method Details

.create(params = {}) ⇒ Object

Parameters:

  • params (Hash) (defaults to: {})

    Job details

Options Hash (params):

  • input_id (Integer)

    Job input id

  • output_id (Integer)

    Job output id

  • encoding_profile_id (Integer)

    Encoding profile id

  • audio_meta_data (Hash)

    Meta data of the audio streams (Only available when using standard as speed setting)

    • :default_stream_id (Integer) - Default stream id of the audio stream

    • :language (String) - Language abbreviation [ISO 639-1]

    • :label (String) - Label of the language field

  • manifest_types (Array<String>)

    Available values: mpd | m3u8

  • extract_closed_captinos (Boolean)

    Extract closed captions from the input file

  • deinterlace (Boolean)

    Create de-interlaced output

  • merge_audio_channel_configs (Hash)

    Merge multiple mono audio input streams to stereo or 5.1 audio streams (Only available when using standard as speed setting)

    • :audio_channels [Array] - Array of mono input streams



71
72
73
# File 'lib/bitmovin/job.rb', line 71

def self.create(params={})
  new(params).create
end

.list(status = :all, page = 1, reload = false) ⇒ Array<Bitmovin::Job>

Get list of available jobs (10 Jobs per page)

Parameters:

  • status (String, Symbol) (defaults to: :all)

    Available values: all | finished | enqueued | inprogress | error

  • page (Integer) (defaults to: 1)

    number of page

  • reload (Integer) (defaults to: false)

    Force reload from server

Returns:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/bitmovin/job.rb', line 120

def list(status = :all, page = 1, reload = false)
  var_name = :"@#{status}_list#{ page }"

  val = instance_variable_get var_name

  return val if val && !reload

  get = Net::HTTP::Get.new "/api/jobs/#{ page }/#{ status }", initheaders = headers

  response = Bitmovin.http.request get

  json = prepare_response_json(response.body)
  
  value_to_set = json[:jobs].map { |p| Bitmovin::Job.new(p) }

  instance_variable_set var_name, value_to_set
end

Instance Method Details

#createBitmovin::Job

Creates a new bitmovin encoding job with params given within initialization

Returns:



78
79
80
# File 'lib/bitmovin/job.rb', line 78

def create
  make_create_request
end

#details(reload = false) ⇒ Hash

Get bitmovin encoding job details

Parameters:

  • reload (defaults to: false)

    Force reload from server

Returns:

  • (Hash)

    Bitmovin Job details



86
87
88
89
90
# File 'lib/bitmovin/job.rb', line 86

def details(reload = false)
  return @details unless reload

  reload_details
end

#manifest(reload = false) ⇒ Hash

Get bitmovin encoding job status

Parameters:

  • reload (defaults to: false)

    Force reload from server

Returns:

  • (Hash)

    Bitmovin Job details



104
105
106
107
108
# File 'lib/bitmovin/job.rb', line 104

def manifest(reload = false)
  return @manifest if !reload && @manifest

  reload_manifest
end

#status(reload = false) ⇒ Hash

Get bitmovin encoding job status

Parameters:

  • reload (defaults to: false)

    Force reload from server

Returns:

  • (Hash)

    Bitmovin Job details



95
96
97
98
99
# File 'lib/bitmovin/job.rb', line 95

def status(reload = false)
  return @status if !reload && @status

  reload_status
end