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