[dali_2.3.25] Merge branch 'devel/master'
[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) 2022 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/devel-api/adaptor-framework/video-sync-mode.h>
23 #include <dali/public-api/object/base-handle.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 class Any;
32
33 namespace Internal
34 {
35 namespace Adaptor
36 {
37 class VideoPlayer;
38 } // namespace Adaptor
39
40 } // namespace Internal
41
42 /**
43  * @brief VideoPlayer class is used for video playback.
44  * @SINCE_1_1.38
45  */
46 class DALI_ADAPTOR_API VideoPlayer : public BaseHandle
47 {
48 public:
49   /**
50    * @brief Constructor.
51    * @SINCE_1_1.38
52    */
53   VideoPlayer();
54
55   /**
56    * @brief Destructor.
57    * @SINCE_1_1.38
58    */
59   ~VideoPlayer();
60
61   /**
62    * @brief Creates a new instance of a VideoPlayer.
63    * @SINCE_1_1.38
64    */
65   static VideoPlayer New();
66
67   /**
68    * @brief Creates a new instance of a VideoPlayer.
69    *
70    * If you want the video player works with Ui synchronous when video player is resized/moved,
71    * put the video view actor and the enabled syncMode.
72    *
73    * @param[in] actor video view's actor instance
74    * @param[in] syncMode The synchronization mode between the UI (transparent hole) and VideoPlayer.
75    */
76   static VideoPlayer New(Dali::Actor actor, VideoSyncMode syncMode);
77
78   /**
79    * @brief Copy constructor.
80    *
81    * @SINCE_1_1.38
82    * @param[in] player VideoPlayer to copy. The copied player will point at the same implementation
83    */
84   VideoPlayer(const VideoPlayer& player);
85
86   /**
87    * @brief Assignment operator.
88    *
89    * @SINCE_1_1.38
90    * @param[in] player The VideoPlayer to assign from.
91    * @return The updated VideoPlayer.
92    */
93   VideoPlayer& operator=(const VideoPlayer& player);
94
95   /**
96    * @brief Move constructor.
97    *
98    * @SINCE_2_1.45
99    * @param[in] player VideoPlayer to move. The moved player will point at the same implementation
100    */
101   VideoPlayer(VideoPlayer&& player);
102
103   /**
104    * @brief Move assignment operator.
105    *
106    * @SINCE_2_1.45
107    * @param[in] player The VideoPlayer to move assign from.
108    * @return The updated VideoPlayer.
109    */
110   VideoPlayer& operator=(VideoPlayer&& player);
111
112   /**
113    * @brief Downcast a handle to VideoPlayer handle.
114    *
115    * If handle points to a VideoPlayer the downcast produces valid
116    * handle. If not the returned handle is left uninitialized.
117    *
118    * @SINCE_1_1.38
119    * @param[in] handle Handle to an object
120    * @return Handle to a VideoPlayer or an uninitialized handle
121    */
122   static VideoPlayer DownCast(BaseHandle handle);
123
124   /**
125    * @brief Sets a URL of the video file to play.
126    *
127    * @SINCE_1_1.38
128    * @param [in] url The url of video file
129    */
130   void SetUrl(const std::string& url);
131
132   /**
133    * @brief Returns the URL of the video file.
134    * @SINCE_1_1.38
135    * @return Url of string type
136    */
137   std::string GetUrl();
138
139   /**
140    * @brief Sets the player looping status.
141    * @SINCE_1_1.38
142    *
143    * @param [in] looping The new looping status: true or false
144    */
145   void SetLooping(bool looping);
146
147   /**
148    * @brief Returns the player looping status.
149    * @SINCE_1_1.38
150    *
151    * @return True if player is looping, false otherwise.
152    */
153   bool IsLooping();
154
155   /**
156    * @brief Starts the video playback.
157    * @SINCE_1_1.38
158    */
159   void Play();
160
161   /**
162    * @brief Pauses the video playback.
163    * @SINCE_1_1.38
164    */
165   void Pause();
166
167   /**
168    * @brief Stops the video playback.
169    * @SINCE_1_1.38
170    */
171   void Stop();
172
173   /**
174    * @brief Sets the player mute status.
175    * @SINCE_1_1.38
176    * @param[in] mute The new mute status, true is mute.
177    */
178   void SetMute(bool mute);
179
180   /**
181    * @brief Returns the player mute status.
182    * @SINCE_1_1.38
183    * @return True if player is mute.
184    */
185   bool IsMuted();
186
187   /**
188    * @brief Sets the player volume.
189    * @SINCE_1_1.38
190    * @param[in] left The left volume scalar
191    * @param[in] right The right volume scalar
192    */
193   void SetVolume(float left, float right);
194
195   /**
196    * @brief Returns current volume factor.
197    * @SINCE_1_1.38
198    * @param[out] left The current left volume scalar
199    * @param[out] right The current right volume scalar
200    */
201   void GetVolume(float& left, float& right);
202
203   /**
204    * @brief Sets video rendering target.
205    * @SINCE_1_1.38
206    * @param[in] target The target for video rendering, window surface or native image source
207    */
208   void SetRenderingTarget(Any target);
209
210   /**
211    * @brief Sets the position for playback.
212    * @SINCE_1_1.38
213    *
214    * @param[in] millisecond The position for playback
215    */
216   void SetPlayPosition(int millisecond);
217
218   /**
219    * @brief Gets the current position in milliseconds.
220    * @SINCE_1_1.38
221    *
222    * @return The current position of playback
223    */
224   int GetPlayPosition();
225
226   /**
227    * @brief Sets the area of video display.
228    * @SINCE_1_2.46
229    * param[in] area The left-top position and size of the video display area
230    */
231   void SetDisplayArea(DisplayArea area);
232
233   /**
234    * @brief Sets video display rotation
235    * @SINCE_1_1.38
236    * @param[in] rotation The rotation of display
237    */
238   void SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation);
239
240   /**
241    * @brief Returns rotation of current video display
242    * @SINCE_1_1.38
243    * @return The rotation of current display
244    */
245   Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
246
247   /**
248    * @brief Connect to this signal to be notified when a video playback have finished.
249    *
250    * @SINCE_1_1.38
251    * @return A signal object to connect with.
252    */
253   Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
254
255   /**
256    * @brief Seeks forward by the specified number of milliseconds.
257    *
258    * @SINCE_1_2.46
259    * @param[in] millisecond The position for forward playback
260    */
261   void Forward(int millisecond);
262
263   /**
264    * @brief Seeks backward by the specified number of milliseconds.
265    *
266    * @SINCE_1_2.46
267    * @param[in] millisecond The position for backward playback
268    */
269   void Backward(int millisecond);
270
271   /**
272    * @brief Checks whether the video texture is supported
273    * @return True if supported, otherwise false.
274    */
275   bool IsVideoTextureSupported();
276
277   /**
278    * @brief Sets codec type
279    * @param[in] type The VideoCodec::Type
280    */
281   void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
282
283   /**
284    * @brief Gets codec type
285    * @return VideoCodec::Type
286    */
287   Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
288
289   /**
290    * @brief Sets the display mode for playback.
291    * @param[in] mode of playback
292    */
293   void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
294
295   /**
296    * @brief Gets display mode
297    * @return DisplayMode
298    */
299   Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
300
301   /**
302    * @brief Gets the media player of video player
303    * @return player The media player
304    */
305   Any GetMediaPlayer();
306
307   /**
308    * @brief calls synchronization function in window system
309    * This function is called, the synchronization is started between UI(transparent hole) and video player.
310    */
311   void StartSynchronization();
312
313   /**
314    * @brief calls desynchronization function in window system
315    * This function is called, the synchronization is ended between UI(transparent hole) and video player.
316    */
317   void FinishSynchronization();
318
319   /**
320    * @brief Raise the video player above the target video plaer.
321    *
322    * @param[in] target The target video player
323    */
324   void RaiseAbove(Dali::VideoPlayer target);
325
326   /**
327    * @brief Lower the video player to below the target video player.
328    *
329    * @param[in] target The target video player
330    */
331   void LowerBelow(Dali::VideoPlayer target);
332
333   /**
334    * @brief Raise video player above all other sibling video players.
335    */
336   void RaiseToTop();
337
338   /**
339    * @brief Lower video player to the bottom of all other sibling video players.
340    */
341   void LowerToBottom();
342
343 private: // Not intended for application developers
344   /**
345    * @brief Internal constructor
346    * @SINCE_1_1.38
347    */
348   explicit DALI_INTERNAL VideoPlayer(Internal::Adaptor::VideoPlayer* internal);
349 };
350
351 } // namespace Dali
352
353 #endif // DALI_VIDEO_PLAYER_H