mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-01 07:22:23 +08:00
整理MediaSource派生类
修复转协议或录制时忽然Track的问题
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user