• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_SHARING_AAC_RTP_CODEC_H
17 #define OHOS_SHARING_AAC_RTP_CODEC_H
18 
19 #include "frame/frame.h"
20 #include "frame/frame_merger.h"
21 #include "frame/h264_frame.h"
22 #include "rtp_codec.h"
23 #include "rtp_def.h"
24 #include "rtp_maker.h"
25 
26 namespace OHOS {
27 namespace Sharing {
28 class RtpDecoderAAC : public RtpDecoder {
29 public:
30     using Ptr = std::shared_ptr<RtpDecoderAAC>;
31 
32     RtpDecoderAAC(const RtpPlaylodParam &rpp);
33     ~RtpDecoderAAC();
34 
35     void SetOnFrame(const OnFrame &cb) override;
36     void InputRtp(const RtpPacket::Ptr &rtp) override;
37 
38 private:
39     void FlushData();
40     FrameImpl::Ptr ObtainFrame();
41     void InputFrame(const Frame::Ptr &frame);
42 
43 private:
44     uint32_t lastDts_ = 0;
45     std::string aacConfig_;
46 
47     RtpPlaylodParam rpp_;
48     FrameImpl::Ptr frame_ = nullptr;
49 };
50 
51 class RtpEncoderAAC : public RtpEncoder,
52                       public RtpMaker {
53 public:
54     using Ptr = std::shared_ptr<RtpEncoderAAC>;
55 
56     RtpEncoderAAC(uint32_t ssrc, uint32_t mtuSize, uint32_t sampleRate, uint8_t payloadType, uint16_t seq = 0);
57     ~RtpEncoderAAC();
58 
59     void SetOnRtpPack(const OnRtpPack &cb) override;
60     void InputFrame(const Frame::Ptr &frame) override;
61     void MakeAACRtp(const void *data, size_t len, bool mark, uint32_t stamp);
62 
63 private:
64     unsigned char sectionBuf_[1600];
65 };
66 } // namespace Sharing
67 } // namespace OHOS
68 #endif