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 
16 #ifndef AVCODEC_MUXER_PLUGIN_H
17 #define AVCODEC_MUXER_PLUGIN_H
18 
19 #include "plugin/plugin_definition.h"
20 #include "data_sink.h"
21 #include "meta/meta.h"
22 #include "buffer/avbuffer.h"
23 
24 namespace OHOS {
25 namespace Media {
26 namespace Plugins {
27 class MuxerPlugin : public PluginBase {
28 public:
MuxerPlugin(std::string && name)29     explicit MuxerPlugin(std::string &&name) : PluginBase(std::move(name)) {}
30     virtual Status SetDataSink(const std::shared_ptr<DataSink> &dataSink) = 0;
31     virtual Status SetParameter(const std::shared_ptr<Meta> &param) = 0;
SetUserMeta(const std::shared_ptr<Meta> & userMeta)32     virtual Status SetUserMeta(const std::shared_ptr<Meta> &userMeta) { return Status::ERROR_INVALID_PARAMETER; }
33     virtual Status AddTrack(int32_t &trackIndex, const std::shared_ptr<Meta> &trackDesc) = 0;
34     virtual Status Start() = 0;
35     virtual Status WriteSample(uint32_t trackIndex, const std::shared_ptr<AVBuffer> &sample) = 0;
36     virtual Status Stop() = 0;
37     virtual Status Reset() = 0;
38 };
39 
40 /// Muxer plugin api major number.
41 #define MUXER_API_VERSION_MAJOR (1)
42 
43 /// Muxer plugin api minor number
44 #define MUXER_API_VERSION_MINOR (0)
45 
46 /// Muxer plugin version
47 #define MUXER_API_VERSION MAKE_VERSION(MUXER_API_VERSION_MAJOR, MUXER_API_VERSION_MINOR)
48 
49 
50 struct MuxerPluginDef : public PluginDefBase {
MuxerPluginDefMuxerPluginDef51     MuxerPluginDef() : PluginDefBase()
52     {
53         apiVersion = MUXER_API_VERSION; ///< Muxer plugin version.
54         pluginType = PluginType::MUXER; ///< Plugin type, MUST be MUXER.
55     }
56 };
57 } // namespace Plugins
58 } // namespace Media
59 } // namespace OHOS
60 #endif // AVCODEC_MUXER_PLUGIN_H