new easyRTC()
- Version:
- 0.9.0
Provides client side support for the easyRTC framework. Please see the easyrtc_client_api.md and easyrtc_client_tutorial.md for more details.
copyright Copyright (c) 2013, Priologic Software Inc. All rights reserved.Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- 0.9.0
- Source:
- easyrtc.js, line 40
Members
-
<static> BECOMING_CONNECTED
-
Value returned by easyRTC.getConnectStatus if the other user is in the process of getting connected
- Source:
- easyrtc.js, line 1469
-
<static> cookieId
-
private
- Source:
- easyrtc.js, line 102
-
<static> errCodes :Dictionary.
-
Error codes that the easyRTC will use in the errCode field of error object passed to error handler set by easyRTC.setOnError. The error codes are short printable strings.
- Source:
- easyrtc.js, line 46
-
<static> IS_CONNECTED
-
Value returned by easyRTC.getConnectStatus if the other user is connected.
- Source:
- easyrtc.js, line 1472
-
<static> nativeVideoHeight
-
The height of the local media stream video in pixels. This field is set an indeterminate period of time after easyRTC.initMediaSource succeeds.
- Source:
- easyrtc.js, line 112
-
<static> nativeVideoWidth
-
The width of the local media stream video in pixels. This field is set an indeterminate period of time after easyRTC.initMediaSource succeeds.
- Source:
- easyrtc.js, line 117
-
<static> NOT_CONNECTED
-
Value returned by easyRTC.getConnectStatus if the other user isn't connected.
- Source:
- easyrtc.js, line 1466
-
<static> room
-
The name user is in. This only applies to room oriented applications and is set at the same time a token is received.
- Source:
- easyrtc.js, line 125
-
<static> setDataListener
-
Sets a listener for data sent from another client (either peer to peer or via websockets).
- Deprecated:
- This is now a synonym for setPeerListener.
- Source:
- easyrtc.js, line 1121
Example
easyRTC.setDataListener( function(easyrtcid, data) { ("From " + easyRTC.idToName(easyrtcid) + " sent the follow data " + JSON.stringify(data)); });
-
<static> userNamePattern
-
Regular expression pattern for user ids. This will need modification to support non US character sets
- Source:
- easyrtc.js, line 60
Methods
-
<static> addNewStream(otherUser, stream)
-
This method adds a new stream to an existing connection.
Parameters:
Name Type Description otherUser
string the easyrtcid of the other party in the connection. stream
MediaStream the other local media stream. - Source:
- easyrtc.js, line 1775
-
<static> call(otherUser, callSuccessCB, callFailureCB, wasAcceptedCB)
-
Initiates a call to another user. If it succeeds, the streamAcceptor callback will be called.
Parameters:
Name Type Description otherUser
String the easyrtcid of the peer being called. callSuccessCB
Function (otherCaller, mediaType) - is called when the datachannel is established or the mediastream is established. mediaType will have a value of "audiovideo" or "datachannel" callFailureCB
Function (errMessage) - is called if there was a system error interfering with the call. wasAcceptedCB
Function (wasAccepted:boolean,otherUser:string) - is called when a call is accepted or rejected by another party. It can be left null. - Source:
- easyrtc.js, line 1548
Example
easyRTC.call( otherEasyrtcid, function(easyrtcid, mediaType) { console.log("Got mediatype " + mediaType + " from " + easyRTC.idToName(easyrtcid); }, function(errMessage) { console.log("call to " + easyRTC.idToName(otherEasyrtcid) + " failed:" + errMessage); }, function(wasAccepted, easyrtcid) { if( wasAccepted ) { console.log("call accepted by " + easyRTC.idToName(easyrtcid)); } else { console.log("call rejected" + easyRTC.idToName(easyrtcid)); } });
-
<static> cleanId(idString) → {String}
-
A convenience function to ensure that a string doesn't have symbols that will be interpreted by HTML.
Parameters:
Name Type Description idString
String - Source:
- easyrtc.js, line 565
Returns:
- Type
- String
Example
console.log( easyRTC.cleanId('&hello'));
-
<static> clearMediaStream(element) → {undefined}
-
Clears the media stream on a video object.
Parameters:
Name Type Description element
type the video object. - Source:
- easyrtc.js, line 747
Returns:
- Type
- undefined
-
<static> connect(applicationName, successCallback, errorCallback)
-
easyRTC.connect(args) performs the connection to the server. You must connect before trying to call other users.
Parameters:
Name Type Description applicationName
String is a string that identifies the application so that different applications can have different lists of users. successCallback
Function (actualName, cookieOwner) - is called on successful connect. actualName is guaranteed to be unique. cookieOwner is true if the server sent back a isOwner:true field in response to a cookie. errorCallback
Function (msgString) - is called on unsuccessful connect. if null, an alert is called instead. - Source:
- easyrtc.js, line 1289
-
<static> disconnect()
-
Disconnect from the easyRTC server.
- Source:
- easyrtc.js, line 389
-
<static> dontAddCloseButtons()
-
By default, the initManaged routine sticks a "close" button on top of each caller video object that it manages. Call this function (before calling initManaged) to disable that particular feature.
- Source:
- easyrtc.js, line 2711
-
<static> enableAudio(enabled)
-
Sets whether audio is transmitted by the local user in any subsequent calls.
Parameters:
Name Type Description enabled
Boolean true to include audio, false to exclude audio. The default is true. - Source:
- easyrtc.js, line 646
Example
easyRTC.enableAudio(false);
-
<static> enableDataChannels(enabled)
-
Sets whether webrtc data channels are used to send inter-client messages. This is only the messages that applications explicitly send to other applications, not the webrtc signalling messages.
Parameters:
Name Type Description enabled
Boolean true to use data channels, false otherwise. The default is false. - Source:
- easyrtc.js, line 669
Example
easyRTC.enableDataChannels(true);
-
<static> enableDebug(enable)
-
Enable or disable logging to the console. Note: if you want to control the printing of debug messages, override the easyRTC.debugPrinter variable with a function that takes a message string as it's argument. This is exactly what easyRTC.enableDebug does when it's enable argument is true.
Parameters:
Name Type Description enable
Boolean true to turn on debugging, false to turn off debugging. Default is false. - Source:
- easyrtc.js, line 246
Example
easyRTC.enableDebug(true);
-
<static> enableVideo(enabled)
-
Sets whether video is transmitted by the local user in any subsequent calls.
Parameters:
Name Type Description enabled
Boolean true to include video, false to exclude video. The default is true. - Source:
- easyrtc.js, line 657
Example
easyRTC.enableVideo(false);
-
<static> getConnectionCount() → {Number}
-
Returns the number of live peer connections the client has.
- Source:
- easyrtc.js, line 630
Returns:
- Type
- Number
Example
("You have " + easyRTC.getConnectionCount() + " peer connections");
-
<static> getConnectStatus(otherUser) → {String}
-
Return true if the client has a peer-2-peer connection to another user. The return values are text strings so you can use them in debugging output.
Parameters:
Name Type Description otherUser
String the easyrtcid of the other user. - Source:
- easyrtc.js, line 1486
Returns:
one of the following values: easyRTC.NOT_CONNECTED, easyRTC.BECOMING_CONNECTED, easyRTC.IS_CONNECTED- Type
- String
Example
if( easyRTC.getConnectStatus(otherEasyrtcid) == easyRTC.NOT_CONNECTED ) { easyRTC.connect(otherEasyrtcid, function() { console.log("success"); }, function() { console.log("failure"); }); }
-
<static> getLocalStream() → {MediaStream}
-
Returns a media stream for your local camera and microphone. It can be called only after easyRTC.initMediaSource has succeeded. It returns a stream that can be used as an argument to easyRTC.setVideoObjectSrc.
- Source:
- easyrtc.js, line 698
Returns:
- Type
- MediaStream
Example
easyRTC.setVideoObjectSrc( document.getElementById("myVideo"), easyRTC.getLocalStream());
-
<static> getLocalStreamAsUrl() → {URL}
-
Returns a URL for your local camera and microphone. It can be called only after easyRTC.initMediaSource has succeeded. It returns a url that can be used as a source by the chrome video element or the <canvas> element.
- Source:
- easyrtc.js, line 682
Returns:
- Type
- URL
Example
document.getElementById("myVideo").src = easyRTC.getLocalStreamAsUrl();
-
<static> getStats(otherUser, collector, fieldsOfInterest) → {boolean}
-
Collects statistics on a particular connection.
Parameters:
Name Type Description otherUser
string the easyrtcid the connection is attached to. collector
function a function that will be invoked with a map of statistics values fieldsOfInterest
DOMObject a map listing just the statistics to be reported. Can be null in which case all statics are reported. - Source:
- easyrtc.js, line 1701
Returns:
true if statistics are collectable, false if not.- Type
- boolean
-
<static> hangup(otherUser)
-
Hang up on a particular user or all users.
Parameters:
Name Type Description otherUser
String the easyrtcid of the person to hang up on. - Source:
- easyrtc.js, line 1735
Example
easyRTC.hangup(someEasyrtcid);
-
<static> hangupAll()
-
Hangs up on all current connections.
- Source:
- easyrtc.js, line 1750
Example
easyRTC.hangupAll();
-
<static> haveAudioTrack(easyrtcid) → {boolean}
-
Determines if a particular peer2peer connection has an audio track.
Parameters:
Name Type Description easyrtcid
the id of the other caller in the connection. Null for local media stream. - Source:
- easyrtc.js, line 1253
Returns:
- Type
- boolean
-
<static> haveVideoTrack(easyrtcid) → {string}
-
Determines if a particular peer2peer connection has a video track.
Parameters:
Name Type Description easyrtcid
the id of the other caller in the connection. Null for local media stream. - Source:
- easyrtc.js, line 1264
Returns:
"yes", "no", "unknown"- Type
- string
-
<static> idToName(easyrtcid) → {String}
-
Convert an easyrtcid to a user name. This is useful for labelling buttons and messages regarding peers.
Parameters:
Name Type Description easyrtcid
String - Source:
- easyrtc.js, line 1197
Returns:
- Type
- String
Example
console.log(easyrtcid + " is actually " + easyRTC.idToName(easyrtcid));
-
<static> initManaged(applicationName, monitorVideoId, videoIds, onReady, onFailure)
-
Provides a layer on top of the easyRTC.initMediaSource and easyRTC.connect, assign the local media stream to the video object identified by monitorVideoId, assign remote video streams to the video objects identified by videoIds, and then call onReady. One of it's side effects is to add hangup buttons to the remote video objects, buttons that only appear when you hover over them with the mouse cursor. This method will also add the easyRTCMirror class to the monitor video object so that it behaves like a mirror.
Parameters:
Name Type Description applicationName
String name of the application. monitorVideoId
String the id of the video object used for monitoring the local stream. videoIds
Array an array of video object ids (strings) onReady
Function a callback function used on success. onFailure
Function a callbackfunction used on failure (failed to get local media or a connection of the signaling server). - Source:
- easyrtc.js, line 2732
Example
easyRTC.initManaged('multiChat', 'selfVideo', ['remote1', 'remote2', 'remote3'], function() { console.log("successfully connected."); });
-
<static> initMediaSource(successCallback, errorCallback)
-
Initializes your access to a local camera and microphone. Failure could be caused a browser that didn't support webrtc, or by the user not granting permission. If you are going to call easyRTC.enableAudio or easyRTC.enableVideo, you need to do it before calling easyRTC.initMediaSource.
Parameters:
Name Type Description successCallback
Function will be called when the media source is ready. errorCallback
Function is called with a message string if the attempt to get media failed. - Source:
- easyrtc.js, line 835
Example
easyRTC.initMediaSource( function() { easyRTC.setVideoObjectSrc( document.getElementById("mirrorVideo"), easyRTC.getLocalStream()); }, function() { easyRTC.showError("no-media", "Unable to get local media"); });
-
<static> isNameValid(name) → {Boolean}
-
Checks if the supplied string is a valid user name (standard identifier rules)
Parameters:
Name Type Description name
String - Source:
- easyrtc.js, line 136
Returns:
true for a valid user name- Type
- Boolean
Example
var name = document.getElementById('nameField').value; if( !easyRTC.isNameValid(name)) { alert("Bad user name"); }
-
<static> sendData(destUser, data)
-
Sends data to another user. This method uses datachannels if one has been set up, or websockets otherwise.
Parameters:
Name Type Description destUser
String (an easyrtcid) data
String an object which can be JSON'ed. - Source:
- easyrtc.js, line 1454
Example
easyRTC.sendData(someEasyrtcid, {room:499, bldgNum:'asd'});
-
<static> sendDataP2P(destUser, data)
-
Sends data to another user using previously established data channel. This method will fail if no data channel has been established yet. Unlike the easyRTC.sendWS method, you can't send a dictionary, convert dictionaries to strings using JSON.stringify first. What datatypes you can send, and how large a datatype depends on your browser.
Parameters:
Name Type Description destUser
String (an easyrtcid) data
Object an object which can be JSON'ed. - Source:
- easyrtc.js, line 1401
Example
easyRTC.sendDataP2P(someEasyrtcid, {room:499, bldgNum:'asd'});
-
<static> sendDataWS(destUser, data)
-
Sends data to another user using websockets.
Parameters:
Name Type Description destUser
String (an easyrtcid) data
String an object which can be JSON'ed. - Source:
- easyrtc.js, line 1428
Example
easyRTC.sendDataWS(someEasyrtcid, {room:499, bldgNum:'asd'});
-
<static> sendEasyrtcCmd(instruction, data) → {undefined}
-
Sends a easyrtcCmd command to the server, rather than another client.
Parameters:
Name Type Description instruction
string data
object - Source:
- easyrtc.js, line 708
Returns:
- Type
- undefined
-
<static> setAcceptChecker(acceptCheck)
-
easyRTC.setAcceptChecker sets the callback used to decide whether to accept or reject an incoming call.
Parameters:
Name Type Description acceptCheck
Function takes the arguments (callerEasyrtcid, function():boolean ) {} The acceptCheck callback is passed (as it's second argument) a function that should be called with either a true value (accept the call) or false value( reject the call). - Source:
- easyrtc.js, line 1007
Example
easyRTC.setAcceptChecker( function(easyrtcid, acceptor) { if( easyRTC.idToName(easyrtcid) === 'Fred' ) { acceptor(true); } else if( easyRTC.idToName(easyrtcid) === 'Barney' ) { setTimeout( function() { acceptor(true)}, 10000); } else { acceptor(false); } });
-
<static> setApiKey(key)
-
Set the API Key. The API key identifies the owner of the application. The API key has no meaning for the Open Source server.
Parameters:
Name Type Description key
String - Source:
- easyrtc.js, line 206
Example
easyRTC.setApiKey('cmhslu5vo57rlocg');
-
<static> setAppDefinedFields(fields)
-
Provide a set of application defined fields that will be part of this instances configuration information. This data will get sent to other peers via the websocket path.
Parameters:
Name Type Description fields
type just be JSON serializable to a length of not more than 128 bytes. - Source:
- easyrtc.js, line 431
Example
easyRTC.setAppDefinedFields( { favorite_alien:'Mr Spock'}); easyRTC.setLoggedInListener( function(list) { for( var i in list ) { console.log("easyrtcid=" + i + " favorite alien is " + list[i].appDefinedFields.favorite_alien); } });
-
<static> setApplicationName(name)
-
Set the application name. Applications can only communicate with other applications that share the sname API Key and application name. There is no predefined set of application names. Maximum length is
Parameters:
Name Type Description name
String - Source:
- easyrtc.js, line 218
Example
easyRTC.setApplicationName('simpleAudioVideo');
-
<static> setCallCancelled(callCancelled)
-
Sets the callCancelled callback. This will be called when a remote user initiates a call to you, but does a "hangup" before you have a chance to get his video stream.
Parameters:
Name Type Description callCancelled
Function takes an easyrtcid as an argument and a boolean that indicates whether the call was explicitly cancelled remotely (true), or actually accepted by the user attempting a call to the same party. - Source:
- easyrtc.js, line 1055
Example
easyRTC.setCallCancelled( function(easyrtcid, explicitlyCancelled) { if( explicitlyCancelled ) { console..log(easyrtc.idToName(easyrtcid) + " stopped trying to reach you"); } else { console.log("Implicitly called " + easyrtc.idToName(easyrtcid)); } });
-
<static> setCookieId(cookieId)
-
This function sets the name of the cookie that client side library will look for and transmit back to the server as it's easyrtcsid in the first message.
Parameters:
Name Type Description cookieId
type - Source:
- easyrtc.js, line 155
-
<static> setDataChannelCloseListener(listener)
-
Sets a callback that is called when a previously open data channel closes. The callback will be called with an easyrtcid as it's sole argument.
Parameters:
Name Type Description listener
Function - Source:
- easyrtc.js, line 621
Example
easyRTC.setDataChannelCloseListener( function(easyrtcid) { ("No longer connected to " + easyRTC.idToName(easyrtcid)); });
-
<static> setDataChannelOpenListener(listener)
-
Sets a callback that is called when a data channel is open and ready to send data. The callback will be called with an easyrtcid as it's sole argument.
Parameters:
Name Type Description listener
Function - Source:
- easyrtc.js, line 608
Example
easyRTC.setDataChannelOpenListener( function(easyrtcid) { easyRTC.sendDataP2P(easyrtcid, "hello"); });
-
<static> setDisconnectListener(disconnectListener)
-
Sets the listener for socket disconnection by external (to the API) reasons.
Parameters:
Name Type Description disconnectListener
Function takes no arguments and is not called as a result of calling easyRTC.disconnect. - Source:
- easyrtc.js, line 1183
Example
easyRTC.setDisconnectListener(function() { easyRTC.showError("SYSTEM-ERROR", "Lost our connection to the socket server"); });
-
<static> setFilterOutTurn(filterOut) → {undefined}
-
This function allows you to select whether turn servers are filtered out of the peer connection configuration. It's primary purpose to is to allow you to easily determine whether you need a turn server to form a connection.
Parameters:
Name Type Description filterOut
boolean is true to filter out turn servers, false to include them. - Source:
- easyrtc.js, line 147
Returns:
- Type
- undefined
-
<static> setGotConnection(gotConnectionCB)
-
Sets an event handler that gets called when a connection to the signalling server has or has not been made. Can only be called after calling easyRTC.initManaged.
Parameters:
Name Type Description gotConnectionCB
Function has the signature (gotConnection, why) - Source:
- easyrtc.js, line 2791
Example
easyRTC.setGotConnection( function(gotConnection, why) { if( gotConnection ) { console.log("Successfully connected to signalling server"); } else { console.log("Failed to connect to signalling server because: " + why); } });
-
<static> setGotMedia(gotMediaCB)
-
Sets an event handler that gets called when the local media stream is created or not. Can only be called after calling easyRTC.initManaged.
Parameters:
Name Type Description gotMediaCB
Function has the signature function(gotMedia, why) - Source:
- easyrtc.js, line 2773
Example
easyRTC.setGotMedia( function(gotMediaCB, why) { if( gotMedia ) { console.log("Got the requested user media"); } else { console.log("Failed to get media because: " + why); } });
-
<static> setLoggedInListener(listener)
-
Set the callback that will be invoked when the list of people logged in changes. The callback expects to receive a map whose ideas are easyrtcids and whose values are in turn maps supplying user specific information. The inner maps have the following keys: userName, applicationName, browserFamily, browserMajor, osFamily, osMajor, deviceFamily. The callback also receives a boolean that indicates whether the owner is the primary owner of a room.
Parameters:
Name Type Description listener
Function - Source:
- easyrtc.js, line 593
Example
easyRTC.setLoggedInListener( function(list, isPrimaryOwner) { for( var i in list ) { ("easyrtcid=" + i + " belongs to user " + list[i].userName); } });
-
<static> setOnCall(cb)
-
Sets an event handler that gets called when a call is established. It's only purpose (so far) is to support transitions on video elements. This function is only defined after easyRTC.initManaged is called. The slot argument is the index into the array of video ids.
Parameters:
Name Type Description cb
Function has the signature function(easyrtcid, slot) {} - Source:
- easyrtc.js, line 2805
Example
easyRTC.setOnCall( function(easyrtcid, slot) { console.log("call with " + easyrtcid + "established"); });
-
<static> setOnError(errListener)
-
Sets the easyRTC.onError field to a user specified function.
Parameters:
Name Type Description errListener
Function takes an object of the form { errCode: String, errText: String} - Source:
- easyrtc.js, line 1034
Example
easyRTC.setOnError( function(errorObject) { document.getElementById("errMessageDiv").innerHTML += errorObject.errText; });
-
<static> setOnHangup(cb)
-
Sets an event handler that gets called when a call is ended. it's only purpose (so far) is to support transitions on video elements. x * this function is only defined after easyRTC.initManaged is called. The slot is parameter is the index into the array of video ids. Note: if you call easyRTC.getConnectionCount() from inside your callback it's count will reflect the number of connections before the hangup started.
Parameters:
Name Type Description cb
Function has the signature function(easyrtcid, slot) {} - Source:
- easyrtc.js, line 2821
Example
easyRTC.setOnHangup( function(easyrtcid, slot) { console.log("call with " + easyrtcid + "ended"); });
-
<static> setOnStreamClosed(onStreamClosed)
-
Sets a callback to receive notification of a media stream closing. The usual use of this is to clear the source of your video object so you aren't left with the last frame of the video displayed on it.
Parameters:
Name Type Description onStreamClosed
Function takes an easyrtcid as it's first parameter. - Source:
- easyrtc.js, line 1069
Example
easyRTC.setOnStreamClosed( function(easyrtcid) { easyRTC.setVideoObjectSrc( document.getElementById("callerVideo"), ""); ( easyRTC.idToName(easyrtcid) + " went away"); });
-
<static> setPeerListener(listener)
-
Sets a listener for data sent from another client (either peer to peer or via websockets).
Parameters:
Name Type Description listener
Function has the signature (easyrtcid, data) - Source:
- easyrtc.js, line 1106
Example
easyRTC.setPeerListener( function(easyrtcid, data) { ("From " + easyRTC.idToName(easyrtcid) + " sent the follow data " + JSON.stringify(data)); });
-
<static> setScreenCapture()
-
This function requests that screen capturing be used to provide the local media source rather than a webcam. If you have multiple screens, they are composited side by side.
- Source:
- easyrtc.js, line 191
Example
easyRTC.setScreenCapture();
-
<static> setServerListener(listener)
-
Sets a listener for messages from the server.
Parameters:
Name Type Description listener
Function has the signature (data) - Source:
- easyrtc.js, line 1131
Example
easyRTC.setPeerListener( function(data) { ("From Server sent the follow data " + JSON.stringify(data)); });
-
<static> setSipConfig(connectConfig) → {undefined}
-
Setup the JsSIP User agent.
Parameters:
Name Type Description connectConfig
type is a dictionary that contains the following fields: { ws_servers, uri, password } - Source:
- easyrtc.js, line 229
Returns:
- Type
- undefined
-
<static> setSocketUrl(socketUrl)
-
Sets the url of the Socket server. The node.js server is great as a socket server, but it doesn't have all the hooks you'd like in a general web server, like PHP or Python plug-ins. By setting the serverPath your application can get it's regular pages from a regular webserver, but the easyRTC library can still reach the socket server.
Parameters:
Name Type Description socketUrl
DOMString - Source:
- easyrtc.js, line 1148
Example
easyRTC.setSocketUrl(":8080");
-
<static> setStreamAcceptor(acceptor)
-
easyRTC.setStreamAcceptor sets a callback to receive media streams from other peers, independent of where the call was initiated (caller or callee).
Parameters:
Name Type Description acceptor
Function takes arguments (caller, mediaStream) - Source:
- easyrtc.js, line 1022
Example
easyRTC.setStreamAcceptor(function(easyrtcid, stream) { document.getElementById('callerName').innerHTML = easyRTC.idToName(easyrtcid); easyRTC.setVideoObjectSrc( document.getElementById("callerVideo"), stream); });
-
<static> setUserName(userName) → {Boolean}
-
Sets the user name associated with the connection.
Parameters:
Name Type Description userName
String must obey standard identifier conventions. - Source:
- easyrtc.js, line 1164
Returns:
true if the call succeeded, false if the username was invalid.- Type
- Boolean
Example
if ( !easyRTC.setUserName("JohnSmith") ) { alert("bad user name);
-
<static> setVideoBandwidth(kbitsPerSecond)
-
Sets the bandwidth for sending video data. Setting the rate too low will cause connection attempts to fail. 40 is probably good lower limit. The default is 50. A value of zero will remove bandwidth limits.
Parameters:
Name Type Description kbitsPerSecond
Number is rate in kilobits per second. - Source:
- easyrtc.js, line 1082
Example
easyRTC.setVideoBandwidth( 40);
-
<static> setVideoDims(width, height)
-
This function is used to set the dimensions of the local camera, usually to get HD. If called, it must be called before calling easyRTC.initMediaSource (explicitly or implicitly). assuming it is supported. If you don't pass any parameters, it will default to 720p dimensions.
Parameters:
Name Type Description width
Number in pixels height
Number in pixels - Source:
- easyrtc.js, line 168
Examples
easyRTC.setVideoDims(1280,720);
easyRTC.setVideoDims();
-
<static> setVideoObjectSrc(videoObject, stream)
-
Sets a video or audio object from a media stream. Chrome uses the src attribute and expects a URL, while firefox uses the mozSrcObject and expects a stream. This procedure hides that from you. If the media stream is from a local webcam, you may want to add the easyRTCMirror class to the video object so it looks like a proper mirror. The easyRTCMirror class is defined in easyrtc.css, which is automatically added when you add the easyrtc.js file to an HTML file.
Parameters:
Name Type Description videoObject
DOMObject an HTML5 video object stream
MediaStream a media stream as returned by easyRTC.getLocalStream or your stream acceptor. - Source:
- easyrtc.js, line 773
Example
easyRTC.setVideoObjectSrc( document.getElementById("myVideo"), easyRTC.getLocalStream());
-
<static> showError(messageCode, message)
-
Default error reporting function. The default implementation displays error messages in a programatically created div with the id easyRTCErrorDialog. The div has title component with a classname of easyRTCErrorDialog_title. The error messages get added to a container with the id easyRTCErrorDialog_body. Each error message is a text node inside a div with a class of easyRTCErrorDialog_element. There is an "okay" button with the className of easyRTCErrorDialog_okayButton.
Parameters:
Name Type Description messageCode
String An error message code message
String the error message text without any markup. - Source:
- easyrtc.js, line 452
Example
easyRTC.showError("BAD_NAME", "Invalid username");
-
<static> supportsGetUserMedia() → {Boolean}
-
Determines if the local browser supports WebRTC GetUserMedia (access to camera and microphone).
- Source:
- easyrtc.js, line 271
Returns:
True getUserMedia is supported.- Type
- Boolean
-
<static> supportsPeerConnection() → {Boolean}
-
Determines if the local browser supports WebRTC Peer connections to the extent of being able to do video chats.
- Source:
- easyrtc.js, line 278
Returns:
True if Peer connections are supported.- Type
- Boolean