1da853ecaSopenharmony_ci/*
2da853ecaSopenharmony_ci * Copyright (C) 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 I_AVCODEC_SERVICE_H
17da853ecaSopenharmony_ci#define I_AVCODEC_SERVICE_H
18da853ecaSopenharmony_ci
19da853ecaSopenharmony_ci#include <memory>
20da853ecaSopenharmony_ci
21da853ecaSopenharmony_ci#ifdef SUPPORT_CODEC
22da853ecaSopenharmony_ci#include "i_codec_service.h"
23da853ecaSopenharmony_ci#endif
24da853ecaSopenharmony_ci
25da853ecaSopenharmony_ci#ifdef SUPPORT_CODECLIST
26da853ecaSopenharmony_ci#include "i_codeclist_service.h"
27da853ecaSopenharmony_ci#endif
28da853ecaSopenharmony_ci
29da853ecaSopenharmony_cinamespace OHOS {
30da853ecaSopenharmony_cinamespace MediaAVCodec {
31da853ecaSopenharmony_ciclass IAVCodecService {
32da853ecaSopenharmony_cipublic:
33da853ecaSopenharmony_ci    virtual ~IAVCodecService() = default;
34da853ecaSopenharmony_ci
35da853ecaSopenharmony_ci#ifdef SUPPORT_CODECLIST
36da853ecaSopenharmony_ci    /**
37da853ecaSopenharmony_ci     * @brief Create a codeclist service.
38da853ecaSopenharmony_ci     *
39da853ecaSopenharmony_ci     * All player functions must be created and obtained first.
40da853ecaSopenharmony_ci     *
41da853ecaSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
42da853ecaSopenharmony_ci     * @since 4.0
43da853ecaSopenharmony_ci     * @version 4.0
44da853ecaSopenharmony_ci     */
45da853ecaSopenharmony_ci    virtual std::shared_ptr<ICodecListService> CreateCodecListService() = 0;
46da853ecaSopenharmony_ci
47da853ecaSopenharmony_ci    /**
48da853ecaSopenharmony_ci     * @brief Destroy a codeclist service.
49da853ecaSopenharmony_ci     *
50da853ecaSopenharmony_ci     * call the API to destroy the codeclist service.
51da853ecaSopenharmony_ci     *
52da853ecaSopenharmony_ci     * @param pointer to the codeclist service.
53da853ecaSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
54da853ecaSopenharmony_ci     * @since 4.0
55da853ecaSopenharmony_ci     * @version 4.0
56da853ecaSopenharmony_ci     */
57da853ecaSopenharmony_ci    virtual int32_t DestroyCodecListService(std::shared_ptr<ICodecListService> avCodecList) = 0;
58da853ecaSopenharmony_ci#endif
59da853ecaSopenharmony_ci
60da853ecaSopenharmony_ci#ifdef SUPPORT_CODEC
61da853ecaSopenharmony_ci    /**
62da853ecaSopenharmony_ci     * @brief Create an avcodec service.
63da853ecaSopenharmony_ci     *
64da853ecaSopenharmony_ci     * All player functions must be created and obtained first.
65da853ecaSopenharmony_ci     *
66da853ecaSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
67da853ecaSopenharmony_ci     * @since 5.0
68da853ecaSopenharmony_ci     * @version 5.0
69da853ecaSopenharmony_ci     */
70da853ecaSopenharmony_ci    virtual int32_t CreateCodecService(std::shared_ptr<ICodecService> &codecClient) = 0;
71da853ecaSopenharmony_ci
72da853ecaSopenharmony_ci    /**
73da853ecaSopenharmony_ci     * @brief Destroy a avcodec service.
74da853ecaSopenharmony_ci     *
75da853ecaSopenharmony_ci     * call the API to destroy the avcodec service.
76da853ecaSopenharmony_ci     *
77da853ecaSopenharmony_ci     * @param pointer to the avcodec service.
78da853ecaSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
79da853ecaSopenharmony_ci     * @since 4.0
80da853ecaSopenharmony_ci     * @version 4.0
81da853ecaSopenharmony_ci     */
82da853ecaSopenharmony_ci    virtual int32_t DestroyCodecService(std::shared_ptr<ICodecService> codec) = 0;
83da853ecaSopenharmony_ci#endif
84da853ecaSopenharmony_ci};
85da853ecaSopenharmony_ciclass __attribute__((visibility("default"))) AVCodecServiceFactory {
86da853ecaSopenharmony_cipublic:
87da853ecaSopenharmony_ci    /**
88da853ecaSopenharmony_ci     * @brief IAVCodecService singleton
89da853ecaSopenharmony_ci     *
90da853ecaSopenharmony_ci     * Create Muxer and Demuxer Service Through the AVCodec Service.
91da853ecaSopenharmony_ci     *
92da853ecaSopenharmony_ci     * @return Returns IAVCodecService singleton;
93da853ecaSopenharmony_ci     * @since 4.0
94da853ecaSopenharmony_ci     * @version 4.0
95da853ecaSopenharmony_ci     */
96da853ecaSopenharmony_ci    static IAVCodecService &GetInstance();
97da853ecaSopenharmony_ciprivate:
98da853ecaSopenharmony_ci    AVCodecServiceFactory() = delete;
99da853ecaSopenharmony_ci    ~AVCodecServiceFactory() = delete;
100da853ecaSopenharmony_ci};
101da853ecaSopenharmony_ci} // namespace MediaAVCodec
102da853ecaSopenharmony_ci} // namespace OHOS
103da853ecaSopenharmony_ci#endif // I_AVCODEC_SERVICE_H
104