api/easyrtc.js
function(window) {
    var URL = window && window.URL;

    if (!(typeof window === 'object' && window.HTMLMediaElement &&
          'srcObject' in window.HTMLMediaElement.prototype &&
        URL.createObjectURL && URL.revokeObjectURL)) {
      // Only shim CreateObjectURL using srcObject if srcObject exists.
      return undefined;
    }

    var nativeCreateObjectURL = URL.createObjectURL.bind(URL);
    var nativeRevokeObjectURL = URL.revokeObjectURL.bind(URL);
    var streams = new Map(), newId = 0;

    URL.createObjectURL = function(stream) {
      if ('getTracks' in stream) {
        var url = 'polyblob:' + (++newId);
        streams.set(url, stream);
        utils.deprecated('URL.createObjectURL(stream)',
            'elem.srcObject = stream');
        return url;
      }
      return nativeCreateObjectURL(stream);
    };
    URL.revokeObjectURL = function(url) {
      nativeRevokeObjectURL(url);
      streams.delete(url);
    };

    var dsc = Object.getOwnPropertyDescriptor(window.HTMLMediaElement.prototype,
                                              'src');
    Object.defineProperty(window.HTMLMediaElement.prototype, 'src', {
      get: function() {
        return dsc.get.apply(this);
      },
      set: function(url) {
        this.srcObject = streams.get(url) || null;
        return dsc.set.apply(this, [url]);
      }
    });

    var nativeSetAttribute = window.HTMLMediaElement.prototype.setAttribute;
    window.HTMLMediaElement.prototype.setAttribute = function() {
      if (arguments.length === 2 &&
          ('' + arguments[0]).toLowerCase() === 'src') {
        this.srcObject = streams.get(arguments[1]) || null;
      }
      return nativeSetAttribute.apply(this, arguments);
    };
  }
function(window) {
    var URL = window && window.URL;

    if (!(typeof window === 'object' && window.HTMLMediaElement &&
          'srcObject' in window.HTMLMediaElement.prototype &&
        URL.createObjectURL && URL.revokeObjectURL)) {
      // Only shim CreateObjectURL using srcObject if srcObject exists.
      return undefined;
    }

    var nativeCreateObjectURL = URL.createObjectURL.bind(URL);
    var nativeRevokeObjectURL = URL.revokeObjectURL.bind(URL);
    var streams = new Map(), newId = 0;

    URL.createObjectURL = function(stream) {
      if ('getTracks' in stream) {
        var url = 'polyblob:' + (++newId);
        streams.set(url, stream);
        utils.deprecated('URL.createObjectURL(stream)',
            'elem.srcObject = stream');
        return url;
      }
      return nativeCreateObjectURL(stream);
    };
    URL.revokeObjectURL = function(url) {
      nativeRevokeObjectURL(url);
      streams.delete(url);
    };

    var dsc = Object.getOwnPropertyDescriptor(window.HTMLMediaElement.prototype,
                                              'src');
    Object.defineProperty(window.HTMLMediaElement.prototype, 'src', {
      get: function() {
        return dsc.get.apply(this);
      },
      set: function(url) {
        this.srcObject = streams.get(url) || null;
        return dsc.set.apply(this, [url]);
      }
    });

    var nativeSetAttribute = window.HTMLMediaElement.prototype.setAttribute;
    window.HTMLMediaElement.prototype.setAttribute = function() {
      if (arguments.length === 2 &&
          ('' + arguments[0]).toLowerCase() === 'src') {
        this.srcObject = streams.get(arguments[1]) || null;
      }
      return nativeSetAttribute.apply(this, arguments);
    };
  }
function ( window ) { var URL = window && window . URL ; if ( ! ( typeof window === 'object' && window . HTMLMediaElement && 'srcObject' in window . HTMLMediaElement . prototype && URL . createObjectURL && URL . revokeObjectURL ) ) { // Only shim CreateObjectURL using srcObject if srcObject exists. return undefined ; } var nativeCreateObjectURL = URL . createObjectURL . bind ( URL ) ; var nativeRevokeObjectURL = URL . revokeObjectURL . bind ( URL ) ; var streams = new Map ( ) , newId = 0 ; URL . createObjectURL = function ( stream ) { if ( 'getTracks' in stream ) { var url = 'polyblob:' + ( ++ newId ) ; streams . set ( url , stream ) ; utils . deprecated ( 'URL.createObjectURL(stream)' , 'elem.srcObject = stream' ) ; return url ; } return nativeCreateObjectURL ( stream ) ; } ; URL . revokeObjectURL = function ( url ) { nativeRevokeObjectURL ( url ) ; streams . delete ( url ) ; } ; var dsc = Object . getOwnPropertyDescriptor ( window . HTMLMediaElement . prototype , 'src' ) ; Object . defineProperty ( window . HTMLMediaElement . prototype , 'src' , { get : function ( ) { return dsc . get . apply ( this ) ; } , set : function ( url ) { this . srcObject = streams . get ( url ) || null ; return dsc . set . apply ( this , [ url ] ) ; } } ) ; var nativeSetAttribute = window . HTMLMediaElement . prototype . setAttribute ; window . HTMLMediaElement . prototype . setAttribute = function ( ) { if ( arguments . length === 2 && ( '' + arguments [ 0 ] ) . toLowerCase ( ) === 'src' ) { this . srcObject = streams . get ( arguments [ 1 ] ) || null ; } return nativeSetAttribute . apply ( this , arguments ) ; } ; }
shimCreateObjectURL must be called before shimSourceObject to avoid loop.
shimCreateObjectURL must be called before shimSourceObject to avoid loop .