Skip to content

Commit

Permalink
chamada do servidor de gravação concluida
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarubbi committed Jun 7, 2017
1 parent 1089d72 commit b2789c9
Show file tree
Hide file tree
Showing 20 changed files with 10,618 additions and 23 deletions.
16 changes: 16 additions & 0 deletions WebRTCPOC/Hubs/WebRTCHub.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;

namespace WebRTCPOC.Hubs
{
public class WebRTCHub : Hub
{
public void Hello()
{
Clients.All.hello();
}
}
}
4 changes: 2 additions & 2 deletions WebRTCPOC/Scripts/WSAudioRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
* Most of this code is copied wholesale from https://github.com/mattdiamond/Recorderjs
* This is not Stereo, on the right channel is grabbed but that is enough for me
*/
var WSAudioRecorder = function (source, wsURL, wsProtocol) {
var WSAudioRecorder = function (source, server, peerId) {{
var recording = false;
var worker = new Worker(WORKER_PATH);
worker.postMessage({
command: 'init',
config: {
uri: wsURL, protocol: wsProtocol
serverObject: server, id: peerId
}
});
var config = {};
Expand Down
4 changes: 2 additions & 2 deletions WebRTCPOC/Scripts/WSVideoRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function dataURItoView(dataURI) {
* Some hipster may read this and think that JavaScript is practically as fast as
* C or C++, well, you are an idiot mister hipster
**/
function WSVideoRecorder(mediaStream, wsURL, wsProtocol) {
function WSVideoRecorder(mediaStream, server, peerId) {
var recording = false;
var previousImage; //so that we do not burden the network or receiver with dupes.
this.isRecording = function () {
Expand All @@ -33,7 +33,7 @@ function WSVideoRecorder(mediaStream, wsURL, wsProtocol) {
worker.postMessage({
command: 'init',
config: {
uri: wsURL, protocol: wsProtocol
serverObject: server, id: peerId
}
});
this.record = function () {
Expand Down
Binary file modified WebRTCPOC/Scripts/_references.js
Binary file not shown.
25 changes: 12 additions & 13 deletions WebRTCPOC/Scripts/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var recordServer = $.connection.webRTCHub;
var localAudioRec,
localVideoRec,
localStream;
Expand Down Expand Up @@ -35,8 +35,6 @@ peer.on('call', function(call) {
// Click handlers setup
$(function () {

var wsVIDEO = "ws:https://localhost:4000";
var wsAUDIO = "ws:https://localhost:4001";
var audioContext = new AudioContext;

$('#make-call').click(function() {
Expand All @@ -45,12 +43,7 @@ $(function () {

step3(call);

/* localVideoRec = new WSVideoRecorder(window.localStream, wsVIDEO, 'video-protocol');
setTimeout(function () { localVideoRec.record(); }, 500);
var input = audioContext.createMediastreamSource(window.localStream);
localAudioRec = new WSAudioRecorder(input, wsAUDIO, 'audio-protocol');
setTimeout(function () { localAudioRec.record(); }, 500);*/


});
$('#end-call').click(function (e) {
e.preventDefault();
Expand All @@ -62,7 +55,7 @@ $(function () {
// Retry if getUserMedia fails
$('#step1-retry').click(function() {
$('#step1-error').hide();
step();
step1();
});

// Get things started
Expand Down Expand Up @@ -93,7 +86,7 @@ function step3(call) {

// Wait for stream on the call, then setup peer video
call.on('stream', function (stream) {
beginRecord(stream);
beginRecord(call.peer);
$('#their-video').prop('src', URL.createObjectURL(stream));
});

Expand All @@ -105,9 +98,15 @@ function step3(call) {
}


function beginRecord(stream)
function beginRecord(id)
{
var url = URL.createObjectURL(stream);
$.connection.hub.start().done(function () {
localVideoRec = new WSVideoRecorder(window.localStream, chat.server, id);
setTimeout(function () { localVideoRec.record(); }, 500);
var input = audioContext.createMediastreamSource(window.localStream);
localAudioRec = new WSAudioRecorder(input, chat.server, id);
setTimeout(function () { localAudioRec.record(); }, 500);
});
}


Expand Down
7 changes: 4 additions & 3 deletions WebRTCPOC/Scripts/audioWorker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var ws;
var serverObject;

this.onmessage = function (e) {
switch (e.data.command) {
Expand All @@ -12,9 +12,10 @@ this.onmessage = function (e) {
};

function init(config) {
ws = new WebSocket(config.uri, config.protocol);
serverObject = config.serverObject;
serverObject.initAudio(config.id);
}

function record(samples) {
ws.send(samples);
serverObject.sendSamples(samples);
}
Loading

0 comments on commit b2789c9

Please sign in to comment.