Rename of Control Renderers to Visuals
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / video-view / video-view-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/property-map.h>
23 #include <dali/public-api/images/native-image.h>
24 #include <dali/devel-api/adaptor-framework/video-player.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/internal/controls/renderers/image/image-visual.h>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
30
31 namespace Dali
32 {
33
34 namespace Toolkit
35 {
36
37 class VideoView;
38
39 namespace Internal
40 {
41
42 class VideoView: public Control
43 {
44 protected:
45
46   VideoView();
47
48   virtual ~VideoView();
49
50 public:
51
52   /**
53    * @copydoc Toolkit::VideoView::New()
54    */
55   static Toolkit::VideoView New();
56
57   /**
58    * @brief Sets a video url to play.
59    *
60    * @SINCE_1_1.38
61    * @param [in] url The url of the video resource to play
62    */
63   void SetUrl( const std::string& url );
64
65   /**
66    * @brief Returns a video url.
67    * @SINCE_1_1.38
68    * @return Url of string type
69    */
70   std::string GetUrl();
71
72   /**
73    * @brief Sets the player looping status.
74    *
75    * @SINCE_1_1.38
76    * @param [in] looping The new looping status: true or false
77    */
78   void SetLooping(bool looping);
79
80   /**
81    * @brief Returns the player looping status.
82    *
83    * @SINCE_1_1.38
84    * @return True if player is looping, false otherwise.
85    */
86   bool IsLooping();
87
88   /**
89    * @copydoc Toolkit::VideoView::Play()
90    */
91   void Play();
92
93   /**
94    * @copydoc Toolkit::VideoView::Pause()
95    */
96   void Pause();
97
98   /**
99    * @copydoc Toolkit::VideoView::Stop()
100    */
101   void Stop();
102
103   /**
104    * @copydoc Toolkit::VideoView::Forward()
105    */
106   void Forward( int millisecond );
107
108   /**
109    * @copydoc Toolkit::VideoView::Backward()
110    */
111   void Backward( int millisecond );
112
113   /**
114    * @brief Sets the player mute status.
115    * @SINCE_1_1.38
116    * @param[i] mute The new mute status, true is mute.
117    */
118   void SetMute( bool mute );
119
120   /**
121    * @brief Returns the player mute status.
122    * @SINCE_1_1.38
123    * @return True if player is mute.
124    */
125   bool IsMuted();
126
127   /**
128    * @brief Sets the player volume.
129    * @SINCE_1_1.38
130    * @param[in] left The left volume scalar
131    * @param[in] right The right volume scalar
132    */
133   void SetVolume( float left, float right );
134
135   /**
136    * @brief Returns current volume factor.
137    * @SINCE_1_1.38
138    * @param[out] left The current left volume scalar
139    * @param[out] right The current right volume scalar
140    */
141   void GetVolume( float& left, float& right );
142
143  /**
144    * @copydoc Dali::Toolkit::VideoView::FinishedSignal()
145    */
146   Dali::Toolkit::VideoView::VideoViewSignalType& FinishedSignal();
147
148   /**
149    * @brief Emit the finished signal
150    */
151   void EmitSignalFinish();
152
153   /**
154    * @brief Set property map
155    * @SINCE_1_1.38
156    * @param[in] map The Dali::Property::Map to use for to display.
157    */
158   void SetPropertyMap( Property::Map map );
159
160   // Properties
161   /**
162    * @brief Called when a property of an object of this type is set.
163    * @SINCE_1_1.38
164    * @param[in] object The object whose property is set.
165    * @param[in] index The property index.
166    * @param[in] value The new property value.
167    */
168   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
169
170   /**
171    * @brief Called to retrieve a property of an object of this type.
172    * @SINCE_1_1.38
173    * @param[in] object The object whose property is to be retrieved.
174    * @param[in] index The property index.
175    * @return The current value of the property.
176    */
177   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
178
179   /**
180    * @brief Set the depth index of this image renderer
181    *
182    * Renderer with higher depth indices are rendered in front of other renderers with smaller values
183    * @SINCE_1_1.38
184    * @param[in] depthIndex The depth index of this renderer
185    */
186   void SetDepthIndex( int depthIndex );
187
188
189   /**
190    * @brief Performs actions as requested using the action name.
191    * @SINCE_1_1.38
192    * @param[in] object The object on which to perform the action.
193    * @param[in] actionName The action to perform.
194    * @param[in] attributes The attributes with which to perfrom this action.
195    * @return True if action has been accepted by this control
196    */
197   static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
198
199   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
200
201 private: // From Control
202
203   /**
204    * @copydoc Toolkit::Control::OnStageConnect()
205    */
206   virtual void OnStageConnection( int depth );
207
208   /**
209    * @copydoc Toolkit::Control::OnStageDisconnection()
210    */
211   virtual void OnStageDisconnection();
212
213   /**
214    * @copydoc Toolkit::Control::GetNaturalSize
215    */
216   virtual Vector3 GetNaturalSize();
217
218   /**
219    * @copydoc Toolkit::Control::GetHeightForWidth()
220    */
221   virtual float GetHeightForWidth( float width );
222
223   /**
224    * @copydoc Toolkit::Control::GetWidthForHeight()
225    */
226   virtual float GetWidthForHeight( float height );
227
228 private:
229
230   // Undefined
231   VideoView( const VideoView& videoView );
232
233   VideoView& operator=( const VideoView& videoView );
234
235   void SetWindowSurfaceTarget();
236
237   void SetNativeImageTarget();
238
239 private:
240
241   Dali::VideoPlayer mVideoPlayer;
242   Dali::ImageDimensions mVideoSize;
243   Toolkit::Visual mRenderer;
244   Dali::Property::Map mPropertyMap;
245   Dali::NativeImage mNativeImage; ///< Native image handle for video rendering by texture streaming
246   Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
247   std::string mUrl;
248   int mCurrentVideoPlayPosition;
249   bool mSetRenderingTarget;
250   bool mIsPlay;
251   bool mIsPause;
252 };
253
254 } // namespace Internal
255
256 inline Toolkit::Internal::VideoView& GetImpl( Toolkit::VideoView& handle )
257 {
258   DALI_ASSERT_ALWAYS( handle );
259   Dali::RefObject& impl = handle.GetImplementation();
260   return static_cast< Toolkit::Internal::VideoView& >( impl );
261 }
262
263 inline const Toolkit::Internal::VideoView& GetImpl( const Toolkit::VideoView& handle )
264 {
265   DALI_ASSERT_ALWAYS( handle );
266   const Dali::RefObject& impl = handle.GetImplementation();
267   return static_cast< const Toolkit::Internal::VideoView& >( impl );
268 }
269
270 } // namespace Toolkit
271
272 } // namespace Dali
273
274 #endif // __DALI_TOOLKIT_VIDEO_VIEW_H__