evostream-event 0.3.0 → 0.3.1.pre.52

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b64114447fab23fc4145af949a751c2b6aa2fcd5
4
- data.tar.gz: 9f57da4855a3f0857b2e33d11ff5322301c8f517
3
+ metadata.gz: bac0d2f68701f1ade31fa5ce2a9f3349575efff8
4
+ data.tar.gz: 7234b8571fcbef0a2b4db1dc0bc86723e3453e65
5
5
  SHA512:
6
- metadata.gz: fe8b17e977caae49943a17baee185d28b9c9c6d819732323ab9190527a81fa7fa432d406348734eb50d92778d40a0b51d8ae5cf981adf1d26893e56362dd1038
7
- data.tar.gz: 38e868c364d05539e412eb0cc81d506b670a975e95fb79c7d4cd2f66d00b383245c75926325f38339e2b071382601e9adf30ee117a96a55358f40a426f06c1b2
6
+ metadata.gz: 901127bdce584987d49ef5463f8212a1b3cd6d7a25b72711dd3d36948374979b87ea26054e3c2fff444ee6d5bdf4bdc2ff3a8ad4657d0905481b6a4a1e351c84
7
+ data.tar.gz: 012325881d281cec235c886fe3bba4aeb1585950ebf3f98ead1b8bef8ca875674eaf073cc04c7259b076e679af7b27a015bd5a3d347be6ae849dc58c34056227
data/README.md CHANGED
@@ -32,6 +32,36 @@ Or install it yourself as :
32
32
  gem install evostream-event
