1da853ecaSopenharmony_ci/*
2da853ecaSopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
3da853ecaSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4da853ecaSopenharmony_ci * you may not use this file except in compliance with the License.
5da853ecaSopenharmony_ci * You may obtain a copy of the License at
6da853ecaSopenharmony_ci *
7da853ecaSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8da853ecaSopenharmony_ci *
9da853ecaSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10da853ecaSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11da853ecaSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12da853ecaSopenharmony_ci * See the License for the specific language governing permissions and
13da853ecaSopenharmony_ci * limitations under the License.
14da853ecaSopenharmony_ci */
15da853ecaSopenharmony_ci
16da853ecaSopenharmony_ci#ifndef PLUGINS_CODEC_PLUGIN_H
17da853ecaSopenharmony_ci#define PLUGINS_CODEC_PLUGIN_H
18da853ecaSopenharmony_ci
19da853ecaSopenharmony_ci#include <vector>
20da853ecaSopenharmony_ci#include <memory>
21da853ecaSopenharmony_ci#include "meta/media_types.h"
22da853ecaSopenharmony_ci#include "buffer/avbuffer.h"
23da853ecaSopenharmony_ci#include "plugin/plugin_base.h"
24da853ecaSopenharmony_ci#include "plugin/plugin_event.h"
25da853ecaSopenharmony_ci#include "plugin/plugin_definition.h"
26da853ecaSopenharmony_ci#include "meta/meta.h"
27da853ecaSopenharmony_ci#include "common/status.h"
28da853ecaSopenharmony_ci
29da853ecaSopenharmony_cinamespace OHOS {
30da853ecaSopenharmony_cinamespace Media {
31da853ecaSopenharmony_cinamespace Plugins {
32da853ecaSopenharmony_ciclass DataCallback {
33da853ecaSopenharmony_cipublic:
34da853ecaSopenharmony_ci    virtual ~DataCallback() = default;
35da853ecaSopenharmony_ci
36da853ecaSopenharmony_ci    virtual void OnInputBufferDone(const std::shared_ptr<AVBuffer> &inputBuffer) = 0;
37da853ecaSopenharmony_ci
38da853ecaSopenharmony_ci    virtual void OnOutputBufferDone(const std::shared_ptr<AVBuffer> &outputBuffer) = 0;
39da853ecaSopenharmony_ci
40da853ecaSopenharmony_ci    virtual void OnEvent(const std::shared_ptr<Plugins::PluginEvent> event) = 0;
41da853ecaSopenharmony_ci};
42da853ecaSopenharmony_ci
43da853ecaSopenharmony_ciclass CodecPlugin : public Plugins::PluginBase {
44da853ecaSopenharmony_cipublic:
45da853ecaSopenharmony_ci    explicit CodecPlugin(std::string name) : PluginBase(std::move(name)) {}
46da853ecaSopenharmony_ci    virtual Status GetInputBuffers(std::vector<std::shared_ptr<AVBuffer>> &inputBuffers) = 0;
47da853ecaSopenharmony_ci
48da853ecaSopenharmony_ci    virtual Status GetOutputBuffers(std::vector<std::shared_ptr<AVBuffer>> &outputBuffers) = 0;
49da853ecaSopenharmony_ci
50da853ecaSopenharmony_ci    virtual Status QueueInputBuffer(const std::shared_ptr<AVBuffer> &inputBuffer) = 0;
51da853ecaSopenharmony_ci
52da853ecaSopenharmony_ci    virtual Status QueueOutputBuffer(std::shared_ptr<AVBuffer> &outputBuffer) = 0;
53da853ecaSopenharmony_ci
54da853ecaSopenharmony_ci    virtual Status SetParameter(const std::shared_ptr<Meta> &parameter) = 0;
55da853ecaSopenharmony_ci
56da853ecaSopenharmony_ci    virtual Status GetParameter(std::shared_ptr<Meta> &parameter) = 0;
57da853ecaSopenharmony_ci
58da853ecaSopenharmony_ci    virtual Status Start() = 0;
59da853ecaSopenharmony_ci
60da853ecaSopenharmony_ci    virtual Status Stop() = 0;
61da853ecaSopenharmony_ci
62da853ecaSopenharmony_ci    virtual Status Flush() = 0;
63da853ecaSopenharmony_ci
64da853ecaSopenharmony_ci    virtual Status Reset() = 0;
65da853ecaSopenharmony_ci
66da853ecaSopenharmony_ci    virtual Status Release() = 0;
67da853ecaSopenharmony_ci
68da853ecaSopenharmony_ci    virtual Status SetDataCallback(DataCallback *dataCallback) = 0;
69da853ecaSopenharmony_ci};
70da853ecaSopenharmony_ci
71da853ecaSopenharmony_ci/// Codec plugin api major number.
72da853ecaSopenharmony_ci#define CODEC_API_VERSION_MAJOR (1)
73da853ecaSopenharmony_ci
74da853ecaSopenharmony_ci/// Codec plugin api minor number
75da853ecaSopenharmony_ci#define CODEC_API_VERSION_MINOR (0)
76da853ecaSopenharmony_ci
77da853ecaSopenharmony_ci/// Codec plugin version
78da853ecaSopenharmony_ci#define CODEC_API_VERSION MAKE_VERSION(CODEC_API_VERSION_MAJOR, CODEC_API_VERSION_MINOR)
79da853ecaSopenharmony_ci
80da853ecaSopenharmony_ci/**
81da853ecaSopenharmony_ci * @brief Describes the codec plugin information.
82da853ecaSopenharmony_ci *
83da853ecaSopenharmony_ci * @since 1.0
84da853ecaSopenharmony_ci * @version 1.0
85da853ecaSopenharmony_ci */
86da853ecaSopenharmony_cistruct CodecPluginDef : public PluginDefBase {
87da853ecaSopenharmony_ci    CodecPluginDef()
88da853ecaSopenharmony_ci    {
89da853ecaSopenharmony_ci        apiVersion = CODEC_API_VERSION;         ///< Codec plugin version
90da853ecaSopenharmony_ci        pluginType = PluginType::AUDIO_DECODER; ///< Plugin type, MUST be AUDIO_DECODER.
91da853ecaSopenharmony_ci    }
92da853ecaSopenharmony_ci};
93da853ecaSopenharmony_ci} // namespace Plugins
94da853ecaSopenharmony_ci} // namespace Media
95da853ecaSopenharmony_ci} // namespace OHOS
96da853ecaSopenharmony_ci#endif // PLUGINS_MEDIA_CODEC_PLUGIN_H
97