/* * MIT License * * Copyright (c) 2016 xiongziliang <771730766@qq.com> * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef ZLMEDIAKIT_AACRTMPCODEC_H #define ZLMEDIAKIT_AACRTMPCODEC_H #include "RtmpCodec.h" namespace mediakit{ /** * aac Rtmp转adts类 */ class AACRtmpDecoder : public RtmpCodec , public ResourcePoolHelper { public: typedef std::shared_ptr Ptr; AACRtmpDecoder(); ~AACRtmpDecoder() {} /** * 输入Rtmp并解码 * @param Rtmp Rtmp数据包 * @param key_pos 此参数内部强制转换为false,请忽略之 */ bool inputRtmp(const RtmpPacket::Ptr &Rtmp, bool key_pos = false) override; TrackType getTrackType() const override{ return TrackAudio; } CodecId getCodecId() const override{ return CodecAAC; } protected: void onGetAAC(const char* pcData, int iLen, uint32_t ui32TimeStamp); AACFrame::Ptr obtainFrame(); protected: AACFrame::Ptr _adts; string _aac_cfg; }; /** * aac adts转Rtmp类 */ class AACRtmpEncoder : public AACRtmpDecoder , public ResourcePoolHelper { public: typedef std::shared_ptr Ptr; AACRtmpEncoder(){} ~AACRtmpEncoder() {} /** * 输入aac 数据,必须带dats头 * @param frame 带dats头的aac数据 */ void inputFrame(const Frame::Ptr &frame) override; private: void makeAudioConfigPkt(); uint8_t _ui8AudioFlags; }; }//namespace mediakit #endif //ZLMEDIAKIT_AACRTMPCODEC_H