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.
228 * @brief Sets sw codec type.
230 void SetSWCodec( bool on );
233 * @brief Gets play position.
235 int GetPlayPosition();
238 * @brief Sets play position.
240 void SetPlayPosition( int pos );
243 * @brief Sets Display mode.
245 void SetDisplayMode( int mode );
248 * @brief Gets Display mode.
250 int GetDisplayMode() const;
252 private: // From Control
255 * @copydoc Toolkit::Control::OnInitialize()
257 virtual void OnInitialize();
260 * @copydoc Toolkit::Control::OnStageConnect()
262 virtual void OnStageConnection( int depth );
265 * @copydoc Toolkit::Control::OnStageDisconnection()
267 virtual void OnStageDisconnection();
270 * @copydoc Toolkit::Control::GetNaturalSize
272 virtual Vector3 GetNaturalSize();
275 * @copydoc Toolkit::Control::GetHeightForWidth()
277 virtual float GetHeightForWidth( float width );
280 * @copydoc Toolkit::Control::GetWidthForHeight()
282 virtual float GetWidthForHeight( float height );
287 VideoView( const VideoView& videoView );
289 VideoView& operator=( const VideoView& videoView );
291 void SetWindowSurfaceTarget();
293 void SetNativeImageTarget();
297 Dali::VideoPlayer mVideoPlayer;
298 Dali::ImageDimensions mVideoSize;
299 Toolkit::Visual::Base mVisual;
300 Dali::Property::Map mPropertyMap;
301 Dali::NativeImage mNativeImage; ///< Native image handle for video rendering by texture streaming
302 Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
304 Dali::DisplayArea mDisplayArea;
305 Dali::Renderer mRenderer;
306 Dali::PropertyNotification mPositionUpdateNotification;
307 Dali::PropertyNotification mSizeUpdateNotification;
308 Dali::PropertyNotification mScaleUpdateNotification;
310 int mCurrentVideoPlayPosition;
315 } // namespace Internal
317 inline Toolkit::Internal::VideoView& GetImpl( Toolkit::VideoView& handle )
319 DALI_ASSERT_ALWAYS( handle );
320 Dali::RefObject& impl = handle.GetImplementation();
321 return static_cast< Toolkit::Internal::VideoView& >( impl );
324 inline const Toolkit::Internal::VideoView& GetImpl( const Toolkit::VideoView& handle )
326 DALI_ASSERT_ALWAYS( handle );
327 const Dali::RefObject& impl = handle.GetImplementation();
328 return static_cast< const Toolkit::Internal::VideoView& >( impl );
331 } // namespace Toolkit
335 #endif // DALI_TOOLKIT_VIDEO_VIEW_H