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_INTF_MUXER_PLUGIN_H 17 #define HISTREAMER_PLUGIN_INTF_MUXER_PLUGIN_H 18 19 #include "plugin/common/plugin_caps.h" 20 #include "plugin/interface/plugin_base.h" 21 #include "plugin/interface/plugin_definition.h" 22 23 namespace OHOS { 24 namespace Media { 25 namespace Plugin { 26 struct DataSink { 27 virtual ~DataSink() = default; 28 virtual Status WriteAt(int64_t offset, const std::shared_ptr<Buffer>& buffer) = 0; 29 }; 30 31 struct MuxerPlugin : public PluginBase { MuxerPluginMuxerPlugin32 explicit MuxerPlugin(std::string&& name) : PluginBase(std::move(name)) {} 33 virtual Status SetTrackParameter(uint32_t trackId, Plugin::Tag tag, const Plugin::ValueType& value) = 0; 34 virtual Status GetTrackParameter(uint32_t trackId, Plugin::Tag tag, Plugin::ValueType& value) = 0; 35 virtual Status AddTrack(uint32_t& trackId) = 0; 36 virtual Status SetDataSink(const std::shared_ptr<DataSink>& dataSink) = 0; 37 virtual Status WriteHeader() = 0; 38 virtual Status WriteFrame(const std::shared_ptr<Buffer>& buffer) = 0; 39 virtual Status WriteTrailer() = 0; 40 }; 41 42 /// Muxer plugin api major number. 43 #define MUXER_API_VERSION_MAJOR (1) 44 45 /// Muxer plugin api minor number 46 #define MUXER_API_VERSION_MINOR (0) 47 48 /// Muxer plugin version 49 #define MUXER_API_VERSION MAKE_VERSION(MUXER_API_VERSION_MAJOR, MUXER_API_VERSION_MINOR) 50 51 52 struct MuxerPluginDef : public PluginDefBase { 53 CapabilitySet inCaps; ///< Plug-in input capability, For details, @see Capability. 54 CapabilitySet outCaps; ///< Plug-in output capability, For details, @see Capability. 55 PluginCreatorFunc<MuxerPlugin> creator {nullptr}; ///< Muxer plugin create function. MuxerPluginDefMuxerPluginDef56 MuxerPluginDef() 57 { 58 apiVersion = MUXER_API_VERSION; ///< Muxer plugin version. 59 pluginType = PluginType::MUXER; ///< Plugin type, MUST be MUXER. 60 } 61 }; 62 } // Plugin 63 } // Media 64 } // OHOS 65 #endif // HISTREAMER_PLUGIN_INTF_MUXER_PLUGIN_H 66