bitmovin-ruby 0.4.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +1 -1
  5. data/Gemfile.lock +49 -49
  6. data/README.md +1 -1
  7. data/bitmovin-ruby.gemspec +3 -3
  8. data/lib/bitmovin-ruby.rb +2 -2
  9. data/lib/bitmovin/client.rb +8 -6
  10. data/lib/bitmovin/encoding/encodings.rb +4 -1
  11. data/lib/bitmovin/encoding/encodings/input_streams/ingest.rb +44 -0
  12. data/lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb +48 -0
  13. data/lib/bitmovin/encoding/encodings/muxings/drms/drm_muxing_resource.rb +1 -1
  14. data/lib/bitmovin/encoding/encodings/muxings/mp4_muxing.rb +1 -0
  15. data/lib/bitmovin/encoding/encodings/muxings/muxing_resource.rb +1 -1
  16. data/lib/bitmovin/encoding/encodings/sprites/sprite.rb +76 -0
  17. data/lib/bitmovin/encoding/encodings/stream.rb +16 -2
  18. data/lib/bitmovin/encoding/encodings/stream_input.rb +5 -3
  19. data/lib/bitmovin/encoding/encodings/thumbnails/thumbnail.rb +71 -0
  20. data/lib/bitmovin/encoding/manifests/audio_adaptation_set.rb +1 -2
  21. data/lib/bitmovin/encoding/manifests/fmp4_representation.rb +1 -2
  22. data/lib/bitmovin/encoding/manifests/hls_audio_media.rb +16 -11
  23. data/lib/bitmovin/encoding/manifests/hls_variant_stream.rb +1 -1
  24. data/lib/bitmovin/encoding/manifests/hls_variant_stream_list.rb +1 -2
  25. data/lib/bitmovin/encoding/manifests/manifest_resource.rb +1 -1
  26. data/lib/bitmovin/encoding/manifests/period.rb +1 -1
  27. data/lib/bitmovin/encoding/manifests/video_adaptation_set.rb +1 -2
  28. data/lib/bitmovin/encoding/stream_output.rb +1 -0
  29. data/lib/bitmovin/helpers.rb +5 -1
  30. data/lib/bitmovin/resource.rb +19 -13
  31. data/lib/bitmovin/version.rb +1 -1
  32. data/lib/bitmovin/webhooks.rb +1 -0
  33. data/lib/bitmovin/webhooks/encoding_error_webhook.rb +14 -0
  34. data/lib/bitmovin/webhooks/encoding_finished_webhook.rb +9 -0
  35. metadata +17 -17
  36. data/examples/create_encoding_finished_webhook.rb +0 -21
  37. data/examples/dash_hls_mp4_encoding_with_manifests.rb +0 -502
  38. data/examples/hls_multi_codec.rb +0 -205
  39. data/examples/simple_dash.rb +0 -221
  40. data/examples/simple_dash_with_http_input.rb +0 -216
  41. data/examples/simple_hls_with_aes128.rb +0 -197
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5de44e18db229a82ee80c332b3aee2728351fcde
4
- data.tar.gz: c61b99260159081c6727925c5f6dd1704af4e887
3
+ metadata.gz: c7e7c96a8da24343b8ede740f706e42839075e9b
4
+ data.tar.gz: 546d38ea2aee86c1924a92fef236d45a29819e2e
5
5
  SHA512:
6
- metadata.gz: f2ee0b359e8cc3edc9a6da8c0962cfef95ff56a7fa9ba3188d43179d0dbae38fc8788ece33e0f3486156541fb565663f067ed2d765e4f8f311254bfe2b6837cd
7
- data.tar.gz: c56d66a39a98fd244ba6aeb5da50b408141a1ca52657a5d0c781bf0054a7f37f477619f2ddca41c4d98452ed1f90430710da3f89222e777f358f6ac19cc6d80c
6
+ metadata.gz: b1099f19e81c0280f155026a2dd5bc8545d779fac06394baffb8ebc56ac6cfd800df5a9a5faa9c3aa4ea033715266e5b9695d2474d194a48e093da85f576de4f
7
+ data.tar.gz: 458c436ee2795b0cdbb5c20bdaa0550cc95e3429cd78d6a18cc22abbc56fb14efa1b150ccf94342001adc0fe5940e2d132a82affef1b8d1cbaa96bc0bf493d6a
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /vendor/
9
10
  test.rb
10
11
  test-manifest.rb
11
12
  test_encoding.rb
@@ -13,3 +14,4 @@ delete.rb
13
14
  *.gem
