'use strict';

/**
 *	An RTC Object factory that works in Firefox and Chrome when adapter.js is present
 */
function AdapterJsRTCObjectFactory() {

	this.createIceServer = function(url, username, password) {
		return createIceServer(url, username, password);
	};

    this.createRTCSessionDescription = function (sessionDescriptionString) {
        return new RTCSessionDescription(sessionDescriptionString);
    };

    this.createRTCIceCandidate = function (rtcIceCandidateString) {
        return new RTCIceCandidate(rtcIceCandidateString);
    };

    this.createRTCPeerConnection = function(config) {
    	return new RTCPeerConnection(config);
    };
}

module.exports = AdapterJsRTCObjectFactory;
'use strict';

var Utils = require("cyclon.p2p-common");

/**
 *    An RTC Object factory that works in Firefox and Chrome when adapter.js is present
 */
function AdapterJsRTCObjectFactory(logger) {

    Utils.checkArguments(arguments, 1);

    this.createIceServer = function (url, username, password) {
        if (typeof(createIceServer) !== "undefined") {
            return createIceServer(url, username, password);
        }
        else {
            logger.error("adapter.js not present or unsupported browser!");
            return null;
        }
    };

    this.createRTCSessionDescription = function (sessionDescriptionString) {
        if (typeof(RTCSessionDescription) !== "undefined") {
            return new RTCSessionDescription(sessionDescriptionString);
        }
        else {
            logger.error("adapter.js not present or unsupported browser!");
            return null;
        }
    };

    this.createRTCIceCandidate = function (rtcIceCandidateString) {
        if (typeof(RTCIceCandidate) !== "undefined") {
            return new RTCIceCandidate(rtcIceCandidateString);
        }
        else {
            logger.error("adapter.js not present or unsupported browser!");
            return null;
        }
    };

    this.createRTCPeerConnection = function (config) {
        if (typeof(RTCPeerConnection) !== "undefined") {
            return new RTCPeerConnection(config);
        }
        else {
            logger.error("adapter.js not present or unsupported browser!");
            return null;
        }
    };
}

module.exports = AdapterJsRTCObjectFactory;
Handle missing adapter.js more gracefully
Handle missing adapter.js more gracefully
