mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-31 00:37:39 +08:00
Merge pull request #1112 from ZLMediaKit/feature/update_rtcsdkdemo
update zlm rtc sdk demo
This commit is contained in:
commit
03aa9290ab
@ -4,14 +4,14 @@ var ZLMRTCClient = (function (exports) {
|
||||
const Events$1 = {
|
||||
WEBRTC_NOT_SUPPORT: 'WEBRTC_NOT_SUPPORT',
|
||||
WEBRTC_ICE_CANDIDATE_ERROR: 'WEBRTC_ICE_CANDIDATE_ERROR',
|
||||
WEBRTC_OFFER_ANSWER_EXCHANGE_FAILED: 'WEBRTC_OFFER_ANSWER_EXCHANGE_FAILED',
|
||||
WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED: 'WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED',
|
||||
WEBRTC_ON_REMOTE_STREAMS: 'WEBRTC_ON_REMOTE_STREAMS',
|
||||
WEBRTC_ON_LOCAL_STREAM: 'WEBRTC_ON_LOCAL_STREAM',
|
||||
CAPTURE_STREAM_FAILED: 'CAPTURE_STREAM_FAILED'
|
||||
};
|
||||
|
||||
const VERSION = '1.0.1';
|
||||
const BUILD_DATE = 'Mon Jun 07 2021 18:09:53 GMT+0800 (China Standard Time)';
|
||||
const BUILD_DATE = 'Fri Sep 17 2021 10:41:58 GMT+0800 (China Standard Time)';
|
||||
|
||||
// Copyright (C) <2018> Intel Corporation
|
||||
//
|
||||
@ -7342,16 +7342,16 @@ var ZLMRTCClient = (function (exports) {
|
||||
let ret = response.data; //JSON.parse(response.data);
|
||||
|
||||
if (ret.code != 0) {
|
||||
// mean failed for offer/answer exchange
|
||||
this.dispatch(Events$1.WEBRTC_OFFER_ANSWER_EXCHANGE_FAILED, ret);
|
||||
// mean failed for offer/anwser exchange
|
||||
this.dispatch(Events$1.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
let answer = {};
|
||||
answer.sdp = ret.sdp;
|
||||
answer.type = 'answer';
|
||||
let anwser = {};
|
||||
anwser.sdp = ret.sdp;
|
||||
anwser.type = 'answer';
|
||||
log(this.TAG, 'answer:', ret.sdp);
|
||||
this.pc.setRemoteDescription(answer).then(() => {
|
||||
this.pc.setRemoteDescription(anwser).then(() => {
|
||||
log(this.TAG, 'set remote sucess');
|
||||
}).catch(e => {
|
||||
error(this.TAG, e);
|
||||
@ -7399,11 +7399,21 @@ var ZLMRTCClient = (function (exports) {
|
||||
};
|
||||
|
||||
if (this.options.simulcast && stream.getVideoTracks().length > 0) {
|
||||
VideoTransceiverInit.sendEncodings = [
|
||||
{ rid: "h", active: true, maxBitrate: 1000000 },
|
||||
{ rid: "m", active: true, maxBitrate: 500000, scaleResolutionDownBy: 2 },
|
||||
{ rid: "l", active: true, maxBitrate: 200000, scaleResolutionDownBy: 4 }
|
||||
];
|
||||
VideoTransceiverInit.sendEncodings = [{
|
||||
rid: 'h',
|
||||
active: true,
|
||||
maxBitrate: 1000000
|
||||
}, {
|
||||
rid: 'm',
|
||||
active: true,
|
||||
maxBitrate: 500000,
|
||||
scaleResolutionDownBy: 2
|
||||
}, {
|
||||
rid: 'l',
|
||||
active: true,
|
||||
maxBitrate: 200000,
|
||||
scaleResolutionDownBy: 4
|
||||
}];
|
||||
}
|
||||
|
||||
if (stream.getAudioTracks().length > 0) {
|
||||
@ -7442,16 +7452,16 @@ var ZLMRTCClient = (function (exports) {
|
||||
let ret = response.data; //JSON.parse(response.data);
|
||||
|
||||
if (ret.code != 0) {
|
||||
// mean failed for offer/answer exchange
|
||||
this.dispatch(Events$1.WEBRTC_OFFER_ANSWER_EXCHANGE_FAILED, ret);
|
||||
// mean failed for offer/anwser exchange
|
||||
this.dispatch(Events$1.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
let answer = {};
|
||||
answer.sdp = ret.sdp;
|
||||
answer.type = 'answer';
|
||||
let anwser = {};
|
||||
anwser.sdp = ret.sdp;
|
||||
anwser.type = 'answer';
|
||||
log(this.TAG, 'answer:', ret.sdp);
|
||||
this.pc.setRemoteDescription(answer).then(() => {
|
||||
this.pc.setRemoteDescription(anwser).then(() => {
|
||||
log(this.TAG, 'set remote sucess');
|
||||
}).catch(e => {
|
||||
error(this.TAG, e);
|
||||
|
File diff suppressed because one or more lines are too long
@ -22,12 +22,12 @@
|
||||
|
||||
<p>
|
||||
<label for="streamUrl">url:</label>
|
||||
<input type="text" style="co" id='streamUrl' value="http://127.0.0.1/index/api/webrtc?app=live&stream=test&type=play">
|
||||
<input type="text" style="co" id='streamUrl' value="http://192.168.1.101/index/api/webrtc?app=live&stream=xiong&type=play">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="simulcast">simulcast:</label>
|
||||
<input type="checkbox" id='simulcast' checked="checked">
|
||||
<input type="checkbox" id='simulcast'>
|
||||
</p>
|
||||
<p>
|
||||
<label for="useCamera">useCamera:</label>
|
||||
@ -46,14 +46,14 @@
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="method">method(play or push):</label>
|
||||
<input type="radio" name="method" value="push" >push
|
||||
<input type="radio" name="method" value="play" checked = true>play
|
||||
<label for="methond">methond(play or push):</label>
|
||||
<input type="radio" name="methond" value="push" >push
|
||||
<input type="radio" name="methond" value="play" checked = true>play
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="resolution">resolution:</label>
|
||||
<select id="resolution">
|
||||
<label for="resilution">resolution:</label>
|
||||
<select id="resilution">
|
||||
|
||||
</select>
|
||||
</p>
|
||||
@ -69,7 +69,20 @@
|
||||
var recvOnly = true
|
||||
var resArr = []
|
||||
|
||||
document.getElementsByName("method").forEach((el,idx)=>{
|
||||
var ishttps = 'https:' == document.location.protocol ? true : false
|
||||
var isLocal = "file:" == document.location.protocol ? true : false
|
||||
var url = document.location.protocol+"//"+window.location.host+"/index/api/webrtc?app=live&stream=test&type=play"
|
||||
|
||||
|
||||
if(!ishttps && !isLocal){
|
||||
alert('本demo需要在https的网站访问 (this demo must access in site of https)')
|
||||
}
|
||||
|
||||
if(isLocal){
|
||||
url = "http://127.0.0.1"+"/index/api/webrtc?app=live&stream=test&type=play"
|
||||
}
|
||||
document.getElementById('streamUrl').value = url
|
||||
document.getElementsByName("methond").forEach((el,idx)=>{
|
||||
el.onclick=function(e){
|
||||
if(el.value == "play")
|
||||
{
|
||||
@ -91,14 +104,14 @@
|
||||
opt = document.createElement('option');
|
||||
opt.text = r.label +"("+r.width+"x"+r.height+")";
|
||||
opt.value = r;
|
||||
document.getElementById("resolution").add(opt,null)
|
||||
document.getElementById("resilution").add(opt,null)
|
||||
|
||||
//console.log(opt.text.match(/\d+/g))
|
||||
|
||||
|
||||
})
|
||||
function start_play(){
|
||||
let elr = document.getElementById("resolution");
|
||||
let elr = document.getElementById("resilution");
|
||||
let res = elr.options[elr.selectedIndex].text.match(/\d+/g);
|
||||
let h = parseInt(res.pop());
|
||||
let w = parseInt(res.pop());
|
||||
@ -127,9 +140,9 @@
|
||||
console.log('播放成功',e.streams)
|
||||
});
|
||||
|
||||
player.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANSWER_EXCHANGE_FAILED,function(e)
|
||||
{// offer answer 交换失败
|
||||
console.log('offer answer 交换失败',e)
|
||||
player.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,function(e)
|
||||
{// offer anwser 交换失败
|
||||
console.log('offer anwser 交换失败',e)
|
||||
stop();
|
||||
});
|
||||
|
||||
@ -139,7 +152,7 @@
|
||||
document.getElementById('selfVideo').srcObject=s;
|
||||
document.getElementById('selfVideo').muted = true;
|
||||
|
||||
//console.log('offer answer 交换失败',e)
|
||||
//console.log('offer anwser 交换失败',e)
|
||||
});
|
||||
|
||||
player.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,function(s)
|
||||
@ -152,7 +165,7 @@
|
||||
function start()
|
||||
{
|
||||
stop();
|
||||
let elr = document.getElementById("resolution");
|
||||
let elr = document.getElementById("resilution");
|
||||
let res = elr.options[elr.selectedIndex].text.match(/\d+/g);
|
||||
let h = parseInt(res.pop());
|
||||
let w = parseInt(res.pop());
|
||||
@ -176,7 +189,7 @@
|
||||
player.close();
|
||||
player = null;
|
||||
var local = document.getElementById('selfVideo');
|
||||
local.removeAttribute('srcObject');
|
||||
local.srcObject = null;
|
||||
local.load();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user