mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 20:47:08 +08:00
优化函数命名
isCfgFrame -> isConfigFrame getAacCfg -> getConfig
This commit is contained in:
parent
780a1eb9fc
commit
3e9a8b9d8b
@ -246,7 +246,7 @@ AACTrack::AACTrack(const string &aac_cfg) {
|
|||||||
onReady();
|
onReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
const string &AACTrack::getAacCfg() const {
|
const string &AACTrack::getConfig() const {
|
||||||
return _cfg;
|
return _cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ Sdp::Ptr AACTrack::getSdp() {
|
|||||||
WarnL << getCodecName() << " Track未准备好";
|
WarnL << getCodecName() << " Track未准备好";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return std::make_shared<AACSdp>(getAacCfg(), getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024);
|
return std::make_shared<AACSdp>(getConfig(), getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
@ -44,7 +44,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* 获取aac 配置信息
|
* 获取aac 配置信息
|
||||||
*/
|
*/
|
||||||
const std::string &getAacCfg() const;
|
const std::string &getConfig() const;
|
||||||
|
|
||||||
bool ready() override;
|
bool ready() override;
|
||||||
CodecId getCodecId() const override;
|
CodecId getCodecId() const override;
|
||||||
|
@ -16,7 +16,7 @@ using namespace toolkit;
|
|||||||
|
|
||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
static string getAacCfg(const RtmpPacket &thiz) {
|
static string getConfig(const RtmpPacket &thiz) {
|
||||||
string ret;
|
string ret;
|
||||||
if ((RtmpAudioCodec)thiz.getRtmpCodecId() != RtmpAudioCodec::aac) {
|
if ((RtmpAudioCodec)thiz.getRtmpCodecId() != RtmpAudioCodec::aac) {
|
||||||
return ret;
|
return ret;
|
||||||
@ -30,8 +30,8 @@ static string getAacCfg(const RtmpPacket &thiz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AACRtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
|
void AACRtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
|
||||||
if (pkt->isCfgFrame()) {
|
if (pkt->isConfigFrame()) {
|
||||||
_aac_cfg = getAacCfg(*pkt);
|
_aac_cfg = getConfig(*pkt);
|
||||||
if (!_aac_cfg.empty()) {
|
if (!_aac_cfg.empty()) {
|
||||||
onGetAAC(nullptr, 0, 0);
|
onGetAAC(nullptr, 0, 0);
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ AACRtmpEncoder::AACRtmpEncoder(const Track::Ptr &track) {
|
|||||||
void AACRtmpEncoder::makeConfigPacket() {
|
void AACRtmpEncoder::makeConfigPacket() {
|
||||||
if (_track && _track->ready()) {
|
if (_track && _track->ready()) {
|
||||||
//从track中和获取aac配置信息
|
//从track中和获取aac配置信息
|
||||||
_aac_cfg = _track->getAacCfg();
|
_aac_cfg = _track->getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_aac_cfg.empty()) {
|
if (!_aac_cfg.empty()) {
|
||||||
|
@ -64,7 +64,7 @@ AACRtpDecoder::AACRtpDecoder(const Track::Ptr &track) {
|
|||||||
if (!aacTrack || !aacTrack->ready()) {
|
if (!aacTrack || !aacTrack->ready()) {
|
||||||
WarnL << "该aac track无效!";
|
WarnL << "该aac track无效!";
|
||||||
} else {
|
} else {
|
||||||
_aac_cfg = aacTrack->getAacCfg();
|
_aac_cfg = aacTrack->getConfig();
|
||||||
}
|
}
|
||||||
obtainFrame();
|
obtainFrame();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ static bool getH264Config(const RtmpPacket &thiz, string &sps, string &pps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
|
void H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
|
||||||
if (pkt->isCfgFrame()) {
|
if (pkt->isConfigFrame()) {
|
||||||
//缓存sps pps,后续插入到I帧之前
|
//缓存sps pps,后续插入到I帧之前
|
||||||
if (!getH264Config(*pkt, _sps, _pps)) {
|
if (!getH264Config(*pkt, _sps, _pps)) {
|
||||||
WarnL << "get h264 sps/pps failed, rtmp packet is: " << hexdump(pkt->data(), pkt->size());
|
WarnL << "get h264 sps/pps failed, rtmp packet is: " << hexdump(pkt->data(), pkt->size());
|
||||||
|
@ -124,7 +124,7 @@ void H265RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 国内扩展(12) H265 rtmp
|
// 国内扩展(12) H265 rtmp
|
||||||
if (pkt->isCfgFrame()) {
|
if (pkt->isConfigFrame()) {
|
||||||
#ifdef ENABLE_MP4
|
#ifdef ENABLE_MP4
|
||||||
string config;
|
string config;
|
||||||
if (getH265ConfigFrame(*pkt, config)) {
|
if (getH265ConfigFrame(*pkt, config)) {
|
||||||
|
@ -247,7 +247,7 @@ Frame::Ptr MP4Demuxer::makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int6
|
|||||||
AACTrack::Ptr track = dynamic_pointer_cast<AACTrack>(it->second);
|
AACTrack::Ptr track = dynamic_pointer_cast<AACTrack>(it->second);
|
||||||
assert(track);
|
assert(track);
|
||||||
//加上adts头
|
//加上adts头
|
||||||
dumpAacConfig(track->getAacCfg(), buf->size() - DATA_OFFSET, (uint8_t *) buf->data() + (DATA_OFFSET - ADTS_HEADER_LEN), ADTS_HEADER_LEN);
|
dumpAacConfig(track->getConfig(), buf->size() - DATA_OFFSET, (uint8_t *) buf->data() + (DATA_OFFSET - ADTS_HEADER_LEN), ADTS_HEADER_LEN);
|
||||||
ret = std::make_shared<FrameWrapper<FrameFromPtr> >(buf, (uint64_t)dts, (uint64_t)pts, ADTS_HEADER_LEN, DATA_OFFSET - ADTS_HEADER_LEN, codec);
|
ret = std::make_shared<FrameWrapper<FrameFromPtr> >(buf, (uint64_t)dts, (uint64_t)pts, ADTS_HEADER_LEN, DATA_OFFSET - ADTS_HEADER_LEN, codec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -234,8 +234,8 @@ bool MP4MuxerInterface::addTrack(const Track::Ptr &track) {
|
|||||||
audio_track->getAudioChannel(),
|
audio_track->getAudioChannel(),
|
||||||
audio_track->getAudioSampleBit() * audio_track->getAudioChannel(),
|
audio_track->getAudioSampleBit() * audio_track->getAudioChannel(),
|
||||||
audio_track->getAudioSampleRate(),
|
audio_track->getAudioSampleRate(),
|
||||||
audio_track->getAacCfg().data(),
|
audio_track->getConfig().data(),
|
||||||
audio_track->getAacCfg().size());
|
audio_track->getConfig().size());
|
||||||
if (track_id < 0) {
|
if (track_id < 0) {
|
||||||
WarnL << "添加AAC Track失败:" << track_id;
|
WarnL << "添加AAC Track失败:" << track_id;
|
||||||
return false;
|
return false;
|
||||||
|
@ -62,7 +62,7 @@ bool FlvPlayer::onRecvMetadata(const AMFValue &metadata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FlvPlayer::onRecvRtmpPacket(RtmpPacket::Ptr packet) {
|
void FlvPlayer::onRecvRtmpPacket(RtmpPacket::Ptr packet) {
|
||||||
if (!_play_result && !packet->isCfgFrame()) {
|
if (!_play_result && !packet->isConfigFrame()) {
|
||||||
_play_result = true;
|
_play_result = true;
|
||||||
onPlayResult(SockException(Err_success, "play http-flv success"));
|
onPlayResult(SockException(Err_success, "play http-flv success"));
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ bool RtmpPacket::isVideoKeyFrame() const {
|
|||||||
return frame_type == RtmpFrameType::key_frame;
|
return frame_type == RtmpFrameType::key_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RtmpPacket::isCfgFrame() const {
|
bool RtmpPacket::isConfigFrame() const {
|
||||||
switch (type_id) {
|
switch (type_id) {
|
||||||
case MSG_AUDIO: {
|
case MSG_AUDIO: {
|
||||||
return (RtmpAudioCodec)getRtmpCodecId() == RtmpAudioCodec::aac && (RtmpAACPacketType)buffer[1] == RtmpAACPacketType::aac_config_header;
|
return (RtmpAudioCodec)getRtmpCodecId() == RtmpAudioCodec::aac && (RtmpAACPacketType)buffer[1] == RtmpAACPacketType::aac_config_header;
|
||||||
|
@ -169,10 +169,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// video config frame和key frame都返回true
|
// video config frame和key frame都返回true
|
||||||
|
// 用于gop缓存定位
|
||||||
bool isVideoKeyFrame() const;
|
bool isVideoKeyFrame() const;
|
||||||
// aac config或h264/h265 config
|
|
||||||
bool isCfgFrame() const;
|
// aac config或h264/h265 config返回true,支持增强型rtmp
|
||||||
|
// 用于缓存解码配置信息
|
||||||
|
bool isConfigFrame() const;
|
||||||
|
|
||||||
int getRtmpCodecId() const;
|
int getRtmpCodecId() const;
|
||||||
int getAudioSampleRate() const;
|
int getAudioSampleRate() const;
|
||||||
int getAudioSampleBit() const;
|
int getAudioSampleBit() const;
|
||||||
|
@ -54,7 +54,7 @@ void RtmpMediaSource::onWrite(RtmpPacket::Ptr pkt, bool /*= true*/) {
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pkt->isCfgFrame()) {
|
if (pkt->isConfigFrame()) {
|
||||||
std::lock_guard<std::recursive_mutex> lock(_mtx);
|
std::lock_guard<std::recursive_mutex> lock(_mtx);
|
||||||
_config_frame_map[pkt->type_id] = pkt;
|
_config_frame_map[pkt->type_id] = pkt;
|
||||||
if (!_ring) {
|
if (!_ring) {
|
||||||
|
@ -339,7 +339,7 @@ void RtmpPlayer::onMediaData_l(RtmpPacket::Ptr chunk_data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunk_data->isCfgFrame()) {
|
if (chunk_data->isConfigFrame()) {
|
||||||
//输入配置帧以便初始化完成各个track
|
//输入配置帧以便初始化完成各个track
|
||||||
onRtmpPacket(chunk_data);
|
onRtmpPacket(chunk_data);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user