mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
RTC: Refine player sdk, directly use raw HTTP.
This commit is contained in:
parent
1a6d94abcd
commit
b3baa888ee
1 changed files with 20 additions and 25 deletions
|
@ -78,20 +78,17 @@ function SrsRtcPublisherAsync() {
|
||||||
};
|
};
|
||||||
console.log("Generated offer: ", data);
|
console.log("Generated offer: ", data);
|
||||||
|
|
||||||
$.ajax({
|
const http = new XMLHttpRequest();
|
||||||
type: "POST", url: conf.apiUrl, data: JSON.stringify(data),
|
http.onload = function() {
|
||||||
contentType: 'application/json', dataType: 'json'
|
if (http.readyState !== http.DONE) return;
|
||||||
}).done(function (data) {
|
if (http.status !== 200) return reject(http);
|
||||||
|
const data = JSON.parse(http.responseText);
|
||||||
console.log("Got answer: ", data);
|
console.log("Got answer: ", data);
|
||||||
if (data.code) {
|
return data.code ? reject(data) : resolve(data);
|
||||||
reject(data);
|
}
|
||||||
return;
|
http.open('POST', conf.apiUrl, true);
|
||||||
}
|
http.setRequestHeader('Content-type', 'application/json');
|
||||||
|
http.send(JSON.stringify(data));
|
||||||
resolve(data);
|
|
||||||
}).fail(function (reason) {
|
|
||||||
reject(reason);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
await self.pc.setRemoteDescription(
|
await self.pc.setRemoteDescription(
|
||||||
new RTCSessionDescription({type: 'answer', sdp: session.sdp})
|
new RTCSessionDescription({type: 'answer', sdp: session.sdp})
|
||||||
|
@ -314,19 +311,17 @@ function SrsRtcPlayerAsync() {
|
||||||
};
|
};
|
||||||
console.log("Generated offer: ", data);
|
console.log("Generated offer: ", data);
|
||||||
|
|
||||||
$.ajax({
|
const http = new XMLHttpRequest();
|
||||||
type: "POST", url: conf.apiUrl, data: JSON.stringify(data),
|
http.onload = function() {
|
||||||
contentType:'application/json', dataType: 'json'
|
if (http.readyState !== http.DONE) return;
|
||||||
}).done(function(data) {
|
if (http.status !== 200) return reject(http);
|
||||||
|
const data = JSON.parse(http.responseText);
|
||||||
console.log("Got answer: ", data);
|
console.log("Got answer: ", data);
|
||||||
if (data.code) {
|
return data.code ? reject(data) : resolve(data);
|
||||||
reject(data); return;
|
}
|
||||||
}
|
http.open('POST', conf.apiUrl, true);
|
||||||
|
http.setRequestHeader('Content-type', 'application/json');
|
||||||
resolve(data);
|
http.send(JSON.stringify(data));
|
||||||
}).fail(function(reason){
|
|
||||||
reject(reason);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
await self.pc.setRemoteDescription(
|
await self.pc.setRemoteDescription(
|
||||||
new RTCSessionDescription({type: 'answer', sdp: session.sdp})
|
new RTCSessionDescription({type: 'answer', sdp: session.sdp})
|
||||||
|
|
Loading…
Reference in a new issue