|
@@ -137,21 +137,27 @@
|
|
<script src="./worker/index.js" type="module"></script>
|
|
<script src="./worker/index.js" type="module"></script>
|
|
<script type="module">
|
|
<script type="module">
|
|
import { Connection } from "./webrtc/connection.js";
|
|
import { Connection } from "./webrtc/connection.js";
|
|
|
|
+ import { uuid } from "./webrtc/uuid.js";
|
|
document.addEventListener("DOMContentLoaded", async () => {
|
|
document.addEventListener("DOMContentLoaded", async () => {
|
|
const connection = new Connection();
|
|
const connection = new Connection();
|
|
window.connection = connection;
|
|
window.connection = connection;
|
|
const testConfig = {
|
|
const testConfig = {
|
|
- userId: "11use2221ttttt2553",
|
|
|
|
- roomId: "tk12291",
|
|
|
|
|
|
+ userId: uuid(16, 16),
|
|
|
|
+ roomId: "22s1111ss",
|
|
sdkAppId: 1400653314,
|
|
sdkAppId: 1400653314,
|
|
- // role: "audience",
|
|
|
|
- role: "audience",
|
|
|
|
sceneCode: "2111",
|
|
sceneCode: "2111",
|
|
};
|
|
};
|
|
|
|
+ console.log("testConfig", testConfig);
|
|
connection.init(testConfig, async () => {
|
|
connection.init(testConfig, async () => {
|
|
if (connection.client) {
|
|
if (connection.client) {
|
|
await connection.client.join({ roomId: testConfig.roomId });
|
|
await connection.client.join({ roomId: testConfig.roomId });
|
|
console.log("userSig", connection.userSig);
|
|
console.log("userSig", connection.userSig);
|
|
|
|
+
|
|
|
|
+ // connection.socket.on("init-scene", {
|
|
|
|
+ // videos: ["0/0_1_0", "1/0_2_0"],
|
|
|
|
+ // range: [start, end],
|
|
|
|
+ // isRotate: true,
|
|
|
|
+ // });
|
|
connection.socket.emit("getPush", {
|
|
connection.socket.emit("getPush", {
|
|
userId: testConfig.userId,
|
|
userId: testConfig.userId,
|
|
roomId: testConfig.roomId,
|
|
roomId: testConfig.roomId,
|
|
@@ -161,18 +167,23 @@
|
|
connection.socket.on("getPush", (data) => {
|
|
connection.socket.on("getPush", (data) => {
|
|
console.log(
|
|
console.log(
|
|
"getPush",
|
|
"getPush",
|
|
- `ffmpeg -loglevel info -re -stream_loop -1 -i test.mkv -c:v libx264 -preset fast -profile:v baseline -g 30 -sc_threshold 0 -b:v 1500k -f flv "${data}"`
|
|
|
|
|
|
+ `ffmpeg -loglevel info -re -stream_loop -1 -i output.mp4 -c:v libx264 -preset fast -profile:v baseline -g 30 -sc_threshold 0 -b:v 1500k -f flv "${data}"`
|
|
);
|
|
);
|
|
});
|
|
});
|
|
|
|
+ connection.socket.emit("init-webrtc");
|
|
console.log("connection.client", connection.client);
|
|
console.log("connection.client", connection.client);
|
|
|
|
|
|
connection.client.on("peer-join", (event) => {
|
|
connection.client.on("peer-join", (event) => {
|
|
console.log("peer-join", event);
|
|
console.log("peer-join", event);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ connection.client.on("client-banned", () => {
|
|
|
|
+ location.reload();
|
|
|
|
+ });
|
|
connection.client.on("stream-added", (event) => {
|
|
connection.client.on("stream-added", (event) => {
|
|
const remoteStream = event.stream;
|
|
const remoteStream = event.stream;
|
|
const remoteUserId = remoteStream.getUserId();
|
|
const remoteUserId = remoteStream.getUserId();
|
|
|
|
+ console.warn("stream-added", remoteStream);
|
|
console.warn(
|
|
console.warn(
|
|
"received a remoteStream ID: " +
|
|
"received a remoteStream ID: " +
|
|
remoteStream.getId() +
|
|
remoteStream.getId() +
|
|
@@ -180,6 +191,7 @@
|
|
remoteUserId
|
|
remoteUserId
|
|
);
|
|
);
|
|
// 若需要观看该远端流,则需要订阅它
|
|
// 若需要观看该远端流,则需要订阅它
|
|
|
|
+
|
|
connection.client.subscribe(remoteStream);
|
|
connection.client.subscribe(remoteStream);
|
|
});
|
|
});
|
|
// connection.client.on('network-quality', event => {
|
|
// connection.client.on('network-quality', event => {
|
|
@@ -242,3 +254,8 @@
|
|
<script src="https://web.sdk.qcloud.com/trtc/webrtc/demo/latest/dist/trtc.js"></script>
|
|
<script src="https://web.sdk.qcloud.com/trtc/webrtc/demo/latest/dist/trtc.js"></script>
|
|
</html>
|
|
</html>
|
|
</html>
|
|
</html>
|
|
|
|
+ffmpeg -i 'rtmp://127.0.0.1/live?B1wrZUZQc' -i
|
|
|
|
+'http://120.24.252.95:8080/live/livestream.flv' -filter_complex overlay -c:v
|
|
|
|
+libx264 -r 30 -preset ultrafast -tune zerolatency -crf 25 -pix_fmt yuv420p -f
|
|
|
|
+flv
|
|
|
|
+"rtmp://rtmp.rtc.qq.com/push/22s1111ss?sdkappid=1400653314&userid=007E83817D55C01F&usersig=eJw1jsEKgkAURf9l1iFvnHF8CK3UaBFUaGFLYUZ5ijLaoEH074nW8p7Dgftm*SnzzMvSaFikQCLAbmWTGVnEfA-Ytp*6La0lzSIuAVQgBJebIW16RxWtAUCYokAeJkEQAz-8a6oXWVzaeh6HfO6mFl2ZNnOvlZvO13CQVWl4o*OuuD9Udrztf6GjbjnGlUQlBaL-*QLFzTO7"
|