123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- import { SrsRTC } from "./srsRtc.js";
- import { Connection } from "./connection.js";
- const sdk = new SrsRTC();
- const testConfig = {
- sceneCode: "testApp",
- userId: "testUser",
- roomId: "8888",
- };
- const connection = new Connection(testConfig);
- console.log("sdk", sdk);
- console.log("sdk", connection);
- const url = "webrtc://demo-kms.4dage.com/live/test1";
- sdk.start(url);
- console.log("第一个");
- // connection.socket.emit("pushVideo", {
- // videoList: ["0/0_1_0", "0/0_1_1"],
- // sessionId: "1",
- // sceneCode: testConfig.sceneCode,
- // roomId: testConfig.roomId,
- // userId: testConfig.userId,
- // });
- // setTimeout(()=>{
- // console.log('第二个')
- // connection.socket.emit('pushVideo',{
- // videoList:['output'],
- // sessionId:'',
- // sceneCode:testConfig.sceneCode,
- // roomId:testConfig.roomId,
- // userId:testConfig.userId,
- // })
- // },10000)
- // setTimeout(()=>{
- // console.log('第二个')
- // connection.socket.emit('rotate',{
- // videoPath:'sample-5s',
- // sessionId:'2',
- // sceneCode:testConfig.sceneCode,
- // roomId:testConfig.roomId,
- // userId:testConfig.userId,
- // sangle: '0',
- // eangle:'900',
- // reverses:true,
- // })
- // },12000)
- // setTimeout(()=>{
- // console.log('正转')
- // connection.socket.emit('rotate',{
- // videoList:['output'],
- // sessionId:'3',
- // sceneCode:testConfig.sceneCode,
- // roomId:testConfig.roomId,
- // userId:testConfig.userId,
- // })
- // },14000)
- // setTimeout(()=>{
- // console.log('第三个')
- // connection.socket.emit('pushVideo',{
- // videoList:['sample-5s'],
- // sessionId:'4',
- // sceneCode:testConfig.sceneCode,
- // roomId:testConfig.roomId,
- // userId:testConfig.userId,
- // })
- // },20000)
- window.connection = connection;
- // connection.socket.on("getVideo", async (streamUrl) => {
- // if (streamUrl) {
- // const url = "webrtc://demo-kms.4dage.com/" + streamUrl;
- // console.log("getVideo", streamUrl);
- // sdk.close();
- // await getVideo(url);
- // }
- // });
- // 正转
- // connection.socket.emit("getVideo", {
- // videoList: ["0/0_1_0", "0/0_1_1", "0/0_1_2"],
- // // sessionId: "1",
- // sceneCode: testConfig.sceneCode,
- // roomId: testConfig.roomId,
- // userId: testConfig.userId,
- // });
- // connection.socket.emit("getRotateVideo", {
- // videoPath: "0/0_1_0",
- // // sessionId: "3",
- // sceneCode: testConfig.sceneCode,
- // roomId: testConfig.roomId,
- // userId: testConfig.userId,
- // sangle: "0",
- // eangle: "360",
- // reverses: true,
- // });
- connection.socket.on("getSocketVideo", async (data) => {
- console.log("getSocketVideo", data);
- downloadBlob(data, "getSocketVideo.mp4", "application/video");
- });
- const downloadURL = function (r, n) {
- const o = document.createElement("a");
- (o.href = r),
- (o.download = n),
- document.body.appendChild(o),
- (o.style.display = "none"),
- o.click(),
- o.remove();
- };
- let downloadBlob = (data, fileName, mimeType) => {
- const blob = new Blob([data], {
- type: mimeType,
- });
- const url = URL.createObjectURL(blob);
- downloadURL(url, fileName);
- setTimeout(function () {
- return URL.revokeObjectURL(url);
- }, 3000);
- };
- // connection.socket.emit("pushVideo_test", {
- // videoPath: "sample-5s",
- // });
- // connection.socket.on("pushVideo_test", async (data) => {
- // console.log(data);
- // // downloadBlob(data, 'test.mp4', 'application/video')
- // });
- // const getVideo = (videoUrl) => {
- // $("#testVideoFeed").prop("srcObject", sdk.stream);
- // sdk
- // .getVideo(videoUrl)
- // .then(function (session) {
- // console.log("session", session.sessionid);
- // })
- // .catch(function (reason) {
- // console.error(reason);
- // });
- // };
|