bitmovin-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +13 -0
  6. data/Gemfile.lock +125 -0
  7. data/Guardfile +70 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +44 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/bitmovin-ruby.gemspec +31 -0
  14. data/examples/simple_dash.rb +191 -0
  15. data/lib/bitmovin/bitmovin_error.rb +7 -0
  16. data/lib/bitmovin/child_collection.rb +41 -0
  17. data/lib/bitmovin/client.rb +35 -0
  18. data/lib/bitmovin/configuration_resource.rb +4 -0
  19. data/lib/bitmovin/encoding/codec_configurations/aac_configuration.rb +7 -0
  20. data/lib/bitmovin/encoding/codec_configurations/h264_configuration.rb +9 -0
  21. data/lib/bitmovin/encoding/codec_configurations/h265_configuration.rb +8 -0
  22. data/lib/bitmovin/encoding/codec_configurations/vp9_configuration.rb +8 -0
  23. data/lib/bitmovin/encoding/codec_configurations.rb +23 -0
  24. data/lib/bitmovin/encoding/encodings/encoding_task.rb +67 -0
  25. data/lib/bitmovin/encoding/encodings/list.rb +39 -0
  26. data/lib/bitmovin/encoding/encodings/muxing_list.rb +19 -0
  27. data/lib/bitmovin/encoding/encodings/muxings/fmp4_muxing.rb +5 -0
  28. data/lib/bitmovin/encoding/encodings/muxings/fmp4_muxing_list.rb +5 -0
  29. data/lib/bitmovin/encoding/encodings/muxings/mp4_muxing.rb +4 -0
  30. data/lib/bitmovin/encoding/encodings/muxings/mp4_muxing_list.rb +5 -0
  31. data/lib/bitmovin/encoding/encodings/muxings/muxing_resource.rb +56 -0
  32. data/lib/bitmovin/encoding/encodings/muxings/ts_muxing.rb +5 -0
  33. data/lib/bitmovin/encoding/encodings/muxings/ts_muxing_list.rb +5 -0
  34. data/lib/bitmovin/encoding/encodings/muxings/webm_muxing.rb +5 -0
  35. data/lib/bitmovin/encoding/encodings/muxings/webm_muxing_list.rb +5 -0
  36. data/lib/bitmovin/encoding/encodings/stream.rb +102 -0
  37. data/lib/bitmovin/encoding/encodings/stream_input.rb +51 -0
  38. data/lib/bitmovin/encoding/encodings/stream_list.rb +5 -0
  39. data/lib/bitmovin/encoding/encodings.rb +24 -0
  40. data/lib/bitmovin/encoding/inputs/analysis.rb +27 -0
  41. data/lib/bitmovin/encoding/inputs/analysis_task.rb +73 -0
  42. data/lib/bitmovin/encoding/inputs/aspera_input.rb +7 -0
  43. data/lib/bitmovin/encoding/inputs/azure_input.rb +8 -0
  44. data/lib/bitmovin/encoding/inputs/ftp_input.rb +7 -0
  45. data/lib/bitmovin/encoding/inputs/gcs_input.rb +7 -0
  46. data/lib/bitmovin/encoding/inputs/generic_s3_input.rb +7 -0
  47. data/lib/bitmovin/encoding/inputs/http_input.rb +7 -0
  48. data/lib/bitmovin/encoding/inputs/https_input.rb +7 -0
  49. data/lib/bitmovin/encoding/inputs/rtmp_input.rb +6 -0
  50. data/lib/bitmovin/encoding/inputs/s3_input.rb +7 -0
  51. data/lib/bitmovin/encoding/inputs/sftp_input.rb +7 -0
  52. data/lib/bitmovin/encoding/inputs.rb +27 -0
  53. data/lib/bitmovin/encoding/manifests/audio_adaptation_set.rb +22 -0
  54. data/lib/bitmovin/encoding/manifests/dash_manifest.rb +56 -0
  55. data/lib/bitmovin/encoding/manifests/dash_representations.rb +14 -0
  56. data/lib/bitmovin/encoding/manifests/fmp4_representation.rb +18 -0
  57. data/lib/bitmovin/encoding/manifests/hls_manifest.rb +7 -0
  58. data/lib/bitmovin/encoding/manifests/manifest_resource.rb +16 -0
  59. data/lib/bitmovin/encoding/manifests/period.rb +17 -0
  60. data/lib/bitmovin/encoding/manifests/video_adaptation.rb +8 -0
  61. data/lib/bitmovin/encoding/manifests/video_adaptation_set.rb +22 -0
  62. data/lib/bitmovin/encoding/manifests.rb +23 -0
  63. data/lib/bitmovin/encoding/outputs/gcs_output.rb +6 -0
  64. data/lib/bitmovin/encoding/outputs/s3_output.rb +6 -0
  65. data/lib/bitmovin/encoding/outputs.rb +17 -0
  66. data/lib/bitmovin/encoding/stream_output.rb +44 -0
  67. data/lib/bitmovin/encoding.rb +10 -0
  68. data/lib/bitmovin/helpers.rb +55 -0
  69. data/lib/bitmovin/input_resource.rb +16 -0
  70. data/lib/bitmovin/resource.rb +86 -0
  71. data/lib/bitmovin/version.rb +3 -0
  72. data/lib/bitmovin.rb +30 -0
  73. metadata +225 -0
