Add move semantics to common and base Toolkit classes
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / video-view / video-view.h
1 #ifndef DALI_TOOLKIT_VIDEO_VIEW_H
2 #define DALI_TOOLKIT_VIDEO_VIEW_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 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32   class VideoView;
33 } // namespace Internal
34
35 /**
36  * @addtogroup dali_toolkit_controls_video_view
37  * @{
38  */
39
40 /**
41  * @brief VideoView is a control for video playback and display.
42  *
43  * For working VideoView, a video plugin for a platform should be provided.
44  *
45  * Signals
46  * | %Signal Name  | Method                  |
47  * |---------------|-------------------------|
48  * | finished      | @ref FinishedSignal()   |
49  * @SINCE_1_1.38
50  *
51  * Actions
52  * | %Action Name    | Attributes                                         | Description                                             |
53  * |-----------------|----------------------------------------------------|---------------------------------------------------------|
54  * | videoPlay       | Doesn't have attributes                            | Plays video. See @ref DoAction()                        |
55  * | videoPause      | Doesn't have attributes                            | Pauses video. See @ref DoAction()                       |
56  * | videoStop       | Doesn't have attributes                            | Stops video. See @ref DoAction()                        |
57  * | videoForward    | The position ( millisecond ) for forward playback  | Sets forward position for playback. See @ref DoAction() |
58  * | videoBackward   | The position ( millisecond ) for backward playback | Sets backward position for playback. See @ref DoAction()|
59  * @SINCE_1_1.38
60  *
61  */
62 class DALI_TOOLKIT_API VideoView: public Control
63 {
64 public:
65
66   // Signal
67   typedef Signal< void (VideoView&) > VideoViewSignalType; ///< Video playback finished signal type @ SINCE_1_1.38
68
69 public:
70
71   /**
72    * @brief Enumeration for the start and end property ranges for this control.
73    * @SINCE_1_0.0
74    */
75   enum PropertyRange
76   {
77     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,  ///< @SINCE_1_0.0
78   };
79
80   /**
81    * @brief Enumeration for the instance of properties belonging to the VideoView class.
82    * @SINCE_1_1.38
83    */
84   struct Property
85   {
86     /**
87      * @brief Enumeration for the instance of properties belonging to the VideoView class.
88      * @SINCE_1_1.38
89      */
90     enum
91     {
92       /**
93        * @brief name "video", video file url as string type or Property::Map.
94        * @SINCE_1_1.38
95        * @REMARK_INTERNET
96        * @REMARK_STORAGE
97        */
98       VIDEO = PROPERTY_START_INDEX,
99
100      /**
101        * @brief name "looping", looping status, true or false.
102        * @SINCE_1_1.38
103        */
104       LOOPING,
105
106      /**
107        * @brief name "muted", mute status, true or false.
108        * @SINCE_1_1.38
109        */
110       MUTED,
111
112      /**
113        * @brief name "volume", left and right volume scalar as float type, Property::Map with two values ( "left" and "right" ).
114        * @SINCE_1_1.38
115        */
116       VOLUME,
117
118      /**
119        * @brief name "underlay", Video rendering by underlay, true or false
120        * This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view
121        * If false, video-view shows decoded frame images sequentially.
122        * If Platform or video plugin doesn't support decoded frame images, this should always be true.
123        * @SINCE_1_2.62
124        * @REMARK_RAWVIDEO
125        */
126       UNDERLAY,
127
128      /**
129        * @brief The play position (millisecond) of the video.
130        * @details Name "playPosition", type Property::INTEGER
131        * @SINCE_1_3_9
132        */
133       PLAY_POSITION,
134
135       /**
136         * @brief The display mode of the video.
137         * @SINCE_1_3_15
138         */
139       DISPLAY_MODE
140     };
141   };
142
143   /**
144    * @brief The values of this enum determine how the video should be display mode to the view
145    * @SINCE_1_3_15
146    */
147   struct DisplayMode
148   {
149     /**
150      * @brief The values of this enum determine how the video should be display mode to the view.
151      * @SINCE_1_3_15
152      */
153     enum Type
154     {
155       /**
156        * @brief Letter box
157        * @SINCE_1_3_15
158        */
159       LETTER_BOX = 0,
160       /**
161        * @brief Origin size
162        * @SINCE_1_3_15
163        */
164       ORIGIN_SIZE,
165       /**
166        * @brief Full-screen
167        * @SINCE_1_3_15
168        */
169       FULL_SCREEN,
170       /**
171        * @brief Cropped full-screen
172        * @SINCE_1_3_15
173        */
174       CROPPED_FULL,
175       /**
176        * @brief  Origin size (if surface size is larger than video size(width/height)) or Letter box (if video size(width/height) is larger than surface size)
177        * @SINCE_1_3_15
178        */
179       ORIGIN_OR_LETTER,
180       /**
181        * @brief  Region of Interest
182        * @SINCE_1_3_15
183        */
184       DST_ROI
185     };
186   };
187
188 public:
189
190   /**
191    * @brief Creates an initialized VideoView.
192    * @SINCE_1_1.38
193    * @return A handle to a newly allocated Dali ImageView
194    *
195    */
196   static VideoView New();
197
198   /**
199    * @brief Creates an initialized VideoView.
200    * If the string is empty, VideoView will not display anything.
201    *
202    * @SINCE_1_1.38
203    * @REMARK_INTERNET
204    * @REMARK_STORAGE
205    * @param[in] url The url of the video resource to display
206    * @return A handle to a newly allocated Dali VideoView
207    */
208   static VideoView New( const std::string& url );
209
210   /**
211    * @brief Creates an initialized VideoView.
212    * @SINCE_1_3_9
213    * @param[in] swCodec Video rendering by H/W codec if false
214    * @return A handle to a newly allocated Dali ImageView
215    *
216    * @note If platform or target does not support sw codec, video-view shows an error message and video by default codec type
217    */
218   static VideoView New( bool swCodec );
219
220   /**
221    * @brief Creates an initialized VideoView.
222    * If the string is empty, VideoView will not display anything.
223    *
224    * @SINCE_1_3_9
225    * @REMARK_INTERNET
226    * @REMARK_STORAGE
227    * @param[in] url The url of the video resource to display
228    * @param[in] swCodec Video rendering by H/W codec if false
229    * @return A handle to a newly allocated Dali VideoView
230    *
231    * @note If platform or target does not support sw codec, video-view shows an error message and video by default codec type
232    */
233   static VideoView New( const std::string& url, bool swCodec );
234
235   /**
236    * @brief Creates an uninitialized VideoView.
237    * @SINCE_1_1.38
238    */
239   VideoView();
240
241   /**
242    * @brief Destructor.
243    *
244    * This is non-virtual since derived Handel types must not contain data or virtual methods.
245    * @SINCE_1_1.38
246    */
247   ~VideoView();
248
249   /**
250    * @brief Copy constructor.
251    *
252    * @SINCE_1_1.38
253    * @param[in] videoView VideoView to copy. The copied VideoView will point at the same implementation
254    */
255   VideoView( const VideoView& videoView );
256
257   /**
258    * @brief Move constructor
259    * @SINCE_1_9.23
260    *
261    * @param[in] rhs A reference to the moved handle
262    */
263   VideoView( VideoView&& rhs );
264
265   /**
266    * @brief Assignment operator.
267    *
268    * @SINCE_1_1.38
269    * @param[in] videoView The VideoView to assign from
270    * @return The updated VideoView
271    */
272   VideoView& operator=( const VideoView& videoView );
273
274   /**
275    * @brief Move assignment
276    * @SINCE_1_9.23
277    *
278    * @param[in] rhs A reference to the moved handle
279    * @return A reference to this
280    */
281   VideoView& operator=( VideoView&& rhs );
282
283   /**
284    * @brief Downcasts a handle to VideoView handle.
285    *
286    * If handle points to a VideoView, the downcast produces valid handle.
287    * If not, the returned handle is left uninitialized.
288    *
289    * @SINCE_1_1.38
290    * @param[in] handle Handle to an object
291    * @return Handle to a VideoView or an uninitialized handle
292    */
293   static VideoView DownCast( BaseHandle handle );
294
295   /**
296    * @brief Starts the video playback.
297    * @SINCE_1_1.38
298    */
299   void Play();
300
301   /**
302    * @brief Pauses the video playback.
303    * @SINCE_1_1.38
304    */
305   void Pause();
306
307   /**
308    * @brief Stops the video playback.
309    * @SINCE_1_1.38
310    */
311   void Stop();
312
313   /**
314    * @brief Seeks forward by the specified number of milliseconds.
315    *
316    * @SINCE_1_1.38
317    * @param[in] millisecond The position for forward playback
318    */
319   void Forward( int millisecond );
320
321   /**
322    * @brief Seeks backward by the specified number of milliseconds.
323    *
324    * @SINCE_1_1.38
325    * @param[in] millisecond The position for backward playback
326    */
327   void Backward( int millisecond );
328
329   /**
330    * @brief Connects to this signal to be notified when a video playback is finished.
331    *
332    * @SINCE_1_1.38
333    * @return A signal object to connect with
334    */
335   VideoViewSignalType& FinishedSignal();
336
337 public: // Not intended for application developers
338
339   /// @cond internal
340   /**
341    * @brief Creates a handle using the Toolkit::Internal implementation.
342    *
343    * @SINCE_1_1.38
344    * @param[in] implementation The VideoView implementation
345    */
346   DALI_INTERNAL VideoView( Internal::VideoView& implementation );
347
348   /**
349    * @brief Allows the creation of this VideoView from an Internal::CustomActor pointer.
350    *
351    * @SINCE_1_1.38
352    * @param[in] internal A pointer to the internal CustomActor
353    */
354   DALI_INTERNAL VideoView( Dali::Internal::CustomActor* internal );
355   /// @endcond
356
357 };
358
359 /**
360  * @}
361  */
362
363 } // namespace Toolkit
364
365 } // namespace Dali
366
367 #endif // DALI_TOOLKIT_VIDEO_VIEW_H