• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef AVFCODEC_INFO_NATIVE_MOCK_H
17 #define AVFCODEC_INFO_NATIVE_MOCK_H
18 
19 #include "avcodec_mock.h"
20 #include "avcodec_info.h"
21 
22 namespace OHOS {
23 namespace Media {
24 const std::map<AVCodecTypeMock, AVCodecType> AVCODEC_TYPE_INFOS = {
25     {AVCODEC_TYPE_MOCK_NONE, AVCODEC_TYPE_NONE},
26     {AVCODEC_TYPE_MOCK_VIDEO_ENCODER, AVCODEC_TYPE_VIDEO_ENCODER},
27     {AVCODEC_TYPE_MOCK_VIDEO_DECODER, AVCODEC_TYPE_VIDEO_DECODER},
28     {AVCODEC_TYPE_MOCK_AUDIO_ENCODER, AVCODEC_TYPE_AUDIO_ENCODER},
29     {AVCODEC_TYPE_MOCK_AUDIO_DECODER, AVCODEC_TYPE_AUDIO_DECODER},
30 };
31 
32 class AVCodecInfoNativeMock : public AVCodecInfoMock {
33 public:
AVCodecInfoNativeMock(std::shared_ptr<AVCodecInfo> codecInfo)34     explicit AVCodecInfoNativeMock(std::shared_ptr<AVCodecInfo> codecInfo) : codecInfo_(codecInfo) {}
35     AVCodecInfoNativeMock() = default;
36     std::string GetName() const override;
37     int32_t GetType() const override;
38     std::string GetMimeType() const override;
39     bool IsHardwareAccelerated() const override;
40     bool IsSoftwareOnly() const override;
41     bool IsVendor() const override;
42 
43 private:
44     std::shared_ptr<AVCodecInfo> codecInfo_ = nullptr;
45 };
46 
47 class VideoCapsNativeMock : public VideoCapsMock {
48 public:
VideoCapsNativeMock(std::shared_ptr<VideoCaps> videoCaps)49     explicit VideoCapsNativeMock(std::shared_ptr<VideoCaps> videoCaps) : videoCaps_(videoCaps) {}
50     VideoCapsNativeMock() = default;
51     std::shared_ptr<AVCodecInfoMock> GetCodecInfo() const override;
52     RangeMock GetSupportedBitrate() const override;
53     std::vector<int32_t> GetSupportedFormats() const override;
54     int32_t GetSupportedHeightAlignment() const override;
55     int32_t GetSupportedWidthAlignment() const override;
56     RangeMock GetSupportedWidth() const override;
57     RangeMock GetSupportedHeight() const override;
58     std::vector<int32_t> GetSupportedProfiles() const override;
59     std::vector<int32_t> GetSupportedLevels() const override;
60     RangeMock GetSupportedEncodeQuality() const override;
61     bool IsSizeSupported(int32_t width, int32_t height) const override;
62     RangeMock GetSupportedFrameRate() const override;
63     RangeMock GetSupportedFrameRatesFor(int32_t width, int32_t height) const override;
64     bool IsSizeAndRateSupported(int32_t width, int32_t height, double frameRate) const override;
65     RangeMock GetPreferredFrameRate(int32_t width, int32_t height) const override;
66     std::vector<int32_t> GetSupportedBitrateMode() const override;
67     RangeMock GetSupportedQuality() const override;
68     RangeMock GetSupportedComplexity() const override;
69     bool IsSupportDynamicIframe() const override;
70 
71 private:
72     std::shared_ptr<VideoCaps> videoCaps_ = nullptr;
73 };
74 
75 class AudioCapsNativeMock : public AudioCapsMock {
76 public:
AudioCapsNativeMock(std::shared_ptr<AudioCaps> audioCaps)77     explicit AudioCapsNativeMock(std::shared_ptr<AudioCaps> audioCaps) : audioCaps_(audioCaps) {}
78     AudioCapsNativeMock() = default;
79     std::shared_ptr<AVCodecInfoMock> GetCodecInfo() const override;
80     RangeMock GetSupportedBitrate() const override;
81     RangeMock GetSupportedChannel() const override;
82     std::vector<int32_t> GetSupportedFormats() const override;
83     std::vector<int32_t> GetSupportedSampleRates() const override;
84     std::vector<int32_t> GetSupportedProfiles() const override;
85     std::vector<int32_t> GetSupportedLevels() const override;
86     RangeMock GetSupportedComplexity() const override;
87 private:
88     std::shared_ptr<AudioCaps> audioCaps_ = nullptr;
89 };
90 } // Media
91 } // OHOS
92 #endif // AVFCODEC_INFO_NATIVE_MOCK_H