1 /* 2 * Copyright (C) 2023 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 #ifndef DEDEMUXER_PLUGIN_H 16 #define DEDEMUXER_PLUGIN_H 17 18 #include <string> 19 #include "avcodec_common.h" 20 #include "plugin_base.h" 21 #include "plugin_definition.h" 22 #include "avsharedmemory.h" 23 24 namespace OHOS { 25 namespace MediaAVCodec { 26 namespace Plugin { 27 struct DemuxerPlugin : public PluginBase { DemuxerPluginDemuxerPlugin28 explicit DemuxerPlugin() : PluginBase("Demuxer") {} 29 virtual int32_t Create(uintptr_t sourceAddr) = 0; 30 virtual int32_t SelectTrackByID(uint32_t index) = 0; 31 virtual int32_t UnselectTrackByID(uint32_t index) = 0; 32 virtual int32_t ReadSample(uint32_t trackIndex, std::shared_ptr<AVSharedMemory> sample, 33 AVCodecBufferInfo &info, AVCodecBufferFlag &flag) = 0; 34 virtual int32_t SeekToTime(int64_t millisecond, AVSeekMode mode) = 0; SetCallbackDemuxerPlugin35 Status SetCallback(Callback* cb) 36 { 37 (void)cb; 38 return Status::ERROR_UNIMPLEMENTED; 39 }; 40 }; 41 42 /// Demuxer plugin api major number. 43 #define DEMUXER_API_VERSION_MAJOR (1) 44 45 /// Demuxer plugin api minor number 46 #define DEMUXER_API_VERSION_MINOR (0) 47 48 /// Demuxer plugin version 49 #define DEMUXER_API_VERSION MAKE_VERSION(DEMUXER_API_VERSION_MAJOR, DEMUXER_API_VERSION_MINOR) 50 51 /// Demuxer create function 52 using DemuxerPluginCreatorFunc = std::shared_ptr<DemuxerPlugin>(*)(); 53 /// Demuxer sniff function 54 using DemuxerPluginSnifferFunc = int32_t (*)(const std::string& name); 55 56 struct DemuxerPluginDef : public PluginDefBase { 57 DemuxerPluginCreatorFunc creator {nullptr}; ///< Demuxer plugin create function. 58 DemuxerPluginSnifferFunc sniffer {nullptr}; ///< Demuxer plugin sniff function. DemuxerPluginDefDemuxerPluginDef59 DemuxerPluginDef() 60 { 61 apiVersion = DEMUXER_API_VERSION; ///< Demuxer plugin version. 62 pluginType = PluginType::DEMUXER; ///< Plugin type, MUST be DEMUXER. 63 } 64 }; 65 } // namepsace Plugin 66 } // namespace MediaAVCodec 67 } // namespace OHOS 68 #endif // DEDEMUXER_PLUGIN_H