使用 Kurento 媒体服务器在 Chrome 中获取 "ScreenCaptureError"
Getting "ScreenCaptureError" in Chrome using Kurento Media Server
我正在尝试与 Kurento WebRtc 服务器共享我的屏幕。但是出现此错误:
NavigatorUserMediaError {name: "ScreenCaptureError", message: "", constraintName: ""}
同样的代码在Firefox中没有错误。
用于 webrtc 的约束:
var constraints = {
audio: true,
video: {
mandatory : {
chromeMediaSource: 'screen',
maxWidth: 1920,
maxHeight: 1080,
maxFrameRate: 30,
minFrameRate: 15,
minAspectRatio: 1.6
},
optional: []
}
}
var options = {
localVideo : video,
onicecandidate : onIceCandidate,
mediaConstraints : constraints
}
webRtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options,function(error) {
if (error) {
return console.error(error);
}
webRtcPeer.generateOffer(onOfferPresenter);
});
如何使用 chrome 和 kurento 共享我的屏幕?
通过 WebRTC 与 Kurento 共享屏幕,与共享网络摄像头完全相同:从客户端获取流并协商端点。进行屏幕共享时棘手的部分是获取流。 kurento-utils-js 库会给你一点帮助,因为你可以在客户端创建 WebRtcPeer
对象,表明你想要共享你的屏幕或 window。您只需要确保您
- 已安装扩展程序以在 Chrome 中进行屏幕共享。在 FF 中,将域添加到白名单就足够了。检查 this 分机。
- 在创建
kurentoUtils.WebRtcPeer
对象时在选项包中传递一个有效的 sendSource
值(screen
或 window
)
- 在你的 window 对象中有一个
getScreenConstraints
方法,因为它将被使用 here. getScreenConstraints
should return a valid set of constraints, depending on the browser. YOu can check an implementation of that function here
我认为这应该足够了。我们正在与图书馆进行屏幕共享,使用我们自己的 getScreenConstrains
和扩展程序,它工作正常。一旦你有了它,使用 kurento-utils-js 库进行屏幕共享就非常容易了。像这样创建对等点时只需要传递 sendSource
值
var constraints = {
audio: false,
video: true
}
var options = {
localVideo: videoInput, //if you want to see what you are sharing
onicecandidate: onIceCandidate,
mediaConstraints: constraints,
sendSource: 'screen'
}
webRtcPeerScreencast = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function(error) {
if (error) return onError(error) //You'll need to use whatever you use for handling errors
this.generateOffer(onOffer)
});
sendSource
的值为字符串,具体要看你要分享什么
'screen'
:会让你共享整个屏幕。如果您有多个,您可以选择分享哪一个
'window'
:让您在所有打开的 windows 之间进行选择
[ 'screen', 'window' ]
:警告!仅被 Chrome 接受,这将让用户在全屏或 windows 之间进行选择。
'webcam'
:这是默认值,您无需在此处指定任何内容。猜猜会发生什么 ;-)
我正在尝试与 Kurento WebRtc 服务器共享我的屏幕。但是出现此错误:
NavigatorUserMediaError {name: "ScreenCaptureError", message: "", constraintName: ""}
同样的代码在Firefox中没有错误。 用于 webrtc 的约束:
var constraints = {
audio: true,
video: {
mandatory : {
chromeMediaSource: 'screen',
maxWidth: 1920,
maxHeight: 1080,
maxFrameRate: 30,
minFrameRate: 15,
minAspectRatio: 1.6
},
optional: []
}
}
var options = {
localVideo : video,
onicecandidate : onIceCandidate,
mediaConstraints : constraints
}
webRtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options,function(error) {
if (error) {
return console.error(error);
}
webRtcPeer.generateOffer(onOfferPresenter);
});
如何使用 chrome 和 kurento 共享我的屏幕?
通过 WebRTC 与 Kurento 共享屏幕,与共享网络摄像头完全相同:从客户端获取流并协商端点。进行屏幕共享时棘手的部分是获取流。 kurento-utils-js 库会给你一点帮助,因为你可以在客户端创建 WebRtcPeer
对象,表明你想要共享你的屏幕或 window。您只需要确保您
- 已安装扩展程序以在 Chrome 中进行屏幕共享。在 FF 中,将域添加到白名单就足够了。检查 this 分机。
- 在创建
kurentoUtils.WebRtcPeer
对象时在选项包中传递一个有效的sendSource
值(screen
或window
) - 在你的 window 对象中有一个
getScreenConstraints
方法,因为它将被使用 here.getScreenConstraints
should return a valid set of constraints, depending on the browser. YOu can check an implementation of that function here
我认为这应该足够了。我们正在与图书馆进行屏幕共享,使用我们自己的 getScreenConstrains
和扩展程序,它工作正常。一旦你有了它,使用 kurento-utils-js 库进行屏幕共享就非常容易了。像这样创建对等点时只需要传递 sendSource
值
var constraints = {
audio: false,
video: true
}
var options = {
localVideo: videoInput, //if you want to see what you are sharing
onicecandidate: onIceCandidate,
mediaConstraints: constraints,
sendSource: 'screen'
}
webRtcPeerScreencast = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function(error) {
if (error) return onError(error) //You'll need to use whatever you use for handling errors
this.generateOffer(onOffer)
});
sendSource
的值为字符串,具体要看你要分享什么
'screen'
:会让你共享整个屏幕。如果您有多个,您可以选择分享哪一个'window'
:让您在所有打开的 windows 之间进行选择
[ 'screen', 'window' ]
:警告!仅被 Chrome 接受,这将让用户在全屏或 windows 之间进行选择。'webcam'
:这是默认值,您无需在此处指定任何内容。猜猜会发生什么 ;-)