mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-22 00:42:22 +08:00
整理代码
This commit is contained in:
@@ -66,27 +66,27 @@ bool RtmpDemuxer::loadMetaData(const AMFValue &val){
|
||||
}
|
||||
|
||||
bool RtmpDemuxer::inputRtmp(const RtmpPacket::Ptr &pkt) {
|
||||
switch (pkt->typeId) {
|
||||
switch (pkt->type_id) {
|
||||
case MSG_VIDEO: {
|
||||
if(!_tryedGetVideoTrack){
|
||||
_tryedGetVideoTrack = true;
|
||||
if(!_try_get_video_track){
|
||||
_try_get_video_track = true;
|
||||
auto codec = AMFValue(pkt->getMediaType());
|
||||
makeVideoTrack(codec);
|
||||
}
|
||||
if(_videoRtmpDecoder){
|
||||
return _videoRtmpDecoder->inputRtmp(pkt, true);
|
||||
if(_video_rtmp_decoder){
|
||||
return _video_rtmp_decoder->inputRtmp(pkt, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
case MSG_AUDIO: {
|
||||
if(!_tryedGetAudioTrack) {
|
||||
_tryedGetAudioTrack = true;
|
||||
if(!_try_get_audio_track) {
|
||||
_try_get_audio_track = true;
|
||||
auto codec = AMFValue(pkt->getMediaType());
|
||||
makeAudioTrack(codec, pkt->getAudioSampleRate(), pkt->getAudioChannel(), pkt->getAudioSampleBit());
|
||||
}
|
||||
if(_audioRtmpDecoder){
|
||||
_audioRtmpDecoder->inputRtmp(pkt, false);
|
||||
if(_audio_rtmp_decoder){
|
||||
_audio_rtmp_decoder->inputRtmp(pkt, false);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@@ -101,12 +101,12 @@ void RtmpDemuxer::makeVideoTrack(const AMFValue &videoCodec) {
|
||||
_videoTrack = dynamic_pointer_cast<VideoTrack>(Factory::getVideoTrackByAmf(videoCodec));
|
||||
if (_videoTrack) {
|
||||
//生成rtmpCodec对象以便解码rtmp
|
||||
_videoRtmpDecoder = Factory::getRtmpCodecByTrack(_videoTrack, false);
|
||||
if (_videoRtmpDecoder) {
|
||||
_video_rtmp_decoder = Factory::getRtmpCodecByTrack(_videoTrack, false);
|
||||
if (_video_rtmp_decoder) {
|
||||
//设置rtmp解码器代理,生成的frame写入该Track
|
||||
_videoRtmpDecoder->addDelegate(_videoTrack);
|
||||
_video_rtmp_decoder->addDelegate(_videoTrack);
|
||||
onAddTrack(_videoTrack);
|
||||
_tryedGetVideoTrack = true;
|
||||
_try_get_video_track = true;
|
||||
} else {
|
||||
//找不到相应的rtmp解码器,该track无效
|
||||
_videoTrack.reset();
|
||||
@@ -119,12 +119,12 @@ void RtmpDemuxer::makeAudioTrack(const AMFValue &audioCodec,int sample_rate, int
|
||||
_audioTrack = dynamic_pointer_cast<AudioTrack>(Factory::getAudioTrackByAmf(audioCodec, sample_rate, channels, sample_bit));
|
||||
if (_audioTrack) {
|
||||
//生成rtmpCodec对象以便解码rtmp
|
||||
_audioRtmpDecoder = Factory::getRtmpCodecByTrack(_audioTrack, false);
|
||||
if (_audioRtmpDecoder) {
|
||||
_audio_rtmp_decoder = Factory::getRtmpCodecByTrack(_audioTrack, false);
|
||||
if (_audio_rtmp_decoder) {
|
||||
//设置rtmp解码器代理,生成的frame写入该Track
|
||||
_audioRtmpDecoder->addDelegate(_audioTrack);
|
||||
_audio_rtmp_decoder->addDelegate(_audioTrack);
|
||||
onAddTrack(_audioTrack);
|
||||
_tryedGetAudioTrack = true;
|
||||
_try_get_audio_track = true;
|
||||
} else {
|
||||
//找不到相应的rtmp解码器,该track无效
|
||||
_audioTrack.reset();
|
||||
|
||||
Reference in New Issue
Block a user