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