• 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 PLAYER_H
17 #define PLAYER_H
18 
19 #include <cstdint>
20 #ifndef SUPPORT_AUDIO_ONLY
21 #include "surface.h"
22 #endif
23 #include "format.h"
24 #include "media_data_source.h"
25 
26 namespace OHOS {
27 namespace Media {
28 class PlayerKeys {
29 public:
30     static constexpr std::string_view PLAYER_STATE_CHANGED_REASON = "state_changed_reason";
31     static constexpr std::string_view PLAYER_VOLUME_LEVEL = "volume_level";
32     static constexpr std::string_view PLAYER_TRACK_INDEX = "track_index";
33     static constexpr std::string_view PLAYER_TRACK_TYPE = "track_type";
34     static constexpr std::string_view PLAYER_TRACK_INFO = "track_info";
35     static constexpr std::string_view PLAYER_WIDTH = "width";
36     static constexpr std::string_view PLAYER_HEIGHT = "height";
37     static constexpr std::string_view PLAYER_MIME = "codec_mime";
38     static constexpr std::string_view PLAYER_BITRATE = "bitrate";
39     static constexpr std::string_view PLAYER_FRAMERATE = "frame_rate";
40     static constexpr std::string_view PLAYER_LANGUGAE = "language_code";
41     static constexpr std::string_view PLAYER_SAMPLE_RATE = "sample_rate";
42     static constexpr std::string_view PLAYER_CHANNELS = "channel_count";
43     static constexpr std::string_view PLAYER_BUFFERING_START = "buffering_start";
44     static constexpr std::string_view PLAYER_BUFFERING_END = "buffering_end";
45     static constexpr std::string_view PLAYER_BUFFERING_PERCENT = "buffering_percent";
46     static constexpr std::string_view PLAYER_CACHED_DURATION = "cached_duration";
47     static constexpr std::string_view PLAYER_IS_SELECT = "track_is_select";
48     static constexpr std::string_view PLAYER_ERROR_TYPE = "error_type";
49     static constexpr std::string_view PLAYER_ERROR_MSG = "error_msg";
50     static constexpr std::string_view CONTENT_TYPE = "content_type";
51     static constexpr std::string_view STREAM_USAGE = "stream_usage";
52     static constexpr std::string_view RENDERER_FLAG = "renderer_flag";
53     static constexpr std::string_view VIDEO_SCALE_TYPE = "video_scale_type";
54     static constexpr std::string_view AUDIO_INTERRUPT_MODE = "audio_interrupt_mode";
55     static constexpr std::string_view AUDIO_INTERRUPT_TYPE = "audio_interrupt_type";
56     static constexpr std::string_view AUDIO_INTERRUPT_FORCE = "audio_interrupt_force";
57     static constexpr std::string_view AUDIO_INTERRUPT_HINT = "audio_interrupt_hint";
58     static constexpr std::string_view AUDIO_EFFECT_MODE = "audio_effect_mode";
59     static constexpr std::string_view SUBTITLE_TEXT = "subtitle_text";
60 };
61 
62 enum BufferingInfoType : int32_t {
63     /* begin to b buffering */
64     BUFFERING_START = 1,
65     /* end to buffering */
66     BUFFERING_END = 2,
67     /* buffering percent */
68     BUFFERING_PERCENT = 3,
69     /* cached duration in milliseconds */
70     CACHED_DURATION = 4,
71 };
72 
73 enum PlayerErrorType : int32_t {
74     /* Valid error, error code reference defined in media_errors.h */
75     PLAYER_ERROR,
76     /* Unknown error */
77     PLAYER_ERROR_UNKNOWN,
78     /* extend error type start,The extension error type agreed upon by the plug-in and
79        the application will be transparently transmitted by the service. */
80     PLAYER_ERROR_EXTEND_START = 0X10000,
81 };
82 
83 enum PlayerMessageType : int32_t {
84     /* unknown info */
85     PLAYER_INFO_UNKNOWN = 0,
86     /* first video frame start to render. */
87     PLAYER_INFO_VIDEO_RENDERING_START,
88     /* network bandwidth, uint is KB and passed by "extra"(arg 2). */
89     PLAYER_INFO_NETWORK_BANDWIDTH,
90     /* not fatal errors accured, errorcode see "media_errors.h" and passed by "extra"(arg 2). */
91     PLAYER_INFO_WARNING,
92     /* system new info type should be added here.
93        extend start. App and plugins or PlayerEngine extended info type start. */
94     PLAYER_INFO_EXTEND_START = 0X1000,
95 };
96 
97 enum PlayerOnInfoType : int32_t {
98     /* return the message when seeking done. */
99     INFO_TYPE_SEEKDONE = 1,
100     /* return the message when speeding done. */
101     INFO_TYPE_SPEEDDONE,
102     /* return the message when select bitrate done */
103     INFO_TYPE_BITRATEDONE,
104     /* return the message when playback is end of steam. */
105     INFO_TYPE_EOS,
106     /* return the message when PlayerStates changed. */
107     INFO_TYPE_STATE_CHANGE,
108     /* return the current posion of playback automatically. */
109     INFO_TYPE_POSITION_UPDATE,
110     /* return the playback message. */
111     INFO_TYPE_MESSAGE,
112     /* return the message when volume changed. */
113     INFO_TYPE_VOLUME_CHANGE,
114     /* return the message when video size is first known or updated. */
115     INFO_TYPE_RESOLUTION_CHANGE,
116     /* return multiqueue buffering time. */
117     INFO_TYPE_BUFFERING_UPDATE,
118     /* return hls bitrate.
119        Bitrate is to convert data into uint8_t array storage,
120        which needs to be forcibly converted to uint32_t through offset access. */
121     INFO_TYPE_BITRATE_COLLECT,
122     /* return the message when audio focus changed. */
123     INFO_TYPE_INTERRUPT_EVENT,
124     /* return the message when PlayerStates changed by audio. */
125     INFO_TYPE_STATE_CHANGE_BY_AUDIO,
126     /* return the message with extra information in format. */
127     INFO_TYPE_EXTRA_FORMAT,
128     /* return the duration of playback. */
129     INFO_TYPE_DURATION_UPDATE,
130     /* return the playback is live stream. */
131     INFO_TYPE_IS_LIVE_STREAM,
132     /* return the message when track changes. */
133     INFO_TYPE_TRACKCHANGE,
134     /* return the default audio track. */
135     INFO_TYPE_DEFAULTTRACK,
136     /* Return to the end of track processing. */
137     INFO_TYPE_TRACK_DONE,
138     /* Return error message to prompt the user. */
139     INFO_TYPE_ERROR_MSG,
140     /* return the message when subtitle track num updated. */
141     INFO_TYPE_TRACK_NUM_UPDATE,
142     /* return the message when subtitle track info updated. */
143     INFO_TYPE_TRACK_INFO_UPDATE,
144     /* return the subtitle of playback. */
145     INFO_TYPE_SUBTITLE_UPDATE,
146     /* return to the end of adding subtitle processing. */
147     INFO_TYPE_ADD_SUBTITLE_DONE,
148 };
149 
150 enum PlayerStates : int32_t {
151     /* error states */
152     PLAYER_STATE_ERROR = 0,
153     /* idle states */
154     PLAYER_IDLE = 1,
155     /* initialized states(Internal states) */
156     PLAYER_INITIALIZED = 2,
157     /* preparing states(Internal states) */
158     PLAYER_PREPARING = 3,
159     /* prepared states */
160     PLAYER_PREPARED = 4,
161     /* started states */
162     PLAYER_STARTED = 5,
163     /* paused states */
164     PLAYER_PAUSED = 6,
165     /* stopped states */
166     PLAYER_STOPPED = 7,
167     /* Play to the end states */
168     PLAYER_PLAYBACK_COMPLETE = 8,
169     /* released states */
170     PLAYER_RELEASED = 9,
171 };
172 
173 enum PlayerSeekMode : int32_t {
174     /* sync to keyframes after the time point. */
175     SEEK_NEXT_SYNC = 0,
176     /* sync to keyframes before the time point. */
177     SEEK_PREVIOUS_SYNC,
178     /* sync to closest keyframes. */
179     SEEK_CLOSEST_SYNC,
180     /* seek to frames closest the time point. */
181     SEEK_CLOSEST,
182 };
183 
184 enum PlaybackRateMode : int32_t {
185     /* Video playback at 0.75x normal speed */
186     SPEED_FORWARD_0_75_X,
187     /* Video playback at normal speed */
188     SPEED_FORWARD_1_00_X,
189     /* Video playback at 1.25x normal speed */
190     SPEED_FORWARD_1_25_X,
191     /* Video playback at 1.75x normal speed */
192     SPEED_FORWARD_1_75_X,
193     /* Video playback at 2.0x normal speed */
194     SPEED_FORWARD_2_00_X,
195 };
196 
197 enum VideoScaleType : int32_t {
198     /**
199      * The content is stretched to the fit the display surface rendering area. When
200      * the aspect ratio of the content is not same as the display surface, the aspect
201      * of the content is not maintained. This is the default scale type.
202      */
203     VIDEO_SCALE_TYPE_FIT = 0,
204 
205     /**
206      * The content is stretched to the fit the display surface rendering area. When
207      * the aspect ratio of the content is not the same as the display surface, content's
208      * aspect ratio is maintained and the content is cropped to fit the display surface.
209      */
210     VIDEO_SCALE_TYPE_FIT_CROP,
211 };
212 
213 class PlayerCallback {
214 public:
215     virtual ~PlayerCallback() = default;
216     /**
217      * Called when a player message or alarm is received.
218      *
219      * @param type Indicates the information type. For details, see {@link PlayerOnInfoType}.
220      * @param extra Indicates other information, for example, the start time position of a playing file.
221      * @param infoBody According to the info type, the information carrier passed.Is an optional parameter.
222      */
223     virtual void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody) = 0;
224 
225     /**
226      * Called when an error occurred for versions above api9
227      *
228      * @param errorCode Error code.
229      * @param errorMsg Error message.
230      */
231     virtual void OnError(int32_t errorCode, const std::string &errorMsg) = 0;
232 };
233 
234 class Player {
235 public:
236     virtual ~Player() = default;
237 
238     /**
239      * @brief Sets the playback source for the player. The corresponding source can be http url
240      *
241      * @param url Indicates the playback source.
242      * @return Returns {@link MSERR_OK} if the url is set successfully; returns an error code defined
243      * in {@link media_errors.h} otherwise.
244      * @since 1.0
245      * @version 1.0
246      */
247     virtual int32_t SetSource(const std::string &url) = 0;
248 
249     /**
250      * @brief Sets the playback media data source for the player.
251      *
252      * @param dataSrc Indicates the media data source. in {@link media_data_source.h}
253      * @return Returns {@link MSERR_OK} if the mediadatasource is set successfully; returns an error code defined
254      * in {@link media_errors.h} otherwise.
255      * @since 1.0
256      * @version 1.0
257      */
258     virtual int32_t SetSource(const std::shared_ptr<IMediaDataSource> &dataSrc) = 0;
259 
260     /**
261      * @brief Sets the playback media file descriptor source for the player.
262      *
263      * @param fd Indicates the file descriptor of media source.
264      * @param offset Indicates the offset of media source in file descriptor.
265      * @param size Indicates the size of media source.
266      * @return Returns {@link MSERR_OK} if the fd source is set successfully; returns an error code defined
267      * in {@link media_errors.h} otherwise.
268      * @since 1.0
269      * @version 1.0
270      */
271     virtual int32_t SetSource(int32_t fd, int64_t offset = 0, int64_t size = 0) = 0;
272 
273     /**
274      * @brief Add a subtitle source for the player. The corresponding source can be http url.
275      *
276      * @param url Indicates the subtitle source.
277      * @return Returns {@link MSERR_OK} if the url is set successfully; returns an error code defined
278      * in {@link media_errors.h} otherwise.
279      * @since 1.0
280      * @version 1.0
281      */
282     virtual int32_t AddSubSource(const std::string &url) = 0;
283 
284     /**
285      * @brief Add a playback subtitle file descriptor source for the player.
286      *
287      * @param fd Indicates the file descriptor of subtitle source.
288      * @param offset Indicates the offset of subtitle source in file descriptor.
289      * @param size Indicates the size of subtitle source.
290      * @return Returns {@link MSERR_OK} if the fd source is set successfully; returns an error code defined
291      * in {@link media_errors.h} otherwise.
292      * @since 1.0
293      * @version 1.0
294      */
295     virtual int32_t AddSubSource(int32_t fd, int64_t offset = 0, int64_t size = 0) = 0;
296 
297     /**
298      * @brief Start playback.
299      *
300      * This function must be called after {@link Prepare}. If the player state is <b>Prepared</b>,
301      * this function is called to start playback.
302      *
303      * @return Returns {@link MSERR_OK} if the playback is started; otherwise returns an error code defined
304      * in {@link media_errors.h} otherwise.
305      * @since 1.0
306      * @version 1.0
307      */
308     virtual int32_t Play() = 0;
309 
310     /**
311      * @brief Prepares the playback environment and buffers media data asynchronous.
312      *
313      * This function must be called after {@link SetSource}.
314      *
315      * @return Returns {@link MSERR_OK} if {@link Prepare} is successfully added to the task queue;
316      * returns an error code defined in {@link media_errors.h} otherwise.
317      * @since 1.0
318      * @version 1.0
319      */
320     __attribute__((deprecated)) virtual int32_t Prepare() = 0;
321 
322     /**
323      * @brief Prepares the playback environment and buffers media data asynchronous.
324      *
325      * This function must be called after {@link SetSource}.
326      *
327      * @return Returns {@link MSERR_OK} if {@link PrepareAsync} is successfully added to the task queue;
328      * returns an error code defined in {@link media_errors.h} otherwise.
329      * @since 1.0
330      * @version 1.0
331      */
332     virtual int32_t PrepareAsync() = 0;
333 
334     /**
335      * @brief Pauses playback.
336      *
337      * @return Returns {@link MSERR_OK} if {@link Pause} is successfully added to the task queue;
338      * returns an error code defined in {@link media_errors.h} otherwise.
339      * @since 1.0
340      * @version 1.0
341      */
342     virtual int32_t Pause() = 0;
343 
344     /**
345      * @brief Stop playback.
346      *
347      * @return Returns {@link MSERR_OK} if {@link Stop} is successfully added to the task queue;
348      * returns an error code defined in {@link media_errors.h} otherwise.
349      * @since 1.0
350      * @version 1.0
351      */
352     virtual int32_t Stop() = 0;
353 
354     /**
355      * @brief Restores the player to the initial state.
356      *
357      * After the function is called, add a playback source by calling {@link SetSource},
358      * call {@link Play} to start playback again after {@link Prepare} is called.
359      *
360      * @return Returns {@link MSERR_OK} if {@link Reset} is successfully added to the task queue;
361      * returns an error code defined in {@link media_errors.h} otherwise.
362      * @since 1.0
363      * @version 1.0
364      */
365     virtual int32_t Reset() = 0;
366 
367     /**
368      * @brief Releases player resources async
369      *
370      *  Asynchronous release guarantees the performance
371      *  but cannot ensure whether the surfacebuffer is released.
372      *  The caller needs to ensure the life cycle security of the sufrace
373      *
374      * @return Returns {@link MSERR_OK} if {@link Release} is successfully added to the task queue;
375      * returns an error code defined in {@link media_errors.h} otherwise.
376      * @since 1.0
377      * @version 1.0
378      */
379     virtual int32_t Release() = 0;
380 
381     /**
382      * @brief Sets the volume of the player.
383      *
384      * This function can be used during playback or pause. The value <b>0</b> indicates no sound,
385      * and <b>1</b> indicates the original volume. If no audio device is started or no audio
386      * stream exists, the value <b>-1</b> is returned.
387      *
388      * @param leftVolume Indicates the target volume of the left audio channel to set,
389      *        ranging from 0 to 1. each step is 0.01.
390      * @param rightVolume Indicates the target volume of the right audio channel to set,
391      *        ranging from 0 to 1. each step is 0.01.
392      * @return Returns {@link MSERR_OK} if the volume is set; returns an error code defined
393      * in {@link media_errors.h} otherwise.
394      * @since 1.0
395      * @version 1.0
396      */
397     virtual int32_t SetVolume(float leftVolume, float rightVolume) = 0;
398 
399     /**
400      * @brief Changes the playback position.
401      *
402      * This function can be used during play or pause.
403      *
404      * @param mSeconds Indicates the target playback position, accurate to milliseconds.
405      * @param mode Indicates the player seek mode. For details, see {@link PlayerSeekMode}.
406      * @return Returns {@link MSERR_OK} if the seek is done; returns an error code defined
407      * in {@link media_errors.h} otherwise.
408      * @since 1.0
409      * @version 1.0
410     */
411     virtual int32_t Seek(int32_t mSeconds, PlayerSeekMode mode) = 0;
412 
413     /**
414      * @brief Obtains the playback position, accurate to millisecond.
415      *
416      * @param currentTime Indicates the playback position.
417      * @return Returns {@link MSERR_OK} if the current position is get; returns an error code defined
418      * in {@link media_errors.h} otherwise.
419      * @since 1.0
420      * @version 1.0
421      */
422     virtual int32_t GetCurrentTime(int32_t &currentTime) = 0;
423 
424     /**
425      * @brief Obtains the video track info, contains mimeType, bitRate, width, height, frameRata.
426      *
427      * @param video track info vec.
428      * @return Returns {@link MSERR_OK} if the track info is get; returns an error code defined
429      * in {@link media_errors.h} otherwise.
430      * @since 1.0
431      * @version 1.0
432      */
433     virtual int32_t GetVideoTrackInfo(std::vector<Format> &videoTrack) = 0;
434 
435     /**
436      * @brief Obtains the audio track info, contains mimeType, bitRate, sampleRate, channels, language.
437      *
438      * @param audio track info vec.
439      * @return Returns {@link MSERR_OK} if the track info is get; returns an error code defined
440      * in {@link media_errors.h} otherwise.
441      * @since 1.0
442      * @version 1.0
443      */
444     virtual int32_t GetAudioTrackInfo(std::vector<Format> &audioTrack) = 0;
445 
446     /**
447      * @brief get the video width.
448      *
449      * @return Returns width if success; else returns 0
450      * @since 1.0
451      * @version 1.0
452      */
453     virtual int32_t GetVideoWidth() = 0;
454 
455     /**
456      * @brief get the video height.
457      *
458      * @return Returns height if success; else returns 0
459      * @since 1.0
460      * @version 1.0
461      */
462     virtual int32_t GetVideoHeight() = 0;
463 
464     /**
465      * @brief Obtains the total duration of media files, accurate to milliseconds.
466      *
467      * @param duration Indicates the total duration of media files.
468      * @return Returns {@link MSERR_OK} if the current duration is get; returns an error code defined
469      * in {@link media_errors.h} otherwise.
470      * @since 1.0
471      * @version 1.0
472      */
473     virtual int32_t GetDuration(int32_t &duration) = 0;
474 
475     /**
476      * @brief set the player playback rate
477      *
478      * @param mode the rate mode {@link PlaybackRateMode} which can set.
479      * @return Returns {@link MSERR_OK} if the playback rate is set successful; returns an error code defined
480      * in {@link media_errors.h} otherwise.
481      * @since 1.0
482      * @version 1.0
483      */
484     virtual int32_t SetPlaybackSpeed(PlaybackRateMode mode) = 0;
485 
486     /**
487      * @brief get the current player playback rate
488      *
489      * @param mode the rate mode {@link PlaybackRateMode} which can get.
490      * @return Returns {@link MSERR_OK} if the current player playback rate is get; returns an error code defined
491      * in {@link media_errors.h} otherwise.
492      * @since 1.0
493      * @version 1.0
494      */
495     virtual int32_t GetPlaybackSpeed(PlaybackRateMode &mode) = 0;
496 
497     /**
498      * @brief set the bit rate use for hls player
499      * the playback bitrate expressed in bits per second, expressed in bits per second,
500      * which is only valid for HLS protocol network flow. By default,
501      * the player will select the appropriate bit rate and speed according to the network connection.
502      * report the effective bit rate linked list by "INFO_TYPE_BITRATE_COLLECT"
503      * set and select the specified bit rate, and select the bit rate that is less than and closest
504      * to the specified bit rate for playback. When ready, read it to query the currently selected bit rate.
505      * @param bitRate the bit rate, The unit is bps.
506      * @return Returns {@link MSERR_OK} if the bit rate is set successfully; returns an error code defined
507      * in {@link media_errors.h} otherwise.
508      * @since 1.0
509      * @version 1.0
510      */
511     virtual int32_t SelectBitRate(uint32_t bitRate) = 0;
512 
513 #ifdef SUPPORT_AUDIO_ONLY
514 #else
515     /**
516      * @brief Method to set the surface.
517      *
518      * @param surface pointer of the surface.
519      * @return Returns {@link MSERR_OK} if the surface is set; returns an error code defined
520      * in {@link media_errors.h} otherwise.
521      * @since 1.0
522      * @version 1.0
523      */
524     virtual int32_t SetVideoSurface(sptr<Surface> surface) = 0;
525 #endif
526 
527     /**
528      * @brief Checks whether the player is playing.
529      *
530      * @return Returns true if the playback is playing; false otherwise.
531      * @since 1.0
532      * @version 1.0
533      */
534     virtual bool IsPlaying() = 0;
535 
536     /**
537      * @brief Returns the value whether single looping is enabled or not .
538      *
539      * @return Returns true if the playback is single looping; false otherwise.
540      * @since 1.0
541      * @version 1.0
542      */
543     virtual bool IsLooping() = 0;
544 
545     /**
546      * @brief Enables single looping of the media playback.
547      *
548      * @return Returns {@link MSERR_OK} if the single looping is set; returns an error code defined
549      * in {@link media_errors.h} otherwise.
550      * @since 1.0
551      * @version 1.0
552      */
553     virtual int32_t SetLooping(bool loop) = 0;
554 
555     /**
556      * @brief Method to set player callback.
557      *
558      * @param callback object pointer.
559      * @return Returns {@link MSERR_OK} if the playercallback is set; returns an error code defined
560      * in {@link media_errors.h} otherwise.
561      * @since 1.0
562      * @version 1.0
563      */
564     virtual int32_t SetPlayerCallback(const std::shared_ptr<PlayerCallback> &callback) = 0;
565 
566     /**
567      * @brief Sets an extended parameter for player
568      *
569      * @param format Indicates the string key and value. For details, see {@link Format}
570      * @return Returns {@link MSERR_OK} if the parameters are set; returns an error code defined
571      * in {@link media_errors.h} otherwise.
572      * @since 1.0
573      * @version 1.0
574      */
575     virtual int32_t SetParameter(const Format &param) = 0;
576 
577     /**
578      * @brief Releases player resources sync
579      *
580      * Synchronous release ensures effective release of surfacebuffer
581      * but this interface will take a long time (when the engine is not idle state)
582      * requiring the caller to design an asynchronous mechanism by itself
583      *
584      * @return Returns {@link MSERR_OK} if the playback is released; returns an error code defined
585      * in {@link media_errors.h} otherwise.
586      * @since 1.0
587      * @version 1.0
588      */
589     virtual int32_t ReleaseSync() = 0;
590 
591     /**
592      * @brief Select audio or subtitle track.
593      * By default, the first audio stream with data is played, and the subtitle track is not played.
594      * After the settings take effect, the original track will become invalid. Please set subtitles
595      * in prepared/playing/paused/completed state and set audio tracks in prepared state.
596      *
597      * @param index Track index, reference {@link #GetAudioTrackInfo} and {@link #GetVideoTrackInfo}.
598      * @return Returns {@link MSERR_OK} if selected successfully; returns an error code defined
599      * in {@link media_errors.h} otherwise.
600      * @since 1.0
601      * @version 1.0
602     */
603     virtual int32_t SelectTrack(int32_t index) = 0;
604 
605     /**
606      * @brief Deselect the current audio or subtitle track.
607      * After audio is deselected, the default track will be played, and after subtitles are deselected,
608      * they will not be played. Please set subtitles in prepared/playing/paused/completed state and set
609      * audio tracks in prepared state.
610      *
611      * @param index Track index, reference {@link #GetAudioTrackInfo} and {@link #GetVideoTrackInfo}.
612      * @return Returns {@link MSERR_OK} if selected successfully; returns an error code defined
613      * in {@link media_errors.h} otherwise.
614      * @since 1.0
615      * @version 1.0
616     */
617     virtual int32_t DeselectTrack(int32_t index) = 0;
618 
619     /**
620      * @brief Obtain the currently effective track index.
621      * Please get it in the prepared/playing/paused/completed state.
622      *
623      * @param trackType Media type.
624      * @param index Track index, reference {@link #GetAudioTrackInfo} and {@link #GetVideoTrackInfo}.
625      * @return Returns {@link MSERR_OK} if the track index is get; returns an error code defined
626      * in {@link media_errors.h} otherwise.
627      * @since 1.0
628      * @version 1.0
629      */
630     virtual int32_t GetCurrentTrack(int32_t trackType, int32_t &index) = 0;
631 
632     /**
633      * @brief Obtains the subtitle track info, contains mimeType, type, language.
634      *
635      * @param subtitle track info vec.
636      * @return Returns {@link MSERR_OK} if the track info is get; returns an error code defined
637      * in {@link media_errors.h} otherwise.
638      * @since 1.0
639      * @version 1.0
640      */
641     virtual int32_t GetSubtitleTrackInfo(std::vector<Format> &subtitleTrack) = 0;
642 };
643 
644 class __attribute__((visibility("default"))) PlayerFactory {
645 public:
646 #ifdef UNSUPPORT_PLAYER
CreatePlayer()647     static std::shared_ptr<Player> CreatePlayer()
648     {
649         return nullptr;
650     }
651 #else
652     static std::shared_ptr<Player> CreatePlayer();
653 #endif
654 private:
655     PlayerFactory() = default;
656     ~PlayerFactory() = default;
657 };
658 } // namespace Media
659 } // namespace OHOS
660 #endif // PLAYER_H
661