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_OUTPUT_SINK_PLUGIN_H 17 #define HISTREAMER_PLUGIN_INTF_OUTPUT_SINK_PLUGIN_H 18 19 #include "foundation/pre_defines.h" 20 #include "plugin/common/media_sink.h" 21 #include "plugin/common/plugin_caps.h" 22 #include "plugin/common/plugin_tags.h" 23 #include "plugin/interface/plugin_base.h" 24 #include "plugin/interface/plugin_definition.h" 25 26 namespace OHOS { 27 namespace Media { 28 namespace Plugin { 29 struct OutputSinkPlugin : public Plugin::PluginBase { OutputSinkPluginOutputSinkPlugin30 explicit OutputSinkPlugin(std::string name): PluginBase(std::move(name)) {} GetAllocatorOutputSinkPlugin31 std::shared_ptr<Allocator> GetAllocator() override 32 { 33 return nullptr; 34 } SetCallbackOutputSinkPlugin35 Status SetCallback(Callback* cb) override 36 { 37 UNUSED_VARIABLE(cb); 38 return Status::ERROR_UNIMPLEMENTED; 39 } 40 virtual Status SetSink(const MediaSink& sink) = 0; 41 virtual Seekable GetSeekable() = 0; 42 virtual Status SeekTo(uint64_t offset) = 0; 43 virtual Status Write(const std::shared_ptr<Buffer>& buffer) = 0; 44 virtual Status Flush() = 0; 45 }; 46 47 /// Output Sink plugin api major number. 48 #define OUTPUT_SINK_API_VERSION_MAJOR (1) 49 50 /// Output Sink plugin api minor number 51 #define OUTPUT_SINK_API_VERSION_MINOR (0) 52 53 /// Output Sink plugin version 54 #define OUTPUT_SINK_API_VERSION MAKE_VERSION(OUTPUT_SINK_API_VERSION_MAJOR, OUTPUT_SINK_API_VERSION_MINOR) 55 56 struct OutputSinkPluginDef : public PluginDefBase { 57 ProtocolType protocolType; 58 CapabilitySet inCaps; 59 PluginCreatorFunc<OutputSinkPlugin> creator {nullptr}; ///< Output sink plugin create function. OutputSinkPluginDefOutputSinkPluginDef60 OutputSinkPluginDef() 61 { 62 apiVersion = OUTPUT_SINK_API_VERSION; ///< Output sink plugin version. 63 pluginType = PluginType::OUTPUT_SINK; ///< Plugin type, MUST be OUTPUT_SINK. 64 inCaps.emplace_back(Capability("*")); ///< Output sink sink can accept any data 65 } 66 }; 67 } // Plugin 68 } // Media 69 } // OHOS 70 #endif // HISTREAMER_PLUGIN_INTF_OUTPUT_SINK_PLUGIN_H 71