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 "demuxer.h"
17 #include "interface/demuxer_plugin.h"
18 #include "interface/plugin_definition.h"
19
20 #include "plugin_wrapper.h"
21
22 using namespace OHOS::Media::Plugin;
23
Demuxer(uint32_t pkgVer,uint32_t apiVer,std::shared_ptr<DemuxerPlugin> plugin)24 Demuxer::Demuxer(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr<DemuxerPlugin> plugin)
25 : Base(pkgVer, apiVer, plugin), demuxer_(std::move(plugin))
26 {
27 }
28
SeekTo(int32_t trackId,int64_t hstTime,SeekMode mode)29 Status Demuxer::SeekTo(int32_t trackId, int64_t hstTime, SeekMode mode)
30 {
31 return demuxer_->SeekTo(trackId, hstTime, mode);
32 }
33
SetDataSource(const std::shared_ptr<DataSourceHelper> & source)34 Status Demuxer::SetDataSource(const std::shared_ptr<DataSourceHelper>& source)
35 {
36 return demuxer_->SetDataSource(std::make_shared<DataSourceWrapper>(pkgVersion_, source));
37 }
38
GetMediaInfo(MediaInfoHelper & mediaInfo)39 Status Demuxer::GetMediaInfo(MediaInfoHelper& mediaInfo)
40 {
41 MediaInfo info;
42 demuxer_->GetMediaInfo(info);
43 ConvertToMediaInfoHelper(pkgVersion_, info, mediaInfo);
44 return Status::OK;
45 }
46
ReadFrame(Buffer & info,int32_t timeOutMs)47 Status Demuxer::ReadFrame(Buffer& info, int32_t timeOutMs)
48 {
49 return demuxer_->ReadFrame(info, timeOutMs);
50 }
51