mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +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();
|
||||
}
|
||||
|
||||
const string &AACTrack::getAacCfg() const {
|
||||
const string &AACTrack::getConfig() const {
|
||||
return _cfg;
|
||||
}
|
||||
|
||||
@ -342,7 +342,7 @@ Sdp::Ptr AACTrack::getSdp() {
|
||||
WarnL << getCodecName() << " Track未准备好";
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<AACSdp>(getAacCfg(), getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024);
|
||||
return std::make_shared<AACSdp>(getConfig(), getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024);
|
||||
}
|
||||
|
||||
}//namespace mediakit
|
@ -44,7 +44,7 @@ public:
|
||||
/**
|
||||
* 获取aac 配置信息
|
||||
*/
|
||||
const std::string &getAacCfg() const;
|
||||
const std::string &getConfig() const;
|
||||
|
||||
bool ready() override;
|
||||
CodecId getCodecId() const override;
|
||||
|
@ -16,7 +16,7 @@ using namespace toolkit;
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
static string getAacCfg(const RtmpPacket &thiz) {
|
||||
static string getConfig(const RtmpPacket &thiz) {
|
||||
string ret;
|
||||
if ((RtmpAudioCodec)thiz.getRtmpCodecId() != RtmpAudioCodec::aac) {
|
||||
return ret;
|
||||
@ -30,8 +30,8 @@ static string getAacCfg(const RtmpPacket &thiz) {
|
||||
}
|
||||
|
||||
void AACRtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
|
||||
if (pkt->isCfgFrame()) {
|
||||
_aac_cfg = getAacCfg(*pkt);
|
||||
if (pkt->isConfigFrame()) {
|
||||
_aac_cfg = getConfig(*pkt);
|
||||
if (!_aac_cfg.empty()) {
|
||||
onGetAAC(nullptr, 0, 0);
|
||||
}
|
||||
@ -79,7 +79,7 @@ AACRtmpEncoder::AACRtmpEncoder(const Track::Ptr &track) {
|
||||
void AACRtmpEncoder::makeConfigPacket() {
|
||||
if (_track && _track->ready()) {
|
||||
//从track中和获取aac配置信息
|
||||
_aac_cfg = _track->getAacCfg();
|
||||
_aac_cfg = _track->getConfig();
|
||||
}
|
||||
|
||||
if (!_aac_cfg.empty()) {
|
||||
|
@ -64,7 +64,7 @@ AACRtpDecoder::AACRtpDecoder(const Track::Ptr &track) {
|
||||
if (!aacTrack || !aacTrack->ready()) {
|
||||
WarnL << "该aac track无效!";
|
||||
} else {
|
||||
_aac_cfg = aacTrack->getAacCfg();
|
||||
_aac_cfg = aacTrack->getConfig();
|
||||
}
|
||||
obtainFrame();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ static bool getH264Config(const RtmpPacket &thiz, string &sps, string &pps) {
|
||||
}
|
||||
|
||||
void H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
|
||||
if (pkt->isCfgFrame()) {
|
||||
if (pkt->isConfigFrame()) {
|
||||
//缓存sps pps,后续插入到I帧之前
|
||||
if (!getH264Config(*pkt, _sps, _pps)) {
|
||||
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
|
||||
if (pkt->isCfgFrame()) {
|
||||
if (pkt->isConfigFrame()) {
|
||||
#ifdef ENABLE_MP4
|
||||
string 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);
|
||||
assert(track);
|
||||
//加上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);
|
||||
break;
|
||||
}
|
||||
|
@ -234,8 +234,8 @@ bool MP4MuxerInterface::addTrack(const Track::Ptr &track) {
|
||||
audio_track->getAudioChannel(),
|
||||
audio_track->getAudioSampleBit() * audio_track->getAudioChannel(),
|
||||
audio_track->getAudioSampleRate(),
|
||||
audio_track->getAacCfg().data(),
|
||||
audio_track->getAacCfg().size());
|
||||
audio_track->getConfig().data(),
|
||||
audio_track->getConfig().size());
|
||||
if (track_id < 0) {
|
||||
WarnL << "添加AAC Track失败:" << track_id;
|
||||
return false;
|
||||
|
@ -62,7 +62,7 @@ bool FlvPlayer::onRecvMetadata(const AMFValue &metadata) {
|
||||
}
|
||||
|
||||
void FlvPlayer::onRecvRtmpPacket(RtmpPacket::Ptr packet) {
|
||||
if (!_play_result && !packet->isCfgFrame()) {
|
||||
if (!_play_result && !packet->isConfigFrame()) {
|
||||
_play_result = true;
|
||||
onPlayResult(SockException(Err_success, "play http-flv success"));
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ bool RtmpPacket::isVideoKeyFrame() const {
|
||||
return frame_type == RtmpFrameType::key_frame;
|
||||
}
|
||||
|
||||
bool RtmpPacket::isCfgFrame() const {
|
||||
bool RtmpPacket::isConfigFrame() const {
|
||||
switch (type_id) {
|
||||
case MSG_AUDIO: {
|
||||
return (RtmpAudioCodec)getRtmpCodecId() == RtmpAudioCodec::aac && (RtmpAACPacketType)buffer[1] == RtmpAACPacketType::aac_config_header;
|
||||
|
@ -169,10 +169,15 @@ public:
|
||||
}
|
||||
|
||||
void clear();
|
||||
|
||||
// video config frame和key frame都返回true
|
||||
// 用于gop缓存定位
|
||||
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 getAudioSampleRate() const;
|
||||
int getAudioSampleBit() const;
|
||||
|
@ -54,7 +54,7 @@ void RtmpMediaSource::onWrite(RtmpPacket::Ptr pkt, bool /*= true*/) {
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (pkt->isCfgFrame()) {
|
||||
if (pkt->isConfigFrame()) {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mtx);
|
||||
_config_frame_map[pkt->type_id] = pkt;
|
||||
if (!_ring) {
|
||||
|
@ -339,7 +339,7 @@ void RtmpPlayer::onMediaData_l(RtmpPacket::Ptr chunk_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (chunk_data->isCfgFrame()) {
|
||||
if (chunk_data->isConfigFrame()) {
|
||||
//输入配置帧以便初始化完成各个track
|
||||
onRtmpPacket(chunk_data);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user