/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
// CLASS HEADER
#include "tizen-video-constraint-helper.h"
+// EXTERNAL INCLUDES
+#include <tbm_surface_internal.h>
+
namespace Dali
{
namespace Plugin
{
-
VideoConstraintHelperPtr VideoConstraintHelper::New(Dali::NativeImageSourcePtr nativeImageSourcePtr)
{
VideoConstraintHelperPtr ptr = new VideoConstraintHelper(nativeImageSourcePtr);
mIsAutoRotationEnabled(false),
mIsLetterBoxEnabled(false)
{
-
}
VideoConstraintHelper::~VideoConstraintHelper()
{
Dali::Mutex::ScopedLock lock(mConstraintMutex);
mIsSetInfo = true;
+ if(mSurface != NULL)
+ {
+ tbm_surface_internal_unref(mSurface);
+ }
+
mSurface = surface;
+
+ if(mSurface != NULL)
+ {
+ tbm_surface_internal_ref(mSurface);
+ }
+
// Orientation should be set to zero when auto rotation is disabled.
mOrientation = mIsAutoRotationEnabled ? orientation : 0;
- if (mIsLetterBoxEnabled)
+ if(mIsLetterBoxEnabled)
{
- mWidth = width;
+ mWidth = width;
mHeight = height;
}
}
if(mIsSetInfo && mNativeImageSourcePtr)
{
mNativeImageSourcePtr->SetSource(mSurface);
+ if(mSurface != NULL)
+ {
+ tbm_surface_internal_unref(mSurface);
+ }
+ mSurface = NULL;
mIsSetInfo = false;
}
}
Dali::Vector4 VideoConstraintHelper::GetOrientationMatrix()
{
Dali::Mutex::ScopedLock lock(mConstraintMutex);
- switch (mOrientation)
+ switch(mOrientation)
{
case 0:
+ {
return Dali::Vector4(1.0f, 0.0f, 0.0f, 1.0f);
+ }
case 90:
+ {
return Dali::Vector4(0.0f, -1.0f, 1.0f, 0.0f);
+ }
case 180:
+ {
return Dali::Vector4(-1.0f, 0.0f, 0.0f, -1.0f);
+ }
case 270:
+ {
return Dali::Vector4(0.0f, 1.0f, -1.0f, 0.0f);
+ }
default:
+ {
return Dali::Vector4(1.0f, 0.0f, 0.0f, 1.0f);
+ }
}
}
{
Dali::Mutex::ScopedLock lock(mConstraintMutex);
mIsAutoRotationEnabled = enable;
- if (!mIsAutoRotationEnabled)
+ if(!mIsAutoRotationEnabled)
{
mOrientation = 0;
}
{
Dali::Mutex::ScopedLock lock(mConstraintMutex);
mIsLetterBoxEnabled = enable;
- if (!mIsLetterBoxEnabled)
+ if(!mIsLetterBoxEnabled)
{
- mWidth = 0;
+ mWidth = 0;
mHeight = 0;
}
}
return mIsLetterBoxEnabled;
}
-}
-}
+} // namespace Plugin
+} // namespace Dali
#ifndef __DALI_TIZEN_VIDEO_CONSTRAINT_HELPER_H__
#define __DALI_TIZEN_VIDEO_CONSTRAINT_HELPER_H__
-
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
// INTERNAL INCLUDES
-
// EXTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
#include <dali/devel-api/threading/mutex.h>
-#include <tbm_surface.h>
-#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector4.h>
-
+#include <dali/public-api/object/ref-object.h>
+#include <tbm_surface.h>
namespace Dali
{
namespace Plugin
{
-
class VideoConstraintHelper;
typedef Dali::IntrusivePtr<VideoConstraintHelper> VideoConstraintHelperPtr;
-class VideoConstraintHelper: public Dali::RefObject
+class VideoConstraintHelper : public Dali::RefObject
{
public:
-
/**
* @brief Creates a new instance of VideoConstraintHelper
* @param[in] nativeImageSourcePtr Native image source pointer
private:
Dali::NativeImageSourcePtr mNativeImageSourcePtr;
- Dali::Mutex mConstraintMutex;
+
+ Dali::Mutex mConstraintMutex;
tbm_surface_h mSurface;
+
int mOrientation;
int mWidth;
int mHeight;
- bool mIsSetInfo : 1;
- bool mIsAutoRotationEnabled : 1;
- bool mIsLetterBoxEnabled : 1;
+
+ bool mIsSetInfo;
+ bool mIsAutoRotationEnabled;
+ bool mIsLetterBoxEnabled;
};
} // namespace Plugin
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
struct VideoPlayerRotationConstraint
{
- public:
+public:
VideoPlayerRotationConstraint(Dali::IntrusivePtr<VideoConstraintHelper> handler)
- : mVideoHandler(handler)
+ : mVideoHandler(handler)
{
}
- void operator()(Dali::Vector4& current, const Dali::PropertyInputContainer& inputs)
+ void operator()(Dali::Vector4& current, const Dali::PropertyInputContainer& /* unused */)
{
- if(inputs.Size() > 0) { // to avoid build warning
- }
- if (mVideoHandler)
+ if(DALI_LIKELY(mVideoHandler))
{
current = mVideoHandler->GetOrientationMatrix();
mVideoHandler->UpdateVideo();
struct VideoPlayerRatioConstraint
{
- public:
+public:
VideoPlayerRatioConstraint(Dali::IntrusivePtr<VideoConstraintHelper> handler)
- : mVideoHandler(handler)
+ : mVideoHandler(handler)
{
}
- void operator()(Dali::Vector2& current, const Dali::PropertyInputContainer& inputs)
+ void operator()(Dali::Vector2& current, const Dali::PropertyInputContainer& /* unused */)
{
- if(inputs.Size() > 0) { // to avoid build warning
- }
- if (mVideoHandler)
+ if(DALI_LIKELY(mVideoHandler))
{
current = mVideoHandler->RetriveSize();
}
: mUrl(),
mPlayer(NULL),
mPlayerState(PLAYER_STATE_NONE),
- mTbmSurface(NULL),
mPacket(NULL),
mNativeImageSourcePtr(NULL),
mBackgroundColor(Dali::Vector4(1.0f, 1.0f, 1.0f, 0.0f)),
Dali::NativeImageSourcePtr nativeImageSourcePtr = AnyCast<Dali::NativeImageSourcePtr>(target);
+ DALI_LOG_RELEASE_INFO("target is not underlay mode\n");
InitializeTextureStreamMode(nativeImageSourcePtr);
CreateVideoConstraint(nativeImageSourcePtr);
{
DALI_LOG_ERROR("InitializeTextureStreamMode, player_set_display_visible() is failed\n");
}
-
}
}
{
return;
}
-
- error = media_packet_get_tbm_surface(mPacket, &mTbmSurface);
+ tbm_surface_h tbmSurface = NULL;
+ error = media_packet_get_tbm_surface(mPacket, &tbmSurface);
if(error != MEDIA_PACKET_ERROR_NONE)
{
media_packet_destroy(mPacket);
return;
}
- media_packet_rotate_method_e org_orient;
- media_packet_get_rotate_method(mPacket, &org_orient);
+ media_packet_rotate_method_e orginalOrientation;
+ media_packet_get_rotate_method(mPacket, &orginalOrientation);
int orientation = 0;
- switch (org_orient) {
+ switch(orginalOrientation)
+ {
case MEDIA_PACKET_ROTATE_IDENTITY: //0
+ {
orientation = 0;
break;
+ }
case MEDIA_PACKET_ROTATE_90: //1
+ {
orientation = 270;
break;
+ }
case MEDIA_PACKET_ROTATE_180: //2
+ {
orientation = 180;
break;
+ }
case MEDIA_PACKET_ROTATE_270: //3
+ {
orientation = 90;
break;
+ }
default:
- DALI_LOG_ERROR("wrong angle type : %d", org_orient);
+ {
+ DALI_LOG_ERROR("wrong angle type : %d", orginalOrientation);
break;
+ }
}
media_format_h format;
- int width, height;
- if (media_packet_get_format(mPacket, &format) != MEDIA_PACKET_ERROR_NONE)
+ int width, height;
+ if(media_packet_get_format(mPacket, &format) != MEDIA_PACKET_ERROR_NONE)
{
DALI_LOG_ERROR("failed to media_packet_get_format\n");
return;
}
- if (media_format_get_video_info(format, NULL, &width, &height, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE)
+ if(media_format_get_video_info(format, NULL, &width, &height, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE)
{
DALI_LOG_ERROR("failed to media_format_get_video_info\n");
media_format_unref(format);
media_format_unref(format);
- mVideoConstraintHelper->SetInfo(mTbmSurface, orientation, width, height);
+ mVideoConstraintHelper->SetInfo(tbmSurface, orientation, width, height);
}
void TizenVideoPlayer::DestroyPackets()
}
}
- error = sound_manager_destroy_stream_information(mStreamInfo);
- ret = LogPlayerError(error);
- if(ret)
+ if(mStreamInfo != NULL)
{
- DALI_LOG_ERROR("DestroyPlayer, sound_manager_destroy_stream_information() is failed\n");
+ error = sound_manager_destroy_stream_information(mStreamInfo);
+ ret = LogPlayerError(error);
+ if(ret)
+ {
+ DALI_LOG_ERROR("DestroyPlayer, sound_manager_destroy_stream_information() is failed\n");
+ }
}
mPlayerState = PLAYER_STATE_NONE;
mPlayer = NULL;
+ mStreamInfo = NULL;
}
void TizenVideoPlayer::SetCodecType(Dali::VideoPlayerPlugin::CodecType type)
if(syncActor)
{
mVideoRotationPropertyIndex = syncActor.RegisterProperty("uRotationMatrix", Property::Value(Vector4(1.0f, 0.0f, 0.0f, 1.0f)));
- mVideoRatioPropertyIndex = syncActor.RegisterProperty("uSizeRatio", Property::Value(Vector2(0.0f, 0.0f)));
+ mVideoRatioPropertyIndex = syncActor.RegisterProperty("uSizeRatio", Property::Value(Vector2(0.0f, 0.0f)));
- mVideoConstraintHelper = VideoConstraintHelper::New(nativeImageSourcePtr);
+ mVideoConstraintHelper = VideoConstraintHelper::New(nativeImageSourcePtr);
mVideoRotationConstraint = Constraint::New<Vector4>(syncActor, mVideoRotationPropertyIndex, VideoPlayerRotationConstraint(mVideoConstraintHelper));
mVideoRotationConstraint.Apply();