1 #ifndef DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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 #include <dali/integration-api/adaptors/trigger-event-factory.h>
26 #include <dali/public-api/object/property-notification.h>
27 #include <dali/public-api/object/property-conditions.h>
30 #include <dali-toolkit/internal/visuals/image/image-visual.h>
31 #include <dali-toolkit/public-api/controls/control-impl.h>
32 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
45 class VideoView: public Control
56 * @copydoc Toolkit::VideoView::New()
58 static Toolkit::VideoView New();
61 * @brief Sets a video url to play.
64 * @param [in] url The url of the video resource to play
66 void SetUrl( const std::string& url );
69 * @brief Returns a video url.
71 * @return Url of string type
76 * @brief Sets the player looping status.
79 * @param [in] looping The new looping status: true or false
81 void SetLooping(bool looping);
84 * @brief Returns the player looping status.
87 * @return True if player is looping, false otherwise.
92 * @copydoc Toolkit::VideoView::Play()
97 * @copydoc Toolkit::VideoView::Pause()
102 * @copydoc Toolkit::VideoView::Stop()
107 * @copydoc Toolkit::VideoView::Forward()
109 void Forward( int millisecond );
112 * @copydoc Toolkit::VideoView::Backward()
114 void Backward( int millisecond );
117 * @brief Sets the player mute status.
119 * @param[i] mute The new mute status, true is mute.
121 void SetMute( bool mute );
124 * @brief Returns the player mute status.
126 * @return True if player is mute.
131 * @brief Sets the player volume.
133 * @param[in] left The left volume scalar
134 * @param[in] right The right volume scalar
136 void SetVolume( float left, float right );
139 * @brief Returns current volume factor.
141 * @param[out] left The current left volume scalar
142 * @param[out] right The current right volume scalar
144 void GetVolume( float& left, float& right );
147 * @copydoc Dali::Toolkit::VideoView::FinishedSignal()
149 Dali::Toolkit::VideoView::VideoViewSignalType& FinishedSignal();
152 * @brief Emit the finished signal
154 void EmitSignalFinish();
157 * @brief Set property map
159 * @param[in] map The Dali::Property::Map to use for to display.
161 void SetPropertyMap( Property::Map map );
165 * @brief Called when a property of an object of this type is set.
167 * @param[in] object The object whose property is set.
168 * @param[in] index The property index.
169 * @param[in] value The new property value.
171 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
174 * @brief Called to retrieve a property of an object of this type.
176 * @param[in] object The object whose property is to be retrieved.
177 * @param[in] index The property index.
178 * @return The current value of the property.
180 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
183 * @brief Set the depth index of this image renderer
185 * Renderer with higher depth indices are rendered in front of other visuals with smaller values
187 * @param[in] depthIndex The depth index of this renderer
189 void SetDepthIndex( int depthIndex );
192 * @brief Performs actions as requested using the action name.
194 * @param[in] object The object on which to perform the action.
195 * @param[in] actionName The action to perform.
196 * @param[in] attributes The attributes with which to perfrom this action.
197 * @return True if action has been accepted by this control
199 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
202 * Connects a callback function with the object's signals.
203 * @param[in] object The object providing the signal.
204 * @param[in] tracker Used to disconnect the signal.
205 * @param[in] signalName The signal to connect to.
206 * @param[in] functor A newly allocated FunctorDelegate.
207 * @return True if the signal was connected.
208 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
210 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
213 * @brief Updates video display area for window rendering target
215 void UpdateDisplayArea( Dali::PropertyNotification& source );
218 * @brief Sets underlay flag and initializes new rendering target by flag.
220 void SetUnderlay( bool set );
223 * @brief Checks underlay flag.
227 private: // From Control
230 * @copydoc Toolkit::Control::OnInitialize()
232 virtual void OnInitialize();
235 * @copydoc Toolkit::Control::OnStageConnect()
237 virtual void OnStageConnection( int depth );
240 * @copydoc Toolkit::Control::OnStageDisconnection()
242 virtual void OnStageDisconnection();
245 * @copydoc Toolkit::Control::GetNaturalSize
247 virtual Vector3 GetNaturalSize();
250 * @copydoc Toolkit::Control::GetHeightForWidth()
252 virtual float GetHeightForWidth( float width );
255 * @copydoc Toolkit::Control::GetWidthForHeight()
257 virtual float GetWidthForHeight( float height );
262 VideoView( const VideoView& videoView );
264 VideoView& operator=( const VideoView& videoView );
266 void SetWindowSurfaceTarget();
268 void SetNativeImageTarget();
272 Dali::VideoPlayer mVideoPlayer;
273 Dali::ImageDimensions mVideoSize;
274 Toolkit::Visual::Base mVisual;
275 Dali::Property::Map mPropertyMap;
276 Dali::NativeImage mNativeImage; ///< Native image handle for video rendering by texture streaming
277 Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
279 Dali::DisplayArea mDisplayArea;
280 Dali::Renderer mRenderer;
281 Dali::PropertyNotification mPositionUpdateNotification;
282 Dali::PropertyNotification mSizeUpdateNotification;
283 Dali::PropertyNotification mScaleUpdateNotification;
285 int mCurrentVideoPlayPosition;
291 } // namespace Internal
293 inline Toolkit::Internal::VideoView& GetImpl( Toolkit::VideoView& handle )
295 DALI_ASSERT_ALWAYS( handle );
296 Dali::RefObject& impl = handle.GetImplementation();
297 return static_cast< Toolkit::Internal::VideoView& >( impl );
300 inline const Toolkit::Internal::VideoView& GetImpl( const Toolkit::VideoView& handle )
302 DALI_ASSERT_ALWAYS( handle );
303 const Dali::RefObject& impl = handle.GetImplementation();
304 return static_cast< const Toolkit::Internal::VideoView& >( impl );
307 } // namespace Toolkit
311 #endif // DALI_TOOLKIT_VIDEO_VIEW_H