webrtc_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/webrtc_rails/application.js +16 -0
- data/app/assets/javascripts/webrtc_rails/rooms.js +141 -0
- data/app/assets/stylesheets/webrtc_rails/application.css +13 -0
- data/app/assets/stylesheets/webrtc_rails/rooms.css +4 -0
- data/app/controllers/webrtc_rails/application_controller.rb +2 -0
- data/app/controllers/webrtc_rails/rooms_controller.rb +31 -0
- data/app/helpers/webrtc_rails/application_helper.rb +4 -0
- data/app/helpers/webrtc_rails/videoconfs_helper.rb +4 -0
- data/app/models/uri_string.rb +0 -0
- data/app/views/layouts/webrtc_rails/application.html.erb +17 -0
- data/app/views/webrtc_rails/rooms/new.html.erb +15 -0
- data/app/views/webrtc_rails/rooms/show.html.erb +19 -0
- data/config/locales/en.yml +4 -0
- data/config/locales/es.yml +4 -0
- data/config/routes.rb +3 -0
- data/lib/tasks/webrtc_rails_tasks.rake +4 -0
- data/lib/webrtc_rails.rb +8 -0
- data/lib/webrtc_rails/engine.rb +5 -0
- data/lib/webrtc_rails/parameterizable_validator.rb +7 -0
- data/lib/webrtc_rails/room.rb +20 -0
- data/lib/webrtc_rails/version.rb +3 -0
- data/test/controllers/webrtc_rails/videoconfs_controller_test.rb +9 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/helpers/webrtc_rails/videoconfs_helper_test.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/webrtc_rails_test.rb +7 -0
- data/vendor/assets/javascripts/webrtc_rails/getusermedia.js +68 -0
- data/vendor/assets/javascripts/webrtc_rails/hark.js +256 -0
- data/vendor/assets/javascripts/webrtc_rails/simplewebrtc.js +5 -0
- metadata +212 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5d6f3396896b1ebdcdac94633c41dbb5789ee60f
|
4
|
+
data.tar.gz: 05f346ad00b5d00b639354ec5c7e6a07ea2bbedc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1b30915a772582b47a7acfc247ad7ed1da6c5a51330d1b425c2736460466efcaf1638334d16aaf815aa68a9ef2588bd46d2407fcb61b3a368703adeef5da173
|
7
|
+
data.tar.gz: c4cb57029f7efc10ed4b15a5563b89b0149295d6727def0235236811f069c014f553748903ea4eb8c0f549da1392c036401c6883d82a098770eabf59a5ca3820
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'WebrtcRails'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require webrtc_rails/simplewebrtc
|
14
|
+
//= require webrtc_rails/getusermedia
|
15
|
+
//= require webrtc_rails/hark
|
16
|
+
//= require_tree .
|
@@ -0,0 +1,141 @@
|
|
1
|
+
// Place all the behaviors and hooks related to the matching controller here.
|
2
|
+
// All this logic will automatically be available in application.js.
|
3
|
+
|
4
|
+
// grab the room from the URL
|
5
|
+
var Room = {
|
6
|
+
initialize: function(room){
|
7
|
+
this.room = room;
|
8
|
+
this.webrtc = this.connect();
|
9
|
+
this.webrtc.on('readyToCall', this.readyToCall.bind(this));
|
10
|
+
this.webrtc.on('channelMessage', this.channelMessage.bind(this));
|
11
|
+
this.webrtc.on('videoAdded', this.videoAdded.bind(this));
|
12
|
+
this.webrtc.on('videoRemoved', this.videoRemoved.bind(this));
|
13
|
+
this.webrtc.on('volumeChange', this.volumeChange.bind(this));
|
14
|
+
this.webrtc.on('localScreenRemoved', this.localScreenRemoved.bind(this));
|
15
|
+
|
16
|
+
this.stopButton = $('#stopVideoButton');
|
17
|
+
this.stopButton.click(this.stop.bind(this));
|
18
|
+
|
19
|
+
this.muteButton = $('#muteButton');
|
20
|
+
this.muteButton.click(this.mute.bind(this));
|
21
|
+
|
22
|
+
this.shareButton = $('#screenShareButton');
|
23
|
+
this.shareButton.click(this.share.bind(this));
|
24
|
+
this.setShareButton(true);
|
25
|
+
},
|
26
|
+
connect: function(){
|
27
|
+
return new SimpleWebRTC({
|
28
|
+
// the id/element dom element that will hold "our" video
|
29
|
+
localVideoEl: 'localVideo',
|
30
|
+
// the id/element dom element that will hold remote videos
|
31
|
+
remoteVideosEl: 'remotesVideos',
|
32
|
+
// immediately ask for camera access
|
33
|
+
autoRequestMedia: true,
|
34
|
+
debug: false,
|
35
|
+
detectSpeakingEvents: true,
|
36
|
+
autoAdjustMic: false
|
37
|
+
});
|
38
|
+
},
|
39
|
+
readyToCall: function() {
|
40
|
+
if (this.room) this.webrtc.joinRoom(this.room);
|
41
|
+
},
|
42
|
+
showVolume: function(el, volume){
|
43
|
+
if (!el) return;
|
44
|
+
if (volume < -45) { // vary between -45 and -20
|
45
|
+
el.style.height = '0px';
|
46
|
+
} else if (volume > -20) {
|
47
|
+
el.style.height = '100%';
|
48
|
+
} else {
|
49
|
+
el.style.height = '' + Math.floor((volume + 100) * 100 / 25 - 220) + '%';
|
50
|
+
}
|
51
|
+
},
|
52
|
+
channelMessage: function (peer, label, data) {
|
53
|
+
if (data.type == 'volume') {
|
54
|
+
this.showVolume(document.getElementById('volume_' + peer.id), data.volume);
|
55
|
+
}
|
56
|
+
},
|
57
|
+
videoAdded: function(video, peer){
|
58
|
+
console.log('video added', peer);
|
59
|
+
var remotes = document.getElementById('remotes');
|
60
|
+
if (remotes) {
|
61
|
+
var d = document.createElement('div');
|
62
|
+
d.className = 'videoContainer';
|
63
|
+
d.id = 'peer_' + peer.id;
|
64
|
+
d.appendChild(video);
|
65
|
+
var vol = document.createElement('div');
|
66
|
+
vol.id = 'volume_' + peer.id;
|
67
|
+
vol.className = 'volume_bar';
|
68
|
+
d.appendChild(vol);
|
69
|
+
remotes.appendChild(d);
|
70
|
+
}
|
71
|
+
},
|
72
|
+
videoRemoved: function(video, peer){
|
73
|
+
console.log('video added', peer);
|
74
|
+
var remotes = document.getElementById('remotes');
|
75
|
+
var el = document.getElementById('peer_' + peer.id);
|
76
|
+
if (remotes && el) {
|
77
|
+
remotes.removeChild(el);
|
78
|
+
}
|
79
|
+
},
|
80
|
+
volumeChange: function (volume, treshold) {
|
81
|
+
this.showVolume(document.getElementById('localVolume'), volume);
|
82
|
+
},
|
83
|
+
stop: function(){
|
84
|
+
if (this.stopButton.text() == 'Stop'){
|
85
|
+
this.webrtc.pause();
|
86
|
+
this.stopButton.text("Resume");
|
87
|
+
} else {
|
88
|
+
this.webrtc.resume();
|
89
|
+
this.stopButton.text("Stop");
|
90
|
+
}
|
91
|
+
},
|
92
|
+
mute: function(){
|
93
|
+
if (this.muteButton.text() == 'Mute'){
|
94
|
+
this.webrtc.mute();
|
95
|
+
this.muteButton.text("Unmute");
|
96
|
+
} else {
|
97
|
+
this.webrtc.unmute();
|
98
|
+
this.muteButton.text("Mute");
|
99
|
+
}
|
100
|
+
},
|
101
|
+
localScreenRemoved: function(){
|
102
|
+
this.shareButton.set(true);
|
103
|
+
},
|
104
|
+
setShareButton: function(bool){
|
105
|
+
this.shareButton.text(bool ? 'Share Screen' : 'Stop Sharing');
|
106
|
+
},
|
107
|
+
share: function () {
|
108
|
+
if (this.webrtc.getLocalScreen()) {
|
109
|
+
this.webrtc.stopScreenShare();
|
110
|
+
this.setShareButton(true);
|
111
|
+
} else {
|
112
|
+
this.webrtc.shareScreen(function (err) {
|
113
|
+
if (err) {
|
114
|
+
this.setShareButton(false);
|
115
|
+
console.log(err.message);
|
116
|
+
} else {
|
117
|
+
this.setShareButton(true);
|
118
|
+
}
|
119
|
+
}.bind(this));
|
120
|
+
}
|
121
|
+
}
|
122
|
+
};
|
123
|
+
|
124
|
+
/*
|
125
|
+
getUserMedia(function(err, stream) {
|
126
|
+
if (err) throw err
|
127
|
+
|
128
|
+
var options = {};
|
129
|
+
var speechEvents = hark(stream, options);
|
130
|
+
|
131
|
+
speechEvents.on('speaking', function() {
|
132
|
+
console.log('speaking');
|
133
|
+
$('#localVideo').css({height:"300px"});
|
134
|
+
});
|
135
|
+
|
136
|
+
speechEvents.on('stopped_speaking', function() {
|
137
|
+
console.log('stopped_speaking');
|
138
|
+
$('#localVideo').css({height:"100px"});
|
139
|
+
});
|
140
|
+
});
|
141
|
+
*/
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_dependency "webrtc_rails/application_controller"
|
2
|
+
|
3
|
+
module WebrtcRails
|
4
|
+
class RoomsController < ApplicationController
|
5
|
+
|
6
|
+
def new
|
7
|
+
@room = Room.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
@room = Room.new(room_params)
|
12
|
+
|
13
|
+
if @room.valid?
|
14
|
+
redirect_to room_path(@room)
|
15
|
+
else
|
16
|
+
render :new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def show
|
21
|
+
@room = Room.new(name: params[:id])
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def room_params
|
27
|
+
params.require(:room).permit(:name).permit(:name)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>WebrtcRails</title>
|
5
|
+
<%= stylesheet_link_tag "webrtc_rails/application", media: "all" %>
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<%= yield %>
|
10
|
+
|
11
|
+
<%= javascript_include_tag :jquery %>
|
12
|
+
<%= javascript_include_tag 'webrtc_rails/application' %>
|
13
|
+
<% if content_for? :javascript %>
|
14
|
+
<%= yield :javascript %>
|
15
|
+
<% end %>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<h1>Crear sala de reunión</h1>
|
2
|
+
|
3
|
+
<%= form_for @room, url: rooms_path, method: :post do |f| %>
|
4
|
+
|
5
|
+
<% if @room.errors.any? %>
|
6
|
+
<div class="errors">
|
7
|
+
<% @room.errors.messages.each do |error| %>
|
8
|
+
<%= error.first %>: <%= error.last.join(', ') %>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<%= f.text_field :name, autofocus: true %>
|
14
|
+
<%= f.submit %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1><%= @room.name %></h1>
|
2
|
+
<p>Para invitar a alguien a esta sala pasale la siguiente url: <%= link_to room_url(@room), room_url(@room) %></p>
|
3
|
+
|
4
|
+
<button id="screenShareButton">Share Screen</button>
|
5
|
+
<button id="stopVideoButton">Stop</button>
|
6
|
+
<button id="muteButton">Mute</button>
|
7
|
+
|
8
|
+
<div id="remotesVideos" style="width:100%">
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="botombar" style="height:100px; width:100%; margin:1em">
|
12
|
+
<video id="localVideo" style="height:100px"></video>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<% content_for :javascript do %>
|
16
|
+
<%= javascript_tag do %>
|
17
|
+
Room.initialize("<%= @room.name %>");
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
data/config/routes.rb
ADDED
data/lib/webrtc_rails.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module WebrtcRails
|
2
|
+
class Room
|
3
|
+
include Virtus.model
|
4
|
+
extend ActiveModel::Naming
|
5
|
+
include ActiveModel::Conversion
|
6
|
+
include ActiveModel::Validations
|
7
|
+
|
8
|
+
attribute :name, String
|
9
|
+
|
10
|
+
validates :name, presence: true, parameterizable: true
|
11
|
+
|
12
|
+
def persisted?
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_param
|
17
|
+
URI.escape(name).parameterize
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|