14
15
  examples/*_customer.rb
15
16
  .idea
17
+ .vscode/
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.8
data/.travis.yml CHANGED
@@ -2,4 +2,4 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.3.0
5
- before_install: gem install bundler -v 1.13.6
5
+ before_install: gem install bundler -v 2.2.11
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitmovin-ruby (0.3.0)
4
+ bitmovin-ruby (0.9.0)
5
5
  activesupport (>= 4.0.0)
6
6
  faraday (~> 0.11.0)
7
7
  faraday_middleware (~> 0.11.0)
@@ -16,27 +16,29 @@ GEM
16
16
  minitest (~> 5.1)
17
17
  thread_safe (~> 0.3, >= 0.3.4)
18
18
  tzinfo (~> 1.1)
19
- addressable (2.5.0)
20
- public_suffix (~> 2.0, >= 2.0.2)
21
- codecov (0.1.10)
19
+ addressable (2.6.0)
20
+ public_suffix (>= 2.0.2, < 4.0)
21
+ codecov (0.2.5)
22
+ colorize
22
23
  json
23
24
  simplecov
24
- url
25
- coderay (1.1.1)
25
+ coderay (1.1.2)
26
+ colorize (0.8.1)
27
+ concurrent-ruby (1.1.5)
26
28
  crack (0.4.3)
27
29
  safe_yaml (~> 1.0.0)
28
30
  diff-lcs (1.3)
29
- docile (1.1.5)
31
+ docile (1.3.5)
30
32
  faraday (0.11.0)
31
33
  multipart-post (>= 1.2, < 3)
32
34
  faraday_middleware (0.11.0.1)
33
35
  faraday (>= 0.7.4, < 1.0)
34
- ffi (1.9.18)
36
+ ffi (1.11.1)
35
37
  formatador (0.2.5)
36
- guard (2.14.1)
38
+ guard (2.15.0)
37
39
  formatador (>= 0.2.4)
38
40
  listen (>= 2.7, < 4.0)
39
- lumberjack (~> 1.0)
41
+ lumberjack (>= 1.0.12, < 2.0)
40
42
  nenv (~> 0.1)
41
43
  notiffany (~> 0.0)
42
44
  pry (>= 0.9.12)
@@ -47,64 +49,62 @@ GEM
47
49
  guard (~> 2.1)
48
50
  guard-compat (~> 1.1)
49
51
  rspec (>= 2.99.0, < 4.0)
50
- hashdiff (0.3.2)
52
+ hashdiff (1.0.0)
51
53
  httpclient (2.8.3)
52
- i18n (0.8.1)
54
+ i18n (0.9.5)
55
+ concurrent-ruby (~> 1.0)
53
56
  json (1.8.6)
54
57
  listen (3.1.5)
55
58
  rb-fsevent (~> 0.9, >= 0.9.4)
56
59
  rb-inotify (~> 0.9, >= 0.9.7)
57
60
  ruby_dep (~> 1.2)
58
- lumberjack (1.0.11)
59
- method_source (0.8.2)
60
- minitest (5.10.1)
61
- multipart-post (2.0.0)
61
+ lumberjack (1.0.13)
62
+ method_source (0.9.2)
63
+ minitest (5.11.3)
64
+ multipart-post (2.1.1)
62
65
  nenv (0.3.0)
63
- notiffany (0.1.1)
66
+ notiffany (0.1.3)
64
67
  nenv (~> 0.1)
65
68
  shellany (~> 0.0)
66
- pry (0.10.4)
69
+ pry (0.12.2)
67
70
  coderay (~> 1.1.0)
68
- method_source (~> 0.8.1)
69
- slop (~> 3.4)
70
- public_suffix (2.0.5)
71
- rake (10.5.0)
72
- rb-fsevent (0.9.8)
73
- rb-inotify (0.9.8)
74
- ffi (>= 0.5.0)
75
- rspec (3.5.0)
76
- rspec-core (~> 3.5.0)
77
- rspec-expectations (~> 3.5.0)
78
- rspec-mocks (~> 3.5.0)
71
+ method_source (~> 0.9.0)
72
+ public_suffix (3.1.1)
73
+ rake (13.0.1)
74
+ rb-fsevent (0.10.3)
75
+ rb-inotify (0.10.0)
76
+ ffi (~> 1.0)
77
+ rspec (3.8.0)
78
+ rspec-core (~> 3.8.0)
79
+ rspec-expectations (~> 3.8.0)
80
+ rspec-mocks (~> 3.8.0)
79
81
  rspec-collection_matchers (1.1.3)
80
82
  rspec-expectations (>= 2.99.0.beta1)
81
- rspec-core (3.5.4)
82
- rspec-support (~> 3.5.0)
83
- rspec-expectations (3.5.0)
83
+ rspec-core (3.8.2)
84
+ rspec-support (~> 3.8.0)
85
+ rspec-expectations (3.8.4)
84
86
  diff-lcs (>= 1.2.0, < 2.0)
85
- rspec-support (~> 3.5.0)
86
- rspec-mocks (3.5.0)
87
+ rspec-support (~> 3.8.0)
88
+ rspec-mocks (3.8.1)
87
89
  diff-lcs (>= 1.2.0, < 2.0)
88
- rspec-support (~> 3.5.0)
89
- rspec-support (3.5.0)
90
+ rspec-support (~> 3.8.0)
91
+ rspec-support (3.8.2)
90
92
  ruby_dep (1.5.0)
91
- safe_yaml (1.0.4)
93
+ safe_yaml (1.0.5)
92
94
  shellany (0.0.1)
93
- simplecov (0.14.1)
94
- docile (~> 1.1.0)
95
+ simplecov (0.17.1)
96
+ docile (~> 1.1)
95
97
  json (>= 1.8, < 3)
96
98
  simplecov-html (~> 0.10.0)
97
- simplecov-html (0.10.0)
98
- slop (3.6.0)
99
- thor (0.19.4)
99
+ simplecov-html (0.10.2)
100
+ thor (0.20.3)
100
101
  thread_safe (0.3.6)
101
- tzinfo (1.2.3)
102
+ tzinfo (1.2.5)
102
103
  thread_safe (~> 0.1)
103
- url (0.3.2)
104
- webmock (2.3.2)
104
+ webmock (3.6.2)
105
105
  addressable (>= 2.3.6)
106
106
  crack (>= 0.3.2)
107
- hashdiff
107
+ hashdiff (>= 0.4.0, < 2.0.0)
108
108
 
109
109
  PLATFORMS
110
110
  ruby
@@ -112,15 +112,15 @@ PLATFORMS
112
112
  DEPENDENCIES
113
113
  activesupport (= 4.2.0)
114
114
  bitmovin-ruby!
115
- bundler (~> 1.13)
115
+ bundler (~> 2.2.11)
116
116
  codecov
117
117
  guard-rspec
118
118
  pry
119
- rake (~> 10.0)
119
+ rake (~> 13.0)
120
120
  rspec (~> 3.0)
121
121
  rspec-collection_matchers
122
122
  simplecov
123
123
  webmock
124
124
 
125
125
  BUNDLED WITH
126
- 1.14.6
126
+ 2.2.11
data/README.md CHANGED
@@ -29,7 +29,7 @@ Please check out our examples at [examples](https://github.com/bitmovin/bitmovin
29
29
 
30
30
  ## Development
31
31
 
32
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
33
 
34
34
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
35
 
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
18
+ f.match(%r{^(test|spec|features|examples)/})
19
19
  end
20
20
  spec.bindir = "exe"
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency "httpclient", "~> 2.8.3", ">= 2.8.3"
26
26
  spec.add_dependency "activesupport", ">= 4.0.0"
27
27
  spec.add_dependency "faraday_middleware", "~> 0.11.0"
28
- spec.add_development_dependency "bundler", "~> 1.13"
29
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "bundler", "~> 2.2.11"
29
+ spec.add_development_dependency "rake", "~> 13.0"
30
30
  spec.add_development_dependency "rspec", "~> 3.0"
31
31
  end
data/lib/bitmovin-ruby.rb CHANGED
@@ -21,8 +21,8 @@ require 'bitmovin/webhooks'
21
21
  module Bitmovin
22
22
  @@client = nil
23
23
 
24
- def self.init(api_key)
25
- @@client = Client.new({ api_key: api_key })
24
+ def self.init(api_key, organisation_id = nil)
25
+ @@client = Client.new({ api_key: api_key, organisation_id: organisation_id })
26
26
  end
27
27
 
28
28
  def self.client
@@ -6,12 +6,14 @@ module Bitmovin
6
6
  def initialize(config)
7
7
  @api_key = config[:api_key]
8
8
  @base_url = "https://api.bitmovin.com/v1"
9
- @conn = Faraday.new(url: @base_url, headers: {
10
- 'X-Api-Key' => @api_key,
11
- 'X-Api-Client-Version' => Bitmovin::VERSION,
12
- 'X-Api-Client' => 'bitmovin-ruby',
13
- 'Content-Type' => 'application/json'
14
- }) do |faraday|
9
+ headers = {
10
+ 'X-Api-Key' => @api_key,
11
+ 'X-Api-Client-Version' => Bitmovin::VERSION,
12
+ 'X-Api-Client' => 'bitmovin-ruby',
13
+ 'Content-Type' => 'application/json'
14
+ }
15
+ headers['X-Tenant-Org-Id'] = config[:organisation_id] if config[:organisation_id]
16
+ @conn = Faraday.new(url: @base_url, headers: headers) do |faraday|
15
17
 
16
18
  faraday.request :json
17
19
  #faraday.response :logger
@@ -11,7 +11,8 @@ require 'bitmovin/encoding/encodings/stream_input'
11
11
  require 'bitmovin/encoding/encodings/encoding_task'
12
12
  require 'bitmovin/encoding/encodings/list'
13
13
  require 'bitmovin/encoding/encodings/stream_list'
14
- require 'bitmovin/encoding/encodings/stream_list'
14
+ require 'bitmovin/encoding/encodings/input_streams/ingest'
15
+ require 'bitmovin/encoding/encodings/input_streams/trimming/time_based'
15
16
  require 'bitmovin/encoding/encodings/muxing_list'
16
17
  require 'bitmovin/encoding/encodings/muxings/muxing_resource'
17
18
  require 'bitmovin/encoding/encodings/muxings/fmp4_muxing'
@@ -26,3 +27,5 @@ require 'bitmovin/encoding/encodings/muxings/drms/drm_muxings'
26
27
  require 'bitmovin/encoding/encodings/muxings/drms/ts_muxing_drm_list'
27
28
  require 'bitmovin/encoding/encodings/muxings/drms/ts_muxing_aes_encryption_list'
28
29
  require 'bitmovin/encoding/encodings/muxings/drms/drm_muxing_resource'
30
+ require 'bitmovin/encoding/encodings/thumbnails/thumbnail'
31
+ require 'bitmovin/encoding/encodings/sprites/sprite'
@@ -0,0 +1,44 @@
1
+ module Bitmovin::Encoding::Encodings::InputStreams
2
+ class Ingest < Bitmovin::Resource
3
+ attr_accessor :encoding_id, :input_id, :input_path, :selection_mode, :position,
4
+ :name, :description, :created_at, :modified_at, :errors
5
+
6
+ def initialize(encoding_id, hash = {})
7
+ hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
8
+ @encoding_id = encoding_id
9
+
10
+ init_instance(File.join("/v1/encoding/encodings/", encoding_id, "input-streams/ingest"))
11
+ super(hash)
12
+
13
+ @input_id = hash[:input_id]
14
+ @input_path = hash[:input_path]
15
+ @selection_mode = hash[:selection_mode]
16
+ @position = hash[:position]
17
+
18
+ @errors = []
19
+ end
20
+
21
+ def valid?
22
+ validate!
23
+ @errors.empty?
24
+ end
25
+
26
+ def invalid?
27
+ !valid?
28
+ end
29
+
30
+ def errors
31
+ @errors
32
+ end
33
+
34
+ def validate!
35
+ @errors << "input_id cannot be blank" if @input_id.blank?
36
+ @errors << "input_path cannot be blank" if @input_path.blank?
37
+ @errors << "selection_mode cannot be blank" if @selection_mode.blank?
38
+
39
+ if @position.blank? && @selection_mode != "AUTO"
40
+ @errors << "position cannot be blank if selection_mode is not AUTO"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,48 @@
1
+ module Bitmovin::Encoding::Encodings
2
+ module InputStreams
3
+ module Trimming
4
+ class TimeBased < Bitmovin::Resource
5
+ attr_accessor :encoding_id, :input_stream_id, :offset, :duration,
6
+ :name, :description, :created_at, :modified_at, :errors
7
+
8
+ def initialize(encoding_id, hash = {})
9
+ hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
10
+ @encoding_id = encoding_id
11
+
12
+ init_instance(File.join("/v1/encoding/encodings/", encoding_id, "input-streams/trimming/time-based"))
13
+ super(hash)
14
+
15
+ @offset = hash[:offset]
16
+ @duration = hash[:duration]
17
+ @input_stream_id = hash[:input_stream_id]
18
+
19
+ @errors = []
20
+ end
21
+
22
+ def save!
23
+ super if valid?
24
+ end
25
+
26
+ def invalid?
27
+ !valid?
28
+ end
29
+
30
+ def valid?
31
+ validate!
32
+ @errors.empty?
33
+ end
34
+
35
+ def validate!
36
+ @errors = []
37
+
38
+ @errors << "Input Stream Id must be set" unless @input_stream_id
39
+ @errors << "Offset must be set" unless @offset
40
+ @errors << "Duration must be set" unless @duration
41
+ @errors << "Duration must be greater than zero" if @duration.to_i <= 0
42
+
43
+ @errors.flatten!
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -11,7 +11,7 @@ module Bitmovin::Encoding::Encodings::Muxings::Drms
11
11
  @muxing_id = muxing_id
12
12
  muxing_type = self.class.name.demodulize.gsub(/(.*)Muxing.*/, '\1').downcase
