Parcourir la source

fix: 移动msr播放

shuisheng il y a 2 ans
Parent
commit
63c241c79f
3 fichiers modifiés avec 47 ajouts et 41 suppressions
  1. 7 0
      src/hooks/use-pull.ts
  2. 40 40
      src/hooks/use-srs-ws.ts
  3. 0 1
      src/views/push/index.vue

+ 7 - 0
src/hooks/use-pull.ts

@@ -133,6 +133,13 @@ export function usePull() {
           handleHlsPlay(data.hls_url);
         }
         break;
+      case LiveRoomTypeEnum.user_msr:
+        if (appStore.liveLine === LiveLineEnum.flv) {
+          handleFlvPlay();
+        } else if (appStore.liveLine === LiveLineEnum.hls) {
+          handleHlsPlay(data.hls_url);
+        }
+        break;
       case LiveRoomTypeEnum.system:
         if (appStore.liveLine === LiveLineEnum.flv) {
           handleFlvPlay();

+ 40 - 40
src/hooks/use-srs-ws.ts

@@ -375,46 +375,46 @@ export const useSrsWs = () => {
       });
       if (!isPull.value && !isSRS.value) {
         if (!roomLiving.value) return;
-        liveUserList.value.forEach(async (item) => {
-          const receiver = item.id;
-          if (
-            receiver === mySocketId.value ||
-            networkStore.getRtcMap(`${roomId.value}___${receiver!}`)
-          )
-            return;
-          console.warn(
-            '11开始new WebRTCClass',
-            `${roomId.value}___${receiver!}`
-          );
-          const rtc = new WebRTCClass({
-            maxBitrate: currentMaxBitrate.value,
-            maxFramerate: currentMaxFramerate.value,
-            resolutionRatio: currentResolutionRatio.value,
-            roomId: `${roomId.value}___${receiver!}`,
-            videoEl: createVideo({}),
-            isSRS: false,
-            receiver,
-          });
-          networkStore.updateRtcMap(`${roomId.value}___${receiver!}`, rtc);
-          canvasVideoStream.value?.getTracks().forEach((track) => {
-            if (rtc && canvasVideoStream.value) {
-              console.log('22canvasVideoStream插入track', track.kind, track);
-              rtc.peerConnection?.addTrack(track, canvasVideoStream.value);
-            }
-          });
-          const ws = networkStore.wsMap.get(roomId.value)!;
-          const offer = await rtc.createOffer();
-          await rtc.setLocalDescription(offer!);
-          ws.send<WsOfferType['data']>({
-            msgType: WsMsgTypeEnum.offer,
-            data: {
-              sdp: offer,
-              live_room_id: Number(roomId.value),
-              sender: mySocketId.value,
-              receiver,
-            },
-          });
-        });
+        // liveUserList.value.forEach(async (item) => {
+        //   const receiver = item.id;
+        //   if (
+        //     receiver === mySocketId.value ||
+        //     networkStore.getRtcMap(`${roomId.value}___${receiver!}`)
+        //   )
+        //     return;
+        //   console.warn(
+        //     '11开始new WebRTCClass',
+        //     `${roomId.value}___${receiver!}`
+        //   );
+        //   const rtc = new WebRTCClass({
+        //     maxBitrate: currentMaxBitrate.value,
+        //     maxFramerate: currentMaxFramerate.value,
+        //     resolutionRatio: currentResolutionRatio.value,
+        //     roomId: `${roomId.value}___${receiver!}`,
+        //     videoEl: createVideo({}),
+        //     isSRS: false,
+        //     receiver,
+        //   });
+        //   networkStore.updateRtcMap(`${roomId.value}___${receiver!}`, rtc);
+        //   canvasVideoStream.value?.getTracks().forEach((track) => {
+        //     if (rtc && canvasVideoStream.value) {
+        //       console.log('22canvasVideoStream插入track', track.kind, track);
+        //       rtc.peerConnection?.addTrack(track, canvasVideoStream.value);
+        //     }
+        //   });
+        //   const ws = networkStore.wsMap.get(roomId.value)!;
+        //   const offer = await rtc.createOffer();
+        //   await rtc.setLocalDescription(offer!);
+        //   ws.send<WsOfferType['data']>({
+        //     msgType: WsMsgTypeEnum.offer,
+        //     data: {
+        //       sdp: offer,
+        //       live_room_id: Number(roomId.value),
+        //       sender: mySocketId.value,
+        //       receiver,
+        //     },
+        //   });
+        // });
       }
     });
 

+ 0 - 1
src/views/push/index.vue

@@ -597,7 +597,6 @@ function handleMixedAudio() {
   webaudioVideo.value!.srcObject = destination.stream;
   const resAudio = destination.stream.getAudioTracks()[0];
   canvasVideoStream.value?.addTrack(resAudio);
-  console.log(resAudio, 'resAudio');
   networkStore.rtcMap.forEach((rtc) => {
     const sender = rtc.peerConnection
       ?.getSenders()