2014-07-02 27 views
3

我在做一个simpleWebRTCdemo创建一个直播会话。在SimpleWebRTC中获取约束对象

我想实现这一目标是:

  1. 人是领导者。领导者可以播放他的音频和视频。
  2. 其余加入的人都是追随者。他们只能看到和听到领导的广播。

要定期的WebRTC做到这一点,我们有约束的对象,其中,我们可以说:

{audio: false, video: false} 

然而,在simpleWebRTCobject,我没有看到一个约束object曝光。

如何使用完成此操作simpleWebRTC

回答

0

所以,我发现这个文件在这里说(https://simplewebrtc.com/notsosimple.html):

var webrtc = new SimpleWebRTC({ 
    localVideoEl: 'localVideo', 
    remoteVideosEl: 'remotesVideos', 
    autoRequestMedia: true, 
    url: 'https://example.com/' 
    //use the media options to pass constraints for getUserMedia requests 
    media: mediaOptions 
}); 

或者你有修改库:

SimpleWebRTC.prototype.startLocalVideo = -> 
    self = this 
    this.config.constraints ||= {video: true, audio: true} 
    this.webrtc.startLocalMedia this.config.constraints, (err, stream)-> 
    if err 
     self.emit(err) 
    else 
     attachMediaStream(stream, 
     self.getLocalVideoContainer(), 
     {muted: true, mirror: true}) 

然后

webrtc = new SimpleWebRTC 
    localVideoEl: 'localVideo' 
    remoteVideosEl: 'remotes' 
    autoRequestMedia: true 
    debug: true 
    detectSpeakingEvents: true 
    autoAdjustMic: false 
    constraints: 
    audio: true 
    video: 
     mandatory: 
     maxWidth: 320 
     maxHeight: 180 

这里的黑客 http://blog.dev.zyncro-china.com/2014/02/25/hacking-simplewebrtc-js-to-change-the-video-resolution/