13
13
  encryption_type = self.class.name.demodulize.gsub(/.*Muxing(.*)Encryption/, '\1').downcase
14
- self.class.init(File.join("/v1/encoding/encodings/", encoding_id, "muxings", muxing_type, muxing_id, "drm", encryption_type))
14
+ init_instance(File.join("/v1/encoding/encodings/", encoding_id, "muxings", muxing_type, muxing_id, "drm", encryption_type))
15
15
  super(hsh)
16
16
  @outputs = (hsh[:outputs] || []).map do |output|
17
17
  Bitmovin::Encoding::StreamOutput.new(output)
@@ -1,4 +1,5 @@
1
1
  module Bitmovin::Encoding::Encodings::Muxings
2
2
  class Mp4Muxing < MuxingResource
3
+ attr_accessor :filename
3
4
  end
4
5
  end
@@ -8,7 +8,7 @@ module Bitmovin::Encoding::Encodings::Muxings
8
8
  hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
9
9
  @encoding_id = encoding_id
10
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))
11
+ init_instance(File.join("/v1/encoding/encodings/", encoding_id, "muxings", muxing_type))
12
12
  super(hsh)
13
13
  @outputs = (hsh[:outputs] || []).map do |output|
14
14
  Bitmovin::Encoding::StreamOutput.new(output)
