yjj 5 лет назад
Родитель
Сommit
78b5fe2d13

+ 34 - 0
public/libs/H265Session.js

@@ -0,0 +1,34 @@
+function H265Session() {
+
+    let frameRate = null; //根据SDP或者SPS设置
+
+    let decodeMode = 'canvas';
+
+    function constructor() {
+
+    }
+    constructor.prototype = {
+        init() {
+            this.resolutionChangedCallback = () => {
+            };
+        },
+        remuxRTPData(rtspInterleaved, rtpHeader, rtpPayload){
+            console.log('h265session->',rtspInterleaved, rtpHeader, rtpPayload);
+        },
+        set rtpSessionCallback(func) {
+            this.handleDecodedData = func;
+        },
+
+        setFrameRate(fps) {
+            frameRate = fps;
+            //console.log('frameRate: ', frameRate)
+        },
+
+        setResolutionChangedCallback(callback) {
+            this.resolutionChangedCallback = callback;
+        }
+    }
+    return new constructor();
+}
+
+

Разница между файлами не показана из-за своего большого размера
+ 5283 - 0
public/libs/libffmpeg.js


BIN
public/libs/libffmpeg.wasm


+ 15 - 1
public/libs/videoWorker.js

@@ -1,6 +1,8 @@
 importScripts(
     './H264SPSParser.js',
     './H264Session.js',
+    './H265Session.js',
+    './libffmpeg.js'
 );
 
 
@@ -12,7 +14,7 @@ let videoCHID = -1;
 let videoRtpSessionsArray = [];
 
 function  receiveMessage(event) {
-    //console.log(event.data)
+    console.log("h265有数据->",event.data)
     var message = event.data;
 
     switch (message.type) {
@@ -54,6 +56,14 @@ function initRTPSession(sdpInfo) {
                 rtpSession.setFrameRate(sdpInfo[i].Framerate);
             }
         }
+        if(sdpInfo[i].codecName === 'H265') {
+            rtpSession = new H265Session();
+            rtpSession.init();
+            rtpSession.rtpSessionCallback = RtpCallbackH265;
+            if(sdpInfo[i].Framerate) {
+                rtpSession.setFrameRate(sdpInfo[i].Framerate);
+            }
+        }
 
         if(rtpSession !== null) {
             videoCHID = sdpInfo[i].RtpInterlevedID;
@@ -62,6 +72,10 @@ function initRTPSession(sdpInfo) {
     }
 }
 
+function RtpCallbackH265(dataInfo) {
+    console.log('callback->',dataInfo)
+}
+
 function RtpReturnCallback(dataInfo) {
 
     if(dataInfo === null || dataInfo === undefined) {

+ 13 - 1
src/views/common/rtsp-player/libs/websocketServer.js

@@ -246,11 +246,12 @@ function WebSocketServer(options) {
                     SendRtspCommand(CommandConstructor("DESCRIBE", null));
                     break;
                 case "Describe":
+                    //console.log('stringMessage->',stringMessage);
                     rtspSDPData = parseDescribeResponse(stringMessage);
                     if (typeof rtspResponseMsg.ContentBase !== "undefined") {
                         rtspSDPData.ContentBase = rtspResponseMsg.ContentBase
                     }
-                    //console.log(rtspSDPData.Sessions)
+                    console.log("rtspSDPData->",rtspSDPData.Sessions)
                     for (let idx = 0; idx < rtspSDPData.Sessions.length; idx++) {
                         let sdpInfoObj = {};
                         if (rtspSDPData.Sessions[idx].CodecMime === "H264") { //暂时只支持H264
@@ -266,6 +267,16 @@ function WebSocketServer(options) {
                                 sdpInfoObj.SPS = rtspSDPData.Sessions[idx].SPS;
                             }
                             SDPinfo.push(sdpInfoObj)
+                        }
+                        else if(rtspSDPData.Sessions[idx].CodecMime === "H265"){//支持h265实验
+                            sdpInfoObj.codecName = rtspSDPData.Sessions[idx].CodecMime;
+                            sdpInfoObj.trackID = rtspSDPData.Sessions[idx].trackID;
+                            sdpInfoObj.ClockFreq = rtspSDPData.Sessions[idx].ClockFreq;
+                            sdpInfoObj.Port = parseInt(rtspSDPData.Sessions[idx].Port);
+                            if (typeof rtspSDPData.Sessions[idx].Framerate !== "undefined") {
+                                sdpInfoObj.Framerate = parseInt(rtspSDPData.Sessions[idx].Framerate)
+                            }
+                            SDPinfo.push(sdpInfoObj)
                         } else {
                             console.log("Unknown codec type:", rtspSDPData.Sessions[idx].CodecMime, rtspSDPData.Sessions[idx].ControlURL)
                         }
@@ -278,6 +289,7 @@ function WebSocketServer(options) {
                     break;
                 case "Setup":
                     sessionID = rtspResponseMsg.SessionID;
+                    console.log('setup->'+sessionID,SDPinfo)
                     //多路流(如音频流)
                     //在Describe中暂时只解析H264视频流,因此SDPinfo.length始终为1
                     if (setupSDPIndex < SDPinfo.length) {