1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

SquashSRS4: Add demo for RTC

This commit is contained in:
winlin 2021-05-05 13:26:25 +08:00
parent 206d95879f
commit becbe45bcd
34 changed files with 836 additions and 85 deletions

View file

@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="js/srs.console.css"/>
<style>
body {
padding-top: 50px;
padding-top: 30px;
}
</style>
<script type="text/javascript" src="js/3rdparty/angular.min.js"></script>

View file

@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="js/srs.console.css"/>
<style>
body {
padding-top: 50px;
padding-top: 30px;
}
</style>
<script type="text/javascript" src="js/3rdparty/angular.min.js"></script>

View file

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
</style>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>

View file

@ -57,7 +57,7 @@ function SrsRtcPublisherAsync() {
self.pc.addTransceiver("video", {direction: "sendonly"});
var stream = await navigator.mediaDevices.getUserMedia(
{audio: true, video: {height: {max: 320}}}
{audio: true, video: {width: {max: 320}}}
);
// @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream#Migrating_to_addTrack
stream.getTracks().forEach(function (track) {
@ -69,7 +69,8 @@ function SrsRtcPublisherAsync() {
var session = await new Promise(function (resolve, reject) {
// @see https://github.com/rtcdn/rtcdn-draft
var data = {
api: conf.apiUrl, streamurl: conf.streamUrl, clientip: null, sdp: offer.sdp
api: conf.apiUrl, tid: conf.tid, streamurl: conf.streamUrl,
clientip: null, sdp: offer.sdp
};
console.log("Generated offer: ", data);
@ -101,7 +102,7 @@ function SrsRtcPublisherAsync() {
// Close the publisher.
self.close = function () {
self.pc.close();
self.pc && self.pc.close();
self.pc = null;
};
@ -141,7 +142,10 @@ function SrsRtcPublisherAsync() {
var streamUrl = urlObject.url;
return {apiUrl: apiUrl, streamUrl: streamUrl, schema: schema, urlObject: urlObject, port: port};
return {
apiUrl: apiUrl, streamUrl: streamUrl, schema: schema, urlObject: urlObject, port: port,
tid: new Date().getTime().toString(16)
};
},
parse: function (url) {
// @see: http://stackoverflow.com/questions/10469575/how-to-use-location-object-to-parse-url-without-redirecting-the-page-in-javascri
@ -289,7 +293,8 @@ function SrsRtcPlayerAsync() {
var session = await new Promise(function(resolve, reject) {
// @see https://github.com/rtcdn/rtcdn-draft
var data = {
api: conf.apiUrl, streamurl: conf.streamUrl, clientip: null, sdp: offer.sdp
api: conf.apiUrl, tid: conf.tid, streamurl: conf.streamUrl,
clientip: null, sdp: offer.sdp
};
console.log("Generated offer: ", data);
@ -315,7 +320,7 @@ function SrsRtcPlayerAsync() {
// Close the player.
self.close = function() {
self.pc.close();
self.pc && self.pc.close();
self.pc = null;
};
@ -354,7 +359,10 @@ function SrsRtcPlayerAsync() {
var streamUrl = urlObject.url;
return {apiUrl: apiUrl, streamUrl: streamUrl, schema: schema, urlObject: urlObject, port: port};
return {
apiUrl: apiUrl, streamUrl: streamUrl, schema: schema, urlObject: urlObject, port: port,
tid: new Date().getTime().toString(16)
};
},
parse: function (url) {
// @see: http://stackoverflow.com/questions/10469575/how-to-use-location-object-to-parse-url-without-redirecting-the-page-in-javascri

View file

@ -5,7 +5,7 @@
<meta charset="utf-8">
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
</style>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>

View file

@ -5,7 +5,7 @@
<meta charset="utf-8">
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
</style>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>

View file

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
#main_modal {
width: 700px;

View file

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
.accordion-group {
width: 310px;

View file

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
#my_modal_footer {
margin-top: -20px;

View file

@ -6,21 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<style>
body{
padding-top: 55px;
}
#my_modal_footer {
margin-top: -20px;
padding-top: 3px;
}
#main_modal {
margin-top: -60px;
}
.div_play_time {
margin-top: 10px;
}
#pb_buffer_bg {
margin-top: -4px;
margin-bottom: 10px;
padding-top: 30px;
}
</style>
</head>

View file

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
#my_modal_footer {
margin-top: -20px;

View file

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
.accordion-group {
width: 310px;

View file

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
</style>
</head>
@ -335,7 +335,7 @@
$("#btn_publish").click(on_user_publish);
// for publish, we use randome stream name.
$("#txt_url").val($("#txt_url").val() + "." + new Date().getTime());
$("#txt_url").val($("#txt_url").val() + "." + Number(new Date().getTime() + parseInt(String(Math.random() * 10000000000))).toString(16));
// start the publisher.
srs_publisher = new SrsPublisher("local_publisher", 430, 185);

View file

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<style>
body{
padding-top: 55px;
padding-top: 30px;
}
</style>
</head>