1 /*
2 * Copyright (C) 2022 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 #include "avcodec_info_native_mock.h"
17
18 namespace OHOS {
19 namespace Media {
GetName() const20 std::string AVCodecInfoNativeMock::GetName() const
21 {
22 if (codecInfo_ != nullptr) {
23 return codecInfo_->GetName();
24 }
25 return nullptr;
26 }
27
GetType() const28 int32_t AVCodecInfoNativeMock::GetType() const
29 {
30 if (codecInfo_ != nullptr) {
31 return codecInfo_->GetType();
32 }
33 return -1;
34 }
35
GetMimeType() const36 std::string AVCodecInfoNativeMock::GetMimeType() const
37 {
38 if (codecInfo_ != nullptr) {
39 return codecInfo_->GetMimeType();
40 }
41 return "";
42 }
43
IsHardwareAccelerated() const44 bool AVCodecInfoNativeMock::IsHardwareAccelerated() const
45 {
46 if (codecInfo_ != nullptr) {
47 return codecInfo_->IsHardwareAccelerated();
48 }
49 return false;
50 }
51
IsSoftwareOnly() const52 bool AVCodecInfoNativeMock::IsSoftwareOnly() const
53 {
54 if (codecInfo_ != nullptr) {
55 return codecInfo_->IsSoftwareOnly();
56 }
57 return false;
58 }
59
IsVendor() const60 bool AVCodecInfoNativeMock::IsVendor() const
61 {
62 if (codecInfo_ != nullptr) {
63 return codecInfo_->IsVendor();
64 }
65 return false;
66 }
67
GetCodecInfo() const68 std::shared_ptr<AVCodecInfoMock> VideoCapsNativeMock::GetCodecInfo() const
69 {
70 if (videoCaps_ != nullptr) {
71 return std::make_shared<AVCodecInfoNativeMock>(videoCaps_->GetCodecInfo());
72 }
73 return nullptr;
74 }
75
GetSupportedBitrate() const76 RangeMock VideoCapsNativeMock::GetSupportedBitrate() const
77 {
78 RangeMock bitrate;
79 if (videoCaps_ != nullptr) {
80 bitrate.minVal = videoCaps_->GetSupportedBitrate().minVal;
81 bitrate.maxVal = videoCaps_->GetSupportedBitrate().maxVal;
82 }
83 return bitrate;
84 }
85
GetSupportedFormats() const86 std::vector<int32_t> VideoCapsNativeMock::GetSupportedFormats() const
87 {
88 std::vector<int32_t> formats;
89 if (videoCaps_ != nullptr) {
90 formats = videoCaps_->GetSupportedFormats();
91 }
92 return formats;
93 }
94
GetSupportedHeightAlignment() const95 int32_t VideoCapsNativeMock::GetSupportedHeightAlignment() const
96 {
97 if (videoCaps_ != nullptr) {
98 return videoCaps_->GetSupportedHeightAlignment();
99 }
100 return -1;
101 }
102
GetSupportedWidthAlignment() const103 int32_t VideoCapsNativeMock::GetSupportedWidthAlignment() const
104 {
105 if (videoCaps_ != nullptr) {
106 return videoCaps_->GetSupportedWidthAlignment();
107 }
108 return -1;
109 }
110
GetSupportedWidth() const111 RangeMock VideoCapsNativeMock::GetSupportedWidth() const
112 {
113 RangeMock width;
114 if (videoCaps_ != nullptr) {
115 width.minVal = videoCaps_->GetSupportedWidth().minVal;
116 width.maxVal = videoCaps_->GetSupportedWidth().maxVal;
117 }
118 return width;
119 }
120
GetSupportedHeight() const121 RangeMock VideoCapsNativeMock::GetSupportedHeight() const
122 {
123 RangeMock height;
124 if (videoCaps_ != nullptr) {
125 height.minVal = videoCaps_->GetSupportedHeight().minVal;
126 height.maxVal = videoCaps_->GetSupportedHeight().maxVal;
127 }
128 return height;
129 }
130
GetSupportedProfiles() const131 std::vector<int32_t> VideoCapsNativeMock::GetSupportedProfiles() const
132 {
133 std::vector<int32_t> profiles;
134 if (videoCaps_ != nullptr) {
135 profiles = videoCaps_->GetSupportedProfiles();
136 }
137 return profiles;
138 }
139
GetSupportedLevels() const140 std::vector<int32_t> VideoCapsNativeMock::GetSupportedLevels() const
141 {
142 std::vector<int32_t> levels;
143 if (videoCaps_ != nullptr) {
144 levels = videoCaps_->GetSupportedLevels();
145 }
146 return levels;
147 }
148
GetSupportedEncodeQuality() const149 RangeMock VideoCapsNativeMock::GetSupportedEncodeQuality() const
150 {
151 RangeMock quality;
152 if (videoCaps_ != nullptr) {
153 quality.minVal = videoCaps_->GetSupportedEncodeQuality().minVal;
154 quality.maxVal = videoCaps_->GetSupportedEncodeQuality().maxVal;
155 }
156 return quality;
157 }
158
IsSizeSupported(int32_t width,int32_t height) const159 bool VideoCapsNativeMock::IsSizeSupported(int32_t width, int32_t height) const
160 {
161 if (videoCaps_ != nullptr) {
162 return videoCaps_->IsSizeSupported(width, height);
163 }
164 return false;
165 }
166
GetSupportedFrameRate() const167 RangeMock VideoCapsNativeMock::GetSupportedFrameRate() const
168 {
169 RangeMock frameRates;
170 if (videoCaps_ != nullptr) {
171 frameRates.minVal = videoCaps_->GetSupportedFrameRate().minVal;
172 frameRates.maxVal = videoCaps_->GetSupportedFrameRate().maxVal;
173 }
174 return frameRates;
175 }
176
GetSupportedFrameRatesFor(int32_t width,int32_t height) const177 RangeMock VideoCapsNativeMock::GetSupportedFrameRatesFor(int32_t width, int32_t height) const
178 {
179 RangeMock frameRates;
180 if (videoCaps_ != nullptr) {
181 frameRates.minVal = videoCaps_->GetSupportedFrameRatesFor(width, height).minVal;
182 frameRates.maxVal = videoCaps_->GetSupportedFrameRatesFor(width, height).maxVal;
183 }
184 return frameRates;
185 }
186
IsSizeAndRateSupported(int32_t width,int32_t height,double frameRate) const187 bool VideoCapsNativeMock::IsSizeAndRateSupported(int32_t width, int32_t height, double frameRate) const
188 {
189 if (videoCaps_ != nullptr) {
190 return videoCaps_->IsSizeAndRateSupported(width, height, frameRate);
191 }
192 return false;
193 }
194
GetPreferredFrameRate(int32_t width,int32_t height) const195 RangeMock VideoCapsNativeMock::GetPreferredFrameRate(int32_t width, int32_t height) const
196 {
197 RangeMock frameRate;
198 if (videoCaps_ != nullptr) {
199 frameRate.minVal = videoCaps_->GetPreferredFrameRate(width, height).minVal;
200 frameRate.maxVal = videoCaps_->GetPreferredFrameRate(width, height).maxVal;
201 }
202 return frameRate;
203 }
204
GetSupportedBitrateMode() const205 std::vector<int32_t> VideoCapsNativeMock::GetSupportedBitrateMode() const
206 {
207 std::vector<int32_t> bitrateMode;
208 if (videoCaps_ != nullptr) {
209 bitrateMode = videoCaps_->GetSupportedBitrateMode();
210 }
211 return bitrateMode;
212 }
213
GetSupportedQuality() const214 RangeMock VideoCapsNativeMock::GetSupportedQuality() const
215 {
216 RangeMock quality;
217 if (videoCaps_ != nullptr) {
218 quality.minVal = videoCaps_->GetSupportedQuality().minVal;
219 quality.maxVal = videoCaps_->GetSupportedQuality().maxVal;
220 }
221 return quality;
222 }
223
GetSupportedComplexity() const224 RangeMock VideoCapsNativeMock::GetSupportedComplexity() const
225 {
226 RangeMock complexity;
227 if (videoCaps_ != nullptr) {
228 complexity.minVal = videoCaps_->GetSupportedComplexity().minVal;
229 complexity.maxVal = videoCaps_->GetSupportedComplexity().maxVal;
230 }
231 return complexity;
232 }
233
IsSupportDynamicIframe() const234 bool VideoCapsNativeMock::IsSupportDynamicIframe() const
235 {
236 if (videoCaps_ != nullptr) {
237 return videoCaps_->IsSupportDynamicIframe();
238 }
239 return false;
240 }
241
GetCodecInfo() const242 std::shared_ptr<AVCodecInfoMock> AudioCapsNativeMock::GetCodecInfo() const
243 {
244 if (audioCaps_ != nullptr) {
245 return std::make_shared<AVCodecInfoNativeMock>(audioCaps_->GetCodecInfo());
246 }
247 return nullptr;
248 }
249
GetSupportedBitrate() const250 RangeMock AudioCapsNativeMock::GetSupportedBitrate() const
251 {
252 RangeMock bitrate;
253 if (audioCaps_ != nullptr) {
254 bitrate.minVal = audioCaps_->GetSupportedBitrate().minVal;
255 bitrate.maxVal = audioCaps_->GetSupportedBitrate().maxVal;
256 }
257 return bitrate;
258 }
259
GetSupportedChannel() const260 RangeMock AudioCapsNativeMock::GetSupportedChannel() const
261 {
262 RangeMock channel;
263 if (audioCaps_ != nullptr) {
264 channel.minVal = audioCaps_->GetSupportedChannel().minVal;
265 channel.maxVal = audioCaps_->GetSupportedChannel().maxVal;
266 }
267 return channel;
268 }
269
GetSupportedFormats() const270 std::vector<int32_t> AudioCapsNativeMock::GetSupportedFormats() const
271 {
272 std::vector<int32_t> formats;
273 if (audioCaps_ != nullptr) {
274 formats = audioCaps_->GetSupportedFormats();
275 }
276 return formats;
277 }
278
GetSupportedSampleRates() const279 std::vector<int32_t> AudioCapsNativeMock::GetSupportedSampleRates() const
280 {
281 std::vector<int32_t> sampleRates;
282 if (audioCaps_ != nullptr) {
283 sampleRates = audioCaps_->GetSupportedSampleRates();
284 }
285 return sampleRates;
286 }
287
GetSupportedProfiles() const288 std::vector<int32_t> AudioCapsNativeMock::GetSupportedProfiles() const
289 {
290 std::vector<int32_t> profiles;
291 if (audioCaps_ != nullptr) {
292 profiles = audioCaps_->GetSupportedProfiles();
293 }
294 return profiles;
295 }
296
GetSupportedLevels() const297 std::vector<int32_t> AudioCapsNativeMock::GetSupportedLevels() const
298 {
299 std::vector<int32_t> levels;
300 if (audioCaps_ != nullptr) {
301 levels = audioCaps_->GetSupportedLevels();
302 }
303 return levels;
304 }
305
GetSupportedComplexity() const306 RangeMock AudioCapsNativeMock::GetSupportedComplexity() const
307 {
308 RangeMock complexity;
309 if (audioCaps_ != nullptr) {
310 complexity.minVal = audioCaps_->GetSupportedComplexity().minVal;
311 complexity.maxVal = audioCaps_->GetSupportedComplexity().maxVal;
312 }
313 return complexity;
314 }
315 } // Media
316 } // OHOS