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 "avsource_inner_mock.h"
17 
18 namespace OHOS {
19 namespace MediaAVCodec {
Destroy()20 int32_t AVSourceInnerMock::Destroy()
21 {
22     if (source_ != nullptr) {
23         source_ = nullptr;
24         return AV_ERR_OK;
25     }
26     return AV_ERR_UNKNOWN;
27 }
28 
GetSourceFormat()29 std::shared_ptr<FormatMock> AVSourceInnerMock::GetSourceFormat()
30 {
31     if (source_ != nullptr) {
32         Format format;
33         source_->GetSourceFormat(format);
34         return std::make_shared<AVFormatInnerMock>(format);
35     }
36     return nullptr;
37 }
38 
GetTrackFormat(uint32_t trackIndex)39 std::shared_ptr<FormatMock> AVSourceInnerMock::GetTrackFormat(uint32_t trackIndex)
40 {
41     if (source_ != nullptr) {
42         Format format;
43         source_->GetTrackFormat(format, trackIndex);
44         return std::make_shared<AVFormatInnerMock>(format);
45     }
46     return nullptr;
47 }
48 
GetUserData()49 std::shared_ptr<FormatMock> AVSourceInnerMock::GetUserData()
50 {
51     if (source_ != nullptr) {
52         Format format;
53         source_->GetUserMeta(format);
54         return std::make_shared<AVFormatInnerMock>(format);
55     }
56     return nullptr;
57 }
58 
GetAVSource()59 std::shared_ptr<AVSource> AVSourceInnerMock::GetAVSource()
60 {
61     return source_;
62 }
63 } // namespace MediaAVCodec
64 } // namespace OHOS