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