优化代码

This commit is contained in:
xiongziliang
2018-09-18 21:40:26 +08:00
parent 83df74561c
commit bb03af0f7f
5 changed files with 42 additions and 6 deletions

View File

@@ -32,6 +32,7 @@
#include "Common/config.h"
#include "RtmpPlayer.h"
#include "RtmpParser.h"
#include "RtmpMediaSource.h"
#include "Poller/Timer.h"
#include "Util/TimeTicker.h"
@@ -62,6 +63,10 @@ public:
private:
//派生类回调函数
bool onCheckMeta(AMFValue &val) override {
m_pRtmpMediaSrc = dynamic_pointer_cast<RtmpMediaSource>(m_pMediaSrc);
if(m_pRtmpMediaSrc){
m_pRtmpMediaSrc->onGetMetaData(val);
}
try {
m_parser.reset(new RtmpParser(val));
m_parser->setOnVideoCB(m_onGetVideoCB);
@@ -69,14 +74,20 @@ private:
return true;
} catch (std::exception &ex) {
WarnL << ex.what();
return false;
return m_pRtmpMediaSrc ? true : false;
}
}
void onMediaData(const RtmpPacket::Ptr &chunkData) override {
if(m_parser){
m_parser->inputRtmp(chunkData);
}
if(m_pRtmpMediaSrc){
m_pRtmpMediaSrc->onGetMedia(chunkData);
}
}
private:
RtmpMediaSource::Ptr m_pRtmpMediaSrc;
};