• 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_RTP_UNPACK_H
17 #define OHOS_SHARING_RTP_UNPACK_H
18 
19 #include <functional>
20 #include <map>
21 #include "rtp_codec.h"
22 #include "rtp_packet.h"
23 
24 namespace OHOS {
25 namespace Sharing {
26 class RtpUnpack {
27 public:
28     using Ptr = std::shared_ptr<RtpUnpack>;
29     using OnRtpNotify = std::function<void(int32_t)>;
30     // Unpack a RtpPackget callback
31     using OnRtpUnpack = std::function<void(uint32_t, const Frame::Ptr &frame)>;
32 
33     enum {
34         RTP_UNPACK_OK = 0,
35     };
36     /**
37      * @brief Release resources
38      */
39     virtual void Release() = 0;
40     /**
41      * @brief Parse rtp data
42      * @param data rtp data
43      * @param len rtp length
44      */
45     virtual void ParseRtp(const char *data, size_t len) = 0;
46     /**
47      * @brief Externally exposed  rtp unpack callback function
48      * @param cb unpack to a Video/Audio frame callback
49      */
50     virtual void SetOnRtpUnpack(const OnRtpUnpack &cb) = 0;
51     /**
52      * @brief Externally exposed  rtp notify callback function
53      * @param cb rtp notify callback
54      */
55     virtual void SetOnRtpNotify(const OnRtpNotify &cb) = 0;
56 
57 protected:
58     RtpUnpack() = default;
59     virtual ~RtpUnpack() = default;
60 
61 protected:
62     OnRtpUnpack onRtpUnpack_ = nullptr;
63     OnRtpNotify onRtpNotify_ = nullptr;
64 };
65 } // namespace Sharing
66 } // namespace OHOS
67 #endif