Support video capture during playback
[platform/core/multimedia/esplusplayer.git] / include / plusplayer / esplusplayer.h
1 /**
2  * @file           esplusplayer.h
3  * @brief          the playback for elementary stream
4  * @interfacetype  Module
5  * @privlevel      None-privilege
6  * @privilege      None
7  * @product        TV, AV, B2B
8  * @version        0.0.1
9  * @SDK_Support    N
10  *
11  * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
12  * PROPRIETARY/CONFIDENTIAL
13  * This software is the confidential and proprietary
14  * information of SAMSUNG ELECTRONICS ("Confidential Information"). You shall
15  * not disclose such Confidential Information and shall use it only in
16  * accordance with the terms of the license agreement you entered into with
17  * SAMSUNG ELECTRONICS. SAMSUNG make no representations or warranties about the
18  * suitability of the software, either express or implied, including but not
19  * limited to the implied warranties of merchantability, fitness for a
20  * particular purpose, or non-infringement. SAMSUNG shall not be liable for any
21  * damages suffered by licensee as a result of using, modifying or distributing
22  * this software or its derivatives.
23  */
24 #ifndef __PLUSPLAYER_ESPLUSPLAYER__H__
25 #define __PLUSPLAYER_ESPLUSPLAYER__H__
26
27 #include <boost/core/noncopyable.hpp>
28 #include <list>
29 #include <map>
30 #include <memory>
31 #include <string>
32 #include <utility>
33 #include <vector>
34
35 #include "plusplayer/drm.h"
36 #include "plusplayer/elementary_stream.h"
37 #include "plusplayer/es_eventlistener.h"
38 #include "plusplayer/espacket.h"
39 #include "plusplayer/external_drm.h"
40 #include "plusplayer/types/buffer.h"
41 #include "plusplayer/types/display.h"
42 #include "plusplayer/types/error.h"
43 #include "plusplayer/types/submitdata.h"
44
45 namespace plusplayer {
46
47 /**
48  * @brief  Enumerations for es player state.
49  */
50 enum class EsState {
51   kNone,     // Player is created, but not opened
52   kIdle,     // Player is opened, but not prepared or player is stopped
53   kReady,    // Player is ready to play(start)
54   kPlaying,  // Player is playing media
55   kPaused,   // Player is paused while playing media
56 };
57 /**
58  * @brief  Enumerations for espacket submit status.
59  */
60 enum class PacketSubmitStatus {
61   kNotPrepared,    // not prepared to get packet
62   kInvalidPacket,  // invalid packet
63   kOutOfMemory,    // out of memory on device
64   kFull,           // buffer already full
65   kSuccess         // submit succeeded
66 };
67 /**
68  * @brief  Enumerations for adaptive info type.
69  */
70 enum class PlayerAdaptiveInfo {
71   kMinType,
72   kVideoDroppedFrames,
73   kDroppedVideoFramesForCatchup,
74   kDroppedAudioFramesForCatchup,
75   kMaxType,
76 };
77 /**
78  * @brief   Enumerations for low latency mode
79  */
80 enum PlayerLowLatencyMode {
81   kLowLatencyModeNone = 0x0000,
82   /**
83    * @description   to support audio fast decoding/rendering
84    */
85   kLowLatencyModeAudio = 0x0001,
86   /**
87    * @description   to support video fast decoding/rendering
88    *                only this value is set, it does not support seamless resolution change.
89    */
90   kLowLatencyModeVideo = 0x0010,
91   /**
92    * @description   to support video fast decoding/rendering and video
93                     distortion concealment.
94                     Video stream should be composed only of P and I frames.
95                     For applications using the UDP protocol, packet loss can
96                     occur. when video distortion by video packet loss is
97                     detected, it is a function to conceal distortion by showing
98                     previous vido frame. It is supported only in h.264 codec &
99                     FHD or lower resolution.
100    */
101   kLowLatencyModeVideoDistortionConcealment = kLowLatencyModeVideo | 0x0020,
102   /**
103    * @description   to support video fast decoding/rendering and video
104    *                with seamless resolution change.
105    */
106   kLowLatencyModeVideoWithSeamlessResolutionChange = 0x0040,
107   /**
108    * @description   to disable clock sync and a/v sync when rendering. it
109    *                includes #kLowLatencyModeDisablePreroll.
110    */
111   kLowLatencyModeDisableAVSync = 0x0100,
112   /**
113    * @description   to disable preroll which means player doesn't wait for
114    *                first buffer when state is changed to
115    *                #EsState::kReady from #EsState::kIdle.
116    *                It changes the state immediately.
117    *                It's usually used for sparse stream. (e.g. video packet
118    *                arrives but audio packet does't yet.)
119    */
120   kLowLatencyModeDisablePreroll = 0x0200,
121   /**
122    * @description   to set lower video quality
123    */
124   kLowLatencyModeDisableVideoQuality = 0x1000,
125   /**
126    * @description   to set game mode
127    */
128   kLowLatencyModeEnableGameMode = 0x2000
129 };
130
131 /**
132  * @brief   Enumerations for player audio codec type
133  */
134 enum PlayerAudioCodecType {
135   /**
136    * @description   hardware codec can only be selected, default type
137    */
138   kPlayerAudioCodecTypeHW,
139   /**
140    * @description   software codec can only be selected.
141    */
142   kPlayerAudioCodecTypeSW,
143 };
144
145 /**
146  * @brief   Enumerations for player video codec type
147  */
148 enum PlayerVideoCodecType {
149   /**
150    * @description   hardware codec can only be selected, default type
151    */
152   kPlayerVideoCodecTypeHW,
153   /**
154    * @description   software codec can only be selected.
155    */
156   kPlayerVideoCodecTypeSW,
157   /**
158    * @description   hardware codec using n-decoding mode can only be selected.
159                     It must set display type to mixer type by display setting api.
160    */
161   kPlayerVideoCodecTypeHWNdecoding,
162 };
163
164 /**
165  * @brief  the interface of the playback class for elementary stream
166  */
167 class EsPlusPlayer : private boost::noncopyable {
168  public:
169   using Ptr = std::unique_ptr<EsPlusPlayer>;
170   /**
171    * @brief     Create a esplusplayer object
172    * @remarks   You must use this to get esplusplayer object
173    * @return    Player object (unique_ptr<EsPlusPlayer>)
174    */
175   static Ptr Create();
176
177  public:
178   virtual ~EsPlusPlayer() {}
179   /**
180    * @brief     Make player get ready to set playback mode
181    * @remarks   General call sequence to start playback:
182    *            Open() -> SetStream() -> PrepareAsync() -> Start() -> Stop() ->
183    * Close()
184    * @pre       Player state must be kNone
185    * @post      The player state will be EsState::kIdle
186    * @return    @c True on success, otherwise @c False
187    * @see       Close()
188    */
189   virtual bool Open() { return false; }
190   /**
191    * @brief     Release all the player resources
192    * @pre       The player state must be one of
193    *            EsState::kIdle or EsState::kNone
194    * @post      The player state will be kNone
195    * @return    @c True on success, otherwise @c False
196    * @see       EsPlusPlayer::Open()
197    */
198   virtual bool Close() { return false; }
199
200   /**
201    * @brief     Flush the specific buffered stream data and release TV resource
202    *            to change stream.
203    * @remark    To activate, the stream must be set again.
204    * @pre       The player must be set to at least #EsState::kReady
205    * @post       The player state is same as before calling Deactivate().
206    * @return    @c True on success, otherwise @c False.
207    * @see       EsPlusPlayer::Deactivate().
208    */
209   virtual bool Deactivate(const StreamType type) { return false; }
210
211   /**
212    * @brief     Reprepare for the specific stream playback.
213    * @remark    There must be active stream to prepare playback.
214    * @pre       The player must be set to at least #EsState::kReady
215    *            The StreamType must be deactivated in advance.
216    *            Stream should be set in advance.
217    * @return    @c True on success, otherwise @c False
218    * @code
219       PrepareAsync();
220       Deactivate(StreamType::kVideo);
221       VideoStreamPtr video_stream = VideoStream::Create();
222       video_stream->SetMimeType(VideoMimeType::kH264);
223       video_stream->SetWidth(640);
224       video_stream->SetHeight(352);
225       video_stream->SetFramerate(30, 1);
226       SetStream(video_stream);
227       Activate(StreamType::kVideo);
228    * @endcode
229    * @see       EsPlusPlayer::Activate()
230    */
231   virtual bool Activate(const StreamType type) { return false; }
232
233   /**
234    * @brief     Prepare the player for playback, asynchronously.
235    * @remarks   EsEventListener::OnPrepareDone() will be called when prepare is
236    * finished
237    *
238    * @pre       The player state must be set to #EsState::kIdle
239    * @post      The player state will be #EsState::kReady
240    * @return    @c true if async task is correctly started
241    * @see       EsPlusPlayer::Open() \n
242    *            EsPlusPlayer::Stop() \n
243    *            EsPlusPlayer::SubmitPacket()
244    */
245   virtual bool PrepareAsync() { return false; }
246   /**
247    * @brief     Start playback
248    * @pre       The player state should be #EsState::kReady
249    * @post      The player state will be #EsState::kPlaying
250    * @return    @c True on success, otherwise @c False
251    * @see       EsPlusPlayer::Open() \n
252    *            EsPlusPlayer::PrepareAsync() \n
253    *            EsPlusPlayer::Stop() \n
254    *            EsPlusPlayer::Close()
255    */
256   virtual bool Start() { return false; }
257   /**
258    * @brief     Stop playing media content
259    * @remarks   EsPlusPlayer::Close() must be called once after player is
260    * stopped
261    * @pre       The player state must be all of #EsState except #EsState::kNone
262    * @post      The player state will be #EsState::kIdle
263    * @return    @c True on success, otherwise @c False
264    * @see       EsPlusPlayer::Open() \n
265    *            EsPlusPlayer::PrepareAsync() \n
266    *            EsPlusPlayer::Start() \n
267    *            EsPlusPlayer::Pause() \n
268    *            EsPlusPlayer::Resume() \n
269    *            EsPlusPlayer::Close()
270    */
271   virtual bool Stop() { return false; }
272   /**
273    * @brief     Pause playing media content
274    * @remarks   You can resume playback by using EsPlusPlayer::Resume()
275    * @pre       The player state must be one of #EsState::kReady or
276    * #EsState::kPlaying or #EsState::kPaused
277    * @post      The player state will be #EsState::kPaused
278    * @return    @c True on success, otherwise @c False
279    * @see       EsPlusPlayer::Start() \n
280    *            EsPlusPlayer::Resume()
281    */
282   virtual bool Pause() { return false; }
283   /**
284    * @brief     Resume a media content
285    * @pre       The player state must be one of #EsState::kPlaying or
286    * #EsState::kPaused
287    * @post      The player state will be #EsState::kPlaying
288    * @return    @c True on success, otherwise @c False
289    * @see       EsPlusPlayer::Start() \n
290    *            EsPlusPlayer::Pause()
291    */
292   virtual bool Resume() { return false; }
293   /**
294    * @brief     SetPlaybackRate.
295    * @remarks   Set playback rate from 0.0 to 2.0.
296    * @param     [in] rate : The playback rate from 0.0 to 2.0. EsPlayer isn't
297    * support trick play.
298    * @param     [in] audio_mute : The audio is mute on/off,true: mute on, false:
299    * mute off.
300    * @pre       The source and feeder have to push the data as fast as playback
301    * rate.
302    * @return    @c True if set playback rate is finished without any problem
303    * otherwise @c False
304    */
305   virtual bool SetPlaybackRate(const double rate, bool audio_mute) {
306     return false;
307   }
308   /**
309    * @brief     Seek for playback, asynchronously.
310    * @remarks   EsEventListener::OnSeekDone() will be called if seek operation
311    * is finished \n Seek result can be succeeded or not at this moment. \n
312    * @param     [in] time_millisecond : the absolute position(playingtime) of
313    * the stream in milliseconds
314    * @pre       The player state must be one of #EsState::kReady,
315    * #EsState::kPlaying or #EsState::kPaused
316    * @return    @c True if seek operation is started without any problem
317    * otherwise @c False
318    * @see       EsEventListener::OnSeekDone() \n
319    *            EsPlusPlayer::SubmitPacket()
320    */
321   virtual bool Seek(const uint64_t time_millisecond) { return false; }
322   /**
323    * @brief     Set the video display
324    * @remarks   We are not supporting changing display.
325    * @remarks   This API have to be called before calling the
326    * EsPlusPlayer::PrepareAsync() to reflect the display type.
327    * @param     [in] type : display type
328    * @param     [in] obj : The handle to display window
329    * @pre       The player state must be set to #EsState::kIdle
330    * @return    @c True on success, otherwise @c False
331    * @see       DisplayType \n
332    *            EsPlusPlayer::SetDisplayMode() \n
333    *            EsPlusPlayer::SetDisplayRoi() \n
334    *            EsPlusPlayer::SetDisplayVisible()
335    */
336   virtual bool SetDisplay(const DisplayType& type, void* obj) { return false; }
337   /**
338    * @brief     Set the video display
339    * @remarks   We are not supporting changing display.
340    * @remarks   This API have to be called before calling the
341    * EsPlusPlayer::PrepareAsync() to reflect the display type.
342    * @param     [in] type : display type
343    * @param     [in] ecore_wl2_window : The ecore wayland window handle
344    * @param     [in] x : x param of display window
345    * @param     [in] y : y param of display window
346    * @param     [in] w : width of display window
347    * @param     [in] h : height of display window
348    * @pre       The player state must be set to #EsState::kIdle
349    * @return    @c True on success, otherwise @c False
350    * @see       DisplayType \n
351    *            EsPlusPlayer::SetDisplayMode() \n
352    *            EsPlusPlayer::SetDisplayRoi() \n
353    *            EsPlusPlayer::SetDisplayVisible()
354    */
355   virtual bool SetDisplay(const DisplayType& type, void* ecore_wl2_window,
356                           const int x, const int y, const int w, const int h) {
357     return false;
358   }
359   /**
360    * @brief     Set the video display
361    * @remarks   We are not supporting changing display.
362    * @remarks   This API have to be called before calling the
363    * EsPlusPlayer::PrepareAsync() to reflect the display type.
364    * @param     [in] type : display type
365    * @param     [in] surface_id : resource id of window.
366    * @param     [in] x : x param of display window
367    * @param     [in] y : y param of display window
368    * @param     [in] w : width of display window
369    * @param     [in] h : height of display window
370    * @pre       The player state must be set to #EsState::kIdle
371    * @return    @c True on success, otherwise @c False
372    * @see       DisplayType \n
373    *            EsPlusPlayer::SetDisplayMode() \n
374    *            EsPlusPlayer::SetDisplayRoi() \n
375    *            EsPlusPlayer::SetDisplayVisible()
376    */
377   virtual bool SetDisplay(const DisplayType& type, unsigned int surface_id,
378                           const int x, const int y, const int w, const int h) {
379     return false;
380   }
381   /**
382    * @brief     Set the video display mode
383    * @param     [in] mode : display mode
384    * @pre       The player state can be all of #EsState except #EsState::kNone
385    * @return    @c True on success, otherwise @c False
386    * @see       #DisplayMode
387    * @see       EsPlusPlayer::SetDisplay()
388    * @see       EsPlusPlayer::SetDisplayRoi()
389    * @see       EsPlusPlayer::SetDisplayVisible()
390    */
391   virtual bool SetDisplayMode(const DisplayMode& mode) { return false; }
392   /**
393    * @brief     Set the ROI(Region Of Interest) area of display
394    * @remarks   The minimum value of width and height are 1.
395    * @param     [in] roi : Roi Geometry
396    * @pre       The player state can be all of #EsState except #EsState::kNone
397    * \n Before set display ROI, #DisplayMode::kDstRoi must be set with
398    * EsPlusPlayer::SetDisplayMode().
399    * @return    @c True on success, otherwise @c False
400    * @see       DisplayMode \n
401    *            EsPlusPlayer::SetDisplay() \n
402    *            EsPlusPlayer::SetDisplayMode() \n
403    *            EsPlusPlayer::SetDisplayVisible()
404    */
405   virtual bool SetDisplayRoi(const Geometry& roi) { return false; }
406
407   /**
408    * @brief     Set scaled area ratio of display
409    * @param     [in] area : Crop ratio of src area
410    * @pre       The player state can be all of #EsState except #EsState::kNone
411    * @return    @c True on success, otherwise @c False
412    * @remark    The minimum value of input are 0,maximun is 1.
413    */
414   virtual bool SetVideoRoi(const CropArea& area) { return false; }
415
416   /**
417    * @brief     Set the rotate angle of display
418    * @remarks   The default value is 0.
419    * @param     [in] rotate : Rotate angle.
420    * @pre       The player state can be all of #EsState except #EsState::kNone
421    * @return    @c True on success, otherwise @c False
422    * @see       EsPlusPlayer::SetDisplay()
423    */
424   virtual bool SetDisplayRotate(const DisplayRotation& rotate) { return false; }
425
426   /**
427    * @brief     Get the rotate angle of display
428    * @remarks   The default value is 0.
429    * @param     [out] rotate : Stored rotate angle value.
430    * @pre       The player state can be all of #EsState except #EsState::kNone
431    * @return    @c True on success, otherwise @c False
432    * @see       EsPlusPlayer::SetDisplayRotate()
433    */
434   virtual bool GetDisplayRotate(DisplayRotation* rotate) { return false; }
435
436   /**
437    * @brief     Set the visibility of the video display
438    * @param     [in] is_visible : The visibility of the display
439    *            (@c true = visible, @c false = non-visible)
440    * @pre       The player state can be all of #EsState except #EsState::kNone
441    * @return    @c True on success, otherwise @c False
442    * @see       EsPlusPlayer::SetDisplay()
443    */
444   virtual bool SetDisplayVisible(bool is_visible) { return false; }
445
446   /**
447    * @deprecated Use SetSubmitDataType instead.
448    * @brief     Set whether to send decrypted es packets in the trust zone
449    * @remarks   This API have to be called before calling the
450    * EsPlusPlayer::PrepareAsync() \n If is_using_tz is set to true, use
451    * EsPlusPlayer::SubmitTrustZonePacket() to send decrypted packets \n
452    * @param     [in] is_using_tz : whether to use trust zone memory
453    *            (@c true = if decrypted packets are sent in trust zone, @c false
454    * = otherwise)
455    * @pre       The player state must be set to #EsState::kIdle
456    * @return    @c True on success, otherwise @c False
457    * @see       EsPlusPlayer::SubmitTrustZonePacket()
458    */
459   virtual bool SetTrustZoneUse(bool is_using_tz) { return false; }
460   /**
461    * @brief     Set whether to send decrypted es packets in the trust zone or
462    * encrypted es packets
463    * @remarks   This API have to be called before calling the
464    *            EsPlusPlayer::PrepareAsync() \n
465    *            If type is kCleanData, Use SubmitPacket() \n
466    *            If type is kTrustZoneData, Use SubmitTrustZonePacket() \n
467    *            If type is kEncryptedData, Use SubmitEncryptedPacket()
468    * @param     [in] type : whether to use trust zone memory or encrypted data
469    * @pre       The player state must be set to #EsState::kIdle
470    * @return    @c True on success, otherwise @c False
471    * @see       EsPlusPlayer::SubmitPacket() \n
472    *            EsPlusPlayer::SubmitTrustZonePacket() \n
473    *            EsPlusPlayer::SubmitEncryptedPacket() \\n
474    *            SubmitDataType
475    */
476   virtual bool SetSubmitDataType(SubmitDataType type) { return false; }
477   /**
478    * @brief     Set audio stream to have contents information
479    * @remarks   This API have to be called before calling the
480    * EsPlusPlayer::PrepareAsync()
481    * @param     [in] stream : audio stream object
482    * @pre       The player state must be set to #EsState::kIdle
483    * @return    @c True on success, otherwise @c False
484    * @see       AudioStream
485    */
486   virtual bool SetStream(const AudioStreamPtr& stream) { return false; }
487   /**
488    * @brief     Set video stream to have contents information
489    * @remarks   This API have to be called before calling the
490    * EsPlusPlayer::PrepareAsync()
491    * @param     [in] stream : video stream object
492    * @pre       The player state must be set to #EsState::kIdle
493    * @return    @c True on success, otherwise @c False
494    * @see       VideoStream
495    */
496   virtual bool SetStream(const VideoStreamPtr& stream) { return false; }
497   /**
498    * @brief     Submit es packet to decode audio or video
499    * @remarks   Amount of packets for at least one decoded frame must be
500    * submitted after EsPlusPlayer::PrepareAsync() or EsPlusPlayer::Seek() for
501    * calling the EsPlusPlayer::OnPrepareDone() or EsPlusPlayer::OnSeekDone() \n
502    *            User can submit es packets when EsPlusPlayer::OnReadyToPrepare()
503    *            or EsPlusPlayer::OnReadyToSeek() is called \n
504    *            To use this api, Must set SubmitDataType::kCleanData using
505    *            SetSubmitDataType() or Don't set any SubmitDataType \n
506    *            This api must be called from a different thread than other apis
507    * @param     [in] packet : es packet object
508    * @pre       The player state can be all of #EsState except #EsState::kNone
509    * @return    @c PacketSubmitStatus::kSuccess : succeed to submit es packet
510    *            @c otherwise : fail to submit es packet
511    * @see       SetSubmitDataType() \n
512    *            EsPacket \n
513    *            OnBufferStatus \n
514    *            OnReadyToPrepare \n
515    *            OnReadyToSeek \n
516    *            PacketSubmitStatus
517    */
518   virtual PacketSubmitStatus SubmitPacket(const EsPacketPtr& packet) {
519     return PacketSubmitStatus::kNotPrepared;
520   }
521   /**
522    * @brief     Submit es packet to decode audio or video in the trust zone
523    * @remarks   Amount of decrypted packets for at least one decoded frame must
524    * be submitted after EsPlusPlayer::PrepareAsync() or EsPlusPlayer::Seek() for
525    * calling the EsPlusPlayer::OnPrepareDone() or EsPlusPlayer::OnSeekDone() \n
526    *            User can submit es packets when EsPlusPlayer::OnReadyToPrepare()
527    *            or EsPlusPlayer::OnReadyToSeek() is called \n
528    *            EsPlusPlayer::SetTrustZoneUse() must be set to true \n
529    *            To use this api, Must set SubmitDataType::kTrustZoneData using
530    *            SetSubmitDataType() \n
531    *            This api must be called from a different thread than other apis.
532    * @param     [in] packet : es packet object
533    *            [in] tz_handle : a handle for es packet in the trust zone
534    * @pre       The player state can be all of #EsState except #EsState::kNone
535    * @return    @c PacketSubmitStatus::kSuccess : succeed to submit es packet
536    *            @c otherwise : fail to submit es packet
537    * @see       SetSubmitDataType() \n
538    *            EsPacket \n
539    *            OnBufferStatus \n
540    *            OnReadyToPrepare \n
541    *            OnReadyToSeek \n
542    *            PacketSubmitStatus
543    */
544   virtual PacketSubmitStatus SubmitTrustZonePacket(const EsPacketPtr& packet,
545                                                    uint32_t tz_handle = 0) {
546     return PacketSubmitStatus::kNotPrepared;
547   }
548   /**
549    * @brief     Submit encrypted es packet to decode audio or video
550    * @remarks   Amount of encrypted packets for at least one decoded frame must
551    * be submitted after EsPlusPlayer::PrepareAsync() or EsPlusPlayer::Seek() for
552    * calling the EsPlusPlayer::OnPrepareDone() or EsPlusPlayer::OnSeekDone()
553    *            User can submit es packets when EsPlusPlayer::OnReadyToPrepare()
554    *            or EsPlusPlayer::OnReadyToSeek() is called \n
555    *            EsPlusPlayer::SetDrm() must be set to an appropriate drm type \n
556    *            To use this api, Must set SubmitDataType::kEncryptedData using
557    *            SetSubmitDataType() \n
558    *            This api must be called from a different thread than other apis.
559    * @param     [in] packet : encrypted es packet object
560    *            [in] drm_info : information for decryption
561    * @pre       The player state can be all of #EsState except #EsState::kNone
562    * @return    @c PacketSubmitStatus::kSuccess : succeed to submit es packet
563    *            @c PacketSubmitStatus::kFull, PacketSubmitStatus::kNotPrepared :
564    * fail to submit es packet
565    * @see       SetSubmitDataType() \n
566    *            EsPacket \n
567    *            OnBufferStatus \n
568    *            OnReadyToPrepare \n
569    *            OnReadyToSeek \n
570    *            PacketSubmitStatus
571    */
572   virtual PacketSubmitStatus SubmitEncryptedPacket(
573       const EsPacketPtr& packet, const drm::EsPlayerEncryptedInfo& drm_info) {
574     return PacketSubmitStatus::kNotPrepared;
575   }
576   /**
577    * @brief     Get current state of player
578    * @return    current #EsState of player
579    */
580   virtual EsState GetState() { return EsState::kNone; }
581   /**
582    * @brief     Get the current playing time of the associated media.
583    * @param     [out] time_in_milliseconds : current playing time in
584    * milliseconds
585    * @pre       The player must be one of #EsState::kPlaying or
586    * #EsState::kPaused
587    * @return    @c True on success, otherwise @c False
588    *            ("time_in_milliseconds" will be 0)
589    */
590   virtual bool GetPlayingTime(uint64_t* time_in_milliseconds) { return false; }
591   /**
592    * @brief     Get the adaptive info from the plugins
593    * @param     [in] adaptive_type : App wanted get info type
594    * @param     [out] padaptive_info : return value of requested(such as dropped
595    *                    frames)
596    * @pre       The player must be one of #EsState::kPlaying or
597    * #EsState::kPaused or #EsState::kReady
598    * @return    @c True on success, otherwise @c False
599    */
600   virtual bool GetAdaptiveInfo(void* padaptive_info,
601                                const PlayerAdaptiveInfo& adaptive_type) {
602     return false;
603   }
604   /**
605    * @brief     Set on mute of the audio sound
606    * @param     [in] is_mute : On mute of the sound
607    *            (@c true = mute, @c false = non-mute)
608    * @pre       The player state can be all of #EsState except #EsState::kNone
609    * @return    @c True on success, otherwise @c False
610    */
611   virtual bool SetAudioMute(bool is_mute) { return false; }
612
613   /**
614    * @brief     Set decoded video frame buffer type.
615    * @param     [in] type : A type of decoded video frame buffer.
616    * @pre       The player state must be set to #EsState::kIdle
617    */
618   virtual bool SetVideoFrameBufferType(DecodedVideoFrameBufferType type) {
619     return false;
620   }
621
622   /**
623    * @brief     Register eventlistener to player
624    * @param     [in] listener : listener object
625    * @param     [in] userdata : listener object's userdata to be returned via
626    *                            notification without any modification
627    * @pre       The player state can be all of #EsState except #EsState::kNone
628    * @see       EsEventListener
629    */
630   virtual void RegisterListener(EsEventListener* listener,
631                                 EsEventListener::UserData userdata) {
632     return;
633   }
634   /**
635    * @brief     Set volume to player
636    * @param     [in] volume : volume level
637    * @pre       The player state can be all of #EsState except #EsState::kNone
638    * @return       @c True on success, otherwise @c False
639    */
640   virtual bool SetVolume(const int& volume) { return false; }
641   /**
642    * @brief     Get volume to player
643    * @param     [out] volume : volume ptr
644    * @pre       The player state can be all of #EsState except #EsState::kNone
645    * @return       @c True on success, otherwise @c False
646    */
647   virtual bool GetVolume(int* volume) { return false; }
648   /**
649    * @brief     Flush the data in pipeline
650    * @param     [in] type : can be kAudio/kVideo
651    * @pre       The player state can greater than #EsState::kIdle
652    * @return       @c True on success, otherwise @c False
653    */
654   virtual bool Flush(const StreamType& type) { return false; }
655   /**
656    * @brief     Set the buffer size
657    * @param     [in] option : A type of Buffer Option
658    * @pre       The player state must be set to #EsState::kIdle
659    * @return       @c True on success, otherwise @c False
660    */
661   virtual void SetBufferSize(const BufferOption& option, uint64_t size) {
662     return;
663   }
664   /**
665    * @brief     Provided api for setting low latency mode
666    * @remarks   This API have to be called before calling the
667    * EsPlusPlayer::PrepareAsync()
668    * @param     [in] mode : one of the low latency mode to set.
669    * @pre       The player state must be set to #EsState::kIdle
670    * @return    @c True on success, otherwise @c False
671    */
672   virtual bool SetLowLatencyMode(const PlayerLowLatencyMode& mode) {
673     return false;
674   }
675
676   /**
677    * @brief     Provided api for setting unlimited max buffer mode
678    * @remarks   The player does not limit es packet transmission although in
679    *            buffer overrun status.
680    * @pre       The player state must be set to #EsState::kIdle
681    * @return    @c True on success, otherwise @c False
682    */
683   virtual bool SetUnlimitedMaxBufferMode() { return false; }
684   /**
685    * @brief     Provided api for setting audio codec type
686    * @pre       The player state must be set to #EsState::kIdle.
687    * @return    @c True on success, otherwise @c False
688    */
689   virtual bool SetAudioCodecType(const PlayerAudioCodecType& type) {
690     return false;
691   }
692   /**
693    * @brief     Provided api for setting video codec type
694    * @pre       The player state must be set to #EsState::kIdle.
695    * @return    @c True on success, otherwise @c False
696    */
697   virtual bool SetVideoCodecType(const PlayerVideoCodecType& type) {
698     return false;
699   }
700   /**
701    * @brief     Provided api for setting render time offset
702    * @param     [in] type : stream type
703    * @param     [in] offset : offset (milisecond).
704    * @pre       The player state must be set to #EsState::kReady,
705    *            #EsState::kPaused or #EsState::kPlaying.
706    *            It have to be set to low latency mode.
707    * @see       EsPlusPlayer::SetLowLatencyMode()
708    * @return    @c True on success, otherwise @c False
709    */
710   virtual bool SetRenderTimeOffset(const StreamType type, int64_t offset) {
711     return false;
712   }
713   /**
714    * @brief     Provided api for getting render time offset
715    * @param     [in] type : stream type
716    * @param     [out] offset : offset ptr (milisecond).
717    * @pre       The player state must be set to #EsState::kReady,
718    *            #EsState::kPaused or #EsState::kPlaying.
719    *            It have to be set to low latency mode.
720    * @see       EsPlusPlayer::SetLowLatencyMode()
721    * @return    @c True on success, otherwise @c False
722    */
723   virtual bool GetRenderTimeOffset(const StreamType type, int64_t* offset) {
724     return false;
725   }
726   /**
727    * @brief     Get the decoded video packet.
728    * @param     [out] packet
729    * @return    GetDecodedVideoFrameStatus
730    */
731   virtual GetDecodedVideoFrameStatus GetDecodedPacket(
732       DecodedVideoPacket& packet) {
733     return GetDecodedVideoFrameStatus::kUnknown;
734   }
735   /**
736    * @brief     Return the decoded video packet.
737    * @param     [in] packet
738    * @return    @c True on success, otherwise @c False
739    */
740   virtual bool ReturnDecodedPacket(const DecodedVideoPacket& packet) {
741     return false;
742   }
743   /**
744    * @brief     Provided api for enabling video hole
745    * @return    @c True on success, otherwise @c False
746    */
747   virtual bool EnableVideoHole(bool value) { return false; }
748
749  protected:
750   EsPlusPlayer() noexcept {};
751 };  // class EsPlusPlayer
752
753 }  // namespace plusplayer
754
755 #endif  // __PLUSPLAYER_ESPLUSPLAYER__H__