1 #ifndef DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
5 * Copyright (c) 2021 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/devel-api/adaptor-framework/video-player.h>
23 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
24 #include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
25 #include <dali/public-api/adaptor-framework/window.h>
26 #include <dali/public-api/images/image-operations.h>
27 #include <dali/public-api/object/property-conditions.h>
28 #include <dali/public-api/object/property-map.h>
29 #include <dali/public-api/object/property-notification.h>
30 #include <dali/public-api/rendering/renderer.h>
31 #include <dali/public-api/rendering/texture.h>
34 #include <dali-toolkit/public-api/controls/control-impl.h>
35 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
45 class VideoView : public Control
48 VideoView(Dali::VideoSyncMode syncMode);
54 * @copydoc Toolkit::DevelVideoView::New()
56 static Toolkit::VideoView New(VideoSyncMode syncMode);
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(Dali::PropertyNotification& source);
216 * @brief Sets underlay flag and initializes new rendering target by flag.
218 void SetUnderlay(bool set);
221 * @brief Checks underlay flag.
226 * @brief Sets sw codec type.
228 void SetSWCodec(bool on);
231 * @brief Gets play position.
233 int GetPlayPosition();
236 * @brief Sets play position.
238 void SetPlayPosition(int pos);
241 * @brief Sets Display mode.
243 void SetDisplayMode(int mode);
246 * @brief Gets Display mode.
248 int GetDisplayMode() const;
251 * @brief Gets internal media player.
253 Any GetMediaPlayer();
256 * @brief Play the resize or move animation with synchronization between UI(transparent hole) and video player
258 * The resize and move animation's play() function is called.
259 * If the animation is played, UI and video player will work synchronization.
261 * @param[in] videoView The current VideoView
262 * @param[in] animation The animation for video view's resize or move.
264 void PlayAnimation(Dali::Animation animation);
267 * @brief Checks whether the actor is set as a video view or not.
269 * @param[in] actor The actor to be checked
270 * @return True if actor is video view.
272 bool IsVideoView(Actor actor) const;
275 * @brief Gets the Video Player.
277 * @return The return of video player.
279 VideoPlayer GetVideoPlayer();
281 private: // From Control
283 * @copydoc Toolkit::Control::OnInitialize()
285 void OnInitialize() override;
288 * @copydoc Toolkit::Control::OnSceneConnection()
290 void OnSceneConnection(int depth) override;
293 * @copydoc Toolkit::Control::OnSceneDisconnection()
295 void OnSceneDisconnection() override;
298 * @copydoc Toolkit::Control::OnSizeSet()
300 void OnSizeSet(const Vector3& targetSize) override;
303 * @copydoc Toolkit::Control::GetNaturalSize
305 Vector3 GetNaturalSize() override;
308 * @copydoc Toolkit::Control::GetHeightForWidth()
310 float GetHeightForWidth(float width) override;
313 * @copydoc Toolkit::Control::GetWidthForHeight()
315 float GetWidthForHeight(float height) override;
319 * @brief Construct a new VideoView.
321 VideoView(const VideoView& videoView);
323 // Undefined assignment operator.
324 VideoView& operator=(const VideoView& videoView);
327 * @brief SetWindowSurfaceTarget for underlay video playback.
329 void SetWindowSurfaceTarget();
332 * @brief SetNativeImageTarget for native image video playback.
334 void SetNativeImageTarget();
337 * @brief CreateShader for native image target
339 Dali::Shader CreateShader();
342 * @brief Checks whether the property has a string value.
343 * @param Property value
344 * @param String output
345 * @return true if the output was found
347 bool GetStringFromProperty(const Dali::Property::Value& value, std::string& output);
350 * @brief Internal version of SetProperty
352 void SetPropertyInternal(Property::Index index, const Property::Value& value);
355 * @brief Apply properties after reset video player
357 void ApplyBackupProperties();
360 * @brief FrameRender's callback function
362 * This function means the resize/move animation is finished,
363 * so Ui and video player's synchronization can be finished.
366 void FrameRenderCallback(int frameID);
369 * @brief Set frameRender Callback function
371 * This function is added for listenr the resize/move animation is finished,
374 void SetFrameRenderCallback();
377 * @brief resize/move animation finished callback function
379 * This function is called the resize/move animation is finished,
382 void OnAnimationFinished(Dali::Animation& animation);
385 * @brief window's resize callback function
386 * This function is called when window is resized.
388 * @param[in] winHandle The resized window's handle.
389 * @param[in] size The window's new size.
391 void OnWindowResized(Dali::Window winHandle, Dali::Window::WindowSize size);
394 * @brief This signal is emitted when an actor's children change their sibling order
396 * @param[in] actor parent actor.
398 void OnChildOrderChanged(Actor actor);
401 Dali::VideoPlayer mVideoPlayer;
402 Dali::ImageDimensions mVideoSize;
403 Dali::Property::Map mPropertyMap;
404 Dali::Property::Map mEffectPropertyMap;
405 Dali::Texture mNativeTexture;
407 Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
410 Dali::DisplayArea mDisplayArea;
411 Dali::Renderer mOverlayRenderer;
412 Dali::Renderer mTextureRenderer;
414 Dali::PropertyNotification mPositionUpdateNotification;
415 Dali::PropertyNotification mSizeUpdateNotification;
416 Dali::PropertyNotification mScaleUpdateNotification;
418 Dali::Property::Map mPropertyBackup;
420 int mCurrentVideoPlayPosition;
426 Dali::VideoSyncMode mSyncMode;
430 } // namespace Internal
432 inline Toolkit::Internal::VideoView& GetImpl(Toolkit::VideoView& handle)
434 DALI_ASSERT_ALWAYS(handle);
435 Dali::RefObject& impl = handle.GetImplementation();
436 return static_cast<Toolkit::Internal::VideoView&>(impl);
439 inline const Toolkit::Internal::VideoView& GetImpl(const Toolkit::VideoView& handle)
441 DALI_ASSERT_ALWAYS(handle);
442 const Dali::RefObject& impl = handle.GetImplementation();
443 return static_cast<const Toolkit::Internal::VideoView&>(impl);
446 } // namespace Toolkit
450 #endif // DALI_TOOLKIT_VIDEO_VIEW_H