@@ -0,0 +1,76 @@
1
+ module Bitmovin::Encoding::Encodings
2
+ class Sprite < Bitmovin::Resource
3
+
4
+ def initialize(encoding_id, stream_id, hash = {})
5
+ @errors = []
6
+ init_instance(File.join('/v1/encoding/encodings', encoding_id, 'streams', stream_id, 'sprites'))
7
+
8
+ @encoding_id = encoding_id
9
+ @stream_id = stream_id
10
+
11
+ hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
12
+ @height = hsh[:height]
13
+ @width = hsh[:width]
14
+ @sprite_name = hsh[:sprite_name]
15
+ @vtt_name = hsh[:vtt_name]
16
+ @distance = hsh[:distance]
17
+ @outputs = (hsh[:outputs] || []).map {|output| Bitmovin::Encoding::StreamOutput.new(output)}
18
+ end
19
+
20
+ attr_accessor :height, :width, :sprite_name, :vtt_name, :distance, :outputs
21
+
22
+ def save!
23
+ if valid?
24
+ super
25
+ end
26
+ end
27
+
28
+ def errors
29
+ @errors
30
+ end
31
+
32
+ def valid?
33
+ validate!
34
+ unless @errors.empty?
35
+ puts errors
36
+ return false
37
+ end
38
+ true
39
+ end
40
+
41
+ def invalid?
42
+ !valid?
43
+ end
44
+
45
+ def validate!
46
+ @errors = []
47
+
48
+ if @height == nil || @height < 0
49
+ @errors << 'The height has to be set and must be greater than 0'
50
+ end
51
+
52
+ if @width == nil || @width < 0
53
+ @errors << 'The width has to be set and must be greater than 0'
54
+ end
55
+
56
+ if @sprite_name == nil || @sprite_name.blank?
57
+ @errors << 'The spriteName has to be set and must not be blank'
58
+ end
59
+
60
+ if @vtt_name == nil || @vtt_name.blank?
61
+ @errors << 'The vttName has to be set and must not be blank'
62
+ end
63
+
64
+ if @distance < 0
65
+ @errors << 'The distance is not allowed to be less than 0'
66
+ end
67
+
68
+ @outputs.each do |output|
69
+ @errors << output.errors unless output.valid?
70
+ end
71
+
72
+ @errors.flatten!
73
+ end
74
+
75
+ end
76
+ end