Skip to content

Commit

Permalink
Update the meeting sample to fit version4.0 and create a folder depen…
Browse files Browse the repository at this point in the history
…dencies for adapter.js and socket.io.js.

Change-Id: I0e5a3f4377f7d97d46fa41d7cfd064a896537de9
Reviewed-on: https://git-amr-3.devtools.intel.com/gerrit/180578
Tested-by: webrtctest <webrtctest@intel.com>
Reviewed-by: Zhu, Jianjun <jianjun.zhu@intel.com>
  • Loading branch information
Wei,Fan authored and jianjunz committed Jul 19, 2018
1 parent 043b0a2 commit e7ca979
Show file tree
Hide file tree
Showing 11 changed files with 841 additions and 4,648 deletions.
4 changes: 3 additions & 1 deletion scripts/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ window.L = L;\n\
{expand: true,cwd:'src/extension/',src:['**'],dest:'dist/',flatten:false},
{expand: true,cwd:'dist/sdk/',src:['ics.js'],dest:'dist/samples/conference/public/scripts/',flatten:false},
{expand: true,cwd:'dist/samples/conference/public/scripts',src:['rest.js'],dest:'dist/samples/conference/',flatten:false},
{expand: true,cwd:'dist/sdk/',src:['ics.js'],dest:'dist/samples/p2p/js',flatten:false},
{expand: true,cwd:'dist/sdk/',src:['ics.js'],dest:'dist/samples/p2p/js/',flatten:false},
{expand: true,cwd:'src/dependencies',src:['adapter.js','socket.io.js'],dest:'dist/samples/p2p/js/',flatten:false},
{expand: true,cwd:'src/dependencies',src:['adapter.js','socket.io.js'],dest:'dist/samples/conference/public/scripts/',flatten:false}
]
}
},
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/samples/conference/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<script src="scripts/adapter.js" type="text/javascript"></script>
<script src="scripts/ics.js" type="text/javascript"></script>
<script src="scripts/index.js" type="text/javascript"></script>
<script src="scripts/rest-sample.js" type="text/javascript"></script>
<script language="JavaScript">
function getParameterByName(name) {
name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
Expand Down
305 changes: 0 additions & 305 deletions src/samples/conference/public/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,309 +134,4 @@ const runSocketIOSample = function() {
});
};

// REST samples. It sends HTTP requests to sample server, and sample server sends requests to conference server.
// Both this file and sample server are samples.
var send = function(method, entity, body, onRes) {
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState === 4) {
onRes(req.responseText);
}
};
req.open(method, entity, true);
req.setRequestHeader('Content-Type', 'application/json');
if (body !== undefined) {
req.send(JSON.stringify(body));
} else {
req.send();
}
};

var onResponse = function(result) {
if (result) {
try {
console.info('Result:', JSON.parse(result));
} catch (e) {
console.info('Result:', result);
}
} else {
console.info('Null');
}
};

var listRooms = function() {
send('GET', '/rooms/', undefined, onResponse);
};

var getRoom = function(room) {
send('GET', '/rooms/' + room + '/', undefined, onResponse);
};

var createRoom = function() {
send('POST', '/rooms/', {
name: 'testNewRoom',
options: undefined
},
onResponse);
};

var deleteRoom = function(room) {
send('DELETE', '/rooms/' + room + '/', undefined, onResponse);
};

var updateRoom = function(room, config) {
send('PUT', '/rooms/' + room + '/', config, onResponse);
};

var listParticipants = function(room) {
send('GET', '/rooms/' + room + '/participants/', undefined, onResponse);
};

var getParticipant = function(room, participant) {
send('GET', '/rooms/' + room + '/participants/' + participant + '/',
undefined, onResponse);
};

var forbidSub = function(room, participant) {
var jsonPatch = [{
op: 'replace',
path: '/permission/subscribe',
value: {
audio: false,
video: false
}
}];
send('PATCH', '/rooms/' + room + '/participants/' + participant + '/',
jsonPatch, onResponse);
};

var forbidPub = function(room, participant) {
var jsonPatch = [{
op: 'replace',
path: '/permission/publish',
value: {
audio: false,
video: false
}
}];
send('PATCH', '/rooms/' + room + '/participants/' + participant + '/',
jsonPatch, onResponse);
};

var dropParticipant = function(room, participant) {
send('DELETE', '/rooms/' + room + '/participants/' + participant + '/',
undefined, onResponse);
};

var listStreams = function(room) {
send('GET', '/rooms/' + room + '/streams/', undefined, onResponse);
};

var getStream = function(room, stream) {
send('GET', '/rooms/' + room + '/streams/' + stream, undefined,
onResponse);
};

