4f0e12eaa6022ea24029543d31840d7891f386de
[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) 2016 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_IMPORT_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   struct Property
81   {
82     enum
83     {
84       /**
85        * @brief name "video", video file url as string type or Property::Map.
86        * @SINCE_1_1.38
87        * @REMARK_INTERNET
88        * @REMARK_STORAGE
89        */
90       VIDEO = PROPERTY_START_INDEX,
91
92      /**
93        * @brief name "looping", looping status, true or false.
94        * @SINCE_1_1.38
95        */
96       LOOPING,
97
98      /**
99        * @brief name "muted", mute status, true or false.
100        * @SINCE_1_1.38
101        */
102       MUTED,
103
104      /**
105        * @brief name "volume", left and right volume scalar as float type, Property::Map with two values ( "left" and "right" ).
106        * @SINCE_1_1.38
107        */
108       VOLUME,
109
110      /**
111        * @brief name "underlay", Video rendering by underlay, true or false
112        * This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view
113        * If false, video-view shows decoded frame images sequentially.
114        * If Platform or video plugin doesn't support decoded frame images, this should always be true.
115        * @SINCE_1_2.62
116        * @REMARK_RAWVIDEO
117        */
118       UNDERLAY,
119
120      /**
121        * @brief The play position (millisecond) of the video.
122        * @details Name "playPosition", type Property::INTEGER
123        * @SINCE_1_3_9
124        */
125       PLAY_POSITION,
126
127       /**
128         * @brief The display mode of the video.
129         * @SINCE_1_3_15
130         */
131       DISPLAY_MODE
132     };
133   };
134
135   /**
136    * @brief The values of this enum determine how the video should be display mode to the view
137    * @SINCE_1_3_15
138    */
139   struct DisplayMode
140   {
141     enum Type
142     {
143       /**
144        * @brief Letter box
145        * @SINCE_1_3_15
146        */
147       LETTER_BOX = 0,
148       /**
149        * @brief Origin size
150        * @SINCE_1_3_15
151        */
152       ORIGIN_SIZE,
153       /**
154        * @brief Full-screen
155        * @SINCE_1_3_15
156        */
157       FULL_SCREEN,
158       /**
159        * @brief Cropped full-screen
160        * @SINCE_1_3_15
161        */
162       CROPPED_FULL,
163       /**
164        * @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)
165        * @SINCE_1_3_15
166        */
167       ORIGIN_OR_LETTER,
168       /**
169        * @brief  Region of Interest
170        * @SINCE_1_3_15
171        */
172       DST_ROI
173     };
174   };
175
176 public:
177
178   /**
179    * @brief Creates an initialized VideoView.
180    * @SINCE_1_1.38
181    * @return A handle to a newly allocated Dali ImageView
182    *
183    */
184   static VideoView New();
185
186   /**
187    * @brief Creates an initialized VideoView.
188    * If the string is empty, VideoView will not display anything.
189    *
190    * @SINCE_1_1.38
191    * @REMARK_INTERNET
192    * @REMARK_STORAGE
193    * @param[in] url The url of the video resource to display
194    * @return A handle to a newly allocated Dali VideoView
195    */
196   static VideoView New( const std::string& url );
197
198   /**
199    * @brief Creates an initialized VideoView.
200    * @SINCE_1_3_9
201    * @param[in] swCodec Video rendering by H/W codec if false
202    * @return A handle to a newly allocated Dali ImageView
203    *
204    * @note If platform or target does not support sw codec, video-view shows an error message and video by default codec type
205    */
206   static VideoView New( bool swCodec );
207
208   /**
209    * @brief Creates an initialized VideoView.
210    * If the string is empty, VideoView will not display anything.
211    *
212    * @SINCE_1_3_9
213    * @REMARK_INTERNET
214    * @REMARK_STORAGE
215    * @param[in] url The url of the video resource to display
216    * @param[in] swCodec Video rendering by H/W codec if false
217    * @return A handle to a newly allocated Dali VideoView
218    *
219    * @note If platform or target does not support sw codec, video-view shows an error message and video by default codec type
220    */
221   static VideoView New( const std::string& url, bool swCodec );
222
223   /**
224    * @brief Creates an uninitialized VideoView.
225    * @SINCE_1_1.38
226    */
227   VideoView();
228
229   /**
230    * @brief Destructor.
231    *
232    * This is non-virtual since derived Handel types must not contain data or virtual methods.
233    * @SINCE_1_1.38
234    */
235   ~VideoView();
236
237   /**
238    * @brief Copy constructor.
239    *
240    * @SINCE_1_1.38
241    * @param[in] videoView VideoView to copy. The copied VideoView will point at the same implementation
242    */
243   VideoView( const VideoView& videoView );
244
245   /**
246    * @brief Assignment operator.
247    *
248    * @SINCE_1_1.38
249    * @param[in] videoView The VideoView to assign from
250    * @return The updated VideoView
251    */
252   VideoView& operator=( const VideoView& videoView );
253
254   /**
255    * @brief Downcasts a handle to VideoView handle.
256    *
257    * If handle points to a VideoView, the downcast produces valid handle.
258    * If not, the returned handle is left uninitialized.
259    *
260    * @SINCE_1_1.38
261    * @param[in] handle Handle to an object
262    * @return Handle to a VideoView or an uninitialized handle
263    */
264   static VideoView DownCast( BaseHandle handle );
265
266   /**
267    * @brief Starts the video playback.
268    * @SINCE_1_1.38
269    */
270   void Play();
271
272   /**
273    * @brief Pauses the video playback.
274    * @SINCE_1_1.38
275    */
276   void Pause();
277
278   /**
279    * @brief Stops the video playback.
280    * @SINCE_1_1.38
281    */
282   void Stop();
283
284   /**
285    * @brief Seeks forward by the specified number of milliseconds.
286    *
287    * @SINCE_1_1.38
288    * @param[in] millisecond The position for forward playback
289    */
290   void Forward( int millisecond );
291
292   /**
293    * @brief Seeks backward by the specified number of milliseconds.
294    *
295    * @SINCE_1_1.38
296    * @param[in] millisecond The position for backward playback
297    */
298   void Backward( int millisecond );
299
300   /**
301    * @brief Connects to this signal to be notified when a video playback is finished.
302    *
303    * @SINCE_1_1.38
304    * @return A signal object to connect with
305    */
306   VideoViewSignalType& FinishedSignal();
307
308 public: // Not intended for application developers
309
310   /// @cond internal
311   /**
312    * @brief Creates a handle using the Toolkit::Internal implementation.
313    *
314    * @SINCE_1_1.38
315    * @param[in] implementation The VideoView implementation
316    */
317   DALI_INTERNAL VideoView( Internal::VideoView& implementation );
318
319   /**
320    * @brief Allows the creation of this VideoView from an Internal::CustomActor pointer.
321    *
322    * @SINCE_1_1.38
323    * @param[in] internal A pointer to the internal CustomActor
324    */
325   DALI_INTERNAL VideoView( Dali::Internal::CustomActor* internal );
326   /// @endcond
327
328 };
329
330 /**
331  * @}
332  */
333
334 } // namespace Toolkit
335
336 } // namespace Dali
337
338 #endif // __DALI_TOOLKIT_VIDEO_VIEW_H__