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