kurento_rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +25 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/kurento_rails.gemspec +30 -0
- data/lib/generators/kurento_rails/install_generator.rb +45 -0
- data/lib/generators/kurento_rails/templates/config/events.rb +24 -0
- data/lib/generators/kurento_rails/templates/controllers/kurento_controller.rb +27 -0
- data/lib/generators/kurento_rails/templates/controllers/kurento_websockets_controller.rb +103 -0
- data/lib/generators/kurento_rails/templates/javascript/kurento-rails-js/adapterjs/publish/adapter.min.js +3 -0
- data/lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-client/js/kurento-client.map +1 -0
- data/lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-client/js/kurento-client.min.js +557 -0
- data/lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-rails.js +635 -0
- data/lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-utils/js/kurento-utils.map +1 -0
- data/lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-utils/js/kurento-utils.min.js +36 -0
- data/lib/generators/kurento_rails/templates/migrations/create_video_streams.rb +13 -0
- data/lib/generators/kurento_rails/templates/models/kurento_rails_video_stream.rb +2 -0
- data/lib/generators/kurento_rails/templates/views/kurento/broadcast.html.slim +2 -0
- data/lib/generators/kurento_rails/templates/views/kurento/index.html.slim +2 -0
- data/lib/generators/kurento_rails/templates/views/kurento/old_streams.html.slim +2 -0
- data/lib/kurento_rails.rb +5 -0
- data/lib/kurento_rails/version.rb +3 -0
- data/src/events.rb +24 -0
- data/src/kurento-rails.coffee +387 -0
- data/src/kurento_controller.rb +27 -0
- data/src/kurento_rails_video_stream.rb +2 -0
- data/src/kurento_websockets_controller.rb +103 -0
- metadata +161 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
class KurentoController < ApplicationController
|
2
|
+
|
3
|
+
# this shows all currently active streams, then lets a user connect to one if they would like
|
4
|
+
def index
|
5
|
+
@streams = KurentoRailsVideoStream.where(streaming: true)
|
6
|
+
end
|
7
|
+
|
8
|
+
# this allows a user to create a new stream. It probably should be role protected, but isn't for now
|
9
|
+
def broadcast
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
# this is just a simple alias
|
14
|
+
def receive
|
15
|
+
redirect_to action: "index"
|
16
|
+
end
|
17
|
+
|
18
|
+
# This lets a client look at all of the old streams that have been played, and watch whichever one they would like
|
19
|
+
def old_streams
|
20
|
+
@streams = KurentoRailsVideoStream.where(streaming: false).order(updated_at: 'desc')
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def stream_params
|
25
|
+
params.permit :id, :pipeline, :file_url, :sender_rtc, :viewer_rtc, :hub, :streaming, :name
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
class KurentoWebsocketsController < WebsocketRails::BaseController
|
2
|
+
|
3
|
+
public
|
4
|
+
# just to see if this can make things work
|
5
|
+
# def process_action(method, event)
|
6
|
+
# puts "Calling process action with method #{method} and event #{event}"
|
7
|
+
# super(method, event)
|
8
|
+
# end
|
9
|
+
|
10
|
+
def active_streams
|
11
|
+
search_params = message.merge streaming: true
|
12
|
+
streams = KurentoRailsVideoStream.where(search_params)
|
13
|
+
trigger_success streams
|
14
|
+
end
|
15
|
+
|
16
|
+
def recorded_streams
|
17
|
+
search_params = message.merge streaming: false
|
18
|
+
streams = KurentoRailsVideoStream.where(search_params)
|
19
|
+
trigger_success streams
|
20
|
+
end
|
21
|
+
|
22
|
+
# tell all users that a new video is available
|
23
|
+
def broadcast
|
24
|
+
stream = KurentoRailsVideoStream.new(stream_params(message))
|
25
|
+
if stream.save
|
26
|
+
# notify any people watching active streams that this stream is available
|
27
|
+
WebsocketRails[:video_streams].trigger 'new', stream
|
28
|
+
# store the fact that this user was broadcasting
|
29
|
+
connection_store[:streaming] = stream.id
|
30
|
+
# and now trigger the success callback
|
31
|
+
trigger_success stream
|
32
|
+
else
|
33
|
+
trigger_failure stream
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# tell all users that this broadcast is no longer streaming
|
38
|
+
def stop_broadcasting
|
39
|
+
stream = KurentoRailsVideoStream.find(connection_store[:streaming])
|
40
|
+
stream.streaming = false
|
41
|
+
if stream.save
|
42
|
+
# perform the relevant stop streaming actions
|
43
|
+
stop_streaming stream
|
44
|
+
# and finally, trigger the success callback
|
45
|
+
trigger_success stream
|
46
|
+
else
|
47
|
+
trigger_failure stream
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# let a user know if a video is available for streaming or not
|
52
|
+
def view
|
53
|
+
stream = KurentoRailsVideoStream.find(stream_params(message)[:id])
|
54
|
+
# if this stream is active, great
|
55
|
+
if stream.streaming
|
56
|
+
trigger_success stream
|
57
|
+
else
|
58
|
+
trigger_failure stream
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# handle a user disconnecting from rails.
|
63
|
+
# Usually, this would happen because the user refreshes the page
|
64
|
+
def user_disconnect
|
65
|
+
# check to see if the user was broadcasting video. If they were, then we need
|
66
|
+
# to notify all users viewing their channel that they're no longer broadcasting
|
67
|
+
if connection_store[:streaming]
|
68
|
+
stream = KurentoRailsVideoStream.find(connection_store[:streaming])
|
69
|
+
stop_streaming stream
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
def stream_params(params)
|
75
|
+
new_params = {}
|
76
|
+
new_params[:id] = params[:id]
|
77
|
+
new_params[:pipeline] = params[:pipeline]
|
78
|
+
new_params[:file_url] = params[:file_url]
|
79
|
+
new_params[:sender_rtc] = params
|
80
|
+
|
81
|
+
permit params, :id, :pipeline, :file_url, :sender_rtc, :streaming, :name
|
82
|
+
end
|
83
|
+
|
84
|
+
def permit(original_hash, *allowed_fields)
|
85
|
+
new_hash = {}
|
86
|
+
if allowed_fields.nil?
|
87
|
+
return {}
|
88
|
+
end
|
89
|
+
allowed_fields.each do |field|
|
90
|
+
new_hash[field] = original_hash[field]
|
91
|
+
end
|
92
|
+
new_hash
|
93
|
+
end
|
94
|
+
|
95
|
+
def stop_streaming(stream)
|
96
|
+
# Notify any people watching active streams that this stream isn't available any more
|
97
|
+
WebsocketRails[:video_streams].trigger 'remove', stream
|
98
|
+
# Also notify people watching this stream that it has ended
|
99
|
+
WebsocketRails["stream-#{stream.id}"].trigger 'end-of-stream', stream
|
100
|
+
# remove the stream from the connection store
|
101
|
+
connection_store[:streaming] = nil
|
102
|
+
end
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kurento_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Stephenson
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jquery-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coffee-script
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: websocket-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: All of the ruby and javascript files you should need to easily integrate
|
98
|
+
kurento video streaming into your rails project
|
99
|
+
email:
|
100
|
+
- Andrew.Stephenson123@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".travis.yml"
|
107
|
+
- CODE_OF_CONDUCT.md
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- kurento_rails.gemspec
|
115
|
+
- lib/generators/kurento_rails/install_generator.rb
|
116
|
+
- lib/generators/kurento_rails/templates/config/events.rb
|
117
|
+
- lib/generators/kurento_rails/templates/controllers/kurento_controller.rb
|
118
|
+
- lib/generators/kurento_rails/templates/controllers/kurento_websockets_controller.rb
|
119
|
+
- lib/generators/kurento_rails/templates/javascript/kurento-rails-js/adapterjs/publish/adapter.min.js
|
120
|
+
- lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-client/js/kurento-client.map
|
121
|
+
- lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-client/js/kurento-client.min.js
|
122
|
+
- lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-rails.js
|
123
|
+
- lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-utils/js/kurento-utils.map
|
124
|
+
- lib/generators/kurento_rails/templates/javascript/kurento-rails-js/kurento-utils/js/kurento-utils.min.js
|
125
|
+
- lib/generators/kurento_rails/templates/migrations/create_video_streams.rb
|
126
|
+
- lib/generators/kurento_rails/templates/models/kurento_rails_video_stream.rb
|
127
|
+
- lib/generators/kurento_rails/templates/views/kurento/broadcast.html.slim
|
128
|
+
- lib/generators/kurento_rails/templates/views/kurento/index.html.slim
|
129
|
+
- lib/generators/kurento_rails/templates/views/kurento/old_streams.html.slim
|
130
|
+
- lib/kurento_rails.rb
|
131
|
+
- lib/kurento_rails/version.rb
|
132
|
+
- src/events.rb
|
133
|
+
- src/kurento-rails.coffee
|
134
|
+
- src/kurento_controller.rb
|
135
|
+
- src/kurento_rails_video_stream.rb
|
136
|
+
- src/kurento_websockets_controller.rb
|
137
|
+
homepage: https://github.com/andrewls/kurento-rails
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.4.5
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Kurento integration for Rails apps
|
161
|
+
test_files: []
|