From 9e5babf9db52e64bdae60137be7696e56241fca6 Mon Sep 17 00:00:00 2001 From: xingzilong <xingzilong@454eff88-639b-444f-9e54-f578c98de674> Date: 星期五, 18 八月 2017 18:12:17 +0800 Subject: [PATCH] H264 NALU解析 并在RTSPServer判断 --- RtspFace/FFmpegRTSPServer/LiveServerMediaSubsession.cpp | 50 +++++++++++++++++++++++++++++++++++++------------- 1 files changed, 37 insertions(+), 13 deletions(-) diff --git a/RtspFace/FFmpegRTSPServer/LiveServerMediaSubsession.cpp b/RtspFace/FFmpegRTSPServer/LiveServerMediaSubsession.cpp index 6d16082..c949446 100644 --- a/RtspFace/FFmpegRTSPServer/LiveServerMediaSubsession.cpp +++ b/RtspFace/FFmpegRTSPServer/LiveServerMediaSubsession.cpp @@ -7,23 +7,47 @@ // #include "LiveServerMediaSubsession.h" +#include "H264FramedSource.h" namespace MESAI { - LiveServerMediaSubsession * LiveServerMediaSubsession::createNew(UsageEnvironment& env, StreamReplicator* replicator) - { - return new LiveServerMediaSubsession(env,replicator); - } - - FramedSource* LiveServerMediaSubsession::createNewStreamSource(unsigned clientSessionId, unsigned& estBitrate) + +LiveServerMediaSubsession * LiveServerMediaSubsession::createNew(UsageEnvironment& env, StreamReplicator* replicator) +{ + return new LiveServerMediaSubsession(env,replicator); +} + +FramedSource* LiveServerMediaSubsession::createNewStreamSource(unsigned clientSessionId, unsigned& estBitrate) +{ + FramedSource* source = m_replicator->createStreamReplica(); + estBitrate = 512 * 1024 * 8;//#todo + return H264VideoStreamDiscreteFramer::createNew(envir(), source); +} + +RTPSink* LiveServerMediaSubsession::createNewRTPSink(Groupsock* rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource* inputSource) +{ + return H264VideoRTPSink::createNew(envir(), rtpGroupsock,rtpPayloadTypeIfDynamic); +} + +char const* LiveServerMediaSubsession::sdpLines() +{ + if (m_SDPLines.empty()) { - FramedSource* source = m_replicator->createStreamReplica(); - return H264VideoStreamDiscreteFramer::createNew(envir(), source); + m_SDPLines.assign(OnDemandServerMediaSubsession::sdpLines()); + + H264FramedSource* framedSource = nullptr; + { + FramedSource* _framedSource = m_replicator->inputSource(); + framedSource = dynamic_cast<H264FramedSource*>(_framedSource); + }; + + if (framedSource != nullptr) + { + m_SDPLines.append(framedSource->getAuxLine()); + } } - - RTPSink* LiveServerMediaSubsession::createNewRTPSink(Groupsock* rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource* inputSource) - { - return H264VideoRTPSink::createNew(envir(), rtpGroupsock,rtpPayloadTypeIfDynamic); - } + + return m_SDPLines.c_str(); +} } -- Gitblit v1.8.0