1 /*
2  * Copyright (c) 2021-2021 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 "plugin/core/source.h"
17 #include "plugin/interface/source_plugin.h"
18 
19 using namespace OHOS::Media::Plugin;
20 
Source(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr<SourcePlugin> plugin)21 Source::Source(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr<SourcePlugin> plugin)
22     : Base(pkgVer, apiVer, plugin), source_(std::move(plugin))
23 {
24 }
25 
SetSource(std::shared_ptr<MediaSource> source)26 Status Source::SetSource(std::shared_ptr<MediaSource> source)
27 {
28     return source_->SetSource(source);
29 }
30 
Read(std::shared_ptr<Buffer>& buffer, size_t expectedLen)31 Status Source::Read(std::shared_ptr<Buffer>& buffer, size_t expectedLen)
32 {
33     return source_->Read(buffer, expectedLen);
34 }
35 
GetSize(uint64_t& size)36 Status Source::GetSize(uint64_t& size)
37 {
38     return source_->GetSize(size);
39 }
40 
GetSeekable()41 Seekable Source::GetSeekable()
42 {
43     return source_->GetSeekable();
44 }
45 
SeekToPos(int64_t offset)46 Status Source::SeekToPos(int64_t offset)
47 {
48     return source_->SeekToPos(offset);
49 }
50 
SeekToTime(int64_t offset)51 Status Source::SeekToTime(int64_t offset)
52 {
53 	return source_->SeekToTime(offset);
54 }
55 
GetDuration(int64_t& duration)56 Status Source::GetDuration(int64_t& duration)
57 {
58     return source_->GetDuration(duration);
59 }
60 
GetBitRates(std::vector<uint32_t>& bitRates)61 Status Source::GetBitRates(std::vector<uint32_t>& bitRates)
62 {
63     return source_->GetBitRates(bitRates);
64 }
65 
SelectBitRate(uint32_t bitRate)66 Status Source::SelectBitRate(uint32_t bitRate)
67 {
68     return source_->SelectBitRate(bitRate);
69 }