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_PLAYER_SERVICE_H
17049e185fSopenharmony_ci#define I_PLAYER_SERVICE_H
18049e185fSopenharmony_ci
19049e185fSopenharmony_ci#include "player.h"
20049e185fSopenharmony_ci#include "refbase.h"
21049e185fSopenharmony_ci
22049e185fSopenharmony_cinamespace OHOS {
23049e185fSopenharmony_cinamespace Media {
24049e185fSopenharmony_ciclass IPlayerService {
25049e185fSopenharmony_cipublic:
26049e185fSopenharmony_ci    virtual ~IPlayerService() = default;
27049e185fSopenharmony_ci
28049e185fSopenharmony_ci    /**
29049e185fSopenharmony_ci     * @brief Sets the playback source for the player. The corresponding source can be local file url.
30049e185fSopenharmony_ci     *
31049e185fSopenharmony_ci     * @param url Indicates the playback source.
32049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the url is set successfully; returns an error code defined
33049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
34049e185fSopenharmony_ci     * @since 1.0
35049e185fSopenharmony_ci     * @version 1.0
36049e185fSopenharmony_ci     */
37049e185fSopenharmony_ci    virtual int32_t SetSource(const std::string &url) = 0;
38049e185fSopenharmony_ci    /**
39049e185fSopenharmony_ci     * @brief Sets the playback media data source for the player.
40049e185fSopenharmony_ci     *
41049e185fSopenharmony_ci     * @param dataSrc Indicates the media data source. in {@link media_data_source.h}
42049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the dataSrc is set successfully; returns an error code defined
43049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
44049e185fSopenharmony_ci     * @since 1.0
45049e185fSopenharmony_ci     * @version 1.0
46049e185fSopenharmony_ci     */
47049e185fSopenharmony_ci    virtual int32_t SetSource(const std::shared_ptr<IMediaDataSource> &dataSrc) = 0;
48049e185fSopenharmony_ci    /**
49049e185fSopenharmony_ci     * @brief Sets the playback media file descriptor source for the player.
50049e185fSopenharmony_ci     *
51049e185fSopenharmony_ci     * @param fd Indicates the file descriptor of media source.
52049e185fSopenharmony_ci     * @param offset Indicates the offset of media source in file descriptor.
53049e185fSopenharmony_ci     * @param size Indicates the size of media source.
54049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the fd source is set successfully; returns an error code defined
55049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
56049e185fSopenharmony_ci     * @since 1.0
57049e185fSopenharmony_ci     * @version 1.0
58049e185fSopenharmony_ci     */
59049e185fSopenharmony_ci    virtual int32_t SetSource(int32_t fd, int64_t offset, int64_t size) = 0;
60049e185fSopenharmony_ci    /**
61049e185fSopenharmony_ci     * @brief Add a subtitle source for the player. The corresponding source can be local file url.
62049e185fSopenharmony_ci     *
63049e185fSopenharmony_ci     * @param url Indicates the subtitle source.
64049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the url is set successfully; returns an error code defined
65049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
66049e185fSopenharmony_ci     * @since 1.0
67049e185fSopenharmony_ci     * @version 1.0
68049e185fSopenharmony_ci     */
69049e185fSopenharmony_ci    virtual int32_t AddSubSource(const std::string &url) = 0;
70049e185fSopenharmony_ci    /**
71049e185fSopenharmony_ci     * @brief Add a playback subtitle file descriptor source for the player.
72049e185fSopenharmony_ci     *
73049e185fSopenharmony_ci     * @param fd Indicates the file descriptor of subtitle source.
74049e185fSopenharmony_ci     * @param offset Indicates the offset of subtitle source in file descriptor.
75049e185fSopenharmony_ci     * @param size Indicates the size of subtitle source.
76049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the fd source is set successfully; returns an error code defined
77049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
78049e185fSopenharmony_ci     * @since 1.0
79049e185fSopenharmony_ci     * @version 1.0
80049e185fSopenharmony_ci     */
81049e185fSopenharmony_ci    virtual int32_t AddSubSource(int32_t fd, int64_t offset, int64_t size) = 0;
82049e185fSopenharmony_ci    /**
83049e185fSopenharmony_ci     * @brief Start playback.
84049e185fSopenharmony_ci     *
85049e185fSopenharmony_ci     * This function must be called after {@link Prepare}. If the player state is <b>Prepared</b>,
86049e185fSopenharmony_ci     * this function is called to start playback.
87049e185fSopenharmony_ci     *
88049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the playback is started; otherwise returns an error code defined
89049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
90049e185fSopenharmony_ci     * @since 1.0
91049e185fSopenharmony_ci     * @version 1.0
92049e185fSopenharmony_ci     */
93049e185fSopenharmony_ci    virtual int32_t Play() = 0;
94049e185fSopenharmony_ci
95049e185fSopenharmony_ci    /**
96049e185fSopenharmony_ci     * @brief Prepares the playback environment and buffers media data asynchronous.
97049e185fSopenharmony_ci     *
98049e185fSopenharmony_ci     * This function must be called after {@link SetSource}.
99049e185fSopenharmony_ci     *
100049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if {@link Prepare} is successfully added to the task queue;
101049e185fSopenharmony_ci     * returns an error code defined in {@link media_errors.h} otherwise.
102049e185fSopenharmony_ci     * @since 1.0
103049e185fSopenharmony_ci     * @version 1.0
104049e185fSopenharmony_ci     */
105049e185fSopenharmony_ci    virtual int32_t Prepare() = 0;
106049e185fSopenharmony_ci
107049e185fSopenharmony_ci    /**
108049e185fSopenharmony_ci     * @brief Enables render video first frame of the media playback.
109049e185fSopenharmony_ci     *
110049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the single display is set; returns an error code defined
111049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
112049e185fSopenharmony_ci     * @since 1.0
113049e185fSopenharmony_ci     * @version 1.0
114049e185fSopenharmony_ci     */
115049e185fSopenharmony_ci    virtual int32_t SetRenderFirstFrame(bool display)
116049e185fSopenharmony_ci    {
117049e185fSopenharmony_ci        (void)display;
118049e185fSopenharmony_ci        return 0;
119049e185fSopenharmony_ci    }
120049e185fSopenharmony_ci
121049e185fSopenharmony_ci    /**
122049e185fSopenharmony_ci     * @brief Specify the start and end time to play
123049e185fSopenharmony_ci     * This function must be called after {@link SetSource}.
124049e185fSopenharmony_ci     * This function is called to set start and end time
125049e185fSopenharmony_ci     *
126049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the single display is set; returns an error code defined
127049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
128049e185fSopenharmony_ci     * @since 1.0
129049e185fSopenharmony_ci     * @version 1.0
130049e185fSopenharmony_ci     */
131049e185fSopenharmony_ci    virtual int32_t SetPlayRange(int64_t start, int64_t end)
132049e185fSopenharmony_ci    {
133049e185fSopenharmony_ci        (void)start;
134049e185fSopenharmony_ci        (void)end;
135049e185fSopenharmony_ci        return 0;
136049e185fSopenharmony_ci    }
137049e185fSopenharmony_ci
138049e185fSopenharmony_ci    /**
139049e185fSopenharmony_ci     * @brief Set playback start position and end position.
140049e185fSopenharmony_ci     * Use the specified seek mode to jump to the playback start position,
141049e185fSopenharmony_ci     * currently support SEEK_PREVIOUS_SYNC and SEEK_CLOSEST, other values are invalid,
142049e185fSopenharmony_ci     * This function must be called after {@link SetSource}.
143049e185fSopenharmony_ci     *
144049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the single display is set; returns an error code defined
145049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
146049e185fSopenharmony_ci     * @since 1.0
147049e185fSopenharmony_ci     * @version 1.0
148049e185fSopenharmony_ci     */
149049e185fSopenharmony_ci    virtual int32_t SetPlayRangeWithMode(int64_t start, int64_t end, PlayerSeekMode mode)
150049e185fSopenharmony_ci    {
151049e185fSopenharmony_ci        (void)start;
152049e185fSopenharmony_ci        (void)end;
153049e185fSopenharmony_ci        (void)mode;
154049e185fSopenharmony_ci        return 0;
155049e185fSopenharmony_ci    }
156049e185fSopenharmony_ci
157049e185fSopenharmony_ci    /**
158049e185fSopenharmony_ci     * @brief Prepares the playback environment and buffers media data asynchronous.
159049e185fSopenharmony_ci     *
160049e185fSopenharmony_ci     * This function must be called after {@link SetSource}.
161049e185fSopenharmony_ci     *
162049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if {@link PrepareAsync} is successfully added to the task queue;
163049e185fSopenharmony_ci     * returns an error code defined in {@link media_errors.h} otherwise.
164049e185fSopenharmony_ci     * @since 1.0
165049e185fSopenharmony_ci     * @version 1.0
166049e185fSopenharmony_ci     */
167049e185fSopenharmony_ci    virtual int32_t PrepareAsync() = 0;
168049e185fSopenharmony_ci
169049e185fSopenharmony_ci    /**
170049e185fSopenharmony_ci     * @brief Pauses playback.
171049e185fSopenharmony_ci     *
172049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if {@link Pause} is successfully added to the task queue;
173049e185fSopenharmony_ci     * returns an error code defined in {@link media_errors.h} otherwise.
174049e185fSopenharmony_ci     * @since 1.0
175049e185fSopenharmony_ci     * @version 1.0
176049e185fSopenharmony_ci     */
177049e185fSopenharmony_ci    virtual int32_t Pause() = 0;
178049e185fSopenharmony_ci
179049e185fSopenharmony_ci    /**
180049e185fSopenharmony_ci     * @brief Stop playback.
181049e185fSopenharmony_ci     *
182049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if {@link Stop} is successfully added to the task queue;
183049e185fSopenharmony_ci     * returns an error code defined in {@link media_errors.h} otherwise.
184049e185fSopenharmony_ci     * @since 1.0
185049e185fSopenharmony_ci     * @version 1.0
186049e185fSopenharmony_ci     */
187049e185fSopenharmony_ci    virtual int32_t Stop() = 0;
188049e185fSopenharmony_ci
189049e185fSopenharmony_ci    /**
190049e185fSopenharmony_ci     * @brief Restores the player to the initial state.
191049e185fSopenharmony_ci     *
192049e185fSopenharmony_ci     * After the function is called, add a playback source by calling {@link SetSource},
193049e185fSopenharmony_ci     * call {@link Play} to start playback again after {@link Prepare} is called.
194049e185fSopenharmony_ci     *
195049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if {@link Reset} is successfully added to the task queue;
196049e185fSopenharmony_ci     * returns an error code defined in {@link media_errors.h} otherwise.
197049e185fSopenharmony_ci     * @since 1.0
198049e185fSopenharmony_ci     * @version 1.0
199049e185fSopenharmony_ci     */
200049e185fSopenharmony_ci    virtual int32_t Reset() = 0;
201049e185fSopenharmony_ci
202049e185fSopenharmony_ci    /**
203049e185fSopenharmony_ci     * @brief Releases player resources async
204049e185fSopenharmony_ci     *
205049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if {@link Release} is successfully added to the task queue;
206049e185fSopenharmony_ci     * returns an error code defined in {@link media_errors.h} otherwise.
207049e185fSopenharmony_ci     * @since 1.0
208049e185fSopenharmony_ci     * @version 1.0
209049e185fSopenharmony_ci     */
210049e185fSopenharmony_ci    virtual int32_t Release() = 0;
211049e185fSopenharmony_ci
212049e185fSopenharmony_ci    /**
213049e185fSopenharmony_ci     * @brief Releases player resources sync
214049e185fSopenharmony_ci     *
215049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the playback is released; returns an error code defined
216049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
217049e185fSopenharmony_ci     * @since 1.0
218049e185fSopenharmony_ci     * @version 1.0
219049e185fSopenharmony_ci     */
220049e185fSopenharmony_ci    virtual int32_t ReleaseSync()
221049e185fSopenharmony_ci    {
222049e185fSopenharmony_ci        return ERR_OK;
223049e185fSopenharmony_ci    }
224049e185fSopenharmony_ci
225049e185fSopenharmony_ci    /**
226049e185fSopenharmony_ci     * @brief Sets the volume of the player.
227049e185fSopenharmony_ci     *
228049e185fSopenharmony_ci     * This function can be used during playback or pause. The value <b>0</b> indicates no sound,
229049e185fSopenharmony_ci     * and <b>1</b> indicates the original volume. If no audio device is started or no audio
230049e185fSopenharmony_ci     * stream exists, the value <b>-1</b> is returned.
231049e185fSopenharmony_ci     *
232049e185fSopenharmony_ci     * @param leftVolume Indicates the target volume of the left audio channel to set,
233049e185fSopenharmony_ci     *        ranging from 0 to 1. each step is 0.01.
234049e185fSopenharmony_ci     * @param rightVolume Indicates the target volume of the right audio channel to set,
235049e185fSopenharmony_ci     *        ranging from 0 to 1. each step is 0.01.
236049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the volume is set; returns an error code defined
237049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
238049e185fSopenharmony_ci     * @since 1.0
239049e185fSopenharmony_ci     * @version 1.0
240049e185fSopenharmony_ci     */
241049e185fSopenharmony_ci    virtual int32_t SetVolume(float leftVolume, float rightVolume) = 0;
242049e185fSopenharmony_ci
243049e185fSopenharmony_ci    /**
244049e185fSopenharmony_ci     * @brief Changes the playback position.
245049e185fSopenharmony_ci     *
246049e185fSopenharmony_ci     * This function can be used during play or pause.
247049e185fSopenharmony_ci     *
248049e185fSopenharmony_ci     * @param mSeconds Indicates the target playback position, accurate to second.
249049e185fSopenharmony_ci     * @param mode Indicates the player seek mode. For details, see {@link PlayerSeekMode}.
250049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the seek is done; returns an error code defined
251049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
252049e185fSopenharmony_ci     * @since 1.0
253049e185fSopenharmony_ci     * @version 1.0
254049e185fSopenharmony_ci    */
255049e185fSopenharmony_ci    virtual int32_t Seek(int32_t mSeconds, PlayerSeekMode mode) = 0;
256049e185fSopenharmony_ci
257049e185fSopenharmony_ci    /**
258049e185fSopenharmony_ci     * @brief Obtains the playback position, accurate to millisecond.
259049e185fSopenharmony_ci     *
260049e185fSopenharmony_ci     * @param currentTime Indicates the playback position.
261049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the current position is get; returns an error code defined
262049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
263049e185fSopenharmony_ci     * @since 1.0
264049e185fSopenharmony_ci     * @version 1.0
265049e185fSopenharmony_ci     */
266049e185fSopenharmony_ci    virtual int32_t GetCurrentTime(int32_t &currentTime) = 0;
267049e185fSopenharmony_ci
268049e185fSopenharmony_ci    /**
269049e185fSopenharmony_ci     * @brief Obtains the playback position compatible with the livestream, accurate to millisecond.
270049e185fSopenharmony_ci     *
271049e185fSopenharmony_ci     * @param currentTime Indicates the playback position.
272049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the current position is get; returns an error code defined
273049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
274049e185fSopenharmony_ci     * @since 1.0
275049e185fSopenharmony_ci     * @version 1.0
276049e185fSopenharmony_ci     */
277049e185fSopenharmony_ci    virtual int32_t GetPlaybackPosition(int32_t &currentTime) = 0;
278049e185fSopenharmony_ci
279049e185fSopenharmony_ci    /**
280049e185fSopenharmony_ci     * @brief Obtains the video track info, contains mimeType, bitRate, width, height, frameRata.
281049e185fSopenharmony_ci     *
282049e185fSopenharmony_ci     * @param video track info vec.
283049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the track info is get; returns an error code defined
284049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
285049e185fSopenharmony_ci     * @since 1.0
286049e185fSopenharmony_ci     * @version 1.0
287049e185fSopenharmony_ci     */
288049e185fSopenharmony_ci    virtual int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) = 0;
289049e185fSopenharmony_ci
290049e185fSopenharmony_ci    /**
291049e185fSopenharmony_ci     * @brief Obtains playbackInfo, contains server_ip_address, average_download_rate,
292049e185fSopenharmony_ci     * download_rate, is_downloading, buffer_duration.
293049e185fSopenharmony_ci     *
294049e185fSopenharmony_ci     * @param playbackInfo.
295049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the track info is get; returns an error code defined
296049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
297049e185fSopenharmony_ci     * @since 1.0
298049e185fSopenharmony_ci     * @version 1.0
299049e185fSopenharmony_ci     */
300049e185fSopenharmony_ci    virtual int32_t GetPlaybackInfo(Format &playbackInfo) = 0;
301049e185fSopenharmony_ci
302049e185fSopenharmony_ci    /**
303049e185fSopenharmony_ci     * @brief Obtains the audio track info, contains mimeType, bitRate, sampleRate, channels, language.
304049e185fSopenharmony_ci     *
305049e185fSopenharmony_ci     * @param audio track info vec.
306049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the track info is get; returns an error code defined
307049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
308049e185fSopenharmony_ci     * @since 1.0
309049e185fSopenharmony_ci     * @version 1.0
310049e185fSopenharmony_ci     */
311049e185fSopenharmony_ci    virtual int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) = 0;
312049e185fSopenharmony_ci
313049e185fSopenharmony_ci    /**
314049e185fSopenharmony_ci     * @brief get the video width.
315049e185fSopenharmony_ci     *
316049e185fSopenharmony_ci     * @return Returns width if success; else returns 0
317049e185fSopenharmony_ci     * @since 1.0
318049e185fSopenharmony_ci     * @version 1.0
319049e185fSopenharmony_ci     */
320049e185fSopenharmony_ci    virtual int32_t GetVideoWidth() = 0;
321049e185fSopenharmony_ci
322049e185fSopenharmony_ci    /**
323049e185fSopenharmony_ci     * @brief get the video height.
324049e185fSopenharmony_ci     *
325049e185fSopenharmony_ci     * @return Returns height if success; else returns 0
326049e185fSopenharmony_ci     * @since 1.0
327049e185fSopenharmony_ci     * @version 1.0
328049e185fSopenharmony_ci     */
329049e185fSopenharmony_ci    virtual int32_t GetVideoHeight() = 0;
330049e185fSopenharmony_ci
331049e185fSopenharmony_ci    /**
332049e185fSopenharmony_ci     * @brief Obtains the total duration of media files, accurate to milliseconds.
333049e185fSopenharmony_ci     *
334049e185fSopenharmony_ci     * @param duration Indicates the total duration of media files.
335049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the current duration is get; returns an error code defined
336049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
337049e185fSopenharmony_ci     * @since 1.0
338049e185fSopenharmony_ci     * @version 1.0
339049e185fSopenharmony_ci     */
340049e185fSopenharmony_ci    virtual int32_t GetDuration(int32_t &duration) = 0;
341049e185fSopenharmony_ci
342049e185fSopenharmony_ci    /**
343049e185fSopenharmony_ci     * @brief set the player playback rate
344049e185fSopenharmony_ci     *
345049e185fSopenharmony_ci     * @param mode the rate mode {@link PlaybackRateMode} which can set.
346049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the playback rate is set successfully; returns an error code defined
347049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
348049e185fSopenharmony_ci     * @since 1.0
349049e185fSopenharmony_ci     * @version 1.0
350049e185fSopenharmony_ci     */
351049e185fSopenharmony_ci    virtual int32_t SetPlaybackSpeed(PlaybackRateMode mode) = 0;
352049e185fSopenharmony_ci
353049e185fSopenharmony_ci    virtual int32_t SetMediaSource(const std::shared_ptr<AVMediaSource> &mediaSource, AVPlayStrategy strategy) = 0;
354049e185fSopenharmony_ci    /**
355049e185fSopenharmony_ci     * @brief set the bit rate use for hls player
356049e185fSopenharmony_ci     *
357049e185fSopenharmony_ci     * @param bitRate the bit rate.
358049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the bit rate is set successfully; returns an error code defined
359049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
360049e185fSopenharmony_ci     * @since 1.0
361049e185fSopenharmony_ci     * @version 1.0
362049e185fSopenharmony_ci     */
363049e185fSopenharmony_ci    virtual int32_t SelectBitRate(uint32_t bitRate) = 0;
364049e185fSopenharmony_ci
365049e185fSopenharmony_ci    virtual int32_t StopBufferring(bool flag)
366049e185fSopenharmony_ci    {
367049e185fSopenharmony_ci        (void)flag;
368049e185fSopenharmony_ci        return 0;
369049e185fSopenharmony_ci    }
370049e185fSopenharmony_ci    /**
371049e185fSopenharmony_ci     * @brief get the current player playback rate
372049e185fSopenharmony_ci     *
373049e185fSopenharmony_ci     * @param mode the rate mode {@link PlaybackRateMode} which can get.
374049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the current player playback rate is get; returns an error code defined
375049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
376049e185fSopenharmony_ci     * @since 1.0
377049e185fSopenharmony_ci     * @version 1.0
378049e185fSopenharmony_ci     */
379049e185fSopenharmony_ci    virtual int32_t GetPlaybackSpeed(PlaybackRateMode &mode) = 0;
380049e185fSopenharmony_ci
381049e185fSopenharmony_ci    /**
382049e185fSopenharmony_ci     * @brief add for drm, set decrypt module
383049e185fSopenharmony_ci     *
384049e185fSopenharmony_ci     * @param keySessionProxy is the sptr will be setted to playerserver.
385049e185fSopenharmony_ci     * @param svp bool.
386049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if set successfully; returns an error code defined
387049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
388049e185fSopenharmony_ci     * @since
389049e185fSopenharmony_ci     * @version
390049e185fSopenharmony_ci     */
391049e185fSopenharmony_ci    virtual int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySessionProxy,
392049e185fSopenharmony_ci        bool svp) = 0;
393049e185fSopenharmony_ci
394049e185fSopenharmony_ci#ifdef SUPPORT_VIDEO
395049e185fSopenharmony_ci    /**
396049e185fSopenharmony_ci     * @brief Method to set the surface.
397049e185fSopenharmony_ci     *
398049e185fSopenharmony_ci     * @param surface pointer of the surface.
399049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the surface is set; returns an error code defined
400049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
401049e185fSopenharmony_ci     * @since 1.0
402049e185fSopenharmony_ci     * @version 1.0
403049e185fSopenharmony_ci     */
404049e185fSopenharmony_ci    virtual int32_t SetVideoSurface(sptr<Surface> surface) = 0;
405049e185fSopenharmony_ci#endif
406049e185fSopenharmony_ci
407049e185fSopenharmony_ci    /**
408049e185fSopenharmony_ci     * @brief Checks whether the player is playing.
409049e185fSopenharmony_ci     *
410049e185fSopenharmony_ci     * @return Returns true if the playback is playing; false otherwise.
411049e185fSopenharmony_ci     * @since 1.0
412049e185fSopenharmony_ci     * @version 1.0
413049e185fSopenharmony_ci     */
414049e185fSopenharmony_ci    virtual bool IsPlaying() = 0;
415049e185fSopenharmony_ci
416049e185fSopenharmony_ci    /**
417049e185fSopenharmony_ci     * @brief Returns the value whether single looping is enabled or not .
418049e185fSopenharmony_ci     *
419049e185fSopenharmony_ci     * @return Returns true if the playback is single looping; false otherwise.
420049e185fSopenharmony_ci     * @since 1.0
421049e185fSopenharmony_ci     * @version 1.0
422049e185fSopenharmony_ci     */
423049e185fSopenharmony_ci    virtual bool IsLooping() = 0;
424049e185fSopenharmony_ci
425049e185fSopenharmony_ci    /**
426049e185fSopenharmony_ci     * @brief Enables single looping of the media playback.
427049e185fSopenharmony_ci     *
428049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the single looping is set; returns an error code defined
429049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
430049e185fSopenharmony_ci     * @since 1.0
431049e185fSopenharmony_ci     * @version 1.0
432049e185fSopenharmony_ci     */
433049e185fSopenharmony_ci    virtual int32_t SetLooping(bool loop) = 0;
434049e185fSopenharmony_ci
435049e185fSopenharmony_ci    /**
436049e185fSopenharmony_ci     * @brief Enables setting the renderer descriptor for the current media
437049e185fSopenharmony_ci     *
438049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the renderer descriptor is set; returns an error code defined
439049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
440049e185fSopenharmony_ci     * @since 1.0
441049e185fSopenharmony_ci     * @version 1.0
442049e185fSopenharmony_ci     */
443049e185fSopenharmony_ci    virtual int32_t SetParameter(const Format &param) = 0;
444049e185fSopenharmony_ci
445049e185fSopenharmony_ci    /**
446049e185fSopenharmony_ci     * @brief Method to set player callback.
447049e185fSopenharmony_ci     *
448049e185fSopenharmony_ci     * @param callback object pointer.
449049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the playercallback is set; returns an error code defined
450049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
451049e185fSopenharmony_ci     * @since 1.0
452049e185fSopenharmony_ci     * @version 1.0
453049e185fSopenharmony_ci     */
454049e185fSopenharmony_ci    virtual int32_t SetPlayerCallback(const std::shared_ptr<PlayerCallback> &callback) = 0;
455049e185fSopenharmony_ci
456049e185fSopenharmony_ci    /**
457049e185fSopenharmony_ci     * @brief Select audio or subtitle track.
458049e185fSopenharmony_ci     * By default, the first audio stream with data is played, and the subtitle track is not played.
459049e185fSopenharmony_ci     * After the settings take effect, the original track will become invalid.
460049e185fSopenharmony_ci     * Please set it in the prepared/playing/paused/completed state.
461049e185fSopenharmony_ci     *
462049e185fSopenharmony_ci     * @param index Track index, reference {@link #GetAudioTrackInfo} and {@link #GetVideoTrackInfo}.
463049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if selected successfully; returns an error code defined
464049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
465049e185fSopenharmony_ci     * @since 1.0
466049e185fSopenharmony_ci     * @version 1.0
467049e185fSopenharmony_ci    */
468049e185fSopenharmony_ci    virtual int32_t SelectTrack(int32_t index, PlayerSwitchMode mode = PlayerSwitchMode::SWITCH_SMOOTH) = 0;
469049e185fSopenharmony_ci
470049e185fSopenharmony_ci    /**
471049e185fSopenharmony_ci     * @brief Deselect the current audio or subtitle track.
472049e185fSopenharmony_ci     * After audio is deselected, the default track will be played, and after subtitles are deselected,
473049e185fSopenharmony_ci     * they will not be played. Please set it in the prepared/playing/paused/completed state.
474049e185fSopenharmony_ci     *
475049e185fSopenharmony_ci     * @param index Track index, reference {@link #GetAudioTrackInfo} and {@link #GetVideoTrackInfo}.
476049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if selected successfully; returns an error code defined
477049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
478049e185fSopenharmony_ci     * @since 1.0
479049e185fSopenharmony_ci     * @version 1.0
480049e185fSopenharmony_ci    */
481049e185fSopenharmony_ci    virtual int32_t DeselectTrack(int32_t index) = 0;
482049e185fSopenharmony_ci
483049e185fSopenharmony_ci    /**
484049e185fSopenharmony_ci     * @brief Obtain the currently effective track index.
485049e185fSopenharmony_ci     *
486049e185fSopenharmony_ci     * @param trackType Media type.
487049e185fSopenharmony_ci     * @param index Track index, reference {@link #GetAudioTrackInfo} and {@link #GetVideoTrackInfo}.
488049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the track index is get; returns an error code defined
489049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
490049e185fSopenharmony_ci     * @since 1.0
491049e185fSopenharmony_ci     * @version 1.0
492049e185fSopenharmony_ci     */
493049e185fSopenharmony_ci    virtual int32_t GetCurrentTrack(int32_t trackType, int32_t &index) = 0;
494049e185fSopenharmony_ci
495049e185fSopenharmony_ci    /**
496049e185fSopenharmony_ci     * @brief Obtains the subtitle track info, contains mimeType, type, language.
497049e185fSopenharmony_ci     *
498049e185fSopenharmony_ci     * @param subtitle track info vec.
499049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the track info is get; returns an error code defined
500049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
501049e185fSopenharmony_ci     * @since 1.0
502049e185fSopenharmony_ci     * @version 1.0
503049e185fSopenharmony_ci     */
504049e185fSopenharmony_ci    virtual int32_t GetSubtitleTrackInfo(std::vector<Format> &subtitleTrack) = 0;
505049e185fSopenharmony_ci
506049e185fSopenharmony_ci    /**
507049e185fSopenharmony_ci     * @brief set the playback strategy
508049e185fSopenharmony_ci     * the playback strategy includes five fileds:
509049e185fSopenharmony_ci     * preferredWidth: Preferred width, which is of the int type, for example, 1080.
510049e185fSopenharmony_ci     * preferredHeight: Preferred height, which is of the int type, for example, 1920.
511049e185fSopenharmony_ci     * preferredBufferDuration: Preferred buffer duration, in seconds. The value ranges from 1 to 20.
512049e185fSopenharmony_ci     * preferredHdr: Whether HDR is preferred. The value true means that HDR is preferred, and false means the opposite.
513049e185fSopenharmony_ci     * mutedMediaType: The mediaType to be muted before play, which is of the MediaType type,
514049e185fSopenharmony_ci     * for example, MediaType::MEDIA_TYPE_AUD.
515049e185fSopenharmony_ci     * @param playbackStrategy the playback strategy.
516049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the playback strategy is set successfully; returns an error code defined
517049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
518049e185fSopenharmony_ci     * @since 1.0
519049e185fSopenharmony_ci     * @version 1.0
520049e185fSopenharmony_ci     */
521049e185fSopenharmony_ci    virtual int32_t SetPlaybackStrategy(AVPlayStrategy playbackStrategy)
522049e185fSopenharmony_ci    {
523049e185fSopenharmony_ci        (void)playbackStrategy;
524049e185fSopenharmony_ci        return 0;
525049e185fSopenharmony_ci    }
526049e185fSopenharmony_ci
527049e185fSopenharmony_ci    virtual int32_t SetMediaMuted(MediaType mediaType, bool isMuted)
528049e185fSopenharmony_ci    {
529049e185fSopenharmony_ci        (void)mediaType;
530049e185fSopenharmony_ci        (void)isMuted;
531049e185fSopenharmony_ci        return 0;
532049e185fSopenharmony_ci    }
533049e185fSopenharmony_ci
534049e185fSopenharmony_ci    /**
535049e185fSopenharmony_ci     * @brief Set get max ampliutude callback status.
536049e185fSopenharmony_ci     *
537049e185fSopenharmony_ci     * @param status callback status.
538049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the callback status is set; returns an error code defined
539049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
540049e185fSopenharmony_ci     * @since 1.0
541049e185fSopenharmony_ci     * @version 1.0
542049e185fSopenharmony_ci     */
543049e185fSopenharmony_ci    virtual int32_t SetMaxAmplitudeCbStatus(bool status)
544049e185fSopenharmony_ci    {
545049e185fSopenharmony_ci        (void)status;
546049e185fSopenharmony_ci        return 0;
547049e185fSopenharmony_ci    }
548049e185fSopenharmony_ci
549049e185fSopenharmony_ci    /**
550049e185fSopenharmony_ci     * @brief set get device change callback status.
551049e185fSopenharmony_ci     *
552049e185fSopenharmony_ci     * @return Returns {@link MSERR_OK} if the single display is set; returns an error code defined
553049e185fSopenharmony_ci     * in {@link media_errors.h} otherwise.
554049e185fSopenharmony_ci     * @since 1.0
555049e185fSopenharmony_ci     * @version 1.0
556049e185fSopenharmony_ci     */
557049e185fSopenharmony_ci    virtual int32_t SetDeviceChangeCbStatus(bool status)
558049e185fSopenharmony_ci    {
559049e185fSopenharmony_ci        (void)status;
560049e185fSopenharmony_ci        return 0;
561049e185fSopenharmony_ci    }
562049e185fSopenharmony_ci};
563049e185fSopenharmony_ci} // namespace Media
564049e185fSopenharmony_ci} // namespace OHOS
565049e185fSopenharmony_ci#endif // I_PLAYER_SERVICE_H
566