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:
committed by
Jeffrey Tinker
parent
1fee8fd75a
commit
bcfe38dcb0
@@ -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, ¤tTrack);
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user