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>
32 #include <dali-toolkit/public-api/controls/control-impl.h>
33 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
46 class VideoView: public Control
57 * @copydoc Toolkit::VideoView::New()
59 static Toolkit::VideoView New();
62 * @brief Sets a video url to play.
65 * @param [in] url The url of the video resource to play
67 void SetUrl( const std::string& url );
70 * @brief Returns a video url.
72 * @return Url of string type
77 * @brief Sets the player looping status.
80 * @param [in] looping The new looping status: true or false
82 void SetLooping(bool looping);
85 * @brief Returns the player looping status.
88 * @return True if player is looping, false otherwise.
93 * @copydoc Toolkit::VideoView::Play()
98 * @copydoc Toolkit::VideoView::Pause()
103 * @copydoc Toolkit::VideoView::Stop()
108 * @copydoc Toolkit::VideoView::Forward()
110 void Forward( int millisecond );
113 * @copydoc Toolkit::VideoView::Backward()
115 void Backward( int millisecond );
118 * @brief Sets the player mute status.
120 * @param[i] mute The new mute status, true is mute.
122 void SetMute( bool mute );
125 * @brief Returns the player mute status.
127 * @return True if player is mute.
132 * @brief Sets the player volume.
134 * @param[in] left The left volume scalar
135 * @param[in] right The right volume scalar
137 void SetVolume( float left, float right );
140 * @brief Returns current volume factor.
142 * @param[out] left The current left volume scalar
143 * @param[out] right The current right volume scalar
145 void GetVolume( float& left, float& right );
148 * @copydoc Dali::Toolkit::VideoView::FinishedSignal()
150 Dali::Toolkit::VideoView::VideoViewSignalType& FinishedSignal();
153 * @brief Emit the finished signal
155 void EmitSignalFinish();
158 * @brief Set property map
160 * @param[in] map The Dali::Property::Map to use for to display.
162 void SetPropertyMap( Property::Map map );
166 * @brief Called when a property of an object of this type is set.
168 * @param[in] object The object whose property is set.
169 * @param[in] index The property index.
170 * @param[in] value The new property value.
172 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
175 * @brief Called to retrieve a property of an object of this type.
177 * @param[in] object The object whose property is to be retrieved.
178 * @param[in] index The property index.
179 * @return The current value of the property.
181 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
184 * @brief Set the depth index of this image renderer
186 * Renderer with higher depth indices are rendered in front of other visuals with smaller values
188 * @param[in] depthIndex The depth index of this renderer
190 void SetDepthIndex( int depthIndex );
193 * @brief Performs actions as requested using the action name.
195 * @param[in] object The object on which to perform the action.
196 * @param[in] actionName The action to perform.
197 * @param[in] attributes The attributes with which to perfrom this action.
198 * @return True if action has been accepted by this control
200 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
203 * Connects a callback function with the object's signals.
204 * @param[in] object The object providing the signal.
205 * @param[in] tracker Used to disconnect the signal.
206 * @param[in] signalName The signal to connect to.
207 * @param[in] functor A newly allocated FunctorDelegate.
208 * @return True if the signal was connected.
209 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
211 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
214 * @brief Updates video display area for window rendering target
216 void UpdateDisplayArea( Dali::PropertyNotification& source );
219 * @brief Sets underlay flag and initializes new rendering target by flag.
221 void SetUnderlay( bool set );
224 * @brief Checks underlay flag.
229 * @brief Sets sw codec type.
231 void SetSWCodec( bool on );
234 * @brief Gets play position.
236 int GetPlayPosition();
239 * @brief Sets play position.
241 void SetPlayPosition( int pos );
244 * @brief Sets Display mode.
246 void SetDisplayMode( int mode );
249 * @brief Gets Display mode.
251 int GetDisplayMode() const;
254 * @brief Gets internal media player.
256 Any GetMediaPlayer();
258 private: // From Control
261 * @copydoc Toolkit::Control::OnInitialize()
263 virtual void OnInitialize();
266 * @copydoc Toolkit::Control::OnStageConnect()
268 virtual void OnStageConnection( int depth );
271 * @copydoc Toolkit::Control::OnStageDisconnection()
273 virtual void OnStageDisconnection();
276 * @copydoc Toolkit::Control::GetNaturalSize
278 virtual Vector3 GetNaturalSize();
281 * @copydoc Toolkit::Control::GetHeightForWidth()
283 virtual float GetHeightForWidth( float width );
286 * @copydoc Toolkit::Control::GetWidthForHeight()
288 virtual float GetWidthForHeight( float height );
293 * @brief Construct a new VideoView.
295 VideoView( const VideoView& videoView );
297 // Undefined assignment operator.
298 VideoView& operator=( const VideoView& videoView );
301 * @brief SetWindowSurfaceTarget for underlay video playback.
303 void SetWindowSurfaceTarget();
306 * @brief SetNativeImageTarget for native image video playback.
308 void SetNativeImageTarget();
311 * @brief CreateShader for native image target
313 Dali::Shader CreateShader();
316 * @brief Checks whether the property has a string value.
317 * @param Property value
318 * @param String output
319 * @return true if the output was found
321 bool GetStringFromProperty( const Dali::Property::Value& value, std::string& output );
324 * @brief Internal version of SetProperty
326 void SetPropertyInternal( Property::Index index, const Property::Value& value );
329 * @brief Apply properties after reset video player
331 void ApplyBackupProperties();
335 Dali::VideoPlayer mVideoPlayer;
336 Dali::ImageDimensions mVideoSize;
337 Dali::Property::Map mPropertyMap;
338 Dali::Property::Map mEffectPropertyMap;
339 Dali::Texture mNativeTexture;
340 Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
342 Dali::DisplayArea mDisplayArea;
343 Dali::Renderer mOverlayRenderer;
344 Dali::Renderer mTextureRenderer;
345 Dali::PropertyNotification mPositionUpdateNotification;
346 Dali::PropertyNotification mSizeUpdateNotification;
347 Dali::PropertyNotification mScaleUpdateNotification;
348 Dali::Property::Map mPropertyBackup;
350 int mCurrentVideoPlayPosition;
355 } // namespace Internal
357 inline Toolkit::Internal::VideoView& GetImpl( Toolkit::VideoView& handle )
359 DALI_ASSERT_ALWAYS( handle );
360 Dali::RefObject& impl = handle.GetImplementation();
361 return static_cast< Toolkit::Internal::VideoView& >( impl );
364 inline const Toolkit::Internal::VideoView& GetImpl( const Toolkit::VideoView& handle )
366 DALI_ASSERT_ALWAYS( handle );
367 const Dali::RefObject& impl = handle.GetImplementation();
368 return static_cast< const Toolkit::Internal::VideoView& >( impl );
371 } // namespace Toolkit
375 #endif // DALI_TOOLKIT_VIDEO_VIEW_H