From fc22d19774524db1ec75c726ab8c6565e813222a Mon Sep 17 00:00:00 2001 From: EonseokLee Date: Wed, 15 May 2013 13:32:26 +0900 Subject: [PATCH] Fix the issue for VPSS-884 Change-Id: Ia4c2b7bfda65449fa1f91707a82a0601625829c7 Signed-off-by: EonseokLee --- src/FMedia_PlayerImpl.cpp | 33 ++++++++++++++++++++++++++++++--- src/inc/FMedia_PlayerImpl.h | 3 +++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/FMedia_PlayerImpl.cpp b/src/FMedia_PlayerImpl.cpp index 3eb3abe..b9ec52a 100644 --- a/src/FMedia_PlayerImpl.cpp +++ b/src/FMedia_PlayerImpl.cpp @@ -269,6 +269,12 @@ _PlayerImpl::Construct(IPlayerEventListener& listener, const Tizen::Graphics::Bu SysTryCatch(NID_MEDIA, __hCanvas != 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. __hCanvas = %d", __hCanvas); } + __pEndOfStreamHandler.reset(new (std::nothrow) Thread); + SysTryReturn(NID_MEDIA, __pEndOfStreamHandler.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY]could not create memory for End of steam handling thread"); + r = __pEndOfStreamHandler->Construct(*this); + SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Thread::Construct failed", GetErrorMessage(r)); + __pMutex->Acquire(); SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); __playerCount++; @@ -352,6 +358,12 @@ _PlayerImpl::Construct(IPlayerEventListener& listener, IPlayerVideoEventListener r = SetLooping(false); SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform SetLooping operation.", GetErrorMessage(r)); + __pEndOfStreamHandler.reset(new (std::nothrow) Thread); + SysTryReturn(NID_MEDIA, __pEndOfStreamHandler.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY]could not create memory for End of steam handling thread"); + r = __pEndOfStreamHandler->Construct(*this); + SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Thread::Construct failed", GetErrorMessage(r)); + __pMutex->Acquire(); SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); __playerCount++; @@ -422,6 +434,12 @@ _PlayerImpl::Construct(IPlayerEventListener& listener, Tizen::Graphics::Opengl:: r = SetLooping(false); SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform SetLooping operation.", GetErrorMessage(r)); + __pEndOfStreamHandler.reset(new (std::nothrow) Thread); + SysTryReturn(NID_MEDIA, __pEndOfStreamHandler.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY]could not create memory for End of steam handling thread"); + r = __pEndOfStreamHandler->Construct(*this); + SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Thread::Construct failed", GetErrorMessage(r)); + __pMutex->Acquire(); SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); __playerCount++; @@ -1606,6 +1624,15 @@ _PlayerImpl::PlayerSeekCompletedCallBack(void *pUserData) pPlyarImpl->HandlePlayerSeekCompleted(); } +//This is used exclusively for End of stream handling +Tizen::Base::Object* +_PlayerImpl::Run(void) +{ + player_stop(__hPlayer); + __currentState = PLAYER_STATE_ENDOFCLIP; + SendEvent(_PLAYER_EVENT_ENDOFCLIP, 0); +} + //Tizen Handle Functions void _PlayerImpl::HandlePlayerPrepared(int errorCode) @@ -1633,9 +1660,9 @@ _PlayerImpl::HandlePlayerPrepared(int errorCode) void _PlayerImpl::HandlePlayerCompleted(void) { - player_stop(__hPlayer); - __currentState = PLAYER_STATE_ENDOFCLIP; - SendEvent(_PLAYER_EVENT_ENDOFCLIP, 0); + result r = E_SUCCESS; + r = __pEndOfStreamHandler->Start(); + SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Thread::Start failed", GetErrorMessage(r)); } void diff --git a/src/inc/FMedia_PlayerImpl.h b/src/inc/FMedia_PlayerImpl.h index d0dd52e..38c0a6f 100644 --- a/src/inc/FMedia_PlayerImpl.h +++ b/src/inc/FMedia_PlayerImpl.h @@ -54,6 +54,7 @@ enum _PlayerEventType; class _OSP_EXPORT_ _PlayerImpl : public Tizen::Base::Object , public Tizen::Base::Runtime::ITimerEventListener + , public Tizen::Base::Runtime::IRunnable { enum Orientation { @@ -111,6 +112,7 @@ public: int GetHttpStreamingDownloadProgress(void) const; void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + Tizen::Base::Object* Run(void); static void PlayerStartedCallBack(void *pUserData); static void PlayerCompletedCallBack(void *pUserData); @@ -166,6 +168,7 @@ private: std::unique_ptr<_PlayerProgressiveDownloadEvent> __pPlayerProgressiveDownloadEvent; std::unique_ptr __pPdTimer; std::unique_ptr __pTargetByteBuffer; + std::unique_ptr __pEndOfStreamHandler; static std::unique_ptr __pMutex; static bool __isInstanceMutexInitialized; -- 2.7.4