一连接过程继续解读 -----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 是成立的, 所以, 后面的函数没有走
来源: https://www.cnblogs.com/webrtcPC/p/8445412.html