• 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_INTF_OUTPUT_SINK_PLUGIN_H
17 #define HISTREAMER_PLUGIN_INTF_OUTPUT_SINK_PLUGIN_H
18 
19 #include "plugin_base.h"
20 #include "plugin_definition.h"
21 #include "plugin/common/plugin_caps.h"
22 #include "utils/utils.h"
23 
24 namespace OHOS {
25 namespace Media {
26 namespace Plugin {
27 struct OutputSinkPlugin : public Plugin::PluginBase {
OutputSinkPluginOutputSinkPlugin28     explicit OutputSinkPlugin(std::string name): PluginBase(std::move(name)) {}
GetAllocatorOutputSinkPlugin29     std::shared_ptr<Allocator> GetAllocator() override
30     {
31         return nullptr;
32     }
SetCallbackOutputSinkPlugin33     Status SetCallback(Callback* cb) override
34     {
35         UNUSED_VARIABLE(cb);
36         return Status::ERROR_UNIMPLEMENTED;
37     }
38     virtual Status SetSink(const Plugin::ValueType& sink) = 0;
39     virtual bool IsSeekable() = 0;
40     virtual Status SeekTo(uint64_t offset) = 0;
41     virtual Status Write(const std::shared_ptr<Buffer>& buffer) = 0;
42     virtual Status Flush() = 0;
43 };
44 
45 /// Output Sink plugin api major number.
46 #define OUTPUT_SINK_API_VERSION_MAJOR (1)
47 
48 /// Output Sink plugin api minor number
49 #define OUTPUT_SINK_API_VERSION_MINOR (0)
50 
51 /// Output Sink plugin version
52 #define OUTPUT_SINK_API_VERSION MAKE_VERSION(OUTPUT_SINK_API_VERSION_MAJOR, OUTPUT_SINK_API_VERSION_MINOR)
53 
54 enum struct OutputType {
55     UNKNOWN = -1,
56     URI, ///< sink type is uri, sink value is std::string
57     FD, ///< sink type is fd, sink value is int32_t
58 };
59 
60 struct OutputSinkPluginDef : public PluginDefBase {
61     OutputType outputType;
62     CapabilitySet inCaps;
63     PluginCreatorFunc<OutputSinkPlugin> creator {nullptr}; ///< Output sink plugin create function.
OutputSinkPluginDefOutputSinkPluginDef64     OutputSinkPluginDef()
65     {
66         apiVersion = OUTPUT_SINK_API_VERSION; ///< Output sink plugin version.
67         pluginType = PluginType::OUTPUT_SINK; ///< Plugin type, MUST be OUTPUT_SINK.
68         inCaps.emplace_back(Capability("*")); ///< Output sink sink can accept any data
69     }
70 };
71 } // Plugin
72 } // Media
73 } // OHOS
74 #endif // HISTREAMER_PLUGIN_INTF_OUTPUT_SINK_PLUGIN_H
75