From a30a83d665ec981462b8d4c804721d532591197c Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 1 Nov 2019 15:40:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0H265=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/Device.cpp | 24 ++++++++++++++++++++++++ src/Common/Device.h | 15 +++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/Common/Device.cpp b/src/Common/Device.cpp index d98683e1..a04dba72 100644 --- a/src/Common/Device.cpp +++ b/src/Common/Device.cpp @@ -32,6 +32,7 @@ #include "Util/TimeTicker.h" #include "Extension/AAC.h" #include "Extension/H264.h" +#include "Extension/H265.h" using namespace toolkit; @@ -106,6 +107,24 @@ void DevChannel::inputH264(const char* pcData, int iDataLen, uint32_t dts,uint32 inputFrame(std::make_shared((char *)pcData,iDataLen,dts,pts,prefixeSize)); } +void DevChannel::inputH265(const char* pcData, int iDataLen, uint32_t dts,uint32_t pts) { + if(dts == 0){ + dts = (uint32_t)_aTicker[0].elapsedTime(); + } + if(pts == 0){ + pts = dts; + } + int prefixeSize; + if (memcmp("\x00\x00\x00\x01", pcData, 4) == 0) { + prefixeSize = 4; + } else if (memcmp("\x00\x00\x01", pcData, 3) == 0) { + prefixeSize = 3; + } else { + prefixeSize = 0; + } + inputFrame(std::make_shared((char *)pcData,iDataLen,dts,pts,prefixeSize)); +} + void DevChannel::inputAAC(const char* pcData, int iDataLen, uint32_t uiStamp,bool withAdtsHeader) { if(withAdtsHeader){ inputAAC(pcData+7,iDataLen-7,uiStamp,pcData); @@ -135,6 +154,11 @@ void DevChannel::initVideo(const VideoInfo& info) { addTrack(std::make_shared()); } +void DevChannel::initH265Video(const VideoInfo &info){ + _video = std::make_shared(info); + addTrack(std::make_shared()); +} + void DevChannel::initAudio(const AudioInfo& info) { _audio = std::make_shared(info); addTrack(std::make_shared()); diff --git a/src/Common/Device.h b/src/Common/Device.h index 7e5e7684..a8c63daf 100644 --- a/src/Common/Device.h +++ b/src/Common/Device.h @@ -88,6 +88,12 @@ public: */ void initVideo(const VideoInfo &info); + /** + * 初始化h265视频Track + * @param info + */ + void initH265Video(const VideoInfo &info); + /** * 初始化aac音频Track * 相当于MultiMediaSourceMuxer::addTrack(AACTrack::Ptr ); @@ -104,6 +110,15 @@ public: */ void inputH264(const char *pcData, int iDataLen, uint32_t dts,uint32_t pts = 0); + /** + * 输入265帧 + * @param pcData 265单帧数据指针 + * @param iDataLen 数据指针长度 + * @param dts 解码时间戳,单位毫秒;等于0时内部会自动生成时间戳 + * @param pts 播放时间戳,单位毫秒;等于0时内部会赋值为dts + */ + void inputH265(const char *pcData, int iDataLen, uint32_t dts,uint32_t pts = 0); + /** * 输入可能带adts头的aac帧 * @param pcDataWithAdts 可能带adts头的aac帧