@@ -0,0 +1,8 @@
1
+ module Bitmovin::Encoding::CodecConfigurations
2
+ class H265Configuration < Bitmovin::ConfigurationResource
3
+ init 'encoding/configurations/video/h265'
4
+
5
+ attr_accessor :id, :name, :description, :created_at, :modified_at
6
+ attr_accessor :name, :description, :bitrate, :rate, :profile, :bframes, :ref_frames, :qp, :max_bitrate, :min_bitrate, :bufsize, :min_gop, :max_gop, :level, :rc_lookahead, :b_adapt, :max_ctu_size, :tu_intra_depth, :tu_inter_depth, :motion_search, :sub_me, :motion_search_range, :weight_prediction_on_p_slice, :weight_prediction_on_b_slice, :sao
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Bitmovin::Encoding::CodecConfigurations
2
+ class Vp9Configuration < Bitmovin::ConfigurationResource
3
+ init 'encoding/configurations/video/vp9'
4
+
5
+ attr_accessor :id, :name, :description, :created_at, :modified_at
6
+ attr_accessor :bitrate, :rate, :tile_columns, :tile_rows, :frame_parallel, :max_intra_rate, :qp_min, :qp_max, :rate_undershoot_pct, :rate_overshoot_pct, :cpu_used, :quality, :lossless, :aq_mode, :arnr_max_frames, :arnr_strength, :arnr_type
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ module Bitmovin::Encoding
2
+ module CodecConfigurations
3
+ def CodecConfigurations.list(limit = 100, offset = 0)
4
+ response = Bitmovin.client.get '/v1/encoding/configurations', { limit: limit, offset: offset }
5
+ Bitmovin::Helpers.result(response)['items'].map do |item|
6
+ case item['type'].downcase
7
+ when "h264"
8
+ H264Configuration.new(item)
9
+ when "h265"
10
+ H265Configuration.new(item)
11
+ when "aac"
12
+ AacConfiguration.new(item)
13
+ when "vp9"
14
+ Vp9Configuration.new(item)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ require 'bitmovin/encoding/codec_configurations/h264_configuration'
21
+ require 'bitmovin/encoding/codec_configurations/h265_configuration'
22
+ require 'bitmovin/encoding/codec_configurations/aac_configuration'
23
+ require 'bitmovin/encoding/codec_configurations/vp9_configuration'
@@ -0,0 +1,67 @@
1
+ module Bitmovin::Encoding::Encodings
2
+ class EncodingTask < Bitmovin::Resource
3
+ init "/v1/encoding/encodings"
4
+
5
+ def initialize(hash = {})
6
+ super(hash)
7
+ @stream_list = StreamList.new(@id)
8
+ @muxing_list = MuxingList.new(@id)
9
+ end
10
+
11
+ attr_accessor :id, :name, :description
12
+ attr_reader :created_at, :modified_at
13
+ attr_accessor :encoder_version, :cloud_region, :infrastructure_id, :status, :created_at, :modified_at, :type
14
+
15
+ def live?
16
+ type == "LIVE"
17
+ end
18
+
19
+ def vod?
20
+ type == "VOD"
21
+ end
22
+
23
+ def streams
24
+ @stream_list
25
+ end
26
+
27
+ def muxings
28
+ @muxing_list
29
+ end
30
+
31
+ def ignore_fields
32
+ [:@stream_list, :@muxing_list]
33
+ end
34
+
35
+ def save!
36
+ super
37
+ @stream_list = StreamList.new(@id)
38
+ @muxing_list = MuxingList.new(@id)
39
+ end
40
+
41
+ def start!(hsh = {})
42
+ path = File.join("/v1/encoding/encodings/", @id, "start")
43
+ Bitmovin.client.post(path, camelize_hash(hsh))
44
+ end
45
+
46
+ def full_status
47
+ path = File.join("/v1/encoding/encodings/", @id, "status")
48
+ response = Bitmovin.client.get(path)
49
+ hash_to_struct(result(response))
50
+ end
51
+
52
+ def status
53
+ full_status.status
54
+ end
55
+
56
+ def progress
57
+ full_status.progress
58
+ end
59
+
60
+ def self.list(limit = 100, offset = 0)
61
+ response = Bitmovin.client.get("/v1/encoding/encodings", { limit: limit, offset: offset })
62
+ Bitmovin::Helpers.result(response)['items'].map do |item|
63
+ EncodingTask.new(item)
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,39 @@
1
+ module Bitmovin::Encoding::Encodings
2
+ class List
3
+ include Bitmovin::Helpers
4
+
5
+ class << self
6
+ def init(path, klass)
7
+ @resource_path = path
8
+ @klass = klass
9
+ end
10
+ attr_reader :resource_path
11
+ attr_reader :klass
12
+ end
13
+
14
+ attr_accessor :encoding_id
15
+ def initialize(encoding_id)
16
+ @encoding_id = encoding_id
17
+ end
18
+
19
+ def list(limit = 100, offset = 0)
20
+ path = File.join("/v1/encoding/encodings/", @encoding_id, self.class.resource_path)
21
+ response = Bitmovin.client.get(path, { limit: limit, offset: offset })
22
+ result(response)['items'].map { |item| self.class.klass.new(@encoding_id, item) }
23
+ end
24
+
25
+ def add(stream)
26
+ raise "Not implemented yet. Please use #build and Stream#save! for the time being"
27
+ end
28
+
29
+ def build(hash = {})
30
+ self.class.klass.new(@encoding_id, hash)
31
+ end
32
+
33
+ def find(id)
34
+ path = File.join("/v1/encoding/encodings/", @encoding_id, self.class.resource_path, id)
35
+ response = Bitmovin.client.get(path)
36
+ self.class.klass.new(@encoding_id, result(response))
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ module Bitmovin::Encoding::Encodings
2
+ class MuxingList
3
+ include Bitmovin::Helpers
4
+
5
+ attr_accessor :encoding_id
6
+
7
+ def initialize(encoding_id)
8
+ @encoding_id = encoding_id
9
+ end
10
+
11
+ [:fmp4, :webm, :mp4, :ts].each do |muxing_type|
12
+ define_method "#{muxing_type}" do
13
+ klass = "Bitmovin::Encoding::Encodings::Muxings::#{muxing_type.to_s.camelize}MuxingList".constantize
14
+ klass.new(@encoding_id)
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings
2
+ class Fmp4Muxing < MuxingResource
3
+ attr_accessor :segment_naming, :segment_length, :init_segment_name
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings
2
+ class Fmp4MuxingList < Bitmovin::Encoding::Encodings::List
3
+ init "muxings/fmp4", Bitmovin::Encoding::Encodings::Muxings::Fmp4Muxing
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings
2
+ class Mp4Muxing < MuxingResource
3
+ end
4
+ end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings
2
+ class Mp4MuxingList < Bitmovin::Encoding::Encodings::List
3
+ init "muxings/mp4", Bitmovin::Encoding::Encodings::Muxings::TsMuxing
4
+ end
5
+ end
@@ -0,0 +1,56 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings
2
+ class MuxingResource < Bitmovin::Resource
3
+ attr_accessor :name, :description, :created_at, :modified_at
4
+ attr_accessor :encoding_id
5
+ attr_accessor :id
6
+
7
+ def initialize(encoding_id, hash = {})
8
+ hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
9
+ @encoding_id = encoding_id
10
+ muxing_type = self.class.name.demodulize.gsub(/(.*)Muxing/, '\1').downcase
11
+ self.class.init(File.join("/v1/encoding/encodings/", encoding_id, "muxings", muxing_type))
12
+ super(hsh)
13
+ @outputs = (hsh[:outputs] || []).map do |output|
14
+ Bitmovin::Encoding::StreamOutput.new(output)
15
+ end
16
+ @streams = (hsh[:streams] || []).map do |stream|
17
+ stream[:stream_id]
18
+ end
19
+ end
20
+
21
+ attr_accessor :streams, :outputs
22
+
23
+ def build_output(opts = {})
24
+ output = Bitmovin::Encoding::StreamOutput.new(opts)
25
+ @outputs << output
26
+ output
27
+ end
28
+
29
+ private
30
+
31
+ def collect_attributes
32
+ val = Hash.new
33
+ ignored_variables = []
34
+ if (self.respond_to?(:ignore_fields))
35
+ ignored_variables = self.ignore_fields
36
+ end
37
+ instance_variables.each do |name|
38
+ if ignored_variables.include?(name)
39
+ next
40
+ end
41
+ if name == :@outputs
42
+ val["outputs"] = @outputs.map { |o| o.send(:collect_attributes) }
43
+ next
44
+ end
45
+
46
+ if name == :@streams
47
+ val["streams"] = @streams.map { |s| { "streamId" => s } }
48
+ next
49
+ end
50
+ json_name = ActiveSupport::Inflector.camelize(name.to_s.gsub(/@/, ''), false)
51
+ val[json_name] = instance_variable_get(name)
52
+ end
53
+ val
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings
2
+ class TsMuxing < MuxingResource
3
+ attr_accessor :segment_naming, :segment_length
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings
2
+ class TsMuxingList < Bitmovin::Encoding::Encodings::List
3
+ init "muxings/ts", Bitmovin::Encoding::Encodings::Muxings::TsMuxing
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings
2
+ class WebmMuxing < MuxingResource
3
+ attr_accessor :segment_naming, :segment_length, :init_segment_name
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings
2
+ class WebmMuxingList < Bitmovin::Encoding::Encodings::List
3
+ init "muxings/webm", Bitmovin::Encoding::Encodings::Muxings::WebmMuxing
4
+ end
5
+ end
@@ -0,0 +1,102 @@
1
+ module Bitmovin::Encoding::Encodings
2
+ class Stream < Bitmovin::Resource
3
+ attr_accessor :encoding_id
4
+ attr_accessor :id
5
+
6
+ def initialize(encoding_id, hash = {})
7
+ set_defaults
8
+ hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
9
+ @encoding_id = encoding_id
10
+ self.class.init(File.join("/v1/encoding/encodings/", encoding_id, "streams"))
11
+ super(hash)
12
+ @outputs = (hsh[:outputs] || []).map { |output| Bitmovin::Encoding::StreamOutput.new(output) }
13
+ @input_streams = (hsh[:input_streams] || []).map { |input| StreamInput.new(@encoding_id, @id, input) }
14
+
15
+ @errors = []
16
+ end
17
+
18
+ attr_accessor :name, :description, :created_at, :modified_at, :create_quality_meta_data
19
+
20
+ def input_streams
21
+ @input_streams
22
+ end
23
+
24
+ def build_input_stream(opts = {})
25
+ input = StreamInput.new(@encoding_id, @id, opts)
26
+ @input_streams << input
27
+ input
28
+ end
29
+
30
+ def outputs
31
+ @outputs
32
+ end
33
+
34
+ def build_output(opts = {})
35
+ output = Bitmovin::Encoding::StreamOutput.new(opts)
36
+ @outputs << output
37
+ output
38
+ end
39
+
40
+ def codec_configuration=(configuration)
41
+ if configuration.instance_of?(String)
42
+ @codec_config_id = configuration
43
+ else
44
+ @codec_config_id = configuration.id
45
+ end
46
+ end
47
+ def codec_configuration
48
+ @codec_config_id
49
+ end
50
+
51
+ def save!
52
+ if valid?
53
+ super
54
+ end
55
+ end
56
+
57
+ def valid?
58
+ validate!
59
+ @errors.empty?
60
+ end
61
+
62
+ def invalid?
63
+ !valid?
64
+ end
65
+
66
+ def errors
67
+ @errors
68
+ end
69
+
70
+ private
71
+ def collect_attributes
72
+ val = Hash.new
73
+ [:name, :description, :create_quality_meta_data,
74
+ :input_streams, :outputs, :codec_config_id].each do |name|
75
+ json_name = ActiveSupport::Inflector.camelize(name.to_s, false)
76
+ val[json_name] = instance_variable_get("@#{name}")
77
+ end
78
+ val
79
+ end
80
+ def validate!
81
+ @errors = []
82
+ if @input_streams.empty?
83
+ @errors << "Stream needs at least one input_stream"
84
+ end
85
+ @input_streams.each do |stream|
86
+ @errors << stream.errors if !stream.valid?
87
+ end
88
+
89
+ @outputs.each do |output|
90
+ @errors << output.errors if !output.valid?
91
+ end
92
+
93
+ @errors << "codec_configuration must be set" if @codec_config_id.blank?
94
+
95
+ @errors.flatten!
96
+ end
97
+
98
+ def set_defaults
99
+ @create_quality_meta_data = false
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,51 @@
1
+ module Bitmovin::Encoding::Encodings
2
+ class StreamInput
3
+ def initialize(encoding_id, stream_id, hash)
4
+ @errors = []
5
+ @encoding_id = encoding_id
6
+ @stream_id = stream_id
7
+ hash.each do |name, value|
8
+ instance_variable_set("@#{ActiveSupport::Inflector.underscore(name)}", value)
9
+ end
10
+ end
11
+
12
+ attr_accessor :encoding_id, :stream_id
13
+ attr_accessor :input_id, :input_path, :selection_mode, :position
14
+
15
+ def valid?
16
+ validate!
17
+ @errors.empty?
18
+ end
19
+
20
+ def invalid?
21
+ !valid?
22
+ end
23
+
24
+ def errors
25
+ @errors
26
+ end
27
+
28
+ def to_json(args)
29
+ collect_attributes.to_json(args)
30
+ end
31
+
32
+ private
33
+ def collect_attributes
34
+ val = Hash.new
35
+ [:input_id, :input_path, :selection_mode, :position].each do |name|
36
+ json_name = ActiveSupport::Inflector.camelize(name.to_s, false)
37
+ value = instance_variable_get("@#{name}")
38
+ if (!value.nil?)
39
+ val[json_name] = instance_variable_get("@#{name}")
40
+ end
41
+ end
42
+ val
43
+ end
44
+ def validate!
45
+ @errors << "input_id cannot be blank" if @input_id.blank?
46
+ @errors << "input_path cannot be blank" if @input_path.blank?
47
+ @errors << "selection_mode cannot be blank" if @selection_mode.blank?
48
+ @errors << "position cannot be blank if selection_mode is not AUTO" if @position.blank? && @selection_mode != "AUTO"
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Encoding::Encodings
2
+ class StreamList < List
3
+ init "streams", Bitmovin::Encoding::Encodings::Stream
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ module Bitmovin::Encoding
2
+ module Encodings
3
+ # Alias for EncodingTask#list
4
+ def self.list(*args)
5
+ EncodingTask.list(*args)
6
+ end
7
+ end
8
+ end
9
+ require 'bitmovin/encoding/encodings/stream'
10
+ require 'bitmovin/encoding/encodings/stream_input'
11
+ require 'bitmovin/encoding/encodings/encoding_task'
12
+ require 'bitmovin/encoding/encodings/list'
13
+ require 'bitmovin/encoding/encodings/stream_list'
14
+ require 'bitmovin/encoding/encodings/stream_list'
15
+ require 'bitmovin/encoding/encodings/muxing_list'
16
+ require 'bitmovin/encoding/encodings/muxings/muxing_resource'
17
+ require 'bitmovin/encoding/encodings/muxings/fmp4_muxing'
18
+ require 'bitmovin/encoding/encodings/muxings/ts_muxing'
19
+ require 'bitmovin/encoding/encodings/muxings/fmp4_muxing_list'
20
+ require 'bitmovin/encoding/encodings/muxings/ts_muxing_list'
21
+ require 'bitmovin/encoding/encodings/muxings/mp4_muxing'
22
+ require 'bitmovin/encoding/encodings/muxings/mp4_muxing_list'
23
+ require 'bitmovin/encoding/encodings/muxings/webm_muxing'
24
+ require 'bitmovin/encoding/encodings/muxings/webm_muxing_list'
@@ -0,0 +1,27 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class Analysis
3
+ include Bitmovin::Helpers
4
+ def initialize(input_id)
5
+ @id = input_id
6
+ end
7
+
8
+ def list(limit = 100, offset = 0)
9
+ path = File.join("/v1/encoding/inputs/", @id, "analysis")
10
+ response = Bitmovin.client.get(path, limit: limit, offset: offset)
11
+ result(response).map do |result|
12
+ subtask_hash_to_object(result)
13
+ end
14
+ end
15
+
16
+ def find(id)
17
+ path = File.join("/v1/encoding/inputs", @id, "analysis", id)
18
+ response = Bitmovin.client.get(path)
19
+ subtask_hash_to_object(result(response))
20
+ end
21
+
22
+ private
23
+ def subtask_hash_to_object(hash)
24
+ hash_to_struct(underscore_hash(hash))
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,73 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class AnalysisTask
3
+ # Creates a new Analysis object
4
+ # == Parameters:
5
+ # input::
6
+ # Either an input-id (string) or a InputResource
7
+ # analysis_id::
8
+ # Id of the analysis task
9
+ def initialize(input, analysis_id)
10
+ if (input.instance_of?(String))
11
+ @input_id = input
12
+ else
13
+ @input_id = input.id
14
+ @input = input
15
+ end
16
+ @id = analysis_id
17
+ end
18
+
19
+ attr_reader :id, :input_id
20
+
21
+ def input
22
+ @input
23
+ end
24
+
25
+ def status
26
+ five_seconds_ago = (Time.now - 5)
27
+ puts @last_status_call
28
+ if @last_status_call.nil? || @last_status_call <= five_seconds_ago
29
+ response = Bitmovin.client.get File.join("/v1/encoding/inputs/", @input_id, "analysis", @id, "status")
30
+ @status_result = OpenStruct.new(JSON.parse(response.body)['data']['result']['analysis'])
31
+ @last_status_call = Time.now
32
+ end
33
+ @status_result
34
+ end
35
+
36
+ def created?
37
+ status.status == "CREATED"
38
+ end
39
+
40
+ def queued?
41
+ status.status == "QUEUED"
42
+ end
43
+
44
+ def running?
45
+ status.status == "RUNNING"
46
+ end
47
+
48
+ def finished?
49
+ status.status == "FINISHED"
50
+ end
51
+
52
+ def error?
53
+ status.status == "ERROR"
54
+ end
55
+
56
+ def eta?
57
+ status.eta
58
+ end
59
+
60
+ def progress?
61
+ status.progress
62
+ end
63
+
64
+ # Returns the analysis result
65
+ # Will raise and error if analysis is not yet finished
66
+ def result
67
+ if !finished?
68
+ raise BitmovinError.new(self), "analysis is not finished yet"
69
+ end
70
+ Analysis.new(@input_id).find(@id)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,7 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class AsperaInput < Bitmovin::Resource
3
+ init 'encoding/inputs/aspera'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description
5
+ attr_accessor :host, :username, :password, :min_bandwith, :max_bandwith
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class AzureInput < Bitmovin::Resource
3
+ init 'encoding/inputs/azure'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description
5
+ attr_accessor :account_name, :account_key
6
+ attr_accessor :container
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class FtpInput < Bitmovin::Resource
3
+ init 'encoding/inputs/ftp'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description
5
+ attr_accessor :host, :username, :password, :passive, :port
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class GcsInput < Bitmovin::Resource
3
+ init 'encoding/inputs/gcs'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description, :cloud_region, :bucket_name
5
+ attr_accessor :secret_key, :access_key
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class GenericS3Input < Bitmovin::Resource
3
+ init 'encoding/inputs/generic-s3'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description, :cloud_region, :bucket_name, :host, :port
5
+ attr_accessor :secret_key, :access_key
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class HttpInput < Bitmovin::Resource
3
+ init 'encoding/inputs/http'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description
5
+ attr_accessor :host, :username, :password, :port
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class HttpsInput < Bitmovin::Resource
3
+ init 'encoding/inputs/https'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description
5
+ attr_accessor :host, :username, :password, :port
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class RtmpInput < Bitmovin::Resource
3
+ init 'encoding/inputs/rtmp'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class S3Input < Bitmovin::InputResource
3
+ init 'encoding/inputs/s3'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description, :cloud_region, :bucket_name
5
+ attr_accessor :secret_key, :access_key
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Bitmovin::Encoding::Inputs
2
+ class SftpInput < Bitmovin::Resource
3
+ init 'encoding/inputs/sftp'
4
+ attr_accessor :id, :created_at, :modified_at, :name, :description
5
+ attr_accessor :host, :username, :password, :port
6
+ end
7
+ end