Add the synchronization between Ui and Video player
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / video-player.h
1 #ifndef DALI_VIDEO_PLAYER_H
2 #define DALI_VIDEO_PLAYER_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
24
25 //INTERNAL INCLUDES
26 #include <dali/devel-api/adaptor-framework/video-player-plugin.h>
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31
32 class Any;
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39   class VideoPlayer;
40 } // namespace Adaptor
41
42 } // namespace Internal
43
44 /**
45  * @brief VideoPlayer class is used for video playback.
46  * @SINCE_1_1.38
47  */
48 class DALI_ADAPTOR_API VideoPlayer: public BaseHandle
49 {
50 public:
51
52   /**
53    * @brief Constructor.
54    * @SINCE_1_1.38
55    */
56   VideoPlayer();
57
58   /**
59    * @brief Destructor.
60    * @SINCE_1_1.38
61    */
62   ~VideoPlayer();
63
64   /**
65    * @brief Creates a new instance of a VideoPlayer.
66    * @SINCE_1_1.38
67    */
68   static VideoPlayer New();
69
70   /**
71    * @brief Creates a new instance of a VideoPlayer.
72    *
73    * If you want the video player works with Ui synchronous when video player is resized/moved,
74    * put the video view actor and the enabled syncMode.
75    *
76    * @param[in] actor video view's actor instance
77    * @param[in] syncMode The synchronization mode between the UI (transparent hole) and VideoPlayer.
78    */
79   static VideoPlayer New( Dali::Actor actor, VideoSyncMode syncMode );
80
81  /**
82    * @brief Copy constructor.
83    *
84    * @SINCE_1_1.38
85    * @param[in] player VideoPlayer to copy. The copied player will point at the same implementation
86    */
87   VideoPlayer( const VideoPlayer& player );
88
89  /**
90    * @brief Assignment operator.
91    *
92    * @SINCE_1_1.38
93    * @param[in] player The VideoPlayer to assign from.
94    * @return The updated VideoPlayer.
95    */
96   VideoPlayer& operator=( const VideoPlayer& player );
97
98   /**
99    * @brief Downcast a handle to VideoPlayer handle.
100    *
101    * If handle points to a VideoPlayer the downcast produces valid
102    * handle. If not the returned handle is left uninitialized.
103    *
104    * @SINCE_1_1.38
105    * @param[in] handle Handle to an object
106    * @return Handle to a VideoPlayer or an uninitialized handle
107    */
108   static VideoPlayer DownCast( BaseHandle handle );
109
110   /**
111    * @brief Sets a URL of the video file to play.
112    *
113    * @SINCE_1_1.38
114    * @param [in] url The url of video file
115    */
116   void SetUrl( const std::string& url );
117
118   /**
119    * @brief Returns the URL of the video file.
120    * @SINCE_1_1.38
121    * @return Url of string type
122    */
123   std::string GetUrl();
124
125   /**
126    * @brief Sets the player looping status.
127    * @SINCE_1_1.38
128    *
129    * @param [in] looping The new looping status: true or false
130    */
131   void SetLooping(bool looping);
132
133   /**
134    * @brief Returns the player looping status.
135    * @SINCE_1_1.38
136    *
137    * @return True if player is looping, false otherwise.
138    */
139   bool IsLooping();
140
141   /**
142    * @brief Starts the video playback.
143    * @SINCE_1_1.38
144    */
145   void Play();
146
147   /**
148    * @brief Pauses the video playback.
149    * @SINCE_1_1.38
150    */
151   void Pause();
152
153   /**
154    * @brief Stops the video playback.
155    * @SINCE_1_1.38
156    */
157   void Stop();
158
159   /**
160    * @brief Sets the player mute status.
161    * @SINCE_1_1.38
162    * @param[in] mute The new mute status, true is mute.
163    */
164   void SetMute( bool mute );
165
166   /**
167    * @brief Returns the player mute status.
168    * @SINCE_1_1.38
169    * @return True if player is mute.
170    */
171   bool IsMuted();
172
173   /**
174    * @brief Sets the player volume.
175    * @SINCE_1_1.38
176    * @param[in] left The left volume scalar
177    * @param[in] right The right volume scalar
178    */
179   void SetVolume( float left, float right );
180
181   /**
182    * @brief Returns current volume factor.
183    * @SINCE_1_1.38
184    * @param[out] left The current left volume scalar
185    * @param[out] right The current right volume scalar
186    */
187   void GetVolume( float& left, float& right );
188
189   /**
190    * @brief Sets video rendering target.
191    * @SINCE_1_1.38
192    * @param[in] target The target for video rendering, window surface or native image source
193    */
194   void SetRenderingTarget( Any target );
195
196   /**
197    * @brief Sets the position for playback.
198    * @SINCE_1_1.38
199    *
200    * @param[in] millisecond The position for playback
201    */
202   void SetPlayPosition( int millisecond );
203
204   /**
205    * @brief Gets the current position in milliseconds.
206    * @SINCE_1_1.38
207    *
208    * @return The current position of playback
209    */
210   int GetPlayPosition();
211
212   /**
213    * @brief Sets the area of video display.
214    * @SINCE_1_2.46
215    * param[in] area The left-top position and size of the video display area
216    */
217   void SetDisplayArea( DisplayArea area );
218
219   /**
220    * @brief Sets video display rotation
221    * @SINCE_1_1.38
222    * @param[in] rotation The rotation of display
223    */
224   void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation );
225
226   /**
227    * @brief Returns rotation of current video display
228    * @SINCE_1_1.38
229    * @return The rotation of current display
230    */
231   Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
232
233   /**
234    * @brief Connect to this signal to be notified when a video playback have finished.
235    *
236    * @SINCE_1_1.38
237    * @return A signal object to connect with.
238    */
239   Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
240
241   /**
242    * @brief Seeks forward by the specified number of milliseconds.
243    *
244    * @SINCE_1_2.46
245    * @param[in] millisecond The position for forward playback
246    */
247   void Forward( int millisecond );
248
249   /**
250    * @brief Seeks backward by the specified number of milliseconds.
251    *
252    * @SINCE_1_2.46
253    * @param[in] millisecond The position for backward playback
254    */
255   void Backward( int millisecond );
256
257   /**
258    * @brief Checks whether the video texture is supported
259    * @return True if supported, otherwise false.
260    */
261   bool IsVideoTextureSupported();
262
263   /**
264    * @brief Sets codec type
265    * @param[in] type The VideoCodec::Type
266    */
267   void SetCodecType( Dali::VideoPlayerPlugin::CodecType type );
268
269   /**
270    * @brief Gets codec type
271    * @return VideoCodec::Type
272    */
273   Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
274
275   /**
276    * @brief Sets the display mode for playback.
277    * @param[in] mode of playback
278    */
279   void SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode );
280
281   /**
282    * @brief Gets display mode
283    * @return DisplayMode
284    */
285   Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
286
287   /**
288    * @brief Gets the media player of video player
289    * @return player The media player
290    */
291   Any GetMediaPlayer();
292
293   /**
294    * @brief calls synchronization function in window system
295    * This function is called, the synchronization is started between UI(transparent hole) and video player.
296    */
297   void StartSynchronization();
298
299   /**
300    * @brief calls desynchronization function in window system
301    * This function is called, the synchronization is ended between UI(transparent hole) and video player.
302    */
303   void FinishSynchronization();
304
305 private: // Not intended for application developers
306
307   /**
308    * @brief Internal constructor
309    * @SINCE_1_1.38
310    */
311   explicit DALI_INTERNAL VideoPlayer( Internal::Adaptor::VideoPlayer* internal );
312 };
313
314 } // namespace Dali;
315
316 #endif // DALI_VIDEO_PLAYER_H