• 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     virtual Seekable GetSeekable() = 0;
40 };
41 
42 struct DemuxerPlugin;
43 
44 class Demuxer : public Base {
45 public:
46     Demuxer(const Demuxer &) = delete;
47     Demuxer operator=(const Demuxer &) = delete;
48     ~Demuxer() override = default;
49 
50     Status SeekTo(int32_t trackId, int64_t hstTime, SeekMode mode);
51 
52     Status SetDataSource(const std::shared_ptr<DataSourceHelper> &source);
53 
54     Status GetMediaInfo(MediaInfoHelper &mediaInfo);
55 
56     Status ReadFrame(Buffer &info, int32_t timeOutMs);
57 
58 private:
59     friend class PluginManager;
60 
61     Demuxer(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr<DemuxerPlugin> plugin);
62 
63 private:
64     std::shared_ptr<DemuxerPlugin> demuxer_;
65 };
66 } // namespace Plugin
67 } // namespace Media
68 } // namespace OHOS
69 #endif // HISTREAMER_PLUGIN_CORE_DEMUXER_H
70