1 #ifndef DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
5 * Copyright (c) 2019 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/public-api/object/property-notification.h>
25 #include <dali/public-api/object/property-conditions.h>
26 #include <dali/public-api/rendering/renderer.h>
27 #include <dali/public-api/images/image-operations.h>
28 #include <dali/public-api/rendering/texture.h>
29 #include <dali/devel-api/adaptor-framework/video-player.h>
30 #include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
33 #include <dali-toolkit/public-api/controls/control-impl.h>
34 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
47 class VideoView: public Control
58 * @copydoc Toolkit::VideoView::New()
60 static Toolkit::VideoView New();
63 * @brief Sets a video url to play.
66 * @param [in] url The url of the video resource to play
68 void SetUrl( const std::string& url );
71 * @brief Returns a video url.
73 * @return Url of string type
78 * @brief Sets the player looping status.
81 * @param [in] looping The new looping status: true or false
83 void SetLooping(bool looping);
86 * @brief Returns the player looping status.
89 * @return True if player is looping, false otherwise.
94 * @copydoc Toolkit::VideoView::Play()
99 * @copydoc Toolkit::VideoView::Pause()
104 * @copydoc Toolkit::VideoView::Stop()
109 * @copydoc Toolkit::VideoView::Forward()
111 void Forward( int millisecond );
114 * @copydoc Toolkit::VideoView::Backward()
116 void Backward( int millisecond );
119 * @brief Sets the player mute status.
121 * @param[i] mute The new mute status, true is mute.
123 void SetMute( bool mute );
126 * @brief Returns the player mute status.
128 * @return True if player is mute.
133 * @brief Sets the player volume.
135 * @param[in] left The left volume scalar
136 * @param[in] right The right volume scalar
138 void SetVolume( float left, float right );
141 * @brief Returns current volume factor.
143 * @param[out] left The current left volume scalar
144 * @param[out] right The current right volume scalar
146 void GetVolume( float& left, float& right );
149 * @copydoc Dali::Toolkit::VideoView::FinishedSignal()
151 Dali::Toolkit::VideoView::VideoViewSignalType& FinishedSignal();
154 * @brief Emit the finished signal
156 void EmitSignalFinish();
159 * @brief Set property map
161 * @param[in] map The Dali::Property::Map to use for to display.
163 void SetPropertyMap( Property::Map map );
167 * @brief Called when a property of an object of this type is set.
169 * @param[in] object The object whose property is set.
170 * @param[in] index The property index.
171 * @param[in] value The new property value.
173 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
176 * @brief Called to retrieve a property of an object of this type.
178 * @param[in] object The object whose property is to be retrieved.
179 * @param[in] index The property index.
180 * @return The current value of the property.
182 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
185 * @brief Set the depth index of this image renderer
187 * Renderer with higher depth indices are rendered in front of other visuals with smaller values
189 * @param[in] depthIndex The depth index of this renderer
191 void SetDepthIndex( int depthIndex );
194 * @brief Performs actions as requested using the action name.
196 * @param[in] object The object on which to perform the action.
197 * @param[in] actionName The action to perform.
198 * @param[in] attributes The attributes with which to perfrom this action.
199 * @return True if action has been accepted by this control
201 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
204 * Connects a callback function with the object's signals.
205 * @param[in] object The object providing the signal.
206 * @param[in] tracker Used to disconnect the signal.
207 * @param[in] signalName The signal to connect to.
208 * @param[in] functor A newly allocated FunctorDelegate.
209 * @return True if the signal was connected.
210 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
212 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
215 * @brief Updates video display area for window rendering target
217 void UpdateDisplayArea( Dali::PropertyNotification& source );
220 * @brief Sets underlay flag and initializes new rendering target by flag.
222 void SetUnderlay( bool set );
225 * @brief Checks underlay flag.
230 * @brief Sets sw codec type.
232 void SetSWCodec( bool on );
235 * @brief Gets play position.
237 int GetPlayPosition();
240 * @brief Sets play position.
242 void SetPlayPosition( int pos );
245 * @brief Sets Display mode.
247 void SetDisplayMode( int mode );
250 * @brief Gets Display mode.
252 int GetDisplayMode() const;
255 * @brief Gets internal media player.
257 Any GetMediaPlayer();
259 private: // From Control
262 * @copydoc Toolkit::Control::OnInitialize()
264 virtual void OnInitialize();
267 * @copydoc Toolkit::Control::OnStageConnect()
269 virtual void OnStageConnection( int depth );
272 * @copydoc Toolkit::Control::OnStageDisconnection()
274 virtual void OnStageDisconnection();
277 * @copydoc Toolkit::Control::GetNaturalSize
279 virtual Vector3 GetNaturalSize();
284 * @brief Construct a new VideoView.
286 VideoView( const VideoView& videoView );
288 // Undefined assignment operator.
289 VideoView& operator=( const VideoView& videoView );
292 * @brief SetWindowSurfaceTarget for underlay video playback.
294 void SetWindowSurfaceTarget();
297 * @brief SetNativeImageTarget for native image video playback.
299 void SetNativeImageTarget();
302 * @brief CreateShader for native image target
304 Dali::Shader CreateShader();
307 * @brief Checks whether the property has a string value.
308 * @param Property value
309 * @param String output
310 * @return true if the output was found
312 bool GetStringFromProperty( const Dali::Property::Value& value, std::string& output );
315 * @brief Internal version of SetProperty
317 void SetPropertyInternal( Property::Index index, const Property::Value& value );
320 * @brief Apply properties after reset video player
322 void ApplyBackupProperties();
326 Dali::VideoPlayer mVideoPlayer;
327 Dali::ImageDimensions mVideoSize;
328 Dali::Property::Map mPropertyMap;
329 Dali::Property::Map mEffectPropertyMap;
330 Dali::Texture mNativeTexture;
331 Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
333 Dali::DisplayArea mDisplayArea;
334 Dali::Renderer mOverlayRenderer;
335 Dali::Renderer mTextureRenderer;
336 Dali::PropertyNotification mPositionUpdateNotification;
337 Dali::PropertyNotification mSizeUpdateNotification;
338 Dali::PropertyNotification mScaleUpdateNotification;
339 Dali::Property::Map mPropertyBackup;
341 int mCurrentVideoPlayPosition;
346 } // namespace Internal
348 inline Toolkit::Internal::VideoView& GetImpl( Toolkit::VideoView& handle )
350 DALI_ASSERT_ALWAYS( handle );
351 Dali::RefObject& impl = handle.GetImplementation();
352 return static_cast< Toolkit::Internal::VideoView& >( impl );
355 inline const Toolkit::Internal::VideoView& GetImpl( const Toolkit::VideoView& handle )
357 DALI_ASSERT_ALWAYS( handle );
358 const Dali::RefObject& impl = handle.GetImplementation();
359 return static_cast< const Toolkit::Internal::VideoView& >( impl );
362 } // namespace Toolkit
366 #endif // DALI_TOOLKIT_VIDEO_VIEW_H