• 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_info_native_mock.h"
17 #include "avformat_native_mock.h"
18 #include "avcodec_list_native_mock.h"
19 
20 namespace OHOS {
21 namespace Media {
FindVideoDecoder(std::shared_ptr<FormatMock> format) const22 std::string AVCodecListNativeMock::FindVideoDecoder(std::shared_ptr<FormatMock> format) const
23 {
24     std::string ret;
25     if (avCodecList_ != nullptr && format != nullptr) {
26         auto fmt = std::static_pointer_cast<AVFormatNativeMock>(format);
27         ret = avCodecList_->FindVideoDecoder(fmt->GetFormat());
28     }
29     return ret;
30 }
31 
FindVideoEncoder(std::shared_ptr<FormatMock> format) const32 std::string AVCodecListNativeMock::FindVideoEncoder(std::shared_ptr<FormatMock> format) const
33 {
34     std::string ret;
35     if (avCodecList_ != nullptr && format != nullptr) {
36         auto fmt = std::static_pointer_cast<AVFormatNativeMock>(format);
37         ret = avCodecList_->FindVideoEncoder(fmt->GetFormat());
38     }
39     return ret;
40 }
41 
FindAudioDecoder(std::shared_ptr<FormatMock> format) const42 std::string AVCodecListNativeMock::FindAudioDecoder(std::shared_ptr<FormatMock> format) const
43 {
44     std::string ret;
45     if (avCodecList_ != nullptr && format != nullptr) {
46         auto fmt = std::static_pointer_cast<AVFormatNativeMock>(format);
47         ret = avCodecList_->FindAudioDecoder(fmt->GetFormat());
48     }
49     return ret;
50 }
51 
FindAudioEncoder(std::shared_ptr<FormatMock> format) const52 std::string AVCodecListNativeMock::FindAudioEncoder(std::shared_ptr<FormatMock> format) const
53 {
54     std::string ret;
55     if (avCodecList_ != nullptr && format != nullptr) {
56         auto fmt = std::static_pointer_cast<AVFormatNativeMock>(format);
57         ret = avCodecList_->FindAudioEncoder(fmt->GetFormat());
58     }
59     return ret;
60 }
61 
62 
GetVideoDecoderCaps() const63 std::vector<std::shared_ptr<VideoCapsMock>> AVCodecListNativeMock::GetVideoDecoderCaps() const
64 {
65     std::vector<std::shared_ptr<VideoCaps>> videoCapsArray;
66     std::vector<std::shared_ptr<VideoCapsMock>> retVideoCapsArray;
67     if (avCodecList_ == nullptr) {
68         return retVideoCapsArray;
69     }
70     videoCapsArray = avCodecList_->GetVideoDecoderCaps();
71     for (auto iter = videoCapsArray.begin(); iter != videoCapsArray.end(); iter++) {
72         std::shared_ptr<VideoCaps> pVideoCaps = *iter;
73         if (pVideoCaps == nullptr) {
74             break;
75         }
76         retVideoCapsArray.push_back(std::make_shared<VideoCapsNativeMock>(pVideoCaps));
77     }
78     return retVideoCapsArray;
79 }
80 
GetVideoEncoderCaps() const81 std::vector<std::shared_ptr<VideoCapsMock>> AVCodecListNativeMock::GetVideoEncoderCaps() const
82 {
83     std::vector<std::shared_ptr<VideoCaps>> videoCapsArray;
84     std::vector<std::shared_ptr<VideoCapsMock>> retVideoCapsArray;
85     if (avCodecList_ == nullptr) {
86         return retVideoCapsArray;
87     }
88     videoCapsArray = avCodecList_->GetVideoEncoderCaps();
89     for (auto iter = videoCapsArray.begin(); iter != videoCapsArray.end(); iter++) {
90         std::shared_ptr<VideoCaps> pVideoCaps = *iter;
91         if (pVideoCaps == nullptr) {
92             break;
93         }
94         retVideoCapsArray.push_back(std::make_shared<VideoCapsNativeMock>(pVideoCaps));
95     }
96     return retVideoCapsArray;
97 }
98 
GetAudioDecoderCaps() const99 std::vector<std::shared_ptr<AudioCapsMock>> AVCodecListNativeMock::GetAudioDecoderCaps() const
100 {
101     std::vector<std::shared_ptr<AudioCaps>> audioCapsArray;
102     std::vector<std::shared_ptr<AudioCapsMock>> retAudioCapsArray;
103     if (avCodecList_ == nullptr) {
104         return retAudioCapsArray;
105     }
106     audioCapsArray = avCodecList_->GetAudioDecoderCaps();
107     for (auto iter = audioCapsArray.begin(); iter != audioCapsArray.end(); iter++) {
108         std::shared_ptr<AudioCaps> pAudioCaps = *iter;
109         if (pAudioCaps == nullptr) {
110             break;
111         }
112         retAudioCapsArray.push_back(std::make_shared<AudioCapsNativeMock>(pAudioCaps));
113     }
114     return retAudioCapsArray;
115 }
116 
GetAudioEncoderCaps() const117 std::vector<std::shared_ptr<AudioCapsMock>> AVCodecListNativeMock::GetAudioEncoderCaps() const
118 {
119     std::vector<std::shared_ptr<AudioCaps>> audioCapsArray;
120     std::vector<std::shared_ptr<AudioCapsMock>> retAudioCapsArray;
121     if (avCodecList_ == nullptr) {
122         return retAudioCapsArray;
123     }
124     audioCapsArray = avCodecList_->GetAudioEncoderCaps();
125     for (auto iter = audioCapsArray.begin(); iter != audioCapsArray.end(); iter++) {
126         std::shared_ptr<AudioCaps> pAudioCaps = *iter;
127         if (pAudioCaps == nullptr) {
128             break;
129         }
130         retAudioCapsArray.push_back(std::make_shared<AudioCapsNativeMock>(pAudioCaps));
131     }
132     return retAudioCapsArray;
133 }
134 } // Media
135 } // OHOS