• 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 I_AVCODEC_SERVICE_H
17 #define I_AVCODEC_SERVICE_H
18 
19 #include <memory>
20 #include <vector>
21 
22 #ifdef SUPPORT_CODEC
23 #include "i_codec_service.h"
24 #endif
25 
26 #ifdef SUPPORT_CODECLIST
27 #include "i_codeclist_service.h"
28 #endif
29 
30 namespace OHOS {
31 namespace MediaAVCodec {
32 class IAVCodecService {
33 public:
34     virtual ~IAVCodecService() = default;
35 
36     /**
37     * @brief Get freeze status message from suspend manager.
38     *
39     * @param pidList The list of pid to be frozen.
40     * @return Returns {@link AVCS_ERR_OK} if success; returns an error code otherwise.
41     * @since 5.1
42     */
43     virtual int32_t SuspendFreeze(const std::vector<pid_t> &pidList) = 0;
44 
45     /**
46         * @brief Get active status message from suspend manager.
47         *
48         * @param pidList The list of pid to be active.
49         * @return Returns {@link AVCS_ERR_OK} if success; returns an error code otherwise.
50         * @since 5.1
51         */
52     virtual int32_t SuspendActive(const std::vector<pid_t> &pidList) = 0;
53 
54     /**
55         * @brief Reset all frozen pids into active state.
56         *
57         * @return Returns {@link AVCS_ERR_OK} if success; returns an error code otherwise.
58         * @since 5.1
59         */
60     virtual int32_t SuspendActiveAll() = 0;
61 
62 #ifdef SUPPORT_CODECLIST
63     /**
64      * @brief Create a codeclist service.
65      *
66      * All player functions must be created and obtained first.
67      *
68      * @return Returns a valid pointer if the setting is successful;
69      * @since 4.0
70      * @version 4.0
71      */
72     virtual std::shared_ptr<ICodecListService> CreateCodecListService() = 0;
73 
74     /**
75      * @brief Destroy a codeclist service.
76      *
77      * call the API to destroy the codeclist service.
78      *
79      * @param pointer to the codeclist service.
80      * @return Returns a valid pointer if the setting is successful;
81      * @since 4.0
82      * @version 4.0
83      */
84     virtual int32_t DestroyCodecListService(std::shared_ptr<ICodecListService> avCodecList) = 0;
85 #endif
86 
87 #ifdef SUPPORT_CODEC
88     /**
89      * @brief Create an avcodec service.
90      *
91      * All player functions must be created and obtained first.
92      *
93      * @return Returns a valid pointer if the setting is successful;
94      * @since 5.0
95      * @version 5.0
96      */
97     virtual int32_t CreateCodecService(std::shared_ptr<ICodecService> &codecClient) = 0;
98 
99     /**
100      * @brief Destroy a avcodec service.
101      *
102      * call the API to destroy the avcodec service.
103      *
104      * @param pointer to the avcodec service.
105      * @return Returns a valid pointer if the setting is successful;
106      * @since 4.0
107      * @version 4.0
108      */
109     virtual int32_t DestroyCodecService(std::shared_ptr<ICodecService> codec) = 0;
110 #endif
111 };
112 class __attribute__((visibility("default"))) AVCodecServiceFactory {
113 public:
114     /**
115      * @brief IAVCodecService singleton
116      *
117      * Create Muxer and Demuxer Service Through the AVCodec Service.
118      *
119      * @return Returns IAVCodecService singleton;
120      * @since 4.0
121      * @version 4.0
122      */
123     static IAVCodecService &GetInstance();
124 private:
125     AVCodecServiceFactory() = delete;
126     ~AVCodecServiceFactory() = delete;
127 };
128 } // namespace MediaAVCodec
129 } // namespace OHOS
130 #endif // I_AVCODEC_SERVICE_H
131