• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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_MEDIA_SERVICE_H
17 #define I_MEDIA_SERVICE_H
18 
19 #include <memory>
20 #ifdef SUPPORT_RECORDER
21 #include "i_recorder_service.h"
22 #include "i_recorder_profiles_service.h"
23 #endif
24 #ifdef SUPPORT_PLAYER
25 #include "i_player_service.h"
26 #endif
27 #ifdef SUPPORT_METADATA
28 #include "i_avmetadatahelper_service.h"
29 #endif
30 #ifdef SUPPORT_CODEC
31 #include "i_avcodec_service.h"
32 #include "i_avcodeclist_service.h"
33 #endif
34 #ifdef SUPPORT_MUXER
35 #include "i_avmuxer_service.h"
36 #endif
37 
38 namespace OHOS {
39 namespace Media {
40 class IMediaService {
41 public:
42     virtual ~IMediaService() = default;
43 
44 #ifdef SUPPORT_RECORDER
45     /**
46      * @brief Create a recorder service.
47      *
48      * All recorder functions must be created and obtained first.
49      *
50      * @return Returns a valid pointer if the setting is successful;
51      * @since 1.0
52      * @version 1.0
53      */
54     virtual std::shared_ptr<IRecorderService> CreateRecorderService() = 0;
55 
56     /**
57      * @brief Destroy a recorder service.
58      *
59      * call the API to destroy the recorder service.
60      *
61      * @param pointer to the recorder service.
62      * @return Returns a valid pointer if the setting is successful;
63      * @since 1.0
64      * @version 1.0
65      */
66     virtual int32_t DestroyRecorderService(std::shared_ptr<IRecorderService> recorder) = 0;
67 
68     /**
69      * @brief Create a mediaprofile service.
70      *
71      * All player functions must be created and obtained first.
72      *
73      * @return Returns a valid pointer if the setting is successful;
74      * @since 3.2
75      * @version 3.2
76      */
77     virtual std::shared_ptr<IRecorderProfilesService> CreateRecorderProfilesService() = 0;
78 
79     /**
80      * @brief Destroy a mediaprofile service.
81      *
82      * call the API to destroy the mediaprofile service.
83      *
84      * @param pointer to the mediaprofile service.
85      * @return Returns a valid pointer if the setting is successful;
86      * @since 3.2
87      * @version 3.2
88      */
89     virtual int32_t DestroyMediaProfileService(std::shared_ptr<IRecorderProfilesService> recorderProfiles) = 0;
90 #endif
91 
92 #ifdef SUPPORT_PLAYER
93     /**
94      * @brief Create a player service.
95      *
96      * All player functions must be created and obtained first.
97      *
98      * @return Returns a valid pointer if the setting is successful;
99      * @since 1.0
100      * @version 1.0
101      */
102     virtual std::shared_ptr<IPlayerService> CreatePlayerService() = 0;
103 
104     /**
105      * @brief Destroy a player service.
106      *
107      * call the API to destroy the player service.
108      *
109      * @param pointer to the player service.
110      * @return Returns a valid pointer if the setting is successful;
111      * @since 1.0
112      * @version 1.0
113      */
114     virtual int32_t DestroyPlayerService(std::shared_ptr<IPlayerService> player) = 0;
115 #endif
116 
117 #ifdef SUPPORT_CODEC
118     /**
119      * @brief Create a codeclist service.
120      *
121      * All player functions must be created and obtained first.
122      *
123      * @return Returns a valid pointer if the setting is successful;
124      * @since 1.0
125      * @version 1.0
126      */
127     virtual std::shared_ptr<IAVCodecListService> CreateAVCodecListService() = 0;
128 
129     /**
130      * @brief Destroy a codeclist service.
131      *
132      * call the API to destroy the codeclist service.
133      *
134      * @param pointer to the codeclist service.
135      * @return Returns a valid pointer if the setting is successful;
136      * @since 3.1
137      * @version 3.1
138      */
139     virtual int32_t DestroyAVCodecListService(std::shared_ptr<IAVCodecListService> avCodecList) = 0;
140 
141     /**
142      * @brief Create an avcodec service.
143      *
144      * All player functions must be created and obtained first.
145      *
146      * @return Returns a valid pointer if the setting is successful;
147      * @since 3.1
148      * @version 3.1
149      */
150     virtual std::shared_ptr<IAVCodecService> CreateAVCodecService() = 0;
151 
152     /**
153      * @brief Destroy a avcodec service.
154      *
155      * call the API to destroy the avcodec service.
156      *
157      * @param pointer to the avcodec service.
158      * @return Returns a valid pointer if the setting is successful;
159      * @since 3.1
160      * @version 3.1
161      */
162     virtual int32_t DestroyAVCodecService(std::shared_ptr<IAVCodecService> avCodec) = 0;
163 #endif
164 
165 #ifdef SUPPORT_METADATA
166     /**
167      * @brief Create an avmetadatahelper service.
168      *
169      * All player functions must be created and obtained first.
170      *
171      * @return Returns a valid pointer if the setting is successful;
172      * @since 1.0
173      * @version 1.0
174      */
175     virtual std::shared_ptr<IAVMetadataHelperService> CreateAVMetadataHelperService() = 0;
176 
177     /**
178      * @brief Destroy a avmetadatahelper service.
179      *
180      * call the API to destroy the avmetadatahelper service.
181      *
182      * @param pointer to the avmetadatahelper service.
183      * @return Returns a valid pointer if the setting is successful;
184      * @since 1.0
185      * @version 1.0
186      */
187     virtual int32_t DestroyAVMetadataHelperService(std::shared_ptr<IAVMetadataHelperService> avMetadataHelper) = 0;
188 #endif
189 
190 #ifdef SUPPORT_MUXER
191     /**
192      * @brief Create an avmuxer service.
193      *
194      * All avmuxer functions must be created and obtained first.
195      *
196      * @return Returns a valid pointer if the setting is successful;
197      * @since 3.2
198      * @version 3.2
199      */
200     virtual std::shared_ptr<IAVMuxerService> CreateAVMuxerService() = 0;
201 
202     /**
203      * @brief Destroy a avmuxer service.
204      *
205      * call the API to destroy the avmuxer service.
206      *
207      * @param pointer to the avmuxer service.
208      * @return Returns a valid pointer if the setting is successful;
209      * @since 3.2
210      * @version 3.2
211      */
212     virtual int32_t DestroyAVMuxerService(std::shared_ptr<IAVMuxerService> avmuxer) = 0;
213 #endif
214 };
215 
216 class __attribute__((visibility("default"))) MediaServiceFactory {
217 public:
218     /**
219      * @brief IMediaService singleton
220      *
221      * Create Recorder Service and Player Service Through the Media Service.
222      *
223      * @return Returns IMediaService singleton;
224      * @since 1.0
225      * @version 1.0
226      */
227     static IMediaService &GetInstance();
228 private:
229     MediaServiceFactory() = delete;
230     ~MediaServiceFactory() = delete;
231 };
232 } // namespace Media
233 } // namespace OHOS
234 #endif // I_MEDIA_SERVICE_H
235