Fix failure to play through the end of wv videos

Properly compute the buffered and remaining time, also properly account
for the different old and new rates at adaptive switch and other
performance tuning related to b/5153227.

Includes Widevine release libs version 4.5.0.4936

Bug 5336777

Change-Id: I997ea353b7c320dca5e3f5c065395dca206d35a6
This commit is contained in:
Jeff Tinker
2011-10-13 10:06:42 -07:00
committed by Jeffrey Tinker
parent 1fee8fd75a
commit bcfe38dcb0
9 changed files with 21 additions and 41 deletions

View File

@@ -44,10 +44,10 @@ class WVDRMPluginAPI {
virtual bool RegisterDrmInfo(std::string &portal, std::string &dsPath) = 0;
virtual bool UnregisterDrmInfo(std::string &portal, std::string &dsPath) = 0;
virtual bool AcquireDrmInfo(std::string &assetPath, WVCredentials &credentials,
std::string &dsPath, const std::string &assetIdStr,
const std::string &systemIdStr,
std::string &dsPath, const std::string &systemIdStr,
const std::string &assetIdStr,
const std::string &keyIdStr,
uint32_t *assetId, uint32_t *systemId,
uint32_t *systemId, uint32_t *assetId,
uint32_t *keyId) = 0;
virtual bool ProcessDrmInfo(std::string &assetPath, int playbackMode) = 0;
@@ -77,7 +77,7 @@ class WVDRMPluginAPI {
EventType_DeviceId,
EventType_StreamId,
EventType_UserData
};
};
enum EventDestination {
EventDestination_JavaAPI,

View File

@@ -1038,16 +1038,16 @@ CLIENT_API WVStatus
WV_Info_CurrentBandwidth(WVSession *session, unsigned long *bandwidth);
//
// METHOD: WV_Info_BytesBuffered
// METHOD: WV_Info_TimeBuffered
//
// This method retrieves information about the adaptive streaming buffer level
// for the media stream that was setup on the specified session.
// This method returns an approximate duration for the media buffered
// inside the Widevine adaptive client.
//
// Parameters:
// [in] session - The session to query
//
// [out] bytesBuffered - The number of bytes currently queued in the adaptive
// streaming buffer
// [out] secondsBuffered - Duration of the media currently
// buffered, in seconds
//
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
@@ -1055,7 +1055,7 @@ WV_Info_CurrentBandwidth(WVSession *session, unsigned long *bandwidth);
//
CLIENT_API WVStatus
WV_Info_BytesBuffered(WVSession *session, unsigned long long *bytesBuffered);
WV_Info_TimeBuffered(WVSession *session, float *secondsBuffered);
//

View File

@@ -122,11 +122,9 @@ void WVMExtractorImpl::Initialize()
#ifdef REQUIRE_SECURE_BUFFERS
if (!mIsLiveStream) {
LOGD("Not live, using decrypt callback");
WVCallbacks callbacks = {NULL, NULL, NULL, NULL, NULL, NULL, WVMMediaSource::DecryptCallback};
result = WV_Initialize(&callbacks);
} else {
LOGD("Live, NOT using decrypt callback");
result = WV_Initialize(NULL);
}
#else
@@ -418,39 +416,12 @@ int64_t WVMExtractorImpl::getCachedDurationUs(status_t *finalStatus) {
const size_t kMaxEncodedRates = 10;
unsigned long encodedRates[kMaxEncodedRates];
size_t ratesReturned, currentTrack;
uint64_t durationUs = 0;
WVStatus status = WV_Info_GetAdaptiveBitrates(mSession, encodedRates, kMaxEncodedRates,
&ratesReturned, &currentTrack);
if (status == WV_Status_OK) {
if (currentTrack == kMaxEncodedRates || ratesReturned == 0) {
*finalStatus = ERROR_IO;
} else {
unsigned long long bytesBuffered;
status = WV_Info_BytesBuffered(mSession, &bytesBuffered);
if (status == WV_Status_OK) {
*finalStatus = OK;
durationUs = 8000000LL * bytesBuffered / encodedRates[currentTrack];
// Fixed 4515636 Playback stops 5-7 seconds before end of video,
// session isn't terminated. Awesome player pauses video if
// duration is less than 2 seconds (see kLowWaterMarkUs in
// AwesomePlayer.cpp); we return END_OF_STREAM when we have 2
// seconds of data left and let WVMK handles the actual end of media.
std::string szDuration = WV_Info_GetDuration(mSession, "sec");
std::string szCurrent = WV_Info_GetTime(mSession, "sec");
double duration = strtod(szDuration.c_str(), NULL);
double current = strtod(szCurrent.c_str(), NULL);
if ((duration - current) <= 2.00) {
*finalStatus = ERROR_END_OF_STREAM;
}
} else if (status == WV_Status_End_Of_Media) {
*finalStatus = ERROR_END_OF_STREAM;
}
if (currentTrack != kMaxEncodedRates && ratesReturned != 0) {
// Log the current adaptive rate every 5 seconds
// FIXME: need to see if there is a way to send this info to the app
time_t now = time(0);
static time_t lastLogTime = now;
if (now > lastLogTime + 5) {
@@ -459,8 +430,17 @@ int64_t WVMExtractorImpl::getCachedDurationUs(status_t *finalStatus) {
currentTrack, encodedRates[currentTrack]);
}
}
} else {
}
uint64_t durationUs = 0;
float secondsBuffered;
status = WV_Info_TimeBuffered(mSession, &secondsBuffered);
if (status == WV_Status_End_Of_Media) {
*finalStatus = ERROR_END_OF_STREAM;
} else if (status != WV_Status_OK) {
*finalStatus = ERROR_IO;
} else {
durationUs = (uint64_t)(secondsBuffered * 1000000LL);
}
// Scale the duration to account for Stagefright's conservative buffering.