var mixStream = function(room, stream, view) {
var jsonPatch = [{
op: 'add',
path: '/info/inViews',
value: view
}];
send('PATCH', '/rooms/' + room + '/streams/' + stream, jsonPatch,
onResponse);
};

var unmixStream = function(room, stream, view) {
var jsonPatch = [{
op: 'remove',
path: '/info/inViews',
value: view
}];
send('PATCH', '/rooms/' + room + '/streams/' + stream, jsonPatch,
onResponse);
};

var setRegion = function(room, stream, region, subStream) {
send('GET', '/rooms/' + room + '/streams/' + stream, undefined, function(stJSON) {
var st = JSON.parse(stJSON);

if (st.type !== 'mixed') {
return console.info('Invalid stream');
}

var index = 0;
for (index = 0; index <= st.info.layout.length; index++) {
if (st.info.layout[index].region.id === region) {
break;
}
}

if (index < st.info.layout.length) {
var jsonPatch = [{
op: 'replace',
path: '/info/layout/0/stream',
value: subStream
}];
send('PATCH', '/rooms/' + room + '/streams/' + stream, jsonPatch,
onResponse);
} else {
console.info('Invalid region');
}
});
};

var pauseStream = function(room, stream, track) {
var jsonPatch = [];
if (track === 'audio' || track === 'av') {
jsonPatch.push({
op: 'replace',
path: '/media/audio/status',
value: 'inactive'
});
}

if (track === 'video' || track === 'av') {
jsonPatch.push({
op: 'replace',
path: '/media/video/status',
value: 'inactive'
});
}
send('PATCH', '/rooms/' + room + '/streams/' + stream, jsonPatch,
onResponse);
};

var playStream = function(room, stream, track) {
var jsonPatch = [];
if (track === 'audio' || track === 'av') {
jsonPatch.push({
op: 'replace',
path: '/media/audio/status',
value: 'active'
});
}

if (track === 'video' || track === 'av') {
jsonPatch.push({
op: 'replace',
path: '/media/video/status',
value: 'active'
});
}
send('PATCH', '/rooms/' + room + '/streams/' + stream, jsonPatch,
onResponse);
};

var dropStream = function(room, stream) {
send('DELETE', '/rooms/' + room + '/streams/' + stream, undefined,
onResponse);
};

var startStreamingIn = function(room, url) {
var options = {
url: url,
media: {
audio: 'auto',
video: true
},
transport: {
protocol: 'udp',
bufferSize: 2048
}
};
send('POST', '/rooms/' + room + '/streaming-ins', options, onResponse);
};

var stopStreamingIn = function(room, stream) {
send('DELETE', '/rooms/' + room + '/streaming-ins/' + stream, undefined,
onResponse);
};

var listRecordings = function(room) {
send('GET', '/rooms/' + room + '/recordings/', undefined, onResponse);
};

var startRecording = function(room, audioFrom, videoFrom, container) {
var options = {
media: {
audio: {
from: audioFrom
},
video: {
from: videoFrom
}
},
container: (container ? container : 'auto')
};
send('POST', '/rooms/' + room + '/recordings', options, onResponse);
};

var stopRecording = function(room, id) {
send('DELETE', '/rooms/' + room + '/recordings/' + id, undefined,
onResponse);
};

var updateRecording = function(room, id, audioFrom, videoFrom) {
var jsonPatch = [{
op: 'replace',
path: '/media/audio/from',
value: audioFrom
}, {
op: 'replace',
path: '/media/video/from',
value: videoFrom
}];
send('PATCH', '/rooms/' + room + '/recordings/' + id, jsonPatch,
onResponse);
};

var listStreamingOuts = function(room) {
send('GET', '/rooms/' + room + '/streaming-outs/', undefined, onResponse);
};

var startStreamingOut = function(room, url, audioFrom, videoFrom) {
var options = {
media: {
audio: {
from: audioFrom
},
video: {
from: videoFrom
}
},
url: url
};
send('POST', '/rooms/' + room + '/streaming-outs', options, onResponse);
};

var stopStreamingOut = function(room, id) {
send('DELETE', '/rooms/' + room + '/streaming-outs/' + id, undefined,
onResponse);
};

var updateStreamingOut = function(room, id, audioFrom, videoFrom) {
var jsonPatch = [{
op: 'replace',
path: '/media/audio/from',
value: audioFrom
}, {
op: 'replace',
path: '/media/video/from',
value: videoFrom
}];
send('PATCH', '/rooms/' + room + '/streaming-outs/' + id, jsonPatch,
onResponse);
};


var createToken = function(room, user, role, callback) {
var body = {
room: room,
user: user,
role: role
};
send('POST', '/tokens/', body, callback);
};

};
Loading

0 comments on commit e7ca979

Please sign in to comment.