Permalink
Browse files

RecordRTC.js and relevant demos updated.

  • Loading branch information...
1 parent ea08c61 commit 3d4134d3cd552c2bbf74cff06714f720dd6e8732 @muaz-khan committed May 12, 2014
@@ -1,4 +1,4 @@
-// Last time updated at May 09, 2014, 08:32:23
+// Last time updated at May 12, 2014, 08:32:23
// Latest file can be found here: https://www.webrtc-experiment.com/RTCMultiConnection-v1.7.js
// Muaz Khan - www.MuazKhan.com
// MIT License - www.WebRTC-Experiment.com/licence
@@ -466,6 +466,7 @@
mediaConfig.constraints = forcedConstraints || constraints;
mediaConfig.media = connection.media;
+ mediaConfig.connection = connection;
getUserMedia(mediaConfig);
}
}
@@ -2349,9 +2350,6 @@
var self = this;
},
setBandwidth: function (sdp) {
- // todo: should b=AS be inserted after c=IN? (RFC 4566)
- // VoiceActivityDetection: false removes c=IN
-
if (isMobileDevice || isFirefox || !this.bandwidth) return sdp;
var bandwidth = this.bandwidth;
@@ -2390,14 +2388,10 @@
return sdp;
},
setConstraints: function () {
- // c=IN must be there; otherwise chrome will fail for b=AS
- if (isChrome && this.sdpConstraints.mandatory) {
- this.sdpConstraints.mandatory.VoiceActivityDetection = true;
- }
-
-
this.constraints = {
- optional: this.sdpConstraints.optional || [],
+ optional: this.sdpConstraints.optional || [{
+ VoiceActivityDetection: false
+ }],
mandatory: this.sdpConstraints.mandatory || {
OfferToReceiveAudio: !!this.session.audio,
OfferToReceiveVideo: !!this.session.video || !!this.session.screen
@@ -2409,7 +2403,13 @@
this.constraints.mandatory.OfferToReceiveAudio = true;
}
- log('sdp-constraints', toStr(this.constraints.mandatory));
+ if(this.constraints.mandatory) {
+ log('sdp-mandatory-constraints', toStr(this.constraints.mandatory));
+ }
+
+ if(this.constraints.optional) {
+ log('sdp-optional-constraints', toStr(this.constraints.optional));
+ }
this.optionalArgument = {
optional: this.optionalArgument.optional || [{
@@ -2635,6 +2635,8 @@
return;
}
currentUserMediaRequest.mutex = true;
+
+ var connection = options.connection;
// tools.ietf.org/html/draft-alvestrand-constraints-resolution-00
var mediaConstraints = options.mediaConstraints || {};
@@ -2703,13 +2705,41 @@
hints.video.mandatory = merge(hints.video.mandatory, mandatory);
}
- if (mediaConstraints.mandatory)
+ if (mediaConstraints.mandatory) {
hints.video.mandatory = merge(hints.video.mandatory, mediaConstraints.mandatory);
+ }
// mediaConstraints.optional.bandwidth = 1638400;
if (mediaConstraints.optional)
hints.video.optional[0] = merge({}, mediaConstraints.optional);
-
+
+ if(hints.video.mandatory && !isEmpty(hints.video.mandatory) && connection._mediaSources.video) {
+ hints.video.optional.forEach(function(video, index) {
+ if(video.sourceId == connection._mediaSources.video) {
+ delete hints.video.optional[index];
+ }
+ });
+
+ hints.video.optional = swap(hints.video.optional);
+
+ hints.video.optional.push({
+ sourceId: connection._mediaSources.video
+ });
+ }
+
+ if(hints.audio.mandatory && !isEmpty(hints.audio.mandatory) && connection._mediaSources.audio) {
+ hints.audio.optional.forEach(function(audio, index) {
+ if(audio.sourceId == connection._mediaSources.audio) {
+ delete hints.audio.optional[index];
+ }
+ });
+
+ hints.audio.optional = swap(hints.audio.optional);
+
+ hints.audio.optional.push({
+ sourceId: connection._mediaSources.audio
+ });
+ }
if (hints.video && hints.video.optional && hints.video.mandatory) {
if (!hints.video.optional.length && isEmpty(hints.video.mandatory)) {
@@ -94,6 +94,16 @@
connection.open('room-id');
</pre>
</li>
+
+ <li>
+ <a href="http://www.RTCMultiConnection.org/docs/isInitiator/">isInitiator</a>
+ <pre class="sh_javascript">
+if(connection.<a href="http://www.RTCMultiConnection.org/docs/isInitiator/">isInitiator</a>) {
+ connection.<a href="http://www.RTCMultiConnection.org/docs/close/">close</a>(); // close entire session
+}
+</pre>
+ </li>
+
<li>
<a href="http://www.RTCMultiConnection.org/docs/connect/">connect</a>
<pre class="sh_javascript">
@@ -0,0 +1,136 @@
+<!DOCTYPE html>
+<html id="home" lang="en">
+
+<head>
+ <title>RTCMultiConnection API Reference / "isInitiator"</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
+ <link rel="author" type="text/html" href="https://plus.google.com/+MuazKhan">
+ <meta name="author" content="Muaz Khan">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <link rel="stylesheet" href="http://www.rtcmulticonnection.org/style.css">
+
+ <style>
+ p { padding: .8em; }
+
+ li {
+ border-bottom: 1px solid rgb(189, 189, 189);
+ border-left: 1px solid rgb(189, 189, 189);
+ padding: .5em;
+ }
+
+ .image-container {
+ text-align:center;
+ margin: 2em 0;
+ }
+
+ .image-parent {
+ margin: 0 2em;
+ border: 2px solid black;
+ border-radius: 5px;
+ }
+
+ .image-parent img {
+ width: 100%;
+ }
+
+ li pre {
+ margin: 0;
+ }
+ </style>
+ <!-- for HTML5 el styling -->
+ <script>
+ document.createElement('article');
+ document.createElement('footer');
+ </script>
+
+ <script type="text/javascript" src="http://www.rtcmulticonnection.org/syntax/sh_main.min.js"></script>
+ <script type="text/javascript" src="http://www.rtcmulticonnection.org/syntax/sh_javascript.min.js"></script>
+ <script type="text/javascript" src="http://www.rtcmulticonnection.org/syntax/sh_html.min.js"></script>
+ <link type="text/css" rel="stylesheet" href="http://www.rtcmulticonnection.org/syntax/sh_style.css">
+</head>
+
+<body onload="sh_highlightDocument();">
+ <article>
+ <a href="http://www.RTCMultiConnection.org/docs/" style="border-bottom: 1px solid #2844FA; font-size: 1.2em; position: absolute; text-decoration: none;right:0;top:0;">RTCMultiConnection Docs</a>
+
+ <div class="github-stargazers"></div>
+
+ <h1><a href="http://www.RTCMultiConnection.org/">RTCMultiConnection</a> API Reference / "<a href="http://www.RTCMultiConnection.org/docs/isInitiator/">isInitiator</a>"</h1>
+
+ <section class="experiment">
+ <h2>
+ What is "<code><a href="http://www.RTCMultiConnection.org/docs/isInitiator/">isInitiator</a></code>"?
+ </h2>
+
+ <blockquote class="inline">
+ "<code><a href="http://www.RTCMultiConnection.org/docs/isInitiator/">isInitiator</a></code>" is a Boolean property that can be used to detect room owner.
+ </blockquote>
+ </section>
+
+ <section class="experiment">
+ <h2>
+ How to detect room owner?
+ </h2>
+
+ <br />
+ <pre class="sh_javascript">
+if(connection.<a href="http://www.RTCMultiConnection.org/docs/isInitiator/">isInitiator</a>) {
+ connection.<a href="http://www.RTCMultiConnection.org/docs/close/">close</a>(); // close entire session
+}
+</pre>
+ </section>
+
+ <section class="experiment">
+ <h2>
+ Can I set/get this property?
+ </h2>
+
+ <br />
+ <pre class="sh_javascript">
+// yep, you can "set" this property
+connection.<a href="http://www.RTCMultiConnection.org/docs/isInitiator/">isInitiator</a> = true;
+
+// you can "get" it as well:
+if(connection.<a href="http://www.RTCMultiConnection.org/docs/isInitiator/">isInitiator</a> == false) {
+ connection.<a href="http://www.RTCMultiConnection.org/docs/join/">join</a>({
+ userid: 'room-owner-id',
+ extra: {},
+ sessionid: 'room-id',
+ session: {
+ audio: true,
+ video: true
+ }
+ });
+}
+</pre>
+ </section>
+
+ <br />
+ <br />
+ <section style="border: 1px solid rgb(189, 189, 189); margin: 1em 3em; border-radius: .2em;">
+ <h2 id="feedback" style="padding: .2em .4em; border-bottom: 1px solid rgb(189, 189, 189);">Want to ask a Question?</h2>
+ <div>
+ <textarea id="message" style="height: 8em; margin: .2em; width: 98%; border: 1px solid rgb(189, 189, 189); outline: none; resize: vertical;" placeholder="Feel free to ask any question regarding RTCMultiConnection.js!"></textarea>
+ </div>
+ <button id="send-message" style="font-size: 1em;">Ask a Question</button><small style="margin-left:1em;">You can include your email for private conversation!</small>
+ </section>
+
+ <section class="experiment own-widgets latest-commits">
+ <h2 class="header" id="updates" style="color: red; padding-bottom: .1em;"><a href="https://github.com/muaz-khan/WebRTC-Experiment/commits/master" target="_blank">Latest Updates</a></h2>
+ <div id="github-commits"></div>
+ </section>
+ </article>
+
+ <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCMultiConnection" class="fork-left"></a>
+
+ <footer>
+ <a href="https://www.webrtc-experiment.com/" target="_blank">WebRTC Experiments!</a> and
+ <a href="http://www.RTCMultiConnection.org/docs/" target="_blank">RTCMultiConnection.js</a> ©
+ <a href="mailto:muazkh@gmail.com" target="_blank">Muaz Khan</a>:
+ <a href="https://twitter.com/WebRTCWeb" target="_blank">@WebRTCWeb</a>
+ </footer>
+ <script src="http://www.rtcmulticonnection.org/commits.js"> </script>
+</body>
+</html>
@@ -1,4 +1,4 @@
-// Last time updated at May 09, 2014, 08:32:23
+// Last time updated at May 12, 2014, 08:32:23
// Latest file can be found here: https://www.webrtc-experiment.com/RTCMultiConnection-v1.7.js
// Muaz Khan - www.MuazKhan.com
// MIT License - www.WebRTC-Experiment.com/licence
@@ -466,6 +466,7 @@
mediaConfig.constraints = forcedConstraints || constraints;
mediaConfig.media = connection.media;
+ mediaConfig.connection = connection;
getUserMedia(mediaConfig);
}
}
@@ -2349,9 +2350,6 @@
var self = this;
},
setBandwidth: function (sdp) {
- // todo: should b=AS be inserted after c=IN? (RFC 4566)
- // VoiceActivityDetection: false removes c=IN
-
if (isMobileDevice || isFirefox || !this.bandwidth) return sdp;
var bandwidth = this.bandwidth;
@@ -2390,14 +2388,10 @@
return sdp;
},
setConstraints: function () {
- // c=IN must be there; otherwise chrome will fail for b=AS
- if (isChrome && this.sdpConstraints.mandatory) {
- this.sdpConstraints.mandatory.VoiceActivityDetection = true;
- }
-
-
this.constraints = {
- optional: this.sdpConstraints.optional || [],
+ optional: this.sdpConstraints.optional || [{
+ VoiceActivityDetection: false
+ }],
mandatory: this.sdpConstraints.mandatory || {
OfferToReceiveAudio: !!this.session.audio,
OfferToReceiveVideo: !!this.session.video || !!this.session.screen
@@ -2409,7 +2403,13 @@
this.constraints.mandatory.OfferToReceiveAudio = true;
}
- log('sdp-constraints', toStr(this.constraints.mandatory));
+ if(this.constraints.mandatory) {
+ log('sdp-mandatory-constraints', toStr(this.constraints.mandatory));
+ }
+
+ if(this.constraints.optional) {
+ log('sdp-optional-constraints', toStr(this.constraints.optional));
+ }
this.optionalArgument = {
optional: this.optionalArgument.optional || [{
@@ -2635,6 +2635,8 @@
return;
}
currentUserMediaRequest.mutex = true;
+
+ var connection = options.connection;
// tools.ietf.org/html/draft-alvestrand-constraints-resolution-00
var mediaConstraints = options.mediaConstraints || {};
@@ -2703,13 +2705,41 @@
hints.video.mandatory = merge(hints.video.mandatory, mandatory);
}
- if (mediaConstraints.mandatory)
+ if (mediaConstraints.mandatory) {
hints.video.mandatory = merge(hints.video.mandatory, mediaConstraints.mandatory);
+ }
// mediaConstraints.optional.bandwidth = 1638400;
if (mediaConstraints.optional)
hints.video.optional[0] = merge({}, mediaConstraints.optional);
-
+
+ if(hints.video.mandatory && !isEmpty(hints.video.mandatory) && connection._mediaSources.video) {
+ hints.video.optional.forEach(function(video, index) {
+ if(video.sourceId == connection._mediaSources.video) {
+ delete hints.video.optional[index];
+ }
+ });
+
+ hints.video.optional = swap(hints.video.optional);
+
+ hints.video.optional.push({
+ sourceId: connection._mediaSources.video
+ });
+ }
+
+ if(hints.audio.mandatory && !isEmpty(hints.audio.mandatory) && connection._mediaSources.audio) {
+ hints.audio.optional.forEach(function(audio, index) {
+ if(audio.sourceId == connection._mediaSources.audio) {
+ delete hints.audio.optional[index];
+ }
+ });
+
+ hints.audio.optional = swap(hints.audio.optional);
+
+ hints.audio.optional.push({
+ sourceId: connection._mediaSources.audio
+ });
+ }
if (hints.video && hints.video.optional && hints.video.mandatory) {
if (!hints.video.optional.length && isEmpty(hints.video.mandatory)) {
Oops, something went wrong.

0 comments on commit 3d4134d

Please sign in to comment.