bitmovin-ruby 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +1 -1
  4. data/examples/create_encoding_finished_webhook.rb +21 -0
  5. data/examples/dash_hls_mp4_encoding_with_manifests.rb +502 -0
  6. data/examples/hls_multi_codec.rb +205 -0
  7. data/examples/simple_dash_with_http_input.rb +216 -0
  8. data/examples/simple_hls_with_aes128.rb +197 -0
  9. data/lib/bitmovin/encoding/codec_configurations/h265_configuration.rb +1 -0
  10. data/lib/bitmovin/encoding/encodings/muxings/drms/drm_muxing_resource.rb +54 -0
  11. data/lib/bitmovin/encoding/encodings/muxings/drms/drm_muxings.rb +6 -0
  12. data/lib/bitmovin/encoding/encodings/muxings/drms/ts_muxing_aes_encryption.rb +5 -0
  13. data/lib/bitmovin/encoding/encodings/muxings/drms/ts_muxing_aes_encryption_list.rb +15 -0
  14. data/lib/bitmovin/encoding/encodings/muxings/drms/ts_muxing_drm_list.rb +11 -0
  15. data/lib/bitmovin/encoding/encodings/muxings/mp4_muxing_list.rb +1 -1
  16. data/lib/bitmovin/encoding/encodings/muxings/ts_muxing.rb +15 -0
  17. data/lib/bitmovin/encoding/encodings/stream.rb +6 -1
  18. data/lib/bitmovin/encoding/encodings.rb +4 -0
  19. data/lib/bitmovin/encoding/inputs.rb +18 -0
  20. data/lib/bitmovin/encoding/manifests/hls_audio_media.rb +27 -0
  21. data/lib/bitmovin/encoding/manifests/hls_manifest.rb +43 -0
  22. data/lib/bitmovin/encoding/manifests/hls_variant_stream.rb +20 -0
  23. data/lib/bitmovin/encoding/manifests/hls_variant_stream_list.rb +22 -0
  24. data/lib/bitmovin/encoding/manifests/list.rb +39 -0
  25. data/lib/bitmovin/encoding/manifests.rb +3 -0
  26. data/lib/bitmovin/encoding/outputs.rb +2 -0
  27. data/lib/bitmovin/version.rb +1 -1
  28. data/lib/bitmovin/webhooks/encoding_finished_webhook.rb +5 -0
  29. data/lib/bitmovin/webhooks/webhook_encryption.rb +45 -0
  30. data/lib/bitmovin/webhooks/webhook_resource.rb +5 -0
  31. data/lib/bitmovin/webhooks/webhook_signature.rb +45 -0
  32. data/lib/bitmovin/webhooks.rb +8 -0
  33. data/lib/bitmovin-ruby.rb +1 -0
  34. metadata +22 -3
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings::Drms
2
+ class TsMuxingAesEncryption < Bitmovin::Encoding::Encodings::Muxings::Drms::DrmMuxingResource
3
+ attr_accessor :method, :key_file_uri, :key, :iv
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings::Drms
2
+ class TsMuxingAesEncryptionList < Bitmovin::Encoding::Encodings::List
3
+ init "muxings", Bitmovin::Encoding::Encodings::Muxings::Drms::TsMuxingAesEncryption
4
+
5
+ attr_accessor :muxing_id
6
+ def initialize(encoding_id, muxing_id, hash = {})
7
+ @encoding_id = encoding_id
8
+ @muxing_id = muxing_id
9
+ end
10
+
11
+ def build(hash = {})
12
+ self.class.klass.new(@encoding_id, @muxing_id, hash)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Bitmovin::Encoding::Encodings::Muxings::Drms
2
+ class TsMuxingDrmList
3
+ def initialize(encoding_id, muxing_id, hash = {})
4
+ @aes = TsMuxingAesEncryptionList.new(encoding_id, muxing_id)
5
+ end
6
+
7
+ def aes
8
+ @aes
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module Bitmovin::Encoding::Encodings::Muxings
2
2
  class Mp4MuxingList < Bitmovin::Encoding::Encodings::List
3
- init "muxings/mp4", Bitmovin::Encoding::Encodings::Muxings::TsMuxing
3
+ init "muxings/mp4", Bitmovin::Encoding::Encodings::Muxings::Mp4Muxing
4
4
  end
5
5
  end
@@ -1,5 +1,20 @@
1
1
  module Bitmovin::Encoding::Encodings::Muxings
