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>
28 #include <dali-toolkit/internal/visuals/image/image-visual.h>
29 #include <dali-toolkit/public-api/controls/control-impl.h>
30 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
43 class VideoView: public Control
54 * @copydoc Toolkit::VideoView::New()
56 static Toolkit::VideoView New();
59 * @brief Sets a video url to play.
62 * @param [in] url The url of the video resource to play
64 void SetUrl( const std::string& url );
67 * @brief Returns a video url.
69 * @return Url of string type
74 * @brief Sets the player looping status.
77 * @param [in] looping The new looping status: true or false
79 void SetLooping(bool looping);
82 * @brief Returns the player looping status.
85 * @return True if player is looping, false otherwise.
90 * @copydoc Toolkit::VideoView::Play()
95 * @copydoc Toolkit::VideoView::Pause()
100 * @copydoc Toolkit::VideoView::Stop()
105 * @copydoc Toolkit::VideoView::Forward()
107 void Forward( int millisecond );
110 * @copydoc Toolkit::VideoView::Backward()
112 void Backward( int millisecond );
115 * @brief Sets the player mute status.
117 * @param[i] mute The new mute status, true is mute.
119 void SetMute( bool mute );
122 * @brief Returns the player mute status.
124 * @return True if player is mute.
129 * @brief Sets the player volume.
131 * @param[in] left The left volume scalar
132 * @param[in] right The right volume scalar
134 void SetVolume( float left, float right );
137 * @brief Returns current volume factor.
139 * @param[out] left The current left volume scalar
140 * @param[out] right The current right volume scalar
142 void GetVolume( float& left, float& right );
145 * @copydoc Dali::Toolkit::VideoView::FinishedSignal()
147 Dali::Toolkit::VideoView::VideoViewSignalType& FinishedSignal();
150 * @brief Emit the finished signal
152 void EmitSignalFinish();
155 * @brief Set property map
157 * @param[in] map The Dali::Property::Map to use for to display.
159 void SetPropertyMap( Property::Map map );
163 * @brief Called when a property of an object of this type is set.
165 * @param[in] object The object whose property is set.
166 * @param[in] index The property index.
167 * @param[in] value The new property value.
169 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
172 * @brief Called to retrieve a property of an object of this type.
174 * @param[in] object The object whose property is to be retrieved.
175 * @param[in] index The property index.
176 * @return The current value of the property.
178 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
181 * @brief Set the depth index of this image renderer
183 * Renderer with higher depth indices are rendered in front of other visuals with smaller values
185 * @param[in] depthIndex The depth index of this renderer
187 void SetDepthIndex( int depthIndex );
190 * @brief Performs actions as requested using the action name.
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
197 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
200 * Connects a callback function with the object's signals.
201 * @param[in] object The object providing the signal.
202 * @param[in] tracker Used to disconnect the signal.
203 * @param[in] signalName The signal to connect to.
204 * @param[in] functor A newly allocated FunctorDelegate.
205 * @return True if the signal was connected.
206 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
208 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
211 * @brief Updates video display area for window rendering target
213 void UpdateDisplayArea();
216 * @brief Sets underlay flag and initializes new rendering target by flag.
218 void SetUnderlay( bool set );
221 * @brief Checks underlay flag.
225 private: // From Control
228 * @copydoc Toolkit::Control::OnInitialize()
230 virtual void OnInitialize();
233 * @copydoc Toolkit::Control::OnStageConnect()
235 virtual void OnStageConnection( int depth );
238 * @copydoc Toolkit::Control::OnStageDisconnection()
240 virtual void OnStageDisconnection();
243 * @copydoc Toolkit::Control::GetNaturalSize
245 virtual Vector3 GetNaturalSize();
248 * @copydoc Toolkit::Control::GetHeightForWidth()
250 virtual float GetHeightForWidth( float width );
253 * @copydoc Toolkit::Control::GetWidthForHeight()
255 virtual float GetWidthForHeight( float height );
260 VideoView( const VideoView& videoView );
262 VideoView& operator=( const VideoView& videoView );
264 void SetWindowSurfaceTarget();
266 void SetNativeImageTarget();
270 Dali::VideoPlayer mVideoPlayer;
271 Dali::ImageDimensions mVideoSize;
272 Toolkit::Visual::Base mVisual;
273 Dali::Property::Map mPropertyMap;
274 Dali::NativeImage mNativeImage; ///< Native image handle for video rendering by texture streaming
275 Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
277 Dali::DisplayArea mDisplayArea;
278 Dali::Renderer mRenderer;
280 Property::Index mUpdateTriggerPropertyIndex;
281 TriggerEventInterface* mNotification;
283 int mCurrentVideoPlayPosition;
289 } // namespace Internal
291 inline Toolkit::Internal::VideoView& GetImpl( Toolkit::VideoView& handle )
293 DALI_ASSERT_ALWAYS( handle );
294 Dali::RefObject& impl = handle.GetImplementation();
295 return static_cast< Toolkit::Internal::VideoView& >( impl );
298 inline const Toolkit::Internal::VideoView& GetImpl( const Toolkit::VideoView& handle )
300 DALI_ASSERT_ALWAYS( handle );
301 const Dali::RefObject& impl = handle.GetImplementation();
302 return static_cast< const Toolkit::Internal::VideoView& >( impl );
305 } // namespace Toolkit
309 #endif // DALI_TOOLKIT_VIDEO_VIEW_H