• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 PLUGIN_INTF_MUXER_PLUGIN_H
17 #define PLUGIN_INTF_MUXER_PLUGIN_H
18 
19 #include "media_description.h"
20 #include "av_common.h"
21 #include "avcodec_common.h"
22 #include "plugin_base.h"
23 #include "plugin_definition.h"
24 
25 namespace OHOS {
26 namespace MediaAVCodec {
27 namespace Plugin {
28 struct MuxerPlugin : public PluginBase {
MuxerPluginMuxerPlugin29     explicit MuxerPlugin(std::string &&name) : PluginBase(std::move(name)) {}
30     virtual Status SetRotation(int32_t rotation) = 0;
31     virtual Status AddTrack(int32_t &trackIndex, const MediaDescription &trackDesc) = 0;
32     virtual Status Start() = 0;
33     virtual Status WriteSample(uint32_t trackIndex, const uint8_t *sample,
34         AVCodecBufferInfo info, AVCodecBufferFlag flag) = 0;
35     virtual Status Stop() = 0;
SetCallbackMuxerPlugin36     Status SetCallback(Callback* cb)
37     {
38         (void)cb;
39         return Status::ERROR_UNIMPLEMENTED;
40     }
41 };
42 
43 /// Muxer plugin api major number.
44 #define MUXER_API_VERSION_MAJOR (1)
45 
46 /// Muxer plugin api minor number
47 #define MUXER_API_VERSION_MINOR (0)
48 
49 /// Muxer plugin version
50 #define MUXER_API_VERSION MAKE_VERSION(MUXER_API_VERSION_MAJOR, MUXER_API_VERSION_MINOR)
51 
52 /// Muxer create function
53 using MuxerPluginCreatorFunc = std::shared_ptr<MuxerPlugin>(*)(const std::string& name, int32_t fd);
54 /// Muxer sniff function
55 using MuxerPluginSnifferFunc = int32_t (*)(const std::string& name, uint32_t outputFormat);
56 
57 struct MuxerPluginDef : public PluginDefBase {
58     MuxerPluginCreatorFunc creator {nullptr}; ///< Muxer plugin create function.
59     MuxerPluginSnifferFunc sniffer {nullptr}; ///< Muxer plugin sniff function.
MuxerPluginDefMuxerPluginDef60     MuxerPluginDef()
61     {
62         apiVersion = MUXER_API_VERSION; ///< Muxer plugin version.
63         pluginType = PluginType::MUXER; ///< Plugin type, MUST be MUXER.
64     }
65 };
66 } // Plugin
67 } // MediaAVCodec
68 } // OHOS
69 #endif // PLUGIN_INTF_MUXER_PLUGIN_H
70