2
2
  class TsMuxing < MuxingResource
3
+ attr_accessor :id
4
+ attr_accessor :encoding_id
3
5
  attr_accessor :segment_naming, :segment_length
6
+ attr_accessor :drms
7
+
8
+ def initialize(encoding_id, hash = {})
9
+ super(encoding_id, hash)
10
+ @encoding_id = encoding_id
11
+ end
12
+
13
+ def drms
14
+ if !persisted?
15
+ raise BitmovinError.new(self), "Cannot access drms of not persisted muxing"
16
+ end
17
+ Drms::TsMuxingDrmList.new(@encoding_id, @id)
18
+ end
4
19
  end
5
20
  end
@@ -2,6 +2,7 @@ module Bitmovin::Encoding::Encodings
2
2
  class Stream < Bitmovin::Resource
3
3
  attr_accessor :encoding_id
4
4
  attr_accessor :id
5
+ attr_accessor :conditions
5
6
 
6
7
  def initialize(encoding_id, hash = {})
7
8
  set_defaults
@@ -13,6 +14,7 @@ module Bitmovin::Encoding::Encodings
13
14
  @input_streams = (hsh[:input_streams] || []).map { |input| StreamInput.new(@encoding_id, @id, input) }
14
15
 
15
16
  @errors = []
17
+ @conditions = nil
16
18
  end
17
19
 
18
20
  attr_accessor :name, :description, :created_at, :modified_at, :create_quality_meta_data
@@ -71,10 +73,13 @@ module Bitmovin::Encoding::Encodings
71
73
  def collect_attributes
72
74
  val = Hash.new
73
75
  [:name, :description, :create_quality_meta_data,
74
- :input_streams, :outputs, :codec_config_id].each do |name|
76
+ :input_streams, :outputs, :codec_config_id, :conditions].each do |name|
75
77
  json_name = ActiveSupport::Inflector.camelize(name.to_s, false)
76
78
  val[json_name] = instance_variable_get("@#{name}")
77
79
  end
80
+ if @conditions.nil?
81
+ val.delete("conditions")
82
+ end
78
83
  val
79
84
  end
80
85
  def validate!
@@ -22,3 +22,7 @@ require 'bitmovin/encoding/encodings/muxings/mp4_muxing'
22
22
  require 'bitmovin/encoding/encodings/muxings/mp4_muxing_list'
23
23
  require 'bitmovin/encoding/encodings/muxings/webm_muxing'
24
24
  require 'bitmovin/encoding/encodings/muxings/webm_muxing_list'
25
+ require 'bitmovin/encoding/encodings/muxings/drms/drm_muxings'
26
+ require 'bitmovin/encoding/encodings/muxings/drms/ts_muxing_drm_list'
27
+ require 'bitmovin/encoding/encodings/muxings/drms/ts_muxing_aes_encryption_list'
28
+ require 'bitmovin/encoding/encodings/muxings/drms/drm_muxing_resource'
@@ -7,6 +7,24 @@ module Bitmovin::Encoding
7
7
  case item['type'].downcase
8
8
  when "s3"
9
9
  S3Input.new(item)
10
+ when "gcs"
11
+ GcsInput.new(item)
12
+ when "http"
13
+ HttpInput.new(item)
14
+ when "https"
15
+ HttpsInput.new(item)
16
+ when "aspera"
17
+ AsperaInput.new(item)
18
+ when "rtmp"
19
+ RtmpInput.new(item)
20
+ when "generic-s3"
21
+ GenericS3Input.new(item)
22
+ when "azure"
23
+ AzureInput.new(item)
24
+ when "ftp"
25
+ FtpInput.new(item)
26
+ when "sftp"
27
+ SftpInput.new(item)
10
28
  end
11
29
  end
12
30
  list
@@ -0,0 +1,27 @@
1
+ module Bitmovin::Encoding::Manifests
2
+ class HlsAudioMedia < Bitmovin::Resource
3
+ attr_accessor :manifest_id
4
+ attr_accessor :groupId
5
+ attr_accessor :language
6
+ attr_accessor :assocLanguage
7
+ attr_accessor :name
8
+ attr_accessor :isDefault
9
+ attr_accessor :autoselect
10
+ attr_accessor :characteristics
11
+ attr_accessor :segmentPath
12
+ attr_accessor :encodingId
13
+ attr_accessor :streamId
14
+ attr_accessor :muxingId
15
+ attr_accessor :drmId
16
+ attr_accessor :startSegmentNumber
17
+ attr_accessor :endSegmentNumber
18
+ attr_accessor :uri
19
+
20
+ def initialize(manifest_id, hash = {})
21
+ hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
22
+ @manifest_id = manifest_id
23
+ self.class.init(File.join("/v1/encoding/manifests/hls/", manifest_id, "media/audio"))
24
+ super(hsh)
25
+ end
26
+ end
27
+ end
@@ -1,7 +1,50 @@
1
1
  module Bitmovin::Encoding::Manifests
