1 /* 2 * Copyright (C) 2023 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 <memory> 17 #include "avformat_capi_mock.h" 18 #include "avsource_capi_mock.h" 19 20 namespace OHOS { 21 namespace MediaAVCodec { Destroy()22int32_t AVSourceCapiMock::Destroy() 23 { 24 if (source_ != nullptr) { 25 int32_t ret = OH_AVSource_Destroy(source_); 26 source_ = nullptr; 27 return ret; 28 } 29 return AV_ERR_UNKNOWN; 30 } 31 GetSourceFormat()32std::shared_ptr<FormatMock> AVSourceCapiMock::GetSourceFormat() 33 { 34 if (source_ != nullptr) { 35 OH_AVFormat *format = OH_AVSource_GetSourceFormat(source_); 36 return std::make_shared<AVFormatCapiMock>(format); 37 } 38 return nullptr; 39 } 40 GetTrackFormat(uint32_t trackIndex)41std::shared_ptr<FormatMock> AVSourceCapiMock::GetTrackFormat(uint32_t trackIndex) 42 { 43 if (source_ != nullptr) { 44 OH_AVFormat *format = OH_AVSource_GetTrackFormat(source_, trackIndex); 45 if (format != nullptr) { 46 return std::make_shared<AVFormatCapiMock>(format); 47 } 48 return nullptr; 49 } 50 return nullptr; 51 } 52 GetAVSource()53OH_AVSource* AVSourceCapiMock::GetAVSource() 54 { 55 return source_; 56 } 57 } // namespace MediaAVCodec 58 } // namespace OHOS