Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
e2cc9ecd
Commit
e2cc9ecd
authored
Sep 17, 2021
by
xgj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update zlm rtc sdk demo
parent
2b3d32f6
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
45 行增加
和
35 行删除
+45
-35
www/webrtc/ZLMRTCClient.js
+29
-19
www/webrtc/ZLMRTCClient.js.map
+0
-0
www/webrtc/index.html
+16
-16
没有找到文件。
www/webrtc/ZLMRTCClient.js
查看文件 @
e2cc9ecd
...
@@ -4,14 +4,14 @@ var ZLMRTCClient = (function (exports) {
...
@@ -4,14 +4,14 @@ var ZLMRTCClient = (function (exports) {
const
Events$1
=
{
const
Events$1
=
{
WEBRTC_NOT_SUPPORT
:
'WEBRTC_NOT_SUPPORT'
,
WEBRTC_NOT_SUPPORT
:
'WEBRTC_NOT_SUPPORT'
,
WEBRTC_ICE_CANDIDATE_ERROR
:
'WEBRTC_ICE_CANDIDATE_ERROR'
,
WEBRTC_ICE_CANDIDATE_ERROR
:
'WEBRTC_ICE_CANDIDATE_ERROR'
,
WEBRTC_OFFER_AN
SWER_EXCHANGE_FAILED
:
'WEBRTC_OFFER_ANSW
ER_EXCHANGE_FAILED'
,
WEBRTC_OFFER_AN
WSER_EXCHANGE_FAILED
:
'WEBRTC_OFFER_ANWS
ER_EXCHANGE_FAILED'
,
WEBRTC_ON_REMOTE_STREAMS
:
'WEBRTC_ON_REMOTE_STREAMS'
,
WEBRTC_ON_REMOTE_STREAMS
:
'WEBRTC_ON_REMOTE_STREAMS'
,
WEBRTC_ON_LOCAL_STREAM
:
'WEBRTC_ON_LOCAL_STREAM'
,
WEBRTC_ON_LOCAL_STREAM
:
'WEBRTC_ON_LOCAL_STREAM'
,
CAPTURE_STREAM_FAILED
:
'CAPTURE_STREAM_FAILED'
CAPTURE_STREAM_FAILED
:
'CAPTURE_STREAM_FAILED'
};
};
const
VERSION
=
'1.0.1'
;
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
// Copyright (C) <2018> Intel Corporation
//
//
...
@@ -7342,16 +7342,16 @@ var ZLMRTCClient = (function (exports) {
...
@@ -7342,16 +7342,16 @@ var ZLMRTCClient = (function (exports) {
let
ret
=
response
.
data
;
//JSON.parse(response.data);
let
ret
=
response
.
data
;
//JSON.parse(response.data);
if
(
ret
.
code
!=
0
)
{
if
(
ret
.
code
!=
0
)
{
// mean failed for offer/an
sw
er exchange
// mean failed for offer/an
ws
er exchange
this
.
dispatch
(
Events$1
.
WEBRTC_OFFER_AN
SW
ER_EXCHANGE_FAILED
,
ret
);
this
.
dispatch
(
Events$1
.
WEBRTC_OFFER_AN
WS
ER_EXCHANGE_FAILED
,
ret
);
return
;
return
;
}
}
let
an
sw
er
=
{};
let
an
ws
er
=
{};
an
sw
er
.
sdp
=
ret
.
sdp
;
an
ws
er
.
sdp
=
ret
.
sdp
;
an
sw
er
.
type
=
'answer'
;
an
ws
er
.
type
=
'answer'
;
log
(
this
.
TAG
,
'answer:'
,
ret
.
sdp
);
log
(
this
.
TAG
,
'answer:'
,
ret
.
sdp
);
this
.
pc
.
setRemoteDescription
(
an
sw
er
).
then
(()
=>
{
this
.
pc
.
setRemoteDescription
(
an
ws
er
).
then
(()
=>
{
log
(
this
.
TAG
,
'set remote sucess'
);
log
(
this
.
TAG
,
'set remote sucess'
);
}).
catch
(
e
=>
{
}).
catch
(
e
=>
{
error
(
this
.
TAG
,
e
);
error
(
this
.
TAG
,
e
);
...
@@ -7399,11 +7399,21 @@ var ZLMRTCClient = (function (exports) {
...
@@ -7399,11 +7399,21 @@ var ZLMRTCClient = (function (exports) {
};
};
if
(
this
.
options
.
simulcast
&&
stream
.
getVideoTracks
().
length
>
0
)
{
if
(
this
.
options
.
simulcast
&&
stream
.
getVideoTracks
().
length
>
0
)
{
VideoTransceiverInit
.
sendEncodings
=
[
VideoTransceiverInit
.
sendEncodings
=
[{
{
rid
:
"h"
,
active
:
true
,
maxBitrate
:
1000000
},
rid
:
'h'
,
{
rid
:
"m"
,
active
:
true
,
maxBitrate
:
500000
,
scaleResolutionDownBy
:
2
},
active
:
true
,
{
rid
:
"l"
,
active
:
true
,
maxBitrate
:
200000
,
scaleResolutionDownBy
:
4
}
maxBitrate
:
1000000
];
},
{
rid
:
'm'
,
active
:
true
,
maxBitrate
:
500000
,
scaleResolutionDownBy
:
2
},
{
rid
:
'l'
,
active
:
true
,
maxBitrate
:
200000
,
scaleResolutionDownBy
:
4
}];
}
}
if
(
stream
.
getAudioTracks
().
length
>
0
)
{
if
(
stream
.
getAudioTracks
().
length
>
0
)
{
...
@@ -7442,16 +7452,16 @@ var ZLMRTCClient = (function (exports) {
...
@@ -7442,16 +7452,16 @@ var ZLMRTCClient = (function (exports) {
let
ret
=
response
.
data
;
//JSON.parse(response.data);
let
ret
=
response
.
data
;
//JSON.parse(response.data);
if
(
ret
.
code
!=
0
)
{
if
(
ret
.
code
!=
0
)
{
// mean failed for offer/an
sw
er exchange
// mean failed for offer/an
ws
er exchange
this
.
dispatch
(
Events$1
.
WEBRTC_OFFER_AN
SW
ER_EXCHANGE_FAILED
,
ret
);
this
.
dispatch
(
Events$1
.
WEBRTC_OFFER_AN
WS
ER_EXCHANGE_FAILED
,
ret
);
return
;
return
;
}
}
let
an
sw
er
=
{};
let
an
ws
er
=
{};
an
sw
er
.
sdp
=
ret
.
sdp
;
an
ws
er
.
sdp
=
ret
.
sdp
;
an
sw
er
.
type
=
'answer'
;
an
ws
er
.
type
=
'answer'
;
log
(
this
.
TAG
,
'answer:'
,
ret
.
sdp
);
log
(
this
.
TAG
,
'answer:'
,
ret
.
sdp
);
this
.
pc
.
setRemoteDescription
(
an
sw
er
).
then
(()
=>
{
this
.
pc
.
setRemoteDescription
(
an
ws
er
).
then
(()
=>
{
log
(
this
.
TAG
,
'set remote sucess'
);
log
(
this
.
TAG
,
'set remote sucess'
);
}).
catch
(
e
=>
{
}).
catch
(
e
=>
{
error
(
this
.
TAG
,
e
);
error
(
this
.
TAG
,
e
);
...
...
www/webrtc/ZLMRTCClient.js.map
查看文件 @
e2cc9ecd
This source diff could not be displayed because it is too large. You can
view the blob
instead.
www/webrtc/index.html
查看文件 @
e2cc9ecd
...
@@ -22,12 +22,12 @@
...
@@ -22,12 +22,12 @@
<p>
<p>
<label
for=
"streamUrl"
>
url:
</label>
<label
for=
"streamUrl"
>
url:
</label>
<input
type=
"text"
style=
"co"
id=
'streamUrl'
value=
"http://1
27.0.0.1/index/api/webrtc?app=live&stream=test
&type=play"
>
<input
type=
"text"
style=
"co"
id=
'streamUrl'
value=
"http://1
92.168.1.101/index/api/webrtc?app=live&stream=xiong
&type=play"
>
</p>
</p>
<p>
<p>
<label
for=
"simulcast"
>
simulcast:
</label>
<label
for=
"simulcast"
>
simulcast:
</label>
<input
type=
"checkbox"
id=
'simulcast'
checked=
"checked"
>
<input
type=
"checkbox"
id=
'simulcast'
>
</p>
</p>
<p>
<p>
<label
for=
"useCamera"
>
useCamera:
</label>
<label
for=
"useCamera"
>
useCamera:
</label>
...
@@ -46,14 +46,14 @@
...
@@ -46,14 +46,14 @@
</p>
</p>
<p>
<p>
<label
for=
"metho
d"
>
metho
d(play or push):
</label>
<label
for=
"metho
nd"
>
methon
d(play or push):
</label>
<input
type=
"radio"
name=
"method"
value=
"push"
>
push
<input
type=
"radio"
name=
"metho
n
d"
value=
"push"
>
push
<input
type=
"radio"
name=
"method"
value=
"play"
checked =
true
>
play
<input
type=
"radio"
name=
"metho
n
d"
value=
"play"
checked =
true
>
play
</p>
</p>
<p>
<p>
<label
for=
"res
o
lution"
>
resolution:
</label>
<label
for=
"res
i
lution"
>
resolution:
</label>
<select
id=
"res
o
lution"
>
<select
id=
"res
i
lution"
>
</select>
</select>
</p>
</p>
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
var
recvOnly
=
true
var
recvOnly
=
true
var
resArr
=
[]
var
resArr
=
[]
document
.
getElementsByName
(
"method"
).
forEach
((
el
,
idx
)
=>
{
document
.
getElementsByName
(
"metho
n
d"
).
forEach
((
el
,
idx
)
=>
{
el
.
onclick
=
function
(
e
){
el
.
onclick
=
function
(
e
){
if
(
el
.
value
==
"play"
)
if
(
el
.
value
==
"play"
)
{
{
...
@@ -91,14 +91,14 @@
...
@@ -91,14 +91,14 @@
opt
=
document
.
createElement
(
'option'
);
opt
=
document
.
createElement
(
'option'
);
opt
.
text
=
r
.
label
+
"("
+
r
.
width
+
"x"
+
r
.
height
+
")"
;
opt
.
text
=
r
.
label
+
"("
+
r
.
width
+
"x"
+
r
.
height
+
")"
;
opt
.
value
=
r
;
opt
.
value
=
r
;
document
.
getElementById
(
"res
o
lution"
).
add
(
opt
,
null
)
document
.
getElementById
(
"res
i
lution"
).
add
(
opt
,
null
)
//console.log(opt.text.match(/\d+/g))
//console.log(opt.text.match(/\d+/g))
})
})
function
start_play
(){
function
start_play
(){
let
elr
=
document
.
getElementById
(
"res
o
lution"
);
let
elr
=
document
.
getElementById
(
"res
i
lution"
);
let
res
=
elr
.
options
[
elr
.
selectedIndex
].
text
.
match
(
/
\d
+/g
);
let
res
=
elr
.
options
[
elr
.
selectedIndex
].
text
.
match
(
/
\d
+/g
);
let
h
=
parseInt
(
res
.
pop
());
let
h
=
parseInt
(
res
.
pop
());
let
w
=
parseInt
(
res
.
pop
());
let
w
=
parseInt
(
res
.
pop
());
...
@@ -127,9 +127,9 @@
...
@@ -127,9 +127,9 @@
console
.
log
(
'播放成功'
,
e
.
streams
)
console
.
log
(
'播放成功'
,
e
.
streams
)
});
});
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_OFFER_AN
SW
ER_EXCHANGE_FAILED
,
function
(
e
)
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_OFFER_AN
WS
ER_EXCHANGE_FAILED
,
function
(
e
)
{
// offer an
sw
er 交换失败
{
// offer an
ws
er 交换失败
console
.
log
(
'offer an
sw
er 交换失败'
,
e
)
console
.
log
(
'offer an
ws
er 交换失败'
,
e
)
stop
();
stop
();
});
});
...
@@ -139,7 +139,7 @@
...
@@ -139,7 +139,7 @@
document
.
getElementById
(
'selfVideo'
).
srcObject
=
s
;
document
.
getElementById
(
'selfVideo'
).
srcObject
=
s
;
document
.
getElementById
(
'selfVideo'
).
muted
=
true
;
document
.
getElementById
(
'selfVideo'
).
muted
=
true
;
//console.log('offer an
sw
er 交换失败',e)
//console.log('offer an
ws
er 交换失败',e)
});
});
player
.
on
(
ZLMRTCClient
.
Events
.
CAPTURE_STREAM_FAILED
,
function
(
s
)
player
.
on
(
ZLMRTCClient
.
Events
.
CAPTURE_STREAM_FAILED
,
function
(
s
)
...
@@ -152,7 +152,7 @@
...
@@ -152,7 +152,7 @@
function
start
()
function
start
()
{
{
stop
();
stop
();
let
elr
=
document
.
getElementById
(
"res
o
lution"
);
let
elr
=
document
.
getElementById
(
"res
i
lution"
);
let
res
=
elr
.
options
[
elr
.
selectedIndex
].
text
.
match
(
/
\d
+/g
);
let
res
=
elr
.
options
[
elr
.
selectedIndex
].
text
.
match
(
/
\d
+/g
);
let
h
=
parseInt
(
res
.
pop
());
let
h
=
parseInt
(
res
.
pop
());
let
w
=
parseInt
(
res
.
pop
());
let
w
=
parseInt
(
res
.
pop
());
...
@@ -176,7 +176,7 @@
...
@@ -176,7 +176,7 @@
player
.
close
();
player
.
close
();
player
=
null
;
player
=
null
;
var
local
=
document
.
getElementById
(
'selfVideo'
);
var
local
=
document
.
getElementById
(
'selfVideo'
);
local
.
removeAttribute
(
'srcObject'
)
;
local
.
srcObject
=
null
;
local
.
load
();
local
.
load
();
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论