0
修改Kurento羣呼例如只發送音頻,如果一個參與者沒有攝像頭。現在只有在使用相機時纔會收到音頻。當只有麥克風可用時,我收到一個DeviceMediaError。
我設法過濾攝像頭設備是否連接,然後只發送音頻,但這是行不通的。也許參與者應該有音頻標籤而不是視頻標籤?
編輯:它只適用於Firefox而不適用於Chrome。有任何想法嗎?
修改Kurento羣呼例如只發送音頻,如果一個參與者沒有攝像頭。現在只有在使用相機時纔會收到音頻。當只有麥克風可用時,我收到一個DeviceMediaError。
我設法過濾攝像頭設備是否連接,然後只發送音頻,但這是行不通的。也許參與者應該有音頻標籤而不是視頻標籤?
編輯:它只適用於Firefox而不適用於Chrome。有任何想法嗎?
變化以下行 -
sender.getOutgoingWebRtcPeer().connect(incoming, MediaType.AUDIO);
,並設置提供媒體約束視頻:假在瀏覽器JS文件。
更新的代碼 -
let constraints = {
audio: true,
video: false
};
let localParticipant = new Participant(sessionId);
participants[sessionId] = localParticipant;
localVideo = document.getElementById('local_video');
let video = localVideo;
let options = {
localVideo: video,
mediaConstraints: constraints,
onicecandidate: localParticipant.onIceCandidate.bind(localParticipant),
configuration : { iceServers : [
{"url":"stun:74.125.200.127:19302"},
] }
};
localParticipant.rtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options, function(error) {
if (error) {
return console.error(error);
}
localVideoCurrentId = sessionId;
localVideo = document.getElementById('local_video');
localVideo.src = localParticipant.rtcPeer.localVideo.src;
localVideo.muted = true;
this.generateOffer(localParticipant.offerToReceiveVideo.bind(localParticipant));
});
server.js代碼
在服務器端添加介質特徵參數同時加入房間。
function getEndpointForUser(userSession, sender, callback) {
if (userSession.id === sender.id) {
return callback(null, userSession.outgoingMedia);
}
let incoming = userSession.incomingMedia[sender.id];
if (incoming == null) {
console.log(`user : ${userSession.id} create endpoint to receive video from : ${sender.id}`);
getRoom(userSession.roomName, (error, room) => {
if (error) {
return callback(error);
}
room.pipeline.create('WebRtcEndpoint', {mediaProfile : 'WEBM_AUDIO_ONLY'}, (error, incomingMedia) => {
if (error) {
if (Object.keys(room.participants).length === 0) {
room.pipeline.release();
}
return callback(error);
}
console.log(`user: ${userSession.id} successfully create pipeline`);
incomingMedia.setMaxAudioRecvBandwidth(0);
incomingMedia.getMaxAudioRecvBandwidth(0);
接受呼叫時添加介質特徵參數。
希望這有助於。
那麼我還能夠使用視頻,如果我有一個視頻設備? – Towen
您需要檢查設備的視頻,然後相應地設置媒體約束。這必須在服務器和客戶端端以及媒體接收器的客戶端完成。您只需要編寫單獨的功能,僅用於音頻呼叫和音頻 - 視頻呼叫。 –
感謝您的詳細解答。我已經檢查是否有凸輪或只有音頻設備可用。根據這個我把約束改爲假或者真。這就是我所要改變的一切嗎?是僅在音頻呼叫和視頻呼叫之間區分服務器端的唯一步驟嗎? – Towen