1 /*
2  * Copyright (c) 2023 Huawei Device 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_AV_TRANSPORT_EXTEND_META_H
17 #define OHOS_AV_TRANSPORT_EXTEND_META_H
18 
19 #include "av_trans_types.h"
20 
21 // follwing head files depends on histreamer
22 #include "plugin_buffer.h"
23 
24 namespace OHOS {
25 namespace DistributedHardware {
26 using namespace OHOS::Media;
27 using namespace OHOS::Media::Plugin;
28 
29 /**
30  * @brief av transport audio buffer metadata.
31  * Buffer metadata describing how data is laid out inside the buffer
32  */
33 class AVTransAudioBufferMeta : public OHOS::Media::Plugin::BufferMeta {
34 public:
AVTransAudioBufferMeta()35     AVTransAudioBufferMeta() : OHOS::Media::Plugin::BufferMeta(BufferMetaType::AUDIO) {}
36     ~AVTransAudioBufferMeta() override = default;
37 
38     std::shared_ptr<OHOS::Media::Plugin::BufferMeta> Clone() override;
39 
40     std::string MarshalAudioMeta();
41     bool UnmarshalAudioMeta(const std::string &jsonStr);
42 
43 public:
44     int64_t pts_ {0};
45 
46     int64_t cts_ {0};
47 
48     uint32_t frameNum_ {0};
49 
50     uint32_t channels_ {0};
51 
52     uint32_t sampleRate_ {0};
53 
54     BufferDataType dataType_ {BufferDataType::AUDIO};
55 
56     AudioSampleFormat format_ {AudioSampleFormat::S8};
57 
58 private:
59     friend class Buffer;
60 };
61 
62 /**
63  * @brief av transport video buffer metadata.
64  *  Extra buffer metadata describing video properties.
65  */
66 class AVTransVideoBufferMeta : public OHOS::Media::Plugin::BufferMeta {
67 public:
AVTransVideoBufferMeta()68     AVTransVideoBufferMeta() : OHOS::Media::Plugin::BufferMeta(BufferMetaType::VIDEO) {}
69     ~AVTransVideoBufferMeta() override = default;
70 
71     std::shared_ptr<OHOS::Media::Plugin::BufferMeta> Clone() override;
72 
73     std::string MarshalVideoMeta();
74     bool UnmarshalVideoMeta(const std::string &jsonStr);
75 
76     int64_t pts_ {0};
77 
78     int64_t cts_ {0};
79 
80     uint32_t width_ {0};
81 
82     uint32_t height_ {0};
83 
84     uint32_t frameNum_ {0};
85 
86     int64_t extPts_ {0};
87 
88     uint32_t extFrameNum_ {0};
89 
90     VideoPixelFormat format_ {VideoPixelFormat::UNKNOWN};
91 
92     BufferDataType dataType_ {BufferDataType::VIDEO_STREAM};
93 
94 private:
95     friend class Buffer;
96 };
97 } // namespace DistributedHardware
98 } // namespace OHOS
99 #endif // OHOS_AV_TRANSPORT_EXTEND_META_H