整理MediaSource派生类

修复转协议或录制时忽然Track的问题
This commit is contained in:
xiongziliang
2019-12-26 11:53:19 +08:00
parent 806747a9d5
commit 3830792c57
15 changed files with 172 additions and 150 deletions

View File

@@ -29,23 +29,6 @@
namespace mediakit {
RtmpDemuxer::RtmpDemuxer(const AMFValue &val) {
try {
makeVideoTrack(val["videocodecid"]);
makeAudioTrack(val["audiocodecid"]);
val.object_for_each([&](const string &key, const AMFValue &val) {
if (key == "duration") {
_fDuration = val.as_number();
return;
}
});
}catch (std::exception &ex){
WarnL << ex.what();
}
}
bool RtmpDemuxer::inputRtmp(const RtmpPacket::Ptr &pkt) {
switch (pkt->typeId) {
case MSG_VIDEO: {
@@ -86,6 +69,7 @@ void RtmpDemuxer::makeVideoTrack(const AMFValue &videoCodec) {
if (_videoRtmpDecoder) {
//设置rtmp解码器代理生成的frame写入该Track
_videoRtmpDecoder->addDelegate(_videoTrack);
onAddTrack(_videoTrack);
} else {
//找不到相应的rtmp解码器该track无效
_videoTrack.reset();
@@ -102,6 +86,7 @@ void RtmpDemuxer::makeAudioTrack(const AMFValue &audioCodec) {
if (_audioRtmpDecoder) {
//设置rtmp解码器代理生成的frame写入该Track
_audioRtmpDecoder->addDelegate(_audioTrack);
onAddTrack(_audioTrack);
} else {
//找不到相应的rtmp解码器该track无效
_audioTrack.reset();