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
581ebfad
Commit
581ebfad
authored
Mar 25, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加测试web文件
parent
65e470e0
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
180 行增加
和
0 行删除
+180
-0
www/webrtc/index.html
+34
-0
www/webrtc/js/adapter.js
+0
-0
www/webrtc/js/common.js
+12
-0
www/webrtc/js/main.js
+134
-0
没有找到文件。
www/webrtc/index.html
0 → 100644
查看文件 @
581ebfad
<!DOCTYPE html>
<!--
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree.
-->
<html>
<head>
<title>
PeerConnection PRANSWER Demo
</title>
<!-- Load the polyfill to switch-hit between Chrome and Firefox -->
<style>
video
{
border
:
5px
solid
black
;
width
:
800px
;
height
:
600px
;
}
</style>
</head>
<body>
<video
id=
"vid2"
autoplay
></video>
<br>
<p>
ip_address
</p>
<input
id=
"input1"
type=
"text"
name=
"ip_address"
value=
"http://172.26.10.29:20080/webrtc?app=live&stream=test"
>
<br>
<button
id=
"btn1"
>
Call
</button>
<button
id=
"btn3"
>
Hang Up
</button>
</body>
<script
src=
"js/adapter.js"
></script>
<script
src=
"js/common.js"
></script>
<script
src=
"js/main.js"
></script>
</html>
www/webrtc/js/adapter.js
0 → 100644
查看文件 @
581ebfad
差异被折叠。
点击展开。
www/webrtc/js/common.js
0 → 100644
查看文件 @
581ebfad
function
trace
(
text
)
{
// This function is used for logging.
if
(
text
[
text
.
length
-
1
]
===
'
\
n'
)
{
text
=
text
.
substring
(
0
,
text
.
length
-
1
);
}
if
(
window
.
performance
)
{
var
now
=
(
window
.
performance
.
now
()
/
1000
).
toFixed
(
3
);
console
.
log
(
now
+
': '
+
text
);
}
else
{
console
.
log
(
text
);
}
}
www/webrtc/js/main.js
0 → 100644
查看文件 @
581ebfad
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree.
*/
'use strict'
;
var
vid2
=
document
.
getElementById
(
'vid2'
);
var
btn1
=
document
.
getElementById
(
'btn1'
);
var
btn3
=
document
.
getElementById
(
'btn3'
);
var
input1
=
document
.
getElementById
(
'input1'
);
btn1
.
addEventListener
(
'click'
,
start
);
btn3
.
addEventListener
(
'click'
,
stop
);
btn1
.
disabled
=
false
;
btn3
.
disabled
=
true
;
var
pc2
=
null
;
var
xmlhttp
=
null
;
function
start
()
{
btn1
.
disabled
=
true
;
btn3
.
disabled
=
false
;
trace
(
'Starting Call'
);
var
servers
=
null
;
var
addr
=
input1
.
value
;
pc2
=
new
RTCPeerConnection
(
servers
);
trace
(
'Created remote peer connection object pc2'
);
pc2
.
onicecandidate
=
iceCallback
;
pc2
.
onaddstream
=
gotRemoteStream
;
if
(
window
.
XMLHttpRequest
)
{
// IE7+, Firefox, Chrome, Opera, Safari �����ִ�д���
xmlhttp
=
new
XMLHttpRequest
();
}
else
{
// IE6, IE5 �����ִ�д���
xmlhttp
=
new
ActiveXObject
(
"Microsoft.XMLHTTP"
);
}
xmlhttp
.
onreadystatechange
=
function
()
{
if
(
xmlhttp
.
readyState
==
4
&&
xmlhttp
.
status
==
200
)
{
var
res
=
xmlhttp
.
responseText
;
gotoffer
(
res
);
}
}
xmlhttp
.
open
(
"GET"
,
addr
,
true
);
xmlhttp
.
send
();
}
function
onCreateSessionDescriptionError
(
error
)
{
trace
(
'Failed to create session description: '
+
error
.
toString
());
stop
();
}
function
onCreateAnswerError
(
error
)
{
trace
(
'Failed to set createAnswer: '
+
error
.
toString
());
stop
();
}
function
onSetLocalDescriptionError
(
error
)
{
trace
(
'Failed to set setLocalDescription: '
+
error
.
toString
());
stop
();
}
function
onSetLocalDescriptionSuccess
()
{
trace
(
'localDescription success.'
);
}
function
gotoffer
(
offer
)
{
trace
(
'Offer from server
\
n'
+
offer
);
//??????offer sdp????????RTCSessionDescription????
var
desc
=
new
RTCSessionDescription
();
desc
.
sdp
=
offer
;
desc
.
type
=
'offer'
;
pc2
.
setRemoteDescription
(
desc
);
// Since the 'remote' side has no media stream we need
// to pass in the right constraints in order for it to
// accept the incoming offer of audio and video.
pc2
.
createAnswer
().
then
(
gotDescription2
,
onCreateSessionDescriptionError
);
}
function
gotDescription2
(
desc
)
{
// Provisional answer, set a=inactive & set sdp type to pranswer.
/*desc.sdp = desc.sdp.replace(/a=recvonly/g, 'a=inactive');
desc.type = 'pranswer';*/
pc2
.
setLocalDescription
(
desc
).
then
(
onSetLocalDescriptionSuccess
,
onSetLocalDescriptionError
);
trace
(
'Pranswer from pc2
\
n'
+
desc
.
sdp
);
//conn.send(JSON.stringify(desc));
// send desc.sdp to server
}
function
stop
()
{
trace
(
'Ending Call'
+
'
\
n
\
n'
);
pc2
.
close
();
pc2
=
null
;
}
function
gotRemoteStream
(
e
)
{
vid2
.
srcObject
=
e
.
stream
;
trace
(
'Received remote stream'
);
}
function
iceCallback
(
event
)
{
if
(
event
.
candidate
)
{
trace
(
'Remote ICE candidate:
\
n '
+
event
.
candidate
.
candidate
);
//conn.send(JSON.stringify(event.candidate));
}
else
{
// All ICE candidates have been sent
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论