1 /*
2 * Copyright (c) 2024 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 #include <mutex>
16 #include "avcodec_log.h"
17 #include "codecbase.h"
18 #include "fcodec_loader.h"
19 #include "hevc_decoder_loader.h"
20 #include "hcodec_loader.h"
21 #include "avc_encoder_loader.h"
22 #include "unittest_log.h"
23 namespace {
24 std::mutex g_mutex;
25 std::weak_ptr<OHOS::MediaAVCodec::CodecBaseMock> g_mockObject;
26 } // namespace
27
28 namespace OHOS {
29 namespace MediaAVCodec {
CreateByName(const std::string & name)30 std::shared_ptr<CodecBase> HCodecLoader::CreateByName(const std::string &name)
31 {
32 std::lock_guard<std::mutex> lock(g_mutex);
33 UNITTEST_INFO_LOG("name: %s", name.c_str());
34 auto mock = g_mockObject.lock();
35 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, nullptr, "mock object is nullptr");
36 return mock->CreateHCodecByName(name);
37 }
38
CreateByName(const std::string & name)39 std::shared_ptr<CodecBase> FCodecLoader::CreateByName(const std::string &name)
40 {
41 std::lock_guard<std::mutex> lock(g_mutex);
42 UNITTEST_INFO_LOG("name: %s", name.c_str());
43 auto mock = g_mockObject.lock();
44 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, nullptr, "mock object is nullptr");
45 return mock->CreateFCodecByName(name);
46 }
47
CreateByName(const std::string & name)48 std::shared_ptr<CodecBase> HevcDecoderLoader::CreateByName(const std::string &name)
49 {
50 std::lock_guard<std::mutex> lock(g_mutex);
51 UNITTEST_INFO_LOG("name: %s", name.c_str());
52 auto mock = g_mockObject.lock();
53 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, nullptr, "mock object is nullptr");
54 return mock->CreateHevcDecoderByName(name);
55 }
56
CreateByName(const std::string & name)57 std::shared_ptr<CodecBase> AvcEncoderLoader::CreateByName(const std::string &name)
58 {
59 std::lock_guard<std::mutex> lock(g_mutex);
60 UNITTEST_INFO_LOG("name: %s", name.c_str());
61 auto mock = g_mockObject.lock();
62 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, nullptr, "mock object is nullptr");
63 return mock->CreateAvcEncoderByName(name);
64 }
65
GetCapabilityList(std::vector<CapabilityData> & caps)66 int32_t HCodecLoader::GetCapabilityList(std::vector<CapabilityData> &caps)
67 {
68 std::lock_guard<std::mutex> lock(g_mutex);
69 UNITTEST_INFO_LOG("HCodec");
70 auto mock = g_mockObject.lock();
71 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
72 auto item = mock->GetHCapabilityList();
73 caps = item.second;
74 return item.first;
75 }
76
GetCapabilityList(std::vector<CapabilityData> & caps)77 int32_t FCodecLoader::GetCapabilityList(std::vector<CapabilityData> &caps)
78 {
79 std::lock_guard<std::mutex> lock(g_mutex);
80 UNITTEST_INFO_LOG("FCodec");
81 auto mock = g_mockObject.lock();
82 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
83 auto item = mock->GetFCapabilityList();
84 caps = item.second;
85 return item.first;
86 }
87
GetCapabilityList(std::vector<CapabilityData> & caps)88 int32_t HevcDecoderLoader::GetCapabilityList(std::vector<CapabilityData> &caps)
89 {
90 std::lock_guard<std::mutex> lock(g_mutex);
91 UNITTEST_INFO_LOG("HevcDecoder");
92 auto mock = g_mockObject.lock();
93 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
94 auto item = mock->GetHevcDecoderCapabilityList();
95 caps = item.second;
96 return item.first;
97 }
98
GetCapabilityList(std::vector<CapabilityData> & caps)99 int32_t AvcEncoderLoader::GetCapabilityList(std::vector<CapabilityData> &caps)
100 {
101 std::lock_guard<std::mutex> lock(g_mutex);
102 UNITTEST_INFO_LOG("AvcEncoder");
103 auto mock = g_mockObject.lock();
104 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
105 auto item = mock->GetAvcEncoderCapabilityList();
106 caps = item.second;
107 return item.first;
108 }
109
110
RegisterMock(std::shared_ptr<CodecBaseMock> & mock)111 void CodecBase::RegisterMock(std::shared_ptr<CodecBaseMock> &mock)
112 {
113 std::lock_guard<std::mutex> lock(g_mutex);
114 UNITTEST_INFO_LOG("CodecBase:0x%" PRIXPTR, FAKE_POINTER(mock.get()));
115 g_mockObject = mock;
116 }
117
CodecBase()118 CodecBase::CodecBase()
119 {
120 std::lock_guard<std::mutex> lock(g_mutex);
121 UNITTEST_INFO_LOG("");
122 auto mock = g_mockObject.lock();
123 UNITTEST_CHECK_AND_RETURN_LOG(mock != nullptr, "mock object is nullptr");
124 mock->CodecBaseCtor();
125 }
126
~CodecBase()127 CodecBase::~CodecBase()
128 {
129 UNITTEST_INFO_LOG("");
130 }
131
SetCallback(const std::shared_ptr<AVCodecCallback> & callback)132 int32_t CodecBase::SetCallback(const std::shared_ptr<AVCodecCallback> &callback)
133 {
134 std::lock_guard<std::mutex> lock(g_mutex);
135 UNITTEST_INFO_LOG("callback:0x%" PRIXPTR, FAKE_POINTER(callback.get()));
136 auto mock = g_mockObject.lock();
137 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
138 mock->codecCb_ = callback;
139 return mock->SetCallback(std::shared_ptr<AVCodecCallback>(nullptr));
140 }
141
SetCallback(const std::shared_ptr<MediaCodecCallback> & callback)142 int32_t CodecBase::SetCallback(const std::shared_ptr<MediaCodecCallback> &callback)
143 {
144 std::lock_guard<std::mutex> lock(g_mutex);
145 UNITTEST_INFO_LOG("callback:0x%" PRIXPTR, FAKE_POINTER(callback.get()));
146 auto mock = g_mockObject.lock();
147 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
148 mock->videoCb_ = callback;
149 return mock->SetCallback(std::shared_ptr<MediaCodecCallback>(nullptr));
150 }
151
Configure(const Format & format)152 int32_t CodecBase::Configure(const Format &format)
153 {
154 std::lock_guard<std::mutex> lock(g_mutex);
155 UNITTEST_INFO_LOG("format:%s", format.Stringify().c_str());
156 auto mock = g_mockObject.lock();
157 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
158 return mock->Configure();
159 }
160
SetCustomBuffer(std::shared_ptr<AVBuffer> buffer)161 int32_t CodecBase::SetCustomBuffer(std::shared_ptr<AVBuffer> buffer)
162 {
163 std::lock_guard<std::mutex> lock(g_mutex);
164 UNITTEST_INFO_LOG("");
165 auto mock = g_mockObject.lock();
166 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
167 return mock->SetCustomBuffer(buffer);
168 }
169
Start()170 int32_t CodecBase::Start()
171 {
172 std::lock_guard<std::mutex> lock(g_mutex);
173 UNITTEST_INFO_LOG("");
174 auto mock = g_mockObject.lock();
175 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
176 return mock->Start();
177 }
178
Stop()179 int32_t CodecBase::Stop()
180 {
181 std::lock_guard<std::mutex> lock(g_mutex);
182 UNITTEST_INFO_LOG("");
183 auto mock = g_mockObject.lock();
184 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
185 return mock->Stop();
186 }
187
Flush()188 int32_t CodecBase::Flush()
189 {
190 std::lock_guard<std::mutex> lock(g_mutex);
191 UNITTEST_INFO_LOG("");
192 auto mock = g_mockObject.lock();
193 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
194 return mock->Flush();
195 }
196
Reset()197 int32_t CodecBase::Reset()
198 {
199 std::lock_guard<std::mutex> lock(g_mutex);
200 UNITTEST_INFO_LOG("");
201 auto mock = g_mockObject.lock();
202 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
203 return mock->Reset();
204 }
205
Release()206 int32_t CodecBase::Release()
207 {
208 std::lock_guard<std::mutex> lock(g_mutex);
209 UNITTEST_INFO_LOG("");
210 auto mock = g_mockObject.lock();
211 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
212 return mock->Release();
213 }
214
SetParameter(const Format & format)215 int32_t CodecBase::SetParameter(const Format &format)
216 {
217 std::lock_guard<std::mutex> lock(g_mutex);
218 UNITTEST_INFO_LOG("format:%s", format.Stringify().c_str());
219 auto mock = g_mockObject.lock();
220 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
221 return mock->SetParameter();
222 }
223
GetOutputFormat(Format & format)224 int32_t CodecBase::GetOutputFormat(Format &format)
225 {
226 std::lock_guard<std::mutex> lock(g_mutex);
227 UNITTEST_INFO_LOG("format:%s", format.Stringify().c_str());
228 auto mock = g_mockObject.lock();
229 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
230 return mock->GetOutputFormat();
231 }
232
QueueInputBuffer(uint32_t index,const AVCodecBufferInfo & info,AVCodecBufferFlag flag)233 int32_t CodecBase::QueueInputBuffer(uint32_t index, const AVCodecBufferInfo &info, AVCodecBufferFlag flag)
234 {
235 std::lock_guard<std::mutex> lock(g_mutex);
236 UNITTEST_INFO_LOG("index:%u, size:%d, flag:%d", index, info.size, static_cast<int32_t>(flag));
237 auto mock = g_mockObject.lock();
238 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
239 return mock->QueueInputBuffer(index, info, flag);
240 }
241
QueueInputBuffer(uint32_t index)242 int32_t CodecBase::QueueInputBuffer(uint32_t index)
243 {
244 std::lock_guard<std::mutex> lock(g_mutex);
245 UNITTEST_INFO_LOG("index:%u", index);
246 auto mock = g_mockObject.lock();
247 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
248 return mock->QueueInputBuffer(index);
249 }
250
QueueInputParameter(uint32_t index)251 int32_t CodecBase::QueueInputParameter(uint32_t index)
252 {
253 std::lock_guard<std::mutex> lock(g_mutex);
254 UNITTEST_INFO_LOG("index:%u", index);
255 auto mock = g_mockObject.lock();
256 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
257 return mock->QueueInputParameter(index);
258 }
259
ReleaseOutputBuffer(uint32_t index)260 int32_t CodecBase::ReleaseOutputBuffer(uint32_t index)
261 {
262 std::lock_guard<std::mutex> lock(g_mutex);
263 UNITTEST_INFO_LOG("index:%u", index);
264 auto mock = g_mockObject.lock();
265 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
266 return mock->ReleaseOutputBuffer(index);
267 }
268
NotifyEos()269 int32_t CodecBase::NotifyEos()
270 {
271 std::lock_guard<std::mutex> lock(g_mutex);
272 UNITTEST_INFO_LOG("");
273 auto mock = g_mockObject.lock();
274 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
275 return mock->NotifyEos();
276 }
277
CreateInputSurface()278 sptr<Surface> CodecBase::CreateInputSurface()
279 {
280 std::lock_guard<std::mutex> lock(g_mutex);
281 UNITTEST_INFO_LOG("");
282 auto mock = g_mockObject.lock();
283 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, nullptr, "mock object is nullptr");
284 return mock->CreateInputSurface();
285 }
286
SetInputSurface(sptr<Surface> surface)287 int32_t CodecBase::SetInputSurface(sptr<Surface> surface)
288 {
289 std::lock_guard<std::mutex> lock(g_mutex);
290 UNITTEST_INFO_LOG("surface:0x%" PRIXPTR, FAKE_POINTER(surface.GetRefPtr()));
291 auto mock = g_mockObject.lock();
292 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
293 return mock->SetInputSurface(surface);
294 }
295
SetOutputSurface(sptr<Surface> surface)296 int32_t CodecBase::SetOutputSurface(sptr<Surface> surface)
297 {
298 std::lock_guard<std::mutex> lock(g_mutex);
299 UNITTEST_INFO_LOG("");
300 auto mock = g_mockObject.lock();
301 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
302 return mock->SetOutputSurface(surface);
303 }
304
RenderOutputBuffer(uint32_t index)305 int32_t CodecBase::RenderOutputBuffer(uint32_t index)
306 {
307 std::lock_guard<std::mutex> lock(g_mutex);
308 UNITTEST_INFO_LOG("index:%u", index);
309 auto mock = g_mockObject.lock();
310 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
311 return mock->RenderOutputBuffer(index);
312 }
313
SignalRequestIDRFrame()314 int32_t CodecBase::SignalRequestIDRFrame()
315 {
316 std::lock_guard<std::mutex> lock(g_mutex);
317 UNITTEST_INFO_LOG("");
318 auto mock = g_mockObject.lock();
319 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
320 return mock->SignalRequestIDRFrame();
321 }
322
GetInputFormat(Format & format)323 int32_t CodecBase::GetInputFormat(Format &format)
324 {
325 std::lock_guard<std::mutex> lock(g_mutex);
326 UNITTEST_INFO_LOG("format:%s", format.Stringify().c_str());
327 auto mock = g_mockObject.lock();
328 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
329 return mock->GetInputFormat(format);
330 }
331
GetHidumperInfo()332 std::string CodecBase::GetHidumperInfo()
333 {
334 std::lock_guard<std::mutex> lock(g_mutex);
335 UNITTEST_INFO_LOG("");
336 auto mock = g_mockObject.lock();
337 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, "", "mock object is nullptr");
338 return mock->GetHidumperInfo();
339 }
340
Init(Media::Meta & callerInfo)341 int32_t CodecBase::Init(Media::Meta &callerInfo)
342 {
343 (void) callerInfo;
344 std::lock_guard<std::mutex> lock(g_mutex);
345 UNITTEST_INFO_LOG("Init");
346 auto mock = g_mockObject.lock();
347 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
348 return mock->Init();
349 }
350
CreateCodecByName(const std::string & name)351 int32_t CodecBase::CreateCodecByName(const std::string &name)
352 {
353 std::lock_guard<std::mutex> lock(g_mutex);
354 UNITTEST_INFO_LOG("name: %s", name.c_str());
355 auto mock = g_mockObject.lock();
356 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
357 return mock->CreateCodecByName(name);
358 }
359
Configure(const std::shared_ptr<Media::Meta> & meta)360 int32_t CodecBase::Configure(const std::shared_ptr<Media::Meta> &meta)
361 {
362 std::lock_guard<std::mutex> lock(g_mutex);
363 UNITTEST_INFO_LOG("meta:0x%" PRIXPTR, FAKE_POINTER(meta.get()));
364 auto mock = g_mockObject.lock();
365 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
366 return mock->Configure(meta);
367 }
368
SetParameter(const std::shared_ptr<Media::Meta> & parameter)369 int32_t CodecBase::SetParameter(const std::shared_ptr<Media::Meta> ¶meter)
370 {
371 std::lock_guard<std::mutex> lock(g_mutex);
372 UNITTEST_INFO_LOG("parameter:0x%" PRIXPTR, FAKE_POINTER(parameter.get()));
373 auto mock = g_mockObject.lock();
374 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
375 return mock->SetParameter(parameter);
376 }
377
GetOutputFormat(std::shared_ptr<Media::Meta> & parameter)378 int32_t CodecBase::GetOutputFormat(std::shared_ptr<Media::Meta> ¶meter)
379 {
380 std::lock_guard<std::mutex> lock(g_mutex);
381 UNITTEST_INFO_LOG("parameter:0x%" PRIXPTR, FAKE_POINTER(parameter.get()));
382 auto mock = g_mockObject.lock();
383 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
384 return mock->GetOutputFormat(parameter);
385 }
386
SetOutputBufferQueue(const sptr<Media::AVBufferQueueProducer> & bufferQueueProducer)387 int32_t CodecBase::SetOutputBufferQueue(const sptr<Media::AVBufferQueueProducer> &bufferQueueProducer)
388 {
389 std::lock_guard<std::mutex> lock(g_mutex);
390 UNITTEST_INFO_LOG("bufferQueueProducer:0x%" PRIXPTR, FAKE_POINTER(bufferQueueProducer.GetRefPtr()));
391 auto mock = g_mockObject.lock();
392 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
393 return mock->SetOutputBufferQueue(bufferQueueProducer);
394 }
395
Prepare()396 int32_t CodecBase::Prepare()
397 {
398 std::lock_guard<std::mutex> lock(g_mutex);
399 UNITTEST_INFO_LOG("");
400 auto mock = g_mockObject.lock();
401 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
402 return mock->Prepare();
403 }
404
GetInputBufferQueue()405 sptr<Media::AVBufferQueueProducer> CodecBase::GetInputBufferQueue()
406 {
407 std::lock_guard<std::mutex> lock(g_mutex);
408 UNITTEST_INFO_LOG("");
409 auto mock = g_mockObject.lock();
410 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, nullptr, "mock object is nullptr");
411 return mock->GetInputBufferQueue();
412 }
413
ProcessInputBuffer()414 void CodecBase::ProcessInputBuffer()
415 {
416 std::lock_guard<std::mutex> lock(g_mutex);
417 UNITTEST_INFO_LOG("");
418 auto mock = g_mockObject.lock();
419 UNITTEST_CHECK_AND_RETURN_LOG(mock != nullptr, "mock object is nullptr");
420 mock->ProcessInputBuffer();
421 }
422
SetLowPowerPlayerMode(const bool isLpp)423 int32_t CodecBase::SetLowPowerPlayerMode(const bool isLpp)
424 {
425 std::lock_guard<std::mutex> lock(g_mutex);
426 UNITTEST_INFO_LOG("");
427 auto mock = g_mockObject.lock();
428 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
429 return mock->SetLowPowerPlayerMode(isLpp);
430 }
431
GetChannelId(int32_t & channelId)432 int32_t CodecBase::GetChannelId(int32_t &channelId)
433 {
434 std::lock_guard<std::mutex> lock(g_mutex);
435 UNITTEST_INFO_LOG("");
436 auto mock = g_mockObject.lock();
437 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
438 return mock->GetChannelId(channelId);
439 }
440
SetAudioDecryptionConfig(const sptr<DrmStandard::IMediaKeySessionService> & keySession,const bool svpFlag)441 int32_t CodecBase::SetAudioDecryptionConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySession,
442 const bool svpFlag)
443 {
444 std::lock_guard<std::mutex> lock(g_mutex);
445 UNITTEST_INFO_LOG("");
446 auto mock = g_mockObject.lock();
447 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
448 return mock->SetAudioDecryptionConfig(keySession, svpFlag);
449 }
450
NotifyMemoryRecycle()451 int32_t CodecBase::NotifyMemoryRecycle()
452 {
453 std::lock_guard<std::mutex> lock(g_mutex);
454 UNITTEST_INFO_LOG("");
455 auto mock = g_mockObject.lock();
456 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
457 return mock->NotifyMemoryRecycle();
458 }
459
NotifyMemoryWriteBack()460 int32_t CodecBase::NotifyMemoryWriteBack()
461 {
462 std::lock_guard<std::mutex> lock(g_mutex);
463 UNITTEST_INFO_LOG("");
464 auto mock = g_mockObject.lock();
465 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
466 return mock->NotifyMemoryWriteBack();
467 }
468
NotifySuspend()469 int32_t CodecBase::NotifySuspend()
470 {
471 std::lock_guard<std::mutex> lock(g_mutex);
472 UNITTEST_INFO_LOG("");
473 auto mock = g_mockObject.lock();
474 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
475 return mock->NotifySuspend();
476 }
477
NotifyResume()478 int32_t CodecBase::NotifyResume()
479 {
480 std::lock_guard<std::mutex> lock(g_mutex);
481 UNITTEST_INFO_LOG("");
482 auto mock = g_mockObject.lock();
483 UNITTEST_CHECK_AND_RETURN_RET_LOG(mock != nullptr, AVCS_ERR_UNKNOWN, "mock object is nullptr");
484 return mock->NotifyResume();
485 }
486 } // namespace MediaAVCodec
487 } // namespace OHOS
488