/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/devel-api/rendering/texture-devel.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
const char* const DEFAULT_SAMPLER_TYPE_NAME("sampler2D");
const char* const CUSTOM_SAMPLER_TYPE_NAME("samplerExternalOES");
+const char* const IS_VIDEO_VIEW_PROPERTY_NAME = "isVideoView";
+
} // namespace
VideoView::VideoView(Dali::VideoSyncMode syncMode)
mFrameID(0),
mIsPlay(false),
mIsUnderlay(true),
- mSyncMode(syncMode)
+ mSyncMode(syncMode),
+ mSiblingOrder(0)
{
}
void VideoView::OnInitialize()
{
+ Actor self = Self();
mVideoPlayer.FinishedSignal().Connect(this, &VideoView::EmitSignalFinish);
- DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
- return std::unique_ptr<Dali::Accessibility::Accessible>(
- new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::VIDEO));
- });
+ // Accessibility
+ self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::VIDEO);
+ self.SetProperty(DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true);
+
+ //update self property
+ self.RegisterProperty(IS_VIDEO_VIEW_PROPERTY_NAME, true, Property::READ_WRITE);
}
void VideoView::SetUrl(const std::string& url)
void VideoView::OnSceneConnection(int depth)
{
- Control::OnSceneConnection(depth);
-
+ Actor self = Self();
if(mIsUnderlay)
{
+ mSiblingOrder = self.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER);
+ DevelActor::ChildOrderChangedSignal(self.GetParent()).Connect(this, &VideoView::OnChildOrderChanged);
SetWindowSurfaceTarget();
}
+
+ DALI_LOG_RELEASE_INFO("Calls mVideoPlayer.SceneConnection()\n");
+ mVideoPlayer.SceneConnection();
+ Control::OnSceneConnection(depth);
}
void VideoView::OnSceneDisconnection()
{
+ DALI_LOG_RELEASE_INFO("Calls mVideoPlayer.SceneDisconnection()\n");
+ mVideoPlayer.SceneDisconnection();
Control::OnSceneDisconnection();
}
{
if(mIsUnderlay && mSyncMode == Dali::VideoSyncMode::ENABLED)
{
- SetFrameRenderCallback();
+ // TODO: SR Video shell's designed is completed,
+ // it will be re-designed and implemented.
+ // Until it is completed, the below code will be commented.
+
+ //SetFrameRenderCallback();
mVideoPlayer.StartSynchronization();
}
Control::OnSizeSet(targetSize);
}
+void VideoView::OnChildOrderChanged(Actor actor)
+{
+ Actor self = Self();
+ int currentSiblingOrder = self.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER);
+ if(currentSiblingOrder != mSiblingOrder)
+ {
+ Actor parent = self.GetParent();
+ Actor child;
+ Actor upper;
+ Actor lower;
+
+ int numChildren = static_cast<int>(parent.GetChildCount());
+ for(int i = 0; i < numChildren; i++)
+ {
+ child = parent.GetChildAt(i);
+ if(!IsVideoView(child))
+ {
+ continue;
+ }
+
+ if(child == self)
+ {
+ continue;
+ }
+
+ if(i < currentSiblingOrder)
+ {
+ lower = child;
+ }
+ else if(i > currentSiblingOrder)
+ {
+ upper = child;
+ break;
+ }
+ }
+
+ if(lower)
+ {
+ Toolkit::VideoView lowerView = Toolkit::VideoView::DownCast(lower);
+ mVideoPlayer.RaiseAbove(GetImpl(lowerView).GetVideoPlayer());
+ }
+
+ if(upper)
+ {
+ Toolkit::VideoView upperView = Toolkit::VideoView::DownCast(upper);
+ mVideoPlayer.LowerBelow(GetImpl(upperView).GetVideoPlayer());
+ }
+ mSiblingOrder = currentSiblingOrder;
+ }
+}
+
Vector3 VideoView::GetNaturalSize()
{
Vector3 size;
}
}
-float VideoView::GetHeightForWidth(float width)
-{
- if(mVideoSize.GetWidth() > 0 && mVideoSize.GetHeight() > 0)
- {
- return GetHeightForWidthBase(width);
- }
- else
- {
- return Control::GetHeightForWidthBase(width);
- }
-}
-
-float VideoView::GetWidthForHeight(float height)
-{
- if(mVideoSize.GetWidth() > 0 && mVideoSize.GetHeight() > 0)
- {
- return GetWidthForHeightBase(height);
- }
- else
- {
- return Control::GetWidthForHeightBase(height);
- }
-}
-
void VideoView::SetWindowSurfaceTarget()
{
Actor self = Self();
return;
}
+ Dali::Window window = DevelWindow::Get(self);
+ window.ResizeSignal().Connect(this, &VideoView::OnWindowResized);
+
int curPos = mVideoPlayer.GetPlayPosition();
if(mIsPlay)
{
// For underlay rendering mode, video display area have to be transparent.
Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
- Shader shader = Shader::New(SHADER_VIDEO_VIEW_VERT, SHADER_VIDEO_VIEW_FRAG);
+ Shader shader = Shader::New(SHADER_VIDEO_VIEW_VERT, SHADER_VIDEO_VIEW_FRAG, Shader::Hint::NONE, "VIDEO_VIEW_OVERLAY");
mOverlayRenderer = Renderer::New(geometry, shader);
mOverlayRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF);
}
{
// If mSyncMode is enabled, Video player's size and poistion is updated in Video player's constraint.
// Because video view and player should be work syncronization.
- if(!mIsUnderlay || mSyncMode == Dali::VideoSyncMode::ENABLED)
+
+ // TODO: SR Video shell's designed is completed,
+ // it will be re-designed and implemented.
+ // Until it is completed, the below code will be commented.
+ if(!mIsUnderlay /* || mSyncMode == Dali::VideoSyncMode::ENABLED */)
{
return;
}
void VideoView::OnAnimationFinished(Animation& animation)
{
// send desync
- SetFrameRenderCallback();
+ // TODO: SR Video shell's designed is completed,
+ // it will be re-designed and implemented.
+ // Until it is completed, the below code will be commented.
+
+ //SetFrameRenderCallback();
+}
+
+void VideoView::OnWindowResized(Dali::Window winHandle, Dali::Window::WindowSize size)
+{
+ Dali::VideoPlayerPlugin::DisplayRotation videoAngle = mVideoPlayer.GetDisplayRotation();
+ int windowAngle = (DevelWindow::GetPhysicalOrientation(winHandle) / 90);
+
+ if(windowAngle != videoAngle)
+ {
+ mVideoPlayer.SetDisplayRotation(static_cast<Dali::VideoPlayerPlugin::DisplayRotation>(windowAngle));
+ }
}
void VideoView::PlayAnimation(Dali::Animation animation)
Dali::Shader VideoView::CreateShader()
{
- std::string fragmentShader = "#extension GL_OES_EGL_image_external:require\n";
+ std::string fragmentShader;
std::string vertexShader;
std::string customFragmentShader;
bool checkShader = false;
if(!fragmentShaderValue || !checkShader)
{
- fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
+ fragmentShader = SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
+ DevelTexture::ApplyNativeFragmentShader(mNativeTexture, fragmentShader);
}
}
else
{
- vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
- fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
+ vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
+ fragmentShader = SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
+ DevelTexture::ApplyNativeFragmentShader(mNativeTexture, fragmentShader);
}
- return Dali::Shader::New(vertexShader, fragmentShader);
+ return Dali::Shader::New(vertexShader, fragmentShader, Shader::Hint::NONE, "VIDEO_VIEW");
}
bool VideoView::GetStringFromProperty(const Dali::Property::Value& value, std::string& output)
mFrameID);
}
+bool VideoView::IsVideoView(Actor actor) const
+{
+ // Check whether the actor is a VideoView
+ bool isVideoView = false;
+
+ if(actor)
+ {
+ Property::Index propertyIsVideoView = actor.GetPropertyIndex(IS_VIDEO_VIEW_PROPERTY_NAME);
+ if(propertyIsVideoView != Property::INVALID_INDEX)
+ {
+ isVideoView = actor.GetProperty<bool>(propertyIsVideoView);
+ }
+ }
+
+ return isVideoView;
+}
+
+VideoPlayer VideoView::GetVideoPlayer()
+{
+ return mVideoPlayer;
+}
+
} // namespace Internal
} // namespace Toolkit