PVMFInfoBufferingStatus for HTTP streaming when content length is
unknown should not be propagated to the application, because it
represents the actual number of bytes downloaded instead of a
percentage value.
diff --git a/android/playerdriver.cpp b/android/playerdriver.cpp
index aa282da..077f23f 100644
--- a/android/playerdriver.cpp
+++ b/android/playerdriver.cpp
@@ -305,6 +305,7 @@
bool mSeekPending;
bool mIsLiveStreaming;
bool mEmulation;
+ bool mContentLengthKnown;
void* mLibHandle;
// video display surface
@@ -323,7 +324,8 @@
mSeekComp(true),
mSeekPending(false),
mIsLiveStreaming(false),
- mEmulation(false)
+ mEmulation(false),
+ mContentLengthKnown(false)
{
LOGV("constructor");
mSyncSem = new OsclSemaphore();
@@ -459,6 +461,7 @@
{
if (mDoLoop) {
mEndOfData = false;
+ mContentLengthKnown = false;
PVPPlaybackPosition begin, end;
begin.iIndeterminate = false;
begin.iPosUnit = PVPPBPOSUNIT_SEC;
@@ -1024,6 +1027,7 @@
mIsLooping = false;
mDoLoop = false;
mEndOfData = false;
+ mContentLengthKnown = false;
OSCL_TRY(error, mPlayer->Reset(command));
OSCL_FIRST_CATCH_ANY(error, commandFailed(command));
@@ -1314,9 +1318,17 @@
{
const void *buffer = aEvent.GetLocalBuffer();
const size_t size = aEvent.GetLocalBufferSize();
- int percentage;
- if (GetBufferingPercentage(buffer, size, &percentage))
+ int percentage;
+ // For HTTP sessions, if PVMFInfoContentLength has been
+ // received, only then the buffering status is a percentage
+ // of content length. Otherwise, it is the total number of
+ // bytes downloaded.
+ // For RTSP session, the buffering status is a percentage
+ // of the data that needs to be downloaded to start/resume
+ // playback.
+ if ( (mContentLengthKnown || (getFormatType() == PVMF_MIME_DATA_SOURCE_RTSP_URL) ) &&
+ (GetBufferingPercentage(buffer, size, &percentage)))
{
LOGD("buffering (%d)", percentage);
mPvPlayer->sendEvent(MEDIA_BUFFERING_UPDATE, percentage);
@@ -1384,12 +1396,15 @@
PVMFInfoContentTruncated);
break;
+ case PVMFInfoContentLength:
+ mContentLengthKnown = true;
+ break;
+
/* Certain events we don't really care about, but don't
* want log spewage, so just no-op them here.
*/
case PVMFInfoPositionStatus:
case PVMFInfoBufferingComplete:
- case PVMFInfoContentLength:
case PVMFInfoContentType:
case PVMFInfoUnderflow:
case PVMFInfoDataDiscarded: