1049e185fSopenharmony_ci/*
2049e185fSopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
3049e185fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4049e185fSopenharmony_ci * you may not use this file except in compliance with the License.
5049e185fSopenharmony_ci * You may obtain a copy of the License at
6049e185fSopenharmony_ci *
7049e185fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8049e185fSopenharmony_ci *
9049e185fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10049e185fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11049e185fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12049e185fSopenharmony_ci * See the License for the specific language governing permissions and
13049e185fSopenharmony_ci * limitations under the License.
14049e185fSopenharmony_ci */
15049e185fSopenharmony_ci
16049e185fSopenharmony_ci#ifndef I_MEDIA_SERVICE_H
17049e185fSopenharmony_ci#define I_MEDIA_SERVICE_H
18049e185fSopenharmony_ci
19049e185fSopenharmony_ci#include <memory>
20049e185fSopenharmony_ci#ifdef SUPPORT_RECORDER
21049e185fSopenharmony_ci#include "i_recorder_service.h"
22049e185fSopenharmony_ci#include "i_recorder_profiles_service.h"
23049e185fSopenharmony_ci#endif
24049e185fSopenharmony_ci#ifdef SUPPORT_TRANSCODER
25049e185fSopenharmony_ci#include "i_transcoder_service.h"
26049e185fSopenharmony_ci#endif
27049e185fSopenharmony_ci#ifdef SUPPORT_PLAYER
28049e185fSopenharmony_ci#include "i_player_service.h"
29049e185fSopenharmony_ci#endif
30049e185fSopenharmony_ci#ifdef SUPPORT_METADATA
31049e185fSopenharmony_ci#include "i_avmetadatahelper_service.h"
32049e185fSopenharmony_ci#endif
33049e185fSopenharmony_ci#ifdef SUPPORT_SCREEN_CAPTURE
34049e185fSopenharmony_ci#include "i_screen_capture_service.h"
35049e185fSopenharmony_ci#include "i_screen_capture_monitor_service.h"
36049e185fSopenharmony_ci#include "i_screen_capture_controller.h"
37049e185fSopenharmony_ci#endif
38049e185fSopenharmony_ci#include "i_standard_monitor_service.h"
39049e185fSopenharmony_ci
40049e185fSopenharmony_cinamespace OHOS {
41049e185fSopenharmony_cinamespace Media {
42049e185fSopenharmony_ciclass IMediaService {
43049e185fSopenharmony_cipublic:
44049e185fSopenharmony_ci    virtual ~IMediaService() = default;
45049e185fSopenharmony_ci
46049e185fSopenharmony_ci#ifdef SUPPORT_RECORDER
47049e185fSopenharmony_ci    /**
48049e185fSopenharmony_ci     * @brief Create a recorder service.
49049e185fSopenharmony_ci     *
50049e185fSopenharmony_ci     * All recorder functions must be created and obtained first.
51049e185fSopenharmony_ci     *
52049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
53049e185fSopenharmony_ci     * @since 1.0
54049e185fSopenharmony_ci     * @version 1.0
55049e185fSopenharmony_ci     */
56049e185fSopenharmony_ci    virtual std::shared_ptr<IRecorderService> CreateRecorderService() = 0;
57049e185fSopenharmony_ci
58049e185fSopenharmony_ci    /**
59049e185fSopenharmony_ci     * @brief Destroy a recorder service.
60049e185fSopenharmony_ci     *
61049e185fSopenharmony_ci     * call the API to destroy the recorder service.
62049e185fSopenharmony_ci     *
63049e185fSopenharmony_ci     * @param pointer to the recorder service.
64049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
65049e185fSopenharmony_ci     * @since 1.0
66049e185fSopenharmony_ci     * @version 1.0
67049e185fSopenharmony_ci     */
68049e185fSopenharmony_ci    virtual int32_t DestroyRecorderService(std::shared_ptr<IRecorderService> recorder) = 0;
69049e185fSopenharmony_ci
70049e185fSopenharmony_ci    /**
71049e185fSopenharmony_ci     * @brief Create a mediaprofile service.
72049e185fSopenharmony_ci     *
73049e185fSopenharmony_ci     * All player functions must be created and obtained first.
74049e185fSopenharmony_ci     *
75049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
76049e185fSopenharmony_ci     * @since 3.2
77049e185fSopenharmony_ci     * @version 3.2
78049e185fSopenharmony_ci     */
79049e185fSopenharmony_ci    virtual std::shared_ptr<IRecorderProfilesService> CreateRecorderProfilesService() = 0;
80049e185fSopenharmony_ci
81049e185fSopenharmony_ci    /**
82049e185fSopenharmony_ci     * @brief Destroy a mediaprofile service.
83049e185fSopenharmony_ci     *
84049e185fSopenharmony_ci     * call the API to destroy the mediaprofile service.
85049e185fSopenharmony_ci     *
86049e185fSopenharmony_ci     * @param pointer to the mediaprofile service.
87049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
88049e185fSopenharmony_ci     * @since 3.2
89049e185fSopenharmony_ci     * @version 3.2
90049e185fSopenharmony_ci     */
91049e185fSopenharmony_ci    virtual int32_t DestroyMediaProfileService(std::shared_ptr<IRecorderProfilesService> recorderProfiles) = 0;
92049e185fSopenharmony_ci#endif
93049e185fSopenharmony_ci
94049e185fSopenharmony_ci#ifdef SUPPORT_TRANSCODER
95049e185fSopenharmony_ci    virtual std::shared_ptr<ITransCoderService> CreateTransCoderService() = 0;
96049e185fSopenharmony_ci    virtual int32_t DestroyTransCoderService(std::shared_ptr<ITransCoderService> transCoder) = 0;
97049e185fSopenharmony_ci#endif
98049e185fSopenharmony_ci
99049e185fSopenharmony_ci#ifdef SUPPORT_PLAYER
100049e185fSopenharmony_ci    /**
101049e185fSopenharmony_ci     * @brief Create a player service.
102049e185fSopenharmony_ci     *
103049e185fSopenharmony_ci     * All player functions must be created and obtained first.
104049e185fSopenharmony_ci     *
105049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
106049e185fSopenharmony_ci     * @since 1.0
107049e185fSopenharmony_ci     * @version 1.0
108049e185fSopenharmony_ci     */
109049e185fSopenharmony_ci    virtual std::shared_ptr<IPlayerService> CreatePlayerService() = 0;
110049e185fSopenharmony_ci
111049e185fSopenharmony_ci    /**
112049e185fSopenharmony_ci     * @brief Destroy a player service.
113049e185fSopenharmony_ci     *
114049e185fSopenharmony_ci     * call the API to destroy the player service.
115049e185fSopenharmony_ci     *
116049e185fSopenharmony_ci     * @param pointer to the player service.
117049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
118049e185fSopenharmony_ci     * @since 1.0
119049e185fSopenharmony_ci     * @version 1.0
120049e185fSopenharmony_ci     */
121049e185fSopenharmony_ci    virtual int32_t DestroyPlayerService(std::shared_ptr<IPlayerService> player) = 0;
122049e185fSopenharmony_ci#endif
123049e185fSopenharmony_ci
124049e185fSopenharmony_ci#ifdef SUPPORT_METADATA
125049e185fSopenharmony_ci    /**
126049e185fSopenharmony_ci     * @brief Create an avmetadatahelper service.
127049e185fSopenharmony_ci     *
128049e185fSopenharmony_ci     * All player functions must be created and obtained first.
129049e185fSopenharmony_ci     *
130049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
131049e185fSopenharmony_ci     * @since 1.0
132049e185fSopenharmony_ci     * @version 1.0
133049e185fSopenharmony_ci     */
134049e185fSopenharmony_ci    virtual std::shared_ptr<IAVMetadataHelperService> CreateAVMetadataHelperService() = 0;
135049e185fSopenharmony_ci
136049e185fSopenharmony_ci    /**
137049e185fSopenharmony_ci     * @brief Destroy a avmetadatahelper service.
138049e185fSopenharmony_ci     *
139049e185fSopenharmony_ci     * call the API to destroy the avmetadatahelper service.
140049e185fSopenharmony_ci     *
141049e185fSopenharmony_ci     * @param pointer to the avmetadatahelper service.
142049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
143049e185fSopenharmony_ci     * @since 1.0
144049e185fSopenharmony_ci     * @version 1.0
145049e185fSopenharmony_ci     */
146049e185fSopenharmony_ci    virtual int32_t DestroyAVMetadataHelperService(std::shared_ptr<IAVMetadataHelperService> avMetadataHelper) = 0;
147049e185fSopenharmony_ci#endif
148049e185fSopenharmony_ci
149049e185fSopenharmony_ci#ifdef SUPPORT_SCREEN_CAPTURE
150049e185fSopenharmony_ci    /**
151049e185fSopenharmony_ci     * @brief Create an screenCaptureHelper service.
152049e185fSopenharmony_ci     *
153049e185fSopenharmony_ci     * All player functions must be created and obtained first.
154049e185fSopenharmony_ci     *
155049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
156049e185fSopenharmony_ci     * @since 1.0
157049e185fSopenharmony_ci     * @version 1.0
158049e185fSopenharmony_ci     */
159049e185fSopenharmony_ci    virtual std::shared_ptr<IScreenCaptureService> CreateScreenCaptureService() = 0;
160049e185fSopenharmony_ci
161049e185fSopenharmony_ci    /**
162049e185fSopenharmony_ci     * @brief Destroy a screenCaptureHelper service.
163049e185fSopenharmony_ci     *
164049e185fSopenharmony_ci     * call the API to destroy the screenCaptureHelper service.
165049e185fSopenharmony_ci     *
166049e185fSopenharmony_ci     * @param pointer to the screenCaptureHelper service.
167049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
168049e185fSopenharmony_ci     * @since 1.0
169049e185fSopenharmony_ci     * @version 1.0
170049e185fSopenharmony_ci     */
171049e185fSopenharmony_ci    virtual int32_t DestroyScreenCaptureService(std::shared_ptr<IScreenCaptureService> screenCaptureHelper) = 0;
172049e185fSopenharmony_ci
173049e185fSopenharmony_ci    /**
174049e185fSopenharmony_ci     * @brief Create an screenCaptureMonitor service.
175049e185fSopenharmony_ci     *
176049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
177049e185fSopenharmony_ci     * @since 1.0
178049e185fSopenharmony_ci     * @version 1.0
179049e185fSopenharmony_ci     */
180049e185fSopenharmony_ci    virtual std::shared_ptr<IScreenCaptureMonitorService> CreateScreenCaptureMonitorService() = 0;
181049e185fSopenharmony_ci
182049e185fSopenharmony_ci    /**
183049e185fSopenharmony_ci     * @brief Destroy a screenCaptureMonitor service.
184049e185fSopenharmony_ci     *
185049e185fSopenharmony_ci     * call the API to destroy the screenCaptureMonitor service.
186049e185fSopenharmony_ci     *
187049e185fSopenharmony_ci     * @param pointer to the screenCaptureMonitor service.
188049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
189049e185fSopenharmony_ci     * @since 1.0
190049e185fSopenharmony_ci     * @version 1.0
191049e185fSopenharmony_ci     */
192049e185fSopenharmony_ci    virtual int32_t DestroyScreenCaptureMonitorService(
193049e185fSopenharmony_ci        std::shared_ptr<IScreenCaptureMonitorService> screenCaptureMonitor) = 0;
194049e185fSopenharmony_ci
195049e185fSopenharmony_ci    /**
196049e185fSopenharmony_ci     * @brief Create an ScreenCaptureControllerClient service.
197049e185fSopenharmony_ci     *
198049e185fSopenharmony_ci     * All player functions must be created and obtained first.
199049e185fSopenharmony_ci     *
200049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
201049e185fSopenharmony_ci     * @since 1.0
202049e185fSopenharmony_ci     * @version 1.0
203049e185fSopenharmony_ci     */
204049e185fSopenharmony_ci    virtual std::shared_ptr<IScreenCaptureController> CreateScreenCaptureControllerClient() = 0;
205049e185fSopenharmony_ci
206049e185fSopenharmony_ci    /**
207049e185fSopenharmony_ci     * @brief Destroy a ScreenCaptureControllerClient service.
208049e185fSopenharmony_ci     *
209049e185fSopenharmony_ci     * call the API to destroy the ScreenCaptureControllerClient service.
210049e185fSopenharmony_ci     *
211049e185fSopenharmony_ci     * @param pointer to the ScreenCaptureControllerClient service.
212049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
213049e185fSopenharmony_ci     * @since 1.0
214049e185fSopenharmony_ci     * @version 1.0
215049e185fSopenharmony_ci     */
216049e185fSopenharmony_ci    virtual int32_t DestroyScreenCaptureControllerClient(std::shared_ptr<IScreenCaptureController> controller) = 0;
217049e185fSopenharmony_ci#endif
218049e185fSopenharmony_ci
219049e185fSopenharmony_ci    /**
220049e185fSopenharmony_ci     * @brief Get an monitor proxy.
221049e185fSopenharmony_ci     *
222049e185fSopenharmony_ci     * To communicate with the server monitor, you must first obtain the monitor proxy.
223049e185fSopenharmony_ci     *
224049e185fSopenharmony_ci     * @return Returns a valid pointer if the setting is successful;
225049e185fSopenharmony_ci     * @since 1.0
226049e185fSopenharmony_ci     * @version 1.0
227049e185fSopenharmony_ci     */
228049e185fSopenharmony_ci    virtual sptr<IStandardMonitorService> GetMonitorProxy() = 0;
229049e185fSopenharmony_ci};
230049e185fSopenharmony_ci
231049e185fSopenharmony_ciclass __attribute__((visibility("default"))) MediaServiceFactory {
232049e185fSopenharmony_cipublic:
233049e185fSopenharmony_ci    /**
234049e185fSopenharmony_ci     * @brief IMediaService singleton
235049e185fSopenharmony_ci     *
236049e185fSopenharmony_ci     * Create Recorder Service and Player Service Through the Media Service.
237049e185fSopenharmony_ci     *
238049e185fSopenharmony_ci     * @return Returns IMediaService singleton;
239049e185fSopenharmony_ci     * @since 1.0
240049e185fSopenharmony_ci     * @version 1.0
241049e185fSopenharmony_ci     */
242049e185fSopenharmony_ci    static IMediaService &GetInstance();
243049e185fSopenharmony_ciprivate:
244049e185fSopenharmony_ci    MediaServiceFactory() = delete;
245049e185fSopenharmony_ci    ~MediaServiceFactory() = delete;
246049e185fSopenharmony_ci};
247049e185fSopenharmony_ci} // namespace Media
248049e185fSopenharmony_ci} // namespace OHOS
249049e185fSopenharmony_ci#endif // I_MEDIA_SERVICE_H
250