2
2
  class HlsManifest < Bitmovin::Resource
3
+ include Bitmovin::ChildCollection
3
4
  init("/v1/encoding/manifests/hls")
4
5
 
5
6
  attr_accessor :outputs, :manifest_name
7
+
8
+ def initialize(hash = {})
9
+ hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
10
+ super(hash)
11
+ @outputs = (hsh[:outputs] || []).map { |output| Bitmovin::Encoding::StreamOutput.new(output) }
12
+ @streams = nil
13
+ @audio_media = nil
14
+ end
15
+
16
+ child_collection(:streams, "/v1/encoding/manifests/hls/%s/streams", [:id], Bitmovin::Encoding::Manifests::HlsVariantStream)
17
+ child_collection(:audio_media, "/v1/encoding/manifests/hls/%s/media/audio", [:id], Bitmovin::Encoding::Manifests::HlsAudioMedia)
18
+
19
+ def start!
20
+ path = File.join("/v1/encoding/manifests/hls/", @id, "start")
21
+ Bitmovin.client.post(path)
22
+ end
23
+
24
+ def full_status
25
+ path = File.join("/v1/encoding/manifests/hls/", @id, "status")
26
+ response = Bitmovin.client.get(path)
27
+ hash_to_struct(result(response))
28
+ end
29
+
30
+ def status
31
+ full_status.status
32
+ end
33
+
34
+ def progress
35
+ full_status.progress
36
+ end
37
+
38
+ private
39
+
40
+ def collect_attributes
41
+ val = Hash.new
42
+ [:name, :description, :manifest_name].each do |name|
43
+ json_name = ActiveSupport::Inflector.camelize(name.to_s, false)
44
+ val[json_name] = instance_variable_get("@#{name}")
45
+ end
46
+ val["outputs"] = @outputs.map { |o| o.send(:collect_attributes) }
47
+ val
48
+ end
6
49
  end
7
50
  end
