webrtc底层一对一连接过程探索(三)

一、连接过程继续解读—–fun33-fun35解读

完整代码如下:

    //fun33-37
    console.error('fun35-37==>2332==>2332');
    var q = window.MediaStream;
    void 0 === q && 
    "undefined" != typeof webkitMediaStream && 
    (q = webkitMediaStream), 
    void 0 !== q &&
    (   "getVideoTracks" in q.prototype 
        || (q.prototype.getVideoTracks = function() {
                console.info('fun3537.03b==>2348==>2348');
                if (!this.getTracks) return [];
                var e = [];
                return this.getTracks.forEach(function(n) {
                    -1 !== ("" + n.kind).indexOf("video") && e.push(n)
                }), e
           }, 
        console.info('fun3537.04==>2357==>2357'),
        q.prototype.getAudioTracks = function() {
            console.info('fun3537.04==>2356==>2356');
            if (!this.getTracks) return [];
            var e = [];
            return this.getTracks.forEach(function(n) {
                -1 !== ("" + n.kind).indexOf("audio") && e.push(n)
            }), e
        }), 
    console.info('fun3537.05==>2367==>2367'),
    "stop" in q.prototype || (q.prototype.stop = function() {
        console.info('fun3537.05==>2367==>2367');
            this.getAudioTracks().forEach(function(e) {
                e.stop && e.stop()
            }), 
            this.getVideoTracks().forEach(function(e) {
                e.stop && e.stop()
            })
        })
),

1.1 代码段一

var q = window.MediaStream;

 q是个函数,用于获取媒体数据。

1.2 代码段二

void 0 === q &&

"undefined" != typeof webkitMediaStream &&

(q = webkitMediaStream),

注:经测试,void ===q为false,所以就没必要向后执行了,实际上,webkitMediaStream也是个函数,不是undefined.

1.3 代码段三

    void 0 !== q &&

    (   console.info('fun3537.03a==>2345==>2345')&&

        "getVideoTracks" in q.prototype

        || (q.prototype.getVideoTracks = function() {

                console.info('fun3537.03b==>2348==>2348');

                if (!this.getTracks) return [];

                var e = [];

                return this.getTracks.forEach(function(n) {

                    -1 !== ("" + n.kind).indexOf("video") && e.push(n)

                }), e

           },

注:q.prototype是向对象里面添加属性的方法,如下:

因为”getVideoTracks” in q.prototype是成立的,所以,后面的函数没有走。

 

posted on 2018-02-12 19:59 小小梁的博客 阅读() 评论() 编辑 收藏

版权声明:本文为webrtcPC原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/webrtcPC/p/8445412.html