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/images/image-operations.h>
26 #include <dali/public-api/object/property-conditions.h>
27 #include <dali/public-api/object/property-map.h>
28 #include <dali/public-api/object/property-notification.h>
29 #include <dali/public-api/rendering/renderer.h>
30 #include <dali/public-api/rendering/texture.h>
33 #include <dali-toolkit/public-api/controls/control-impl.h>
34 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
44 class VideoView : public Control
47 VideoView(Dali::VideoSyncMode syncMode);
53 * @copydoc Toolkit::DevelVideoView::New()
55 static Toolkit::VideoView New(VideoSyncMode syncMode);
58 * @brief Sets a video url to play.
61 * @param [in] url The url of the video resource to play
63 void SetUrl(const std::string& url);
66 * @brief Returns a video url.
68 * @return Url of string type
73 * @brief Sets the player looping status.
76 * @param [in] looping The new looping status: true or false
78 void SetLooping(bool looping);
81 * @brief Returns the player looping status.
84 * @return True if player is looping, false otherwise.
89 * @copydoc Toolkit::VideoView::Play()
94 * @copydoc Toolkit::VideoView::Pause()
99 * @copydoc Toolkit::VideoView::Stop()
104 * @copydoc Toolkit::VideoView::Forward()
106 void Forward(int millisecond);
109 * @copydoc Toolkit::VideoView::Backward()
111 void Backward(int millisecond);
114 * @brief Sets the player mute status.
116 * @param[i] mute The new mute status, true is mute.
118 void SetMute(bool mute);
121 * @brief Returns the player mute status.
123 * @return True if player is mute.
128 * @brief Sets the player volume.
130 * @param[in] left The left volume scalar
131 * @param[in] right The right volume scalar
133 void SetVolume(float left, float right);
136 * @brief Returns current volume factor.
138 * @param[out] left The current left volume scalar
139 * @param[out] right The current right volume scalar
141 void GetVolume(float& left, float& right);
144 * @copydoc Dali::Toolkit::VideoView::FinishedSignal()
146 Dali::Toolkit::VideoView::VideoViewSignalType& FinishedSignal();
149 * @brief Emit the finished signal
151 void EmitSignalFinish();
154 * @brief Set property map
156 * @param[in] map The Dali::Property::Map to use for to display.
158 void SetPropertyMap(Property::Map map);
162 * @brief Called when a property of an object of this type is set.
164 * @param[in] object The object whose property is set.
165 * @param[in] index The property index.
166 * @param[in] value The new property value.
168 static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
171 * @brief Called to retrieve a property of an object of this type.
173 * @param[in] object The object whose property is to be retrieved.
174 * @param[in] index The property index.
175 * @return The current value of the property.
177 static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
180 * @brief Set the depth index of this image renderer
182 * Renderer with higher depth indices are rendered in front of other visuals with smaller values
184 * @param[in] depthIndex The depth index of this renderer
186 void SetDepthIndex(int depthIndex);
189 * @brief Performs actions as requested using the action name.
191 * @param[in] object The object on which to perform the action.
192 * @param[in] actionName The action to perform.
193 * @param[in] attributes The attributes with which to perfrom this action.
194 * @return True if action has been accepted by this control
196 static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes);
199 * Connects a callback function with the object's signals.
200 * @param[in] object The object providing the signal.
201 * @param[in] tracker Used to disconnect the signal.
202 * @param[in] signalName The signal to connect to.
203 * @param[in] functor A newly allocated FunctorDelegate.
204 * @return True if the signal was connected.
205 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
207 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
210 * @brief Updates video display area for window rendering target
212 void UpdateDisplayArea(Dali::PropertyNotification& source);
215 * @brief Sets underlay flag and initializes new rendering target by flag.
217 void SetUnderlay(bool set);
220 * @brief Checks underlay flag.
225 * @brief Sets sw codec type.
227 void SetSWCodec(bool on);
230 * @brief Gets play position.
232 int GetPlayPosition();
235 * @brief Sets play position.
237 void SetPlayPosition(int pos);
240 * @brief Sets Display mode.
242 void SetDisplayMode(int mode);
245 * @brief Gets Display mode.
247 int GetDisplayMode() const;
250 * @brief Gets internal media player.
252 Any GetMediaPlayer();
255 * @brief Play the resize or move animation with synchronization between UI(transparent hole) and video player
257 * The resize and move animation's play() function is called.
258 * If the animation is played, UI and video player will work synchronization.
260 * @param[in] videoView The current VideoView
261 * @param[in] animation The animation for video view's resize or move.
263 void PlayAnimation(Dali::Animation animation);
265 private: // From Control
267 * @copydoc Toolkit::Control::OnInitialize()
269 void OnInitialize() override;
272 * @copydoc Toolkit::Control::OnSceneConnection()
274 void OnSceneConnection(int depth) override;
277 * @copydoc Toolkit::Control::OnSceneDisconnection()
279 void OnSceneDisconnection() override;
282 * @copydoc Toolkit::Control::OnSizeSet()
284 void OnSizeSet(const Vector3& targetSize) override;
287 * @copydoc Toolkit::Control::GetNaturalSize
289 Vector3 GetNaturalSize() override;
292 * @copydoc Toolkit::Control::GetHeightForWidth()
294 float GetHeightForWidth(float width) override;
297 * @copydoc Toolkit::Control::GetWidthForHeight()
299 float GetWidthForHeight(float height) override;
303 * @brief Construct a new VideoView.
305 VideoView(const VideoView& videoView);
307 // Undefined assignment operator.
308 VideoView& operator=(const VideoView& videoView);
311 * @brief SetWindowSurfaceTarget for underlay video playback.
313 void SetWindowSurfaceTarget();
316 * @brief SetNativeImageTarget for native image video playback.
318 void SetNativeImageTarget();
321 * @brief CreateShader for native image target
323 Dali::Shader CreateShader();
326 * @brief Checks whether the property has a string value.
327 * @param Property value
328 * @param String output
329 * @return true if the output was found
331 bool GetStringFromProperty(const Dali::Property::Value& value, std::string& output);
334 * @brief Internal version of SetProperty
336 void SetPropertyInternal(Property::Index index, const Property::Value& value);
339 * @brief Apply properties after reset video player
341 void ApplyBackupProperties();
344 * @brief FrameRender's callback function
346 * This function means the resize/move animation is finished,
347 * so Ui and video player's synchronization can be finished.
350 void FrameRenderCallback(int frameID);
353 * @brief Set frameRender Callback function
355 * This function is added for listenr the resize/move animation is finished,
358 void SetFrameRenderCallback();
361 * @brief resize/move animation finished callback function
363 * This function is called the resize/move animation is finished,
366 void OnAnimationFinished(Dali::Animation& animation);
369 Dali::VideoPlayer mVideoPlayer;
370 Dali::ImageDimensions mVideoSize;
371 Dali::Property::Map mPropertyMap;
372 Dali::Property::Map mEffectPropertyMap;
373 Dali::Texture mNativeTexture;
375 Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
378 Dali::DisplayArea mDisplayArea;
379 Dali::Renderer mOverlayRenderer;
380 Dali::Renderer mTextureRenderer;
382 Dali::PropertyNotification mPositionUpdateNotification;
383 Dali::PropertyNotification mSizeUpdateNotification;
384 Dali::PropertyNotification mScaleUpdateNotification;
386 Dali::Property::Map mPropertyBackup;
388 int mCurrentVideoPlayPosition;
394 Dali::VideoSyncMode mSyncMode;
397 } // namespace Internal
399 inline Toolkit::Internal::VideoView& GetImpl(Toolkit::VideoView& handle)
401 DALI_ASSERT_ALWAYS(handle);
402 Dali::RefObject& impl = handle.GetImplementation();
403 return static_cast<Toolkit::Internal::VideoView&>(impl);
406 inline const Toolkit::Internal::VideoView& GetImpl(const Toolkit::VideoView& handle)
408 DALI_ASSERT_ALWAYS(handle);
409 const Dali::RefObject& impl = handle.GetImplementation();
410 return static_cast<const Toolkit::Internal::VideoView&>(impl);
413 } // namespace Toolkit
417 #endif // DALI_TOOLKIT_VIDEO_VIEW_H