@@ -0,0 +1,20 @@
1
+ module Bitmovin::Encoding::Manifests
2
+ class HlsVariantStream < Bitmovin::Resource
3
+ attr_accessor :id, :manifest_id
4
+
5
+ # Required
6
+ attr_accessor :closed_captions, :segment_path, :uri
7
+ attr_accessor :encoding_id, :stream_id, :muxing_id
8
+
9
+ attr_accessor :audio, :video, :subtitles
10
+ attr_accessor :drm_id, :start_segment_number, :end_segment_number
11
+
12
+
13
+ def initialize(manifest_id, hash = {})
14
+ hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
15
+ @manifest_id = manifest_id
16
+ self.class.init(File.join("/v1/encoding/manifests/hls/", manifest_id, "streams"))
17
+ super(hsh)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module Bitmovin::Encoding::Manifests
2
+ class HlsVariantStreamList < Bitmovin::Resource
3
+ init "streams"
4
+ attr_accessor :manifest_id
5
+
6
+ def initialize(manifest_id)
7
+ @manifest_id = manifest_id
8
+ self.class.init(File.join("/v1/encoding/manifests/", manifest_id, "streams"))
9
+ #super(hsh)
10
+ end
11
+
12
+ def list(limit = 100, offset = 0)
13
+ path = File.join("/v1/encoding/manifests/hls", @manifest_id, self.class.resource_path)
14
+ response = Bitmovin.client.get(path, { limit: limit, offset: offset })
15
+ result(response)['items'].map { |item| self.class.klass.new(@manifest_id, item) }
16
+ end
17
+
18
+ def build(hash = {})
19
+ HlsVariantStream.new(@manifest_id, hash)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,39 @@
1
+ module Bitmovin::Encoding::Manifests
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 :manifest_id
15
+ def initialize(manifest_id)
16
+ @manifest_id = manifest_id
17
+ end
18
+
19
+ def list(limit = 100, offset = 0)
20
+ path = File.join("/v1/encoding/manifest/", @manifest_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(@manifest_id, hash)
31
+ end
32
+
33
+ def find(id)
34
+ path = File.join("/v1/encoding/manifests/", @manifest_id, self.class.resource_path, id)
35
+ response = Bitmovin.client.get(path)
36
+ self.class.klass.new(@manifest_id, result(response))
37
+ end
38
+ end
39
+ end
@@ -19,5 +19,8 @@ require 'bitmovin/encoding/manifests/audio_adaptation_set'
19
19
  require 'bitmovin/encoding/manifests/video_adaptation_set'
20
20
  require 'bitmovin/encoding/manifests/period'
21
21
  require 'bitmovin/encoding/manifests/dash_manifest'
22
+ require 'bitmovin/encoding/manifests/hls_audio_media'
23
+ require 'bitmovin/encoding/manifests/hls_variant_stream'
22
24
  require 'bitmovin/encoding/manifests/hls_manifest'
23
25
  require 'bitmovin/encoding/manifests/dash_representations'
26
+ require 'bitmovin/encoding/manifests/hls_variant_stream_list'
@@ -7,6 +7,8 @@ module Bitmovin::Encoding
7
7
  case item['type'].downcase
8
8
  when "s3"
9
9
  S3Output.new(item)
10
+ when "gcs"
11
+ GcsOutput.new(item)
10
12
  end
11
13
  end
12
14
  list
@@ -1,3 +1,3 @@
1
1
  module Bitmovin
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Webhooks
2
+ class EncodingFinishedWebhook < WebhookResource
3
+ init 'notifications/webhooks/encoding/encodings/finished'
4
+ end
5
+ end
@@ -0,0 +1,45 @@
1
+ module Bitmovin::Webhooks
2
+ class WebhookEncryption
3
+ def initialize(hash = {})
4
+ @errors = []
5
+ hash.each do |name, value|
6
+ instance_variable_set("@#{ActiveSupport::Inflector.underscore(name)}", value)
7
+ end
8
+ end
9
+
10
+ attr_accessor :type, :key
11
+
12
+ def valid?
13
+ validate!
14
+ @errors.empty?
15
+ end
16
+
17
+ def invalid?
18
+ !valid?
19
+ end
20
+
21
+ def errors
22
+ @errors
23
+ end
24
+
25
+ def to_json(args)
26
+ collect_attributes.to_json(args)
27
+ end
28
+
29
+ private
30
+
31
+ def collect_attributes
32
+ val = Hash.new
33
+ [:type, :key].each do |name|
34
+ json_name = ActiveSupport::Inflector.camelize(name.to_s, false)
35
+ val[json_name] = instance_variable_get("@#{name}")
36
+ end
37
+ val
38
+ end
39
+
40
+ def validate!
41
+ @errors << "type cannot be blank" if @type.blank?
42
+ @errors << "key cannot be blank" if @key.blank?
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,5 @@
1
+ module Bitmovin::Webhooks
2
+ class WebhookResource < Bitmovin::Resource
3
+ attr_accessor :id, :url, :method, :insecure_ssl, :encryption, :signature
4
+ end
5
+ end
@@ -0,0 +1,45 @@
1
+ module Bitmovin::Webhooks
2
+ class WebhookSignature
3
+ def initialize(hash = {})
4
+ @errors = []
5
+ hash.each do |name, value|
6
+ instance_variable_set("@#{ActiveSupport::Inflector.underscore(name)}", value)
7
+ end
8
+ end
9
+
10
+ attr_accessor :type, :key
11
+
12
+ def valid?
13
+ validate!
14
+ @errors.empty?
15
+ end
16
+
17
+ def invalid?
18
+ !valid?
19
+ end
20
+
21
+ def errors
22
+ @errors
23
+ end
24
+
25
+ def to_json(args)
26
+ collect_attributes.to_json(args)
27
+ end
28
+
29
+ private
30
+
31
+ def collect_attributes
32
+ val = Hash.new
33
+ [:type, :key].each do |name|
34
+ json_name = ActiveSupport::Inflector.camelize(name.to_s, false)
35
+ val[json_name] = instance_variable_get("@#{name}")
36
+ end
37
+ val
38
+ end
39
+
40
+ def validate!
41
+ @errors << "type cannot be blank" if @type.blank?
42
+ @errors << "key cannot be blank" if @key.blank?
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,8 @@
1
+ module Bitmovin
2
+ module Webhooks
3
+ end
4
+ end
5
+ require 'bitmovin/webhooks/webhook_resource'
6
+ require 'bitmovin/webhooks/encoding_finished_webhook'
7
+ require 'bitmovin/webhooks/webhook_encryption'
8
+ require 'bitmovin/webhooks/webhook_signature'
data/lib/bitmovin-ruby.rb CHANGED
@@ -16,6 +16,7 @@ require 'bitmovin/input_resource'
16
16
  require 'bitmovin/configuration_resource'
17
17
  require 'bitmovin/client'
18
18
  require 'bitmovin/encoding'
19
+ require 'bitmovin/webhooks'
19
20
 
20
21
  module Bitmovin
21
22
  @@client = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitmovin-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Hoelbling-Inzko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-27 00:00:00.000000000 Z
11
+ date: 2017-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -133,7 +133,12 @@ files:
133
133
  - bin/console
134
134
  - bin/setup
135
135
  - bitmovin-ruby.gemspec
136
+ - examples/create_encoding_finished_webhook.rb
137
+ - examples/dash_hls_mp4_encoding_with_manifests.rb
138
+ - examples/hls_multi_codec.rb
136
139
  - examples/simple_dash.rb
140
+ - examples/simple_dash_with_http_input.rb
141
+ - examples/simple_hls_with_aes128.rb
137
142
  - lib/bitmovin-ruby.rb
138
143
  - lib/bitmovin/bitmovin_error.rb
139
144
  - lib/bitmovin/child_collection.rb
@@ -149,6 +154,11 @@ files:
149
154
  - lib/bitmovin/encoding/encodings/encoding_task.rb
150
155
  - lib/bitmovin/encoding/encodings/list.rb
151
156
  - lib/bitmovin/encoding/encodings/muxing_list.rb
157
+ - lib/bitmovin/encoding/encodings/muxings/drms/drm_muxing_resource.rb
158
+ - lib/bitmovin/encoding/encodings/muxings/drms/drm_muxings.rb
159
+ - lib/bitmovin/encoding/encodings/muxings/drms/ts_muxing_aes_encryption.rb
160
+ - lib/bitmovin/encoding/encodings/muxings/drms/ts_muxing_aes_encryption_list.rb
161
+ - lib/bitmovin/encoding/encodings/muxings/drms/ts_muxing_drm_list.rb
152
162
  - lib/bitmovin/encoding/encodings/muxings/fmp4_muxing.rb
153
163
  - lib/bitmovin/encoding/encodings/muxings/fmp4_muxing_list.rb
154
164
  - lib/bitmovin/encoding/encodings/muxings/mp4_muxing.rb
@@ -179,7 +189,11 @@ files:
179
189
  - lib/bitmovin/encoding/manifests/dash_manifest.rb
180
190
  - lib/bitmovin/encoding/manifests/dash_representations.rb
181
191
  - lib/bitmovin/encoding/manifests/fmp4_representation.rb
192
+ - lib/bitmovin/encoding/manifests/hls_audio_media.rb
182
193
  - lib/bitmovin/encoding/manifests/hls_manifest.rb
194
+ - lib/bitmovin/encoding/manifests/hls_variant_stream.rb
195
+ - lib/bitmovin/encoding/manifests/hls_variant_stream_list.rb
196
+ - lib/bitmovin/encoding/manifests/list.rb
183
197
  - lib/bitmovin/encoding/manifests/manifest_resource.rb
184
198
  - lib/bitmovin/encoding/manifests/period.rb
185
199
  - lib/bitmovin/encoding/manifests/video_adaptation.rb
@@ -192,6 +206,11 @@ files:
192
206
  - lib/bitmovin/input_resource.rb
193
207
  - lib/bitmovin/resource.rb
194
208
  - lib/bitmovin/version.rb
209
+ - lib/bitmovin/webhooks.rb
210
+ - lib/bitmovin/webhooks/encoding_finished_webhook.rb
211
+ - lib/bitmovin/webhooks/webhook_encryption.rb
212
+ - lib/bitmovin/webhooks/webhook_resource.rb
213
+ - lib/bitmovin/webhooks/webhook_signature.rb
195
214
  homepage: https://github.com/bitmovin/bitmovin-ruby
196
215
  licenses:
197
216
  - MIT
@@ -212,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
231
  version: '0'
213
232
  requirements: []
214
233
  rubyforge_project:
215
- rubygems_version: 2.6.11
234
+ rubygems_version: 2.6.12
216
235
  signing_key:
217
236
  specification_version: 4
218
237
  summary: Api Client for the Bitmovin API