1 #ifndef DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
5 * Copyright (c) 2020 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/object/property-notification.h>
24 #include <dali/public-api/object/property-conditions.h>
25 #include <dali/public-api/rendering/renderer.h>
26 #include <dali/public-api/images/image-operations.h>
27 #include <dali/public-api/rendering/texture.h>
28 #include <dali/devel-api/adaptor-framework/video-player.h>
29 #include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
30 #include <dali/devel-api/adaptor-framework/video-sync-mode.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
51 VideoView( Dali::VideoSyncMode syncMode );
58 * @copydoc Toolkit::DevelVideoView::New()
60 static Toolkit::VideoView New( VideoSyncMode syncMode );
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();
260 * @brief Play the resize or move animation with synchronization between UI(transparent hole) and video player
262 * The resize and move animation's play() function is called.
263 * If the animation is played, UI and video player will work synchronization.
265 * @param[in] videoView The current VideoView
266 * @param[in] animation The animation for video view's resize or move.
268 void PlayAnimation( Dali::Animation animation );
270 private: // From Control
273 * @copydoc Toolkit::Control::OnInitialize()
275 virtual void OnInitialize();
278 * @copydoc Toolkit::Control::OnSceneConnection()
280 virtual void OnSceneConnection( int depth );
283 * @copydoc Toolkit::Control::OnSceneDisconnection()
285 virtual void OnSceneDisconnection();
288 * @copydoc Toolkit::Control::OnSizeSet()
290 virtual void OnSizeSet( const Vector3& targetSize );
293 * @copydoc Toolkit::Control::GetNaturalSize
295 virtual Vector3 GetNaturalSize();
298 * @copydoc Toolkit::Control::GetHeightForWidth()
300 virtual float GetHeightForWidth( float width );
303 * @copydoc Toolkit::Control::GetWidthForHeight()
305 virtual float GetWidthForHeight( float height );
310 * @brief Construct a new VideoView.
312 VideoView( const VideoView& videoView );
314 // Undefined assignment operator.
315 VideoView& operator=( const VideoView& videoView );
318 * @brief SetWindowSurfaceTarget for underlay video playback.
320 void SetWindowSurfaceTarget();
323 * @brief SetNativeImageTarget for native image video playback.
325 void SetNativeImageTarget();
328 * @brief CreateShader for native image target
330 Dali::Shader CreateShader();
333 * @brief Checks whether the property has a string value.
334 * @param Property value
335 * @param String output
336 * @return true if the output was found
338 bool GetStringFromProperty( const Dali::Property::Value& value, std::string& output );
341 * @brief Internal version of SetProperty
343 void SetPropertyInternal( Property::Index index, const Property::Value& value );
346 * @brief Apply properties after reset video player
348 void ApplyBackupProperties();
351 * @brief FrameRender's callback function
353 * This function means the resize/move animation is finished,
354 * so Ui and video player's synchronization can be finished.
357 void FrameRenderCallback( int frameID );
360 * @brief Set frameRender Callback function
362 * This function is added for listenr the resize/move animation is finished,
365 void SetFrameRenderCallback();
369 * @brief resize/move animation finished callback function
371 * This function is called the resize/move animation is finished,
374 void OnAnimationFinished( Dali::Animation& animation );
378 Dali::VideoPlayer mVideoPlayer;
379 Dali::ImageDimensions mVideoSize;
380 Dali::Property::Map mPropertyMap;
381 Dali::Property::Map mEffectPropertyMap;
382 Dali::Texture mNativeTexture;
383 Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
385 Dali::DisplayArea mDisplayArea;
386 Dali::Renderer mOverlayRenderer;
387 Dali::Renderer mTextureRenderer;
388 Dali::PropertyNotification mPositionUpdateNotification;
389 Dali::PropertyNotification mSizeUpdateNotification;
390 Dali::PropertyNotification mScaleUpdateNotification;
391 Dali::Property::Map mPropertyBackup;
393 int mCurrentVideoPlayPosition;
399 Dali::VideoSyncMode mSyncMode;
402 } // namespace Internal
404 inline Toolkit::Internal::VideoView& GetImpl( Toolkit::VideoView& handle )
406 DALI_ASSERT_ALWAYS( handle );
407 Dali::RefObject& impl = handle.GetImplementation();
408 return static_cast< Toolkit::Internal::VideoView& >( impl );
411 inline const Toolkit::Internal::VideoView& GetImpl( const Toolkit::VideoView& handle )
413 DALI_ASSERT_ALWAYS( handle );
414 const Dali::RefObject& impl = handle.GetImplementation();
415 return static_cast< const Toolkit::Internal::VideoView& >( impl );
418 } // namespace Toolkit
422 #endif // DALI_TOOLKIT_VIDEO_VIEW_H