完成Rtmp解复用器

This commit is contained in:
xiongziliang
2018-10-24 22:03:17 +08:00
parent de50bf03a9
commit 3921bfb2d9
7 changed files with 232 additions and 281 deletions

View File

@@ -3,6 +3,10 @@
//
#include "Factory.h"
#include "RtmpMuxer/H264RtmpCodec.h"
#include "RtmpMuxer/AACRtmpCodec.h"
#include "RtspMuxer/H264RtpCodec.h"
#include "RtspMuxer/AACRtpCodec.h"
namespace mediakit{
@@ -75,7 +79,7 @@ Track::Ptr Factory::getTrackBySdp(const string &sdp) {
}
CodecId getCodecIdByAmf(const AMFValue &val){
CodecId Factory::getCodecIdByAmf(const AMFValue &val){
if (val.type() == AMF_STRING){
auto str = val.as_string();
if(str == "avc1"){
@@ -153,6 +157,17 @@ RtpCodec::Ptr Factory::getRtpDecoderById(CodecId codecId, uint32_t ui32SampleRat
}
}
RtmpCodec::Ptr Factory::getRtmpCodecById(CodecId codecId) {
switch (codecId){
case CodecH264:
return std::make_shared<H264RtmpEncoder>();
case CodecAAC:
return std::make_shared<AACRtmpEncoder>();
default:
return nullptr;
}
}
}//namespace mediakit

View File

@@ -8,6 +8,8 @@
#include <string>
#include "Player/Track.h"
#include "RtspMuxer/RtspSdp.h"
#include "RtspMuxer/RtpCodec.h"
#include "RtmpMuxer/RtmpCodec.h"
#include "Rtmp/amf.h"
using namespace std;
@@ -21,7 +23,6 @@ public:
* 根据sdp生成Track对象
*/
static Track::Ptr getTrackBySdp(const string &sdp);
static Track::Ptr getTrackByAmf(const AMFValue &amf);
static Track::Ptr getTrackByCodecId(CodecId codecId);
@@ -57,6 +58,13 @@ public:
* @return
*/
static RtpCodec::Ptr getRtpDecoderById(CodecId codecId, uint32_t ui32SampleRate);
//////////////////////////////////////////////////////////////////
static Track::Ptr getTrackByAmf(const AMFValue &amf);
static CodecId getCodecIdByAmf(const AMFValue &val);
static RtmpCodec::Ptr getRtmpCodecById(CodecId codecId);
};
}//namespace mediakit