• 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 #include "avcodec_mock.h"
17 #include "avcodec_list_native_mock.h"
18 #include "enum_native_mock.h"
19 #include "avcodec_info_native_mock.h"
20 #include "avformat_native_mock.h"
21 #include "avmemory_native_mock.h"
22 #include "surface_native_mock.h"
23 #include "audiodec_native_mock.h"
24 #include "audioenc_native_mock.h"
25 #include "videodec_native_mock.h"
26 #include "videoenc_native_mock.h"
27 
28 namespace OHOS {
29 namespace Media {
CreateVideoDecMockByMime(const std::string & mime)30 std::shared_ptr<VideoDecMock> AVCodecMockFactory::CreateVideoDecMockByMime(const std::string &mime)
31 {
32     auto videoDec = VideoDecoderFactory::CreateByMime(mime);
33     if (videoDec != nullptr) {
34         return std::make_shared<VideoDecNativeMock>(videoDec);
35     }
36     return nullptr;
37 }
38 
CreateVideoDecMockByName(const std::string & name)39 std::shared_ptr<VideoDecMock> AVCodecMockFactory::CreateVideoDecMockByName(const std::string &name)
40 {
41     auto videoDec = VideoDecoderFactory::CreateByName(name);
42     if (videoDec != nullptr) {
43         return std::make_shared<VideoDecNativeMock>(videoDec);
44     }
45     return nullptr;
46 }
47 
CreateVideoEncMockByMime(const std::string & mime)48 std::shared_ptr<VideoEncMock> AVCodecMockFactory::CreateVideoEncMockByMime(const std::string &mime)
49 {
50     auto videoEnc = VideoEncoderFactory::CreateByMime(mime);
51     if (videoEnc != nullptr) {
52         return std::make_shared<VideoEncNativeMock>(videoEnc);
53     }
54     return nullptr;
55 }
56 
CreateVideoEncMockByName(const std::string & name)57 std::shared_ptr<VideoEncMock> AVCodecMockFactory::CreateVideoEncMockByName(const std::string &name)
58 {
59     auto videoEnc = VideoEncoderFactory::CreateByName(name);
60     if (videoEnc != nullptr) {
61         return std::make_shared<VideoEncNativeMock>(videoEnc);
62     }
63     return nullptr;
64 }
65 
CreateAudioDecMockByMime(const std::string & mime)66 std::shared_ptr<AudioDecMock> AVCodecMockFactory::CreateAudioDecMockByMime(const std::string &mime)
67 {
68     auto audioDec = AudioDecoderFactory::CreateByMime(mime);
69     if (audioDec != nullptr) {
70         return std::make_shared<AudioDecNativeMock>(audioDec);
71     }
72     return nullptr;
73 }
74 
CreateAudioDecMockByName(const std::string & name)75 std::shared_ptr<AudioDecMock> AVCodecMockFactory::CreateAudioDecMockByName(const std::string &name)
76 {
77     auto audioDec = AudioDecoderFactory::CreateByName(name);
78     if (audioDec != nullptr) {
79         return std::make_shared<AudioDecNativeMock>(audioDec);
80     }
81     return nullptr;
82 }
83 
CreateAudioEncMockByMime(const std::string & mime)84 std::shared_ptr<AudioEncMock> AVCodecMockFactory::CreateAudioEncMockByMime(const std::string &mime)
85 {
86     auto audioEnc = AudioEncoderFactory::CreateByMime(mime);
87     if (audioEnc != nullptr) {
88         return std::make_shared<AudioEncNativeMock>(audioEnc);
89     }
90     return nullptr;
91 }
92 
CreateAudioEncMockByName(const std::string & name)93 std::shared_ptr<AudioEncMock> AVCodecMockFactory::CreateAudioEncMockByName(const std::string &name)
94 {
95     auto audioEnc = AudioEncoderFactory::CreateByName(name);
96     if (audioEnc != nullptr) {
97         return std::make_shared<AudioEncNativeMock>(audioEnc);
98     }
99     return nullptr;
100 }
101 
CreateFormat()102 std::shared_ptr<FormatMock> AVCodecMockFactory::CreateFormat()
103 {
104     return std::make_shared<AVFormatNativeMock>();
105 }
106 
CreateSurface()107 std::shared_ptr<SurfaceMock> AVCodecMockFactory::CreateSurface()
108 {
109     return std::make_shared<SurfaceNativeMock>();
110 }
111 
CreateAVCodecInfo()112 std::shared_ptr<AVCodecInfoMock> AVCodecMockFactory::CreateAVCodecInfo()
113 {
114     return std::make_shared<AVCodecInfoNativeMock>();
115 }
116 
CreateVideoCaps()117 std::shared_ptr<VideoCapsMock> AVCodecMockFactory::CreateVideoCaps()
118 {
119     return std::make_shared<VideoCapsNativeMock>();
120 }
121 
CreateAVCodecList()122 std::shared_ptr<AVCodecListMock> AVCodecMockFactory::CreateAVCodecList()
123 {
124     auto avCodecList = AVCodecListFactory::CreateAVCodecList();
125     if (avCodecList != nullptr) {
126         return std::make_shared<AVCodecListNativeMock>(avCodecList);
127     }
128     return nullptr;
129 }
130 
CreateEnum()131 std::shared_ptr<EnumMock> AVCodecMockFactory::CreateEnum()
132 {
133     return std::make_shared<EnumNativeMock>();
134 }
135 }
136 }