• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef HISTREAMER_PLUGIN_CORE_DEMUXER_H
17 #define HISTREAMER_PLUGIN_CORE_DEMUXER_H
18 
19 #include <memory>
20 
21 #include "base.h"
22 #include "common/plugin_buffer.h"
23 #include "core/plugin_meta.h"
24 
25 namespace OHOS {
26 namespace Media {
27 namespace Plugin {
28 using AllocatorHelper = Allocator;
29 
30 struct MediaInfoHelper {
31     Meta globalMeta;
32     std::vector<Meta> trackMeta;
33 };
34 
35 struct DataSourceHelper {
36     virtual ~DataSourceHelper() = default;
37     virtual Status ReadAt(int64_t offset, std::shared_ptr<Buffer> &buffer, size_t expectedLen) = 0;
38     virtual Status GetSize(size_t &size) = 0;
39 };
40 
41 struct DemuxerPlugin;
42 
43 class Demuxer : public Base {
44 public:
45     Demuxer(const Demuxer &) = delete;
46     Demuxer operator=(const Demuxer &) = delete;
47     ~Demuxer() override = default;
48 
49     Status SeekTo(int32_t trackId, int64_t hstTime, SeekMode mode);
50 
51     Status SetDataSource(const std::shared_ptr<DataSourceHelper> &source);
52 
53     Status GetMediaInfo(MediaInfoHelper &mediaInfo);
54 
55     Status ReadFrame(Buffer &info, int32_t timeOutMs);
56 
57 private:
58     friend class PluginManager;
59 
60     Demuxer(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr<DemuxerPlugin> plugin);
61 
62 private:
63     std::shared_ptr<DemuxerPlugin> demuxer_;
64 };
65 } // namespace Plugin
66 } // namespace Media
67 } // namespace OHOS
68 #endif // HISTREAMER_PLUGIN_CORE_DEMUXER_H
69