mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Refine js for player
This commit is contained in:
parent
72f87e7cbc
commit
9ef8e1bd86
1 changed files with 17 additions and 17 deletions
|
@ -170,13 +170,16 @@
|
||||||
self.pc.addTransceiver("audio", {direction: "recvonly"});
|
self.pc.addTransceiver("audio", {direction: "recvonly"});
|
||||||
self.pc.addTransceiver("video", {direction: "recvonly"});
|
self.pc.addTransceiver("video", {direction: "recvonly"});
|
||||||
|
|
||||||
var onAnswer = function(session) {
|
self.pc.createOffer(function(offer){
|
||||||
var answer = session.sdp;
|
onOffer(offer);
|
||||||
self.pc.setRemoteDescription(
|
}, function(reason){
|
||||||
new RTCSessionDescription({type: 'answer', sdp: answer})
|
fail(reason);
|
||||||
).then(function(){
|
});
|
||||||
success(session);
|
|
||||||
}).catch(function(reason) {
|
var onOffer = function(offer) {
|
||||||
|
self.pc.setLocalDescription(offer, function(){
|
||||||
|
onOfferDone(offer);
|
||||||
|
}, function(reason) {
|
||||||
fail(reason);
|
fail(reason);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -203,19 +206,16 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var onOffer = function(offer) {
|
var onAnswer = function(session) {
|
||||||
self.pc.setLocalDescription(offer, function(){
|
var answer = session.sdp;
|
||||||
onOfferDone(offer);
|
self.pc.setRemoteDescription(
|
||||||
}, function(reason) {
|
new RTCSessionDescription({type: 'answer', sdp: answer})
|
||||||
|
).then(function(){
|
||||||
|
success(session);
|
||||||
|
}).catch(function(reason) {
|
||||||
fail(reason);
|
fail(reason);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self.pc.createOffer(function(offer){
|
|
||||||
onOffer(offer);
|
|
||||||
}, function(reason){
|
|
||||||
fail(reason);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
close: function() {
|
close: function() {
|
||||||
self.pc.close();
|
self.pc.close();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue