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 "UtDemuxerTest1.h"
17
18 using namespace OHOS::Media::Plugin;
19
Sniff(const std::string & name,std::shared_ptr<DataSource> dataSource)20 static int Sniff(const std::string& name, std::shared_ptr<DataSource> dataSource)
21 {
22 int bufferSize = 16;
23 auto bufData = Buffer::CreateDefaultBuffer(BufferMetaType::AUDIO, bufferSize);
24 if (dataSource->ReadAt(0, bufData, bufferSize) == Status::OK) {
25 const uint8_t* data = bufData->GetMemory()->GetReadOnlyData();
26 if (data[0] == 'U' && data[1] == 't') {
27 return 100; // 100
28 }
29 }
30 return 0;
31 }
32
RegisterPlugins(const std::shared_ptr<Register> & reg)33 static Status RegisterPlugins(const std::shared_ptr<Register>& reg)
34 {
35 DemuxerPluginDef regInfo;
36 regInfo.name = "UtDemuxerTest1";
37 regInfo.description = "unit test demuxer test1";
38 regInfo.rank = 100; // 100
39 regInfo.creator = [](const std::string& name) -> std::shared_ptr<DemuxerPlugin> {
40 return std::make_shared<UtDemuxerTest1>(name);
41 };
42 regInfo.sniffer = Sniff;
43 return reg->AddPlugin(regInfo);
44 }
45
__anon26050b9a0202null46 PLUGIN_DEFINITION(UtDemuxerTest1, LicenseType::LGPL, RegisterPlugins, [] {});
47
SetDataSource(const std::shared_ptr<DataSource> & source)48 Status UtDemuxerTest1::SetDataSource(const std::shared_ptr<DataSource> &source)
49 {
50 return Status::OK;
51 }
52
GetMediaInfo(MediaInfo & mediaInfo)53 Status UtDemuxerTest1::GetMediaInfo(MediaInfo &mediaInfo)
54 {
55 return Status::OK;
56 }
57
GetTrackCount()58 size_t UtDemuxerTest1::GetTrackCount()
59 {
60 return 0;
61 }
62
SelectTrack(int32_t trackId)63 Status UtDemuxerTest1::SelectTrack(int32_t trackId)
64 {
65 return Status::OK;
66 }
67
UnselectTrack(int32_t trackId)68 Status UtDemuxerTest1::UnselectTrack(int32_t trackId)
69 {
70 return Status::OK;
71 }
72
GetSelectedTracks(std::vector<int32_t> & trackIds)73 Status UtDemuxerTest1::GetSelectedTracks(std::vector<int32_t> &trackIds)
74 {
75 return Status::OK;
76 }
77
ReadFrame(Buffer & buffer,int32_t timeOutMs)78 Status UtDemuxerTest1::ReadFrame(Buffer &buffer, int32_t timeOutMs)
79 {
80 return Status::OK;
81 }
82
SeekTo(int32_t trackId,int64_t seekTime,SeekMode mode,int64_t & realSeekTime)83 Status UtDemuxerTest1::SeekTo(int32_t trackId, int64_t seekTime, SeekMode mode, int64_t& realSeekTime)
84 {
85 (void)trackId;
86 (void)seekTime;
87 (void)mode;
88 (void)realSeekTime;
89 return Status::OK;
90 }
91
GetAllocator()92 std::shared_ptr<Allocator> UtDemuxerTest1::GetAllocator()
93 {
94 return std::shared_ptr<Allocator>();
95 }
96
SetCallback(Callback * cb)97 Status UtDemuxerTest1::SetCallback(Callback* cb)
98 {
99 return Status::OK;
100 }
101
102