From 389d1394d9e32f75d25827b85de847c7f88469f9 Mon Sep 17 00:00:00 2001 From: EonseokLee Date: Thu, 28 Mar 2013 17:09:57 +0900 Subject: [PATCH] Add the GetHttpStreamingDownloadProgress() Change-Id: I6b8ed57a697e1824866a4d6f64be91e21c7bfac7 Signed-off-by: EonseokLee --- inc/FMediaPlayer.h | 26 ++++++++++++++++++++++++-- src/FMediaPlayer.cpp | 12 ++++++++++++ src/FMedia_PlayerImpl.cpp | 30 +++++++++++++++++++++++++++++- src/inc/FMedia_PlayerImpl.h | 1 + 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/inc/FMediaPlayer.h b/inc/FMediaPlayer.h index 14fea07..9a8c76e 100755 --- a/inc/FMediaPlayer.h +++ b/inc/FMediaPlayer.h @@ -511,7 +511,9 @@ public: * @return The current position of the player in milliseconds * @exception E_SUCCESS The method is successful. * @exception E_INVALID_STATE This instance is in an invalid state for this method. - * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks + * - The specific error code can be accessed using the GetLastResult() method. + * - This method returns -1 when the method failed. * @see SeekTo() */ long GetPosition(void) const; @@ -555,7 +557,9 @@ public: * @exception E_INVALID_STATE This instance is in an invalid state for this method. * @remarks The specific error code can be accessed using the GetLastResult() method. @n * While playing live streaming, this operation returns @c 0. - * @remarks This method is valid in the @c PLAYER_STATE_OPENED @c PLAYER_STATE_PLAYING @c PLAYER_STATE_PAUSED @c PLAYER_STATE_STOPPED states of this instance. + * @remarks + * - This method is valid in the @c PLAYER_STATE_OPENED @c PLAYER_STATE_PLAYING @c PLAYER_STATE_PAUSED @c PLAYER_STATE_STOPPED states of this instance. + * - This method returns -1 when the method failed. * @see GetPosition() */ long GetDuration(void) const; @@ -802,6 +806,24 @@ public: * @remarks This method constructs the %Player instance to render the video content into the video texture area. */ result Construct(IPlayerEventListener& listener, Tizen::Graphics::Opengl::VideoTexture& videoTexture); + + /** + * Gets the current downloading progress of HTTP streaming playback in percent. + * + * @since 2.1 + * + * @return The current position in percent + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The method works for HTTP streaming playback only. + * @exception E_INVALID_STATE This instance is in an invalid state for this method. + * @remarks + * - This method works only for the @c PLAYER_STATE_PLAYING or PLAYER_STATE_PAUSED states of the %Player instance. + * - This method is not supported in HTTP Live Streaming. + * - The specific error code can be accessed using GetLastResult() method. + * - This method returns -1 when the method failed. + */ + int GetHttpStreamingDownloadProgress(void) const; + private: /** * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. diff --git a/src/FMediaPlayer.cpp b/src/FMediaPlayer.cpp index 6573112..3636c45 100644 --- a/src/FMediaPlayer.cpp +++ b/src/FMediaPlayer.cpp @@ -462,4 +462,16 @@ Player::SetProgressiveDownloadIntervalByPercent(int percent) __pPlayerImpl->SetProgressiveDownloadIntervalByPercent(percent); } +int +Player::GetHttpStreamingDownloadProgress(void) const +{ + int curPosition = -1; //MEDIA_INVALID_VALUE; + ClearLastResult(); + + SysAssertf(__pPlayerImpl != null, "Not yet constructed! Construct() should be called before use"); + + curPosition = __pPlayerImpl->GetHttpStreamingDownloadProgress(); + return curPosition; +} + }} // Tizen::Media diff --git a/src/FMedia_PlayerImpl.cpp b/src/FMedia_PlayerImpl.cpp index b918257..e772e3a 100644 --- a/src/FMedia_PlayerImpl.cpp +++ b/src/FMedia_PlayerImpl.cpp @@ -76,7 +76,6 @@ _PlayerImpl::_PlayerImpl(void) , __isMuted(false) , __isLooped(false) , __isLocalData(true) - , __isAsync(false) , __checkCallbackForReadyState(false) , __isStreamingContent(false) , __videoEventCreated(false) @@ -85,6 +84,7 @@ _PlayerImpl::_PlayerImpl(void) , __isProgressiveContent(false) , __isProgressiveTimerStarted(false) , __interruptFlag(false) + , __isAsync(false) { } @@ -2522,6 +2522,34 @@ _PlayerImpl::SetProgressiveDownloadIntervalByPercent(int percent) } } +int +_PlayerImpl::GetHttpStreamingDownloadProgress(void) const +{ + int returnValue = 0; + int startValue = 0; + int err = ::PLAYER_ERROR_NONE; + player_state_e corePlayerCurState; + result r = E_SUCCESS; + + SysAssertf(__hPlayer != null, "Not yet constructed! Construct() should be called before use"); + + SysTryReturn(NID_MEDIA, __isStreamingContent == true, -1, E_INVALID_OPERATION, "[%s] Failed to perform this operation. This method dose not work on local content.", GetErrorMessage(E_INVALID_OPERATION)); + + err = player_get_state(__hPlayer, &corePlayerCurState); + r = MapExceptionToResult(err); + SysTryReturn(NID_MEDIA, r == E_SUCCESS, -1, r, "[%s] Failed to perform player_getstate operation with - 0x%x", GetErrorMessage(r), err); + + SysTryReturn(NID_MEDIA, (corePlayerCurState == ::PLAYER_STATE_PLAYING) || (corePlayerCurState == ::PLAYER_STATE_PAUSED) , + -1, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. Current state is %d", corePlayerCurState); + + err = player_get_streaming_download_progress(__hPlayer, &startValue, &returnValue); + r = MapExceptionToResult(err); + SysTryReturn(NID_MEDIA, r == E_SUCCESS, -1, r, "[%s] Failed to perform player_get_streaming_download_progress operation with - 0x%x", GetErrorMessage(r), err); + + return returnValue; +} + + }; }; // Tizen::Media diff --git a/src/inc/FMedia_PlayerImpl.h b/src/inc/FMedia_PlayerImpl.h index a05cc3c..d0dd52e 100644 --- a/src/inc/FMedia_PlayerImpl.h +++ b/src/inc/FMedia_PlayerImpl.h @@ -108,6 +108,7 @@ public: result OpenUrlAsync(Player* pPlayerInstance, const Tizen::Base::String& url, const Tizen::Base::String& filePath, IPlayerProgressiveDownloadListener& listener, const Tizen::Base::Collection::IMap* pHeader = null); void SetProgressiveDownloadIntervalByPercent(int percent); result Construct(IPlayerEventListener& listener, Tizen::Graphics::Opengl::VideoTexture& videoTexture); + int GetHttpStreamingDownloadProgress(void) const; void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); -- 2.7.4