Merge "Changes after Set/Get synchronous behaviour of registered animatable & custom...
[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/visuals/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 visuals 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    * @brief Performs actions as requested using the action name.
190    * @SINCE_1_1.38
191    * @param[in] object The object on which to perform the action.
192    * @param[in] actionName The action to perform.
193    * @param[in] attributes The attributes with which to perfrom this action.
194    * @return True if action has been accepted by this control
195    */
196   static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
197
198   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
199
200 private: // From Control
201
202   /**
203    * @copydoc Toolkit::Control::OnInitialize()
204    */
205   virtual void OnInitialize();
206
207   /**
208    * @copydoc Toolkit::Control::OnStageConnect()
209    */
210   virtual void OnStageConnection( int depth );
211
212   /**
213    * @copydoc Toolkit::Control::OnStageDisconnection()
214    */
215   virtual void OnStageDisconnection();
216
217   /**
218    * @copydoc Toolkit::Control::GetNaturalSize
219    */
220   virtual Vector3 GetNaturalSize();
221
222   /**
223    * @copydoc Toolkit::Control::GetHeightForWidth()
224    */
225   virtual float GetHeightForWidth( float width );
226
227   /**
228    * @copydoc Toolkit::Control::GetWidthForHeight()
229    */
230   virtual float GetWidthForHeight( float height );
231
232 private:
233
234   // Undefined
235   VideoView( const VideoView& videoView );
236
237   VideoView& operator=( const VideoView& videoView );
238
239   void SetWindowSurfaceTarget();
240
241   void SetNativeImageTarget();
242
243 private:
244
245   Dali::VideoPlayer mVideoPlayer;
246   Dali::ImageDimensions mVideoSize;
247   Toolkit::Visual::Base mVisual;
248   Dali::Property::Map mPropertyMap;
249   Dali::NativeImage mNativeImage; ///< Native image handle for video rendering by texture streaming
250   Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
251   std::string mUrl;
252   int mCurrentVideoPlayPosition;
253   bool mIsNativeImageTarget;
254   bool mIsPlay;
255   bool mIsPause;
256 };
257
258 } // namespace Internal
259
260 inline Toolkit::Internal::VideoView& GetImpl( Toolkit::VideoView& handle )
261 {
262   DALI_ASSERT_ALWAYS( handle );
263   Dali::RefObject& impl = handle.GetImplementation();
264   return static_cast< Toolkit::Internal::VideoView& >( impl );
265 }
266
267 inline const Toolkit::Internal::VideoView& GetImpl( const Toolkit::VideoView& handle )
268 {
269   DALI_ASSERT_ALWAYS( handle );
270   const Dali::RefObject& impl = handle.GetImplementation();
271   return static_cast< const Toolkit::Internal::VideoView& >( impl );
272 }
273
274 } // namespace Toolkit
275
276 } // namespace Dali
277
278 #endif // DALI_TOOLKIT_VIDEO_VIEW_H