|
@@ -3,8 +3,7 @@ export class SrsRTC {
|
|
|
this.stream = new MediaStream();
|
|
|
this.url = url;
|
|
|
this.offer = null;
|
|
|
- this.pc = null;
|
|
|
- // this.pc = new RTCPeerConnection(null);
|
|
|
+
|
|
|
const supportsInsertableStreams =
|
|
|
!!RTCRtpSender.prototype.createEncodedStreams;
|
|
|
console.log("supportsInsertableStreams", supportsInsertableStreams);
|
|
@@ -23,26 +22,26 @@ export class SrsRTC {
|
|
|
this.onIceCandidate(this.pc, e)
|
|
|
);
|
|
|
this.pc.addEventListener("datachannel", this.ondatachannel);
|
|
|
- // this.pc.ondatachannel = (event) => {
|
|
|
- // console.log("ondatachannel", ondatachannel);
|
|
|
- // this.inputChannel.onopen = () => {
|
|
|
- // console.log("连接");
|
|
|
- // };
|
|
|
- // this.inputChannel.onmessage = (event) => {
|
|
|
- // // mark00 rtcp接收
|
|
|
- // console.log("连接", event);
|
|
|
- // };
|
|
|
- // this.inputChannel.close = (event) => {
|
|
|
- // // mark00 rtcp接收
|
|
|
- // console.log("close", event);
|
|
|
- // };
|
|
|
- // };
|
|
|
+ this.pc.ondatachannel = (event) => {
|
|
|
+ console.log("ondatachannel", ondatachannel);
|
|
|
+ this.inputChannel.onopen = () => {
|
|
|
+ console.log("连接");
|
|
|
+ };
|
|
|
+ this.inputChannel.onmessage = (event) => {
|
|
|
+ // mark00 rtcp接收
|
|
|
+ console.log("连接", event);
|
|
|
+ };
|
|
|
+ this.inputChannel.close = (event) => {
|
|
|
+ // mark00 rtcp接收
|
|
|
+ console.log("close", event);
|
|
|
+ };
|
|
|
+ };
|
|
|
}
|
|
|
onIceCandidate(event) {
|
|
|
- console.log("icecandidate", event);
|
|
|
+ console.warn("icecandidate", event);
|
|
|
}
|
|
|
ondatachannel(event) {
|
|
|
- console.log("ondatachannel", ondatachannel);
|
|
|
+ console.warn("ondatachannel", ondatachannel);
|
|
|
}
|
|
|
|
|
|
close() {
|
|
@@ -55,12 +54,12 @@ export class SrsRTC {
|
|
|
}
|
|
|
|
|
|
async start(clipUrl) {
|
|
|
+ this.pc.addTransceiver("video", { direction: "recvonly" });
|
|
|
const serverApi = "https://demo-kms.4dage.com:443/rtc/v1/play/";
|
|
|
const tid = Number(parseInt(new Date().getTime() * Math.random() * 100))
|
|
|
.toString(16)
|
|
|
.slice(0, 7);
|
|
|
var offer = await this.pc.createOffer();
|
|
|
- this.offer = offer;
|
|
|
await this.pc.setLocalDescription(offer);
|
|
|
const session = await new Promise(function (resolve, reject) {
|
|
|
// @see https://github.com/rtcdn/rtcdn-draft
|
|
@@ -92,7 +91,6 @@ export class SrsRTC {
|
|
|
reject(reason);
|
|
|
});
|
|
|
});
|
|
|
- console.log("session", session);
|
|
|
await this.pc.setRemoteDescription(
|
|
|
new RTCSessionDescription({ type: "answer", sdp: session.sdp })
|
|
|
);
|