• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 MOCK_VDEC_ADAPTER_H
17 #define MOCK_VDEC_ADAPTER_H
18 
19 #include <gmock/gmock.h>
20 #include "avcodec_errors.h"
21 #include "avcodec_common.h"
22 
23 namespace OHOS {
24 namespace MediaAVCodec {
25 class AVCodecVideoDecoder : public std::enable_shared_from_this<AVCodecVideoDecoder> {
26 public:
AVCodecVideoDecoder()27     AVCodecVideoDecoder () {};
~AVCodecVideoDecoder()28     ~AVCodecVideoDecoder() {};
29     MOCK_METHOD(int32_t, Configure, (const Format &format));
30     MOCK_METHOD(int32_t, Prepare, ());
31     MOCK_METHOD(int32_t, Start, ());
32     MOCK_METHOD(int32_t, Stop, ());
33     MOCK_METHOD(int32_t, Flush, ());
34     MOCK_METHOD(int32_t, Reset, ());
35     MOCK_METHOD(int32_t, Release, ());
36     MOCK_METHOD(int32_t, SetOutputSurface, (sptr<Surface> surface));
37     MOCK_METHOD(int32_t, QueueInputBuffer, (uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag));
38     MOCK_METHOD(int32_t, QueueInputBuffer, (uint32_t index));
39     MOCK_METHOD(int32_t, GetOutputFormat, (Format &format));
40     MOCK_METHOD(int32_t, ReleaseOutputBuffer, (uint32_t index, bool render));
41     MOCK_METHOD(int32_t, RenderOutputBufferAtTime, (uint32_t index, int64_t renderTimestampNs));
42     MOCK_METHOD(int32_t, SetParameter, (const Format &format));
43     MOCK_METHOD(int32_t, SetCallback, (const std::shared_ptr<AVCodecCallback> &callback));
SetCallback(const std::shared_ptr<MediaCodecCallback> & callback)44     int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback)
45     {
46         (void)callback;
47         return MediaAVCodec::AVCS_ERR_OK;
48     }
49     MOCK_METHOD(int32_t, GetChannelId, (int32_t &channelId));
SetLowPowerPlayerMode(bool isLpp)50     int32_t SetLowPowerPlayerMode(bool isLpp)
51     {
52         (void)isLpp;
53         return MediaAVCodec::AVCS_ERR_OK;
54     }
55     MOCK_METHOD(int32_t, NotifyMemoryExchange, (const bool exchangeFlag));
56     MOCK_METHOD(int32_t, QueryInputBuffer, (uint32_t &index, int64_t timeoutUs));
57     MOCK_METHOD(int32_t, QueryOutputBuffer, (uint32_t &index, int64_t timeoutUs));
58     MOCK_METHOD(std::shared_ptr<AVBuffer>, GetInputBuffer, (uint32_t index));
59     MOCK_METHOD(std::shared_ptr<AVBuffer>, GetOutputBuffer, (uint32_t index));
60 };
61 
62 class VideoDecoderFactory {
63 public:
CreateByMime(const std::string & mime)64     static std::shared_ptr<AVCodecVideoDecoder> CreateByMime(const std::string &mime)
65     {
66         (void)mime;
67         return std::make_shared<AVCodecVideoDecoder>();
68     }
69 private:
70     VideoDecoderFactory() = default;
71     ~VideoDecoderFactory() = default;
72 };
73 } // namespace MediaAVCodec
74 } // namespace OHOS
75 #endif // MOCK_VDEC_ADAPTER_H
76