33
33
  ```
34
34
 
35
+ ### Environment
36
+
37
+ This gem use a configuration file for configure access to EvoStream server.
38
+
39
+ See initializer file.
40
+ ```ruby
41
+ # URL to EvoStream for share video to final user
42
+ config.uri_in = 'http://server_stream.local:80'
43
+
44
+ # URL to EvoStream for sending request to this API
45
+ config.uri_out = 'http://server_stream.local:7777'
46
+
47
+ # Prefix to folder created for each video mangaed by EvoStream
48
+ config.name = 'srteamming_'
49
+
50
+ # Folder for file created by EvoStream
51
+ config.web_root = '/var/www/html'
52
+
53
+ # Name to model manipulate
54
+ config.model = ModelUsedInDatabase
55
+
56
+ # Choose id to document manipulate in Database
57
+ config.model_id = :identifier_used_in_model
58
+
59
+ # Use environment for this gem. Choose between :
60
+ # - development : Write in log and Send request to evoStream
61
+ # - test : Write in Log
62
+ # - production : Send request to EvoStream
63
+ config.environement = :test
64
+ ```
35
65
  ### Usage
36
66
 
37
67
  Create initializer :
@@ -10,6 +10,7 @@ module Evostream
10
10
  def execute_action(command_name)
11
11
  cmd = command_name.sub(/^(\w)/, &:capitalize)
12
12
  klass = "Evostream::Commands::#{cmd}".constantize
13
+ Evostream.logger "Execute action with cmd : #{klass}"
13
14
  Evostream.send_command(klass.new(@payload).cmd)
14
15
  end
15
16
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :reek:UncommunicativeMethodName
4
+
3
5
  module Evostream
4
6
  # Manage command
5
7
  module Commands
@@ -11,12 +13,24 @@ module Evostream
11
13
  @command.push send(command_name, command_param)
12
14
  end
13
15
  end
16
+
17
+ def cmd
18
+ Evostream.logger "Command before encode : #{@command}"
19
+ end
20
+
21
+ private
22
+
23
+ # Encode commands in base 64 with space between each command
24
+ def encode_64
25
+ Base64.strict_encode64(@command.join(' '))
26
+ end
14
27
  end
15
28
  end
16
29
  end
17
30
 
18
31
  require 'evostream/event/commands/create'
19
32
  require 'evostream/event/commands/destroy'
20
- require 'evostream/event/commands/push_stream'
33
+ require 'evostream/event/commands/get_stream_info'
21
34
  require 'evostream/event/commands/list_config'
22
35
  require 'evostream/event/commands/list_streams'
36
+ require 'evostream/event/commands/push_stream'
@@ -16,78 +16,78 @@ module Evostream
16
16
  # The stream(s) that will be used as the input. This is a comma-delimited
17
17
  # list of active stream names (local stream names)
18
18
  def local_stream_names(param = 'null')
19
- "localStreamNames=#{param} "
19
+ "localStreamNames=#{param}"
20
20
  end
21
21
 
22
22
  # The folder where all the manifest and fragment files will be stored.
23
23
  # This folder must be accessible by the DASH clients. It is usually in the
24
24
  # web-root of the server
25
25
  def target_folder(param = 'null')
26
- "targetFolder=#{param} "
26
+ "targetFolder=#{param}"
27
27
  end
28
28
 
29
29
  # The corresponding bandwidths for each stream listed in localStreamNames.
30
30
  # Again, this can be a comma-delimited list
31
31
  def bandwidths(param = 0)
32
- "bandwidths=#{param} "
32
+ "bandwidths=#{param}"
33
33
  end
34
34
 
35
35
  # The name assigned to the DASH stream or group. If the localStreamNames
36
36
  # parameter contains only one entry and groupName is not specified,
37
37
  # groupName will have the value of the input stream name
38
38
  def group_name(param)
39
- "groupName=#{param} "
39
+ "groupName=#{param}"
40
40
  end
41
41
 
42
42
  # Either `appending` or `rolling`
43
43
  def playlist_type(param = 'appending')
44
- "playlistType=#{param} "
44
+ "playlistType=#{param}"
45
45
  end
46
46
 
47
47
  # The number of fragments before the server starts to overwrite the older
48
48
  # fragments. Used only when playlistType is 'rolling'. Ignored otherwise
49
49
  def playlist_length(param = 10)
50
- "playlistLength=#{param} "
50
+ "playlistLength=#{param}"
51
51
  end
52
52
 
53
53
  # The length (in seconds) of fragments to be made
54
54
  def chunk_length(param = 10)
55
- "chunkLength=#{param} "
55
+ "chunkLength=#{param}"
56
56
  end
57
57
 
58
58
  # If true, chunking is performed ONLY on IDR. Otherwise, chunking is
59
59
  # performed whenever chunk length is achieved
60
60
  def chunk_on_idr(param = 1)
61
- "chunkOnIDR=#{param} "
61
+ "chunkOnIDR=#{param}"
62
62
  end
63
63
 
64
64
  # If true, the EMS will attempt to reconnect to the stream source if the
65
65
  # connection is severed
66
66
  def keep_alive(param = 1)
67
- "keepAlive=#{param} "
67
+ "keepAlive=#{param}"
68
68
  end
69
69
 
70
70
  # If true, it will allow overwrite of destination files
71
71
  def overwrite_destination(param = 1)
72
- "overwriteDestination=#{param} "
72
+ "overwriteDestination=#{param}"
73
73
  end
74
74
 
75
75
  # How many old files are kept besides the ones present in the current
76
76
  # version of the playlist. Only applicable for rolling playlists
77
77
  def stale_retention_count(param)
78
- "staleRetentionCount=#{param} "
78
+ "staleRetentionCount=#{param}"
79
79
  end
80
80
 
81
81
  # If true, all manifest and fragment files in the target folder will be
82
82
  # removed before DASH creation is started
83
83
  def cleanup_destination(param = 0)
84
- "cleanupDestination=#{param} "
84
+ "cleanupDestination=#{param}"
85
85
  end
86
86
 
87
87
  # Set this parameter to 1 (default) for a live DASH, otherwise set it to 0
88
88
  # for a VOD
89
89
  def dynamic_profile(param = 1)
90
- "dynamicProfile=#{param} "
90
+ "dynamicProfile=#{param}"
91
91
  end
92
92
  end
93
93
  end
@@ -12,16 +12,14 @@ module Evostream
12
12
  end
13
13
 
14
14
  def cmd
15
- cmd_hash = command.join
16
- Evostream.logger "createDASHStream : #{cmd_hash}"
17
- "createDASHStream?params=#{Base64.urlsafe_encode64(cmd_hash)}"
15
+ "createDASHStream?params=#{encode_64}"
18
16
  end
19
17
 
20
18
  private
21
19
 
22
20
  # The manifest file name
23
21
  def manifest_name(param = 'manifest.mpd')
24
- "manifestName=#{param} "
22
+ "manifestName=#{param}"
25
23
  end
26
24
  end
27
25
  end
@@ -14,20 +14,18 @@ module Evostream
14
14
  end
15
15
 
16
16
  def cmd
17
- cmd_hash = command.join
18
- Evostream.logger "createHLSStream : #{cmd_hash}"
19
- "createHLSStream?params=#{Base64.urlsafe_encode64(cmd_hash)}"
17
+ "createHLSStream?params=#{encode_64}"
20
18
  end
21
19
 
22
20
  private
23
21
 
24
22
  def create_master_playlist(param = 1)
25
- "createMasterPlaylist=#{param} "
23
+ "createMasterPlaylist=#{param}"
26
24
  end
27
25
 
28
26
  # The manifest file name
29
27
  def playlist_name(param = 'playlist.m3u8')
30
- "playlistName=#{param} "
28
+ "playlistName=#{param}"
31
29
  end
32
30
 
33
31
  # This parameter represents the maximum length, in seconds, the EMS will
@@ -35,12 +33,12 @@ module Evostream
35
33
  # chunkOnIDR=true where the EMS will wait for the next key-frame. If the
36
34
  # maxChunkLength is less than chunkLength, the parameter shall be ignored
37
35
  def max_chunk_length(param = 0)
38
- "maxChunkLength=#{param} "
36
+ "maxChunkLength=#{param}"
39
37
  end
40
38
 
41
39
  # The base name used to generate the *.ts chunks
42
40
  def chunk_base_name(param = 'segment')
43
- "chunkBaseName=#{param} "
41
+ "chunkBaseName=#{param}"
44
42
  end
45
43
 
46
44
  # Sets the type of DRM encryption to use. Options are: none (no
@@ -48,36 +46,36 @@ module Evostream
48
46
  # (Verimatrix DRM). For Verimatrix DRM, the 'drm' section of the
49
47
  # config.lua file must be active and properly configured
50
48
  def drm_type(param = 'none')
51
- "drmType=#{param} "
49
+ "drmType=#{param}"
52
50
  end
53
51
 
54
52
  # Specifies the number of keys that will be automatically generated and
55
53
  # rotated over while encrypting this HLS stream
56
54
  def aes_key_count(param = 5)
57
- "AESKeyCount=#{param} "
55
+ "AESKeyCount=#{param}"
58
56
  end
59
57
 
60
58
  # Specifies if the resulting stream will be audio only. A value of 1(true)
61
59
  # will result in a stream without video
62
60
  def audio_only(param = 0)
63
- "audioOnly=#{param} "
61
+ "audioOnly=#{param}"
64
62
  end
65
63
 
66
64
  # If true, HLS will resume in appending segments to previously created
67
65
  # childplaylist even in cases of EMS shutdown or cut off stream source
68
66
  def hls_resume(param = 0)
69
- "hlsResume=#{param} "
67
+ "hlsResume=#{param}"
70
68
  end
71
69
 
72
70
  # If true, corresponding hls files to a stream will be deleted if the said
73
71
  # stream is removed or shut down or disconnected
74
72
  def cleanup_on_close(param = 0)
75
- "cleanupOnClose=#{param} "
73
+ "cleanupOnClose=#{param}"
76
74
  end
77
75
 
78
76
  # If true, will use the EXT-X-BYTERANGE feature of HLS (version 4 and up)
79
77
  def use_byte_range(param = 0)
80
- "useByteRange=#{param} "
78
+ "useByteRange=#{param}"
81
79
  end
82
80
 
83
81
  # When using useByteRange=1, this parameter needs to be set too. This will
@@ -85,23 +83,23 @@ module Evostream
85
83
  # chunkLength in case of EXT-X-BYTERANGE, since chunkLength will be the
86
84
  # byte range chunk
87
85
  def file_length(param = 0)
88
- "fileLength=#{param} "
86
+ "fileLength=#{param}"
89
87
  end
90
88
 
91
89
  # If true, uses UTC in playlist time stamp otherwise will use the local
92
90
  # server time
93
91
  def use_system_time(param = 0)
94
- "useSystemTime=#{param} "
92
+ "useSystemTime=#{param}"
95
93
  end
96
94
 
97
95
  def offset_time(param = 0)
98
- "offsetTime=#{param} "
96
+ "offsetTime=#{param}"
99
97
  end
100
98
 
101
99
  # A parameter valid only for HLS v.6 onwards. This will indicate the start
102
100
  # offset time (in seconds) for the playback of the playlist
103
101
  def start_offset(param = 0)
104
- "startOffset=#{param} "
102
+ "startOffset=#{param}"
105
103
  end
106
104
  end
107
105
  end
@@ -10,7 +10,7 @@ module Evostream
10
10
  end
11
11
 
12
12
  def cmd
13
- "removeConfig?params=#{Base64.urlsafe_encode64(command.join)}"
13
+ "removeConfig?params=#{encode_64}"
14
14
  end
15
15
 
16
16
  private
@@ -21,20 +21,20 @@ module Evostream
21
21
  # can be obtained from the listConfig interface. Removing an inbound
22
22
  # stream will also automatically remove all associated outbound streams.
23
23
  def id(param = 'null')
24
- "id=#{param} "
24
+ "id=#{param}"
25
25
  end
26
26
 
27
27
  # The name of the group that needs to be removed (applicable to HLS, HDS
28
28
  # and external processes). *Mandatory only if the id parameter is not
29
29
  # specified.
30
30
  def group_name(param = 'null')
31
- "groupName=#{param} "
31
+ "groupName=#{param}"
32
32
  end
33
33
 
34
34
  # If 1 (true) and the stream is HLS or HDS, the folder associated with it
35
35
  # will be removed
36
36
  def remove_hls_hds_files(param = 0)
37
- "removeHlsHdsFiles=#{param} "
37
+ "removeHlsHdsFiles=#{param}"
38
38
  end
39
39
  end
40
40
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Evostream
4
+ module Commands
5
+ # Returns a detailed set of information about a stream.
6
+ class GetStreamInfo < Command
7
+ def initialize(commands = {})
8
+ super(commands)
9
+ end
10
+
11
+ def cmd
12
+ "getStreamInfo?params=#{encode_64}"
13
+ end
14
+
15
+ private
16
+
17
+ # The uniqueId of the stream. Usually a value returned by listStreamsIDs.
18
+ # This parameter is not mandatory but either this or the localStreamName
19
+ # should be present to identify the particular stream
20
+ def id(param = 'null')
21
+ "id=#{param}"
22
+ end
23
+
24
+ # The name of the stream. This parameter is not mandatory but either this
25
+ # or the id should be present to identify the particular stream
26
+ def local_stream_name(param = '')
27
+ "localStreamName=#{param}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -9,7 +9,7 @@ module Evostream
9
9
  end
10
10
 
11
11
  def cmd
12
- "listStreams?params=#{Base64.encode64(command.join)}"
12
+ "listStreams?params=#{encode_64}"
13
13
  end
14
14
 
15
15
  private
@@ -19,7 +19,7 @@ module Evostream
19
19
  # If this is 1 (true), internal streams (origin-edge related)
20
20
  # are filtered out from the list
21
21
  def disable_internal_streams(param = 'true')
22
- "disableInternalStreams=#{param} "
22
+ "disableInternalStreams=#{param}"
23
23
  end
24
24
  end
25
25
  end
@@ -11,11 +11,7 @@ module Evostream
11
11
  end
12
12
 
13
13
  def cmd
14
- base = command.join
15
- Evostream.logger "Parameters : #{base}"
16
- string = Base64.strict_encode64(base)
17
- Evostream.logger "Base 64 decoded : #{Base64.strict_decode64(string)}"
18
- "pushStream?params=#{string}"
14
+ "pushStream?params=#{encode_64}"
19
15
  end
20
16
 
21
17
  private
@@ -25,19 +21,19 @@ module Evostream
25
21
  # TheURI of the external stream. Can be RTMP, RTSP or unicast/multicast
26
22
  # (d) mpegts
27
23
  def uri(param = 'null')
28
- "uri=#{param} "
24
+ "uri=#{param}"
29
25
  end
30
26
 
31
27
  # If provided, the stream will be given this name. Otherwise, a fallback
32
28
  # techniqueis used to determine the stream name (based on the URI)
33
29
  def local_stream_name(param = '')
34
- "localStreamName=#{param} "
30
+ "localStreamName=#{param}"
35
31
  end
36
32
 
37
33
  # The name of the stream at destination. If not provided, the target
38
34
  # stream name willbe the same as the local stream name
39
35
  def target_stream_name(param = 'null')
40
- "targetStreamName=#{param} "
36
+ "targetStreamName=#{param}"
41
37
  end
42
38
  end
43
39
  end
@@ -23,6 +23,7 @@ module Evostream
23
23
  def execute_klass(klass)
24
24
  name_flux = extract_name_flux
25
25
  Evostream.logger "Name Flux : #{name_flux}"
26
+ Evostream.logger "Event : #{klass}"
26
27
  case [klass]
27
28
  when [Evostream::Events::OutStreamCreated]
28
29
  klass.new(name_flux, @payload).execute
@@ -12,6 +12,7 @@ module Evostream
12
12
  def execute
13
13
  super do |type_flux|
14
14
  klass = Evostream::Commands::Destroy.new(remove_config(type_flux))
15
+ Evostream.logger 'Send command to server EvoStream'
15
16
  @result = Evostream.send_command(klass.cmd)
16
17
  # yield if block_given?
17
18
  end
@@ -8,6 +8,7 @@ module Evostream
8
8
  super do |type_flux|
9
9
  klass = "Evostream::Commands::Create#{type_flux.upcase}".constantize
10
10
  command = send(type_flux, type_flux)
11
+ Evostream.logger 'Send command to server EvoStream'
11
12
  @result = Evostream.send_command(klass.new(command).cmd)
12
13
  end
13
14
  end
@@ -10,6 +10,7 @@ module Evostream
10
10
  end
11
11
 
12
12
  def execute
13
+ Evostream.logger "Update document (#{model.class}) in Database"
13
14
  stream_flux = what_flux.upcase.constantize
14
15
  model.streams.push(stream_flux.new(config_id: ex_config, flux: ex_flux))
15
16
  model.save
@@ -6,7 +6,7 @@
6
6
  # Define constant to gem.
7
7
  module Evostream
8
8
  # Define version to gem
9
- VERSION = '0.3.0'
9
+ VERSION = '0.3.1'
10
10
 
11
11
  # Name to gem
12
12
  GEM_NAME = 'evostream-event'
@@ -6,16 +6,33 @@ module Evostream
6
6
  class InitializerGenerator < Rails::Generators::Base
7
7
  desc 'Generate a initializer for evostream-event gem.'
8
8
  INITIALIZER = <<-INIT
9
- # frozen_string_literal: true
9
+ # frozen_string_literal: true
10
10
 
11
- Evostream::Service.configuration do |config|
12
- config.uri_in = 'http://server_stream.local:80'
13
- config.uri_out = 'http://server_stream.local:7777'
14
- config.name = 'srteamming_'
15
- config.web_root = '/var/www/html'
16
- config.model = ModelUsedInDatabase
17
- config.model_id = :identifier_used_in_model
18
- end
11
+ Evostream::Service.configuration do |config|
12
+ # URL to EvoStream for share video to final user
13
+ config.uri_in = 'http://server_stream.local:80'
14
+
15
+ # URL to EvoStream for sending request to this API
16
+ config.uri_out = 'http://server_stream.local:7777'
17
+
18
+ # Prefix to folder created for each video mangaed by EvoStream
19
+ config.name = 'srteamming_'
20
+
21
+ # Folder for file created by EvoStream
22
+ config.web_root = '/var/www/html'
23
+
24
+ # Name to model manipulate
25
+ config.model = ModelUsedInDatabase
26
+
27
+ # Choose id to document manipulate in Database
28
+ config.model_id = :identifier_used_in_model
29
+
30
+ # Use environment for this gem. Choose between :
31
+ # - development : Write in log and Send request to evoStream
32
+ # - test : Write in Log
33
+ # - production : Send request to EvoStream
34
+ config.environement = :test
35
+ end
19
36
  INIT
20
37
 
21
38
  # Create initializer in Rails project
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Evostream::Commands::GetStreamInfo do
6
+ let(:command) { Evostream::Commands::GetStreamInfo.new(cmd) }
7
+
8
+ context 'id' do
9
+ let(:arg_value) { Faker::Number.between(1, 999) }
10
+ let(:argument) { 'id' }
11
+
12
+ include_examples 'command'
13
+ end
14
+
15
+ context 'local_stream_name' do
16
+ let(:arg_value) { Faker::Pokemon.name }
17
+ let(:argument) { 'local_stream_name' }
18
+
19
+ include_examples 'command'
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Evostream::Commands::ListStreams do
6
+ let(:command) { Evostream::Commands::ListStreams.new(cmd) }
7
+
8
+ context 'disable_internal_streams' do
9
+ let(:arg_value) { Faker::Boolean.boolean }
10
+ let(:argument) { 'disable_internal_streams' }
11
+
12
+ include_examples 'command'
13
+ end
14
+ end
@@ -6,5 +6,7 @@ RSpec.shared_examples 'command' do
6
6
  let(:cmd) { { argument => arg_value } }
7
7
  let(:result) { "#{argument.camelize(:lower)}=#{arg_value} " }
8
8
 
9
- it { expect(command.instance_variable_get(:@command)[0]).to eql(result) }
9
+ it do
10
+ expect(command.instance_variable_get(:@command)[0] + ' ').to eql(result)
11
+ end
10
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evostream-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1.pre.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-16 00:00:00.000000000 Z
11
+ date: 2017-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -269,6 +269,7 @@ files:
269
269
  - lib/evostream/event/commands/create/dash.rb
270
270
  - lib/evostream/event/commands/create/hls.rb
271
271
  - lib/evostream/event/commands/destroy.rb
272
+ - lib/evostream/event/commands/get_stream_info.rb
272
273
  - lib/evostream/event/commands/list_config.rb
273
274
  - lib/evostream/event/commands/list_streams.rb
274
275
  - lib/evostream/event/commands/push_stream.rb
@@ -287,6 +288,8 @@ files:
287
288
  - spec/evostream/commands/create_hls_spec.rb
288
289
  - spec/evostream/commands/create_spec.rb
289
290
  - spec/evostream/commands/destroy_spec.rb
291
+ - spec/evostream/commands/get_stream_info_spec.rb
292
+ - spec/evostream/commands/list_stream_spec.rb
290
293
  - spec/evostream/commands/push_stream_spec.rb
291
294
  - spec/evostream/event/event_spec.rb
292
295
  - spec/evostream/events/events_spec.rb
@@ -339,9 +342,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
339
342
  version: '0'
340
343
  required_rubygems_version: !ruby/object:Gem::Requirement
341
344
  requirements:
342
- - - ">="
345
+ - - ">"
343
346
  - !ruby/object:Gem::Version
344
- version: '0'
347
+ version: 1.3.1
345
348
  requirements: []
346
349
  rubyforge_project:
347
350
  rubygems_version: 2.4.5