Merge branch 'devel/master' into devel/graphics
[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) 2020 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 Downcast a handle to VideoPlayer handle.
97    *
98    * If handle points to a VideoPlayer the downcast produces valid
99    * handle. If not the returned handle is left uninitialized.
100    *
101    * @SINCE_1_1.38
102    * @param[in] handle Handle to an object
103    * @return Handle to a VideoPlayer or an uninitialized handle
104    */
105   static VideoPlayer DownCast(BaseHandle handle);
106
107   /**
108    * @brief Sets a URL of the video file to play.
109    *
110    * @SINCE_1_1.38
111    * @param [in] url The url of video file
112    */
113   void SetUrl(const std::string& url);
114
115   /**
116    * @brief Returns the URL of the video file.
117    * @SINCE_1_1.38
118    * @return Url of string type
119    */
120   std::string GetUrl();
121
122   /**
123    * @brief Sets the player looping status.
124    * @SINCE_1_1.38
125    *
126    * @param [in] looping The new looping status: true or false
127    */
128   void SetLooping(bool looping);
129
130   /**
131    * @brief Returns the player looping status.
132    * @SINCE_1_1.38
133    *
134    * @return True if player is looping, false otherwise.
135    */
136   bool IsLooping();
137
138   /**
139    * @brief Starts the video playback.
140    * @SINCE_1_1.38
141    */
142   void Play();
143
144   /**
145    * @brief Pauses the video playback.
146    * @SINCE_1_1.38
147    */
148   void Pause();
149
150   /**
151    * @brief Stops the video playback.
152    * @SINCE_1_1.38
153    */
154   void Stop();
155
156   /**
157    * @brief Sets the player mute status.
158    * @SINCE_1_1.38
159    * @param[in] mute The new mute status, true is mute.
160    */
161   void SetMute(bool mute);
162
163   /**
164    * @brief Returns the player mute status.
165    * @SINCE_1_1.38
166    * @return True if player is mute.
167    */
168   bool IsMuted();
169
170   /**
171    * @brief Sets the player volume.
172    * @SINCE_1_1.38
173    * @param[in] left The left volume scalar
174    * @param[in] right The right volume scalar
175    */
176   void SetVolume(float left, float right);
177
178   /**
179    * @brief Returns current volume factor.
180    * @SINCE_1_1.38
181    * @param[out] left The current left volume scalar
182    * @param[out] right The current right volume scalar
183    */
184   void GetVolume(float& left, float& right);
185
186   /**
187    * @brief Sets video rendering target.
188    * @SINCE_1_1.38
189    * @param[in] target The target for video rendering, window surface or native image source
190    */
191   void SetRenderingTarget(Any target);
192
193   /**
194    * @brief Sets the position for playback.
195    * @SINCE_1_1.38
196    *
197    * @param[in] millisecond The position for playback
198    */
199   void SetPlayPosition(int millisecond);
200
201   /**
202    * @brief Gets the current position in milliseconds.
203    * @SINCE_1_1.38
204    *
205    * @return The current position of playback
206    */
207   int GetPlayPosition();
208
209   /**
210    * @brief Sets the area of video display.
211    * @SINCE_1_2.46
212    * param[in] area The left-top position and size of the video display area
213    */
214   void SetDisplayArea(DisplayArea area);
215
216   /**
217    * @brief Sets video display rotation
218    * @SINCE_1_1.38
219    * @param[in] rotation The rotation of display
220    */
221   void SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation);
222
223   /**
224    * @brief Returns rotation of current video display
225    * @SINCE_1_1.38
226    * @return The rotation of current display
227    */
228   Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
229
230   /**
231    * @brief Connect to this signal to be notified when a video playback have finished.
232    *
233    * @SINCE_1_1.38
234    * @return A signal object to connect with.
235    */
236   Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
237
238   /**
239    * @brief Seeks forward by the specified number of milliseconds.
240    *
241    * @SINCE_1_2.46
242    * @param[in] millisecond The position for forward playback
243    */
244   void Forward(int millisecond);
245
246   /**
247    * @brief Seeks backward by the specified number of milliseconds.
248    *
249    * @SINCE_1_2.46
250    * @param[in] millisecond The position for backward playback
251    */
252   void Backward(int millisecond);
253
254   /**
255    * @brief Checks whether the video texture is supported
256    * @return True if supported, otherwise false.
257    */
258   bool IsVideoTextureSupported();
259
260   /**
261    * @brief Sets codec type
262    * @param[in] type The VideoCodec::Type
263    */
264   void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
265
266   /**
267    * @brief Gets codec type
268    * @return VideoCodec::Type
269    */
270   Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
271
272   /**
273    * @brief Sets the display mode for playback.
274    * @param[in] mode of playback
275    */
276   void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
277
278   /**
279    * @brief Gets display mode
280    * @return DisplayMode
281    */
282   Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
283
284   /**
285    * @brief Gets the media player of video player
286    * @return player The media player
287    */
288   Any GetMediaPlayer();
289
290   /**
291    * @brief calls synchronization function in window system
292    * This function is called, the synchronization is started between UI(transparent hole) and video player.
293    */
294   void StartSynchronization();
295
296   /**
297    * @brief calls desynchronization function in window system
298    * This function is called, the synchronization is ended between UI(transparent hole) and video player.
299    */
300   void FinishSynchronization();
301
302   /**
303    * @brief Raise the video player above the target video plaer.
304    *
305    * @param[in] target The target video player
306    */
307   void RaiseAbove(Dali::VideoPlayer target);
308
309   /**
310    * @brief Lower the video player to below the target video player.
311    *
312    * @param[in] target The target video player
313    */
314   void LowerBelow(Dali::VideoPlayer target);
315
316   /**
317    * @brief Raise video player above all other sibling video players.
318    */
319   void RaiseToTop();
320
321   /**
322    * @brief Lower video player to the bottom of all other sibling video players.
323    */
324   void LowerToBottom();
325
326 private: // Not intended for application developers
327   /**
328    * @brief Internal constructor
329    * @SINCE_1_1.38
330    */
331   explicit DALI_INTERNAL VideoPlayer(Internal::Adaptor::VideoPlayer* internal);
332 };
333
334 } // namespace Dali
335
336 #endif // DALI_VIDEO_PLAYER_H