am ba5fa0ef: Fixes for b/4149416:expired license refresh, b/4126624:heartbeats, b/4171055: inconsistent license modes Also includes b/3500025: A/V resync issues
* commit 'ba5fa0ef570f6ca3524f8158a23371528930f0fc': Fixes for b/4149416:expired license refresh, b/4126624:heartbeats, b/4171055: inconsistent license modes Also includes b/3500025: A/V resync issues
This commit is contained in:
@@ -32,8 +32,6 @@ static void _cb(int code)
|
||||
WVMMediaSource::sLastError = (status_t)code;
|
||||
}
|
||||
|
||||
extern DrmManagerClient *gDrmManagerClient;
|
||||
|
||||
status_t WVMMediaSource::sLastError = NO_ERROR;
|
||||
|
||||
WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
|
||||
@@ -156,18 +154,28 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
CHECK(mStarted);
|
||||
|
||||
*buffer = NULL;
|
||||
bool seekNextSync = false;
|
||||
|
||||
int64_t seekTimeUs;
|
||||
ReadOptions::SeekMode mode;
|
||||
if (options && options->getSeekTo(&seekTimeUs, &mode)) {
|
||||
// Let video stream control seek
|
||||
if (mESSelector == WV_EsSelector_Video) {
|
||||
float scaleUsed;
|
||||
std::string when = usecToNPT(seekTimeUs) + std::string("-");
|
||||
WVStatus result = WV_Play(mSession, 1.0, &scaleUsed, when );
|
||||
if (result != WV_Status_OK) {
|
||||
LOGE("WV_Play returned status %d in WVMMediaSource::read\n", result);
|
||||
return ERROR_IO;
|
||||
//LOGD("%s seek mode=%d, seek time=%lld lateby=%lld",
|
||||
// (mESSelector == WV_EsSelector_Video) ? "video" : "audio",
|
||||
// mode, seekTimeUs, options->getLateBy());
|
||||
if (mode == ReadOptions::SEEK_NEXT_SYNC) {
|
||||
// Handle seek next sync by dropping frames on this track that are
|
||||
// prior to the specified time.
|
||||
seekNextSync = true;
|
||||
} else {
|
||||
// Let video stream control seek
|
||||
if (mESSelector == WV_EsSelector_Video) {
|
||||
float scaleUsed;
|
||||
std::string when = usecToNPT(seekTimeUs) + std::string("-");
|
||||
WVStatus result = WV_Play(mSession, 1.0, &scaleUsed, when );
|
||||
if (result != WV_Status_OK) {
|
||||
LOGE("WV_Play returned status %d in WVMMediaSource::read\n", result);
|
||||
return ERROR_IO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,17 +192,20 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
size_t bytesRead;
|
||||
bool auStart;
|
||||
size_t offset = 0;
|
||||
int64_t keyTime;
|
||||
|
||||
bool syncFrame;
|
||||
|
||||
// Pull full access units. Since we aren't sure how big they might be,
|
||||
// start with initial buffer size, then allocate a larger buffer if we
|
||||
// get more a number of bytes equal to the full buffer size and go back
|
||||
// get a number of bytes equal to the full buffer size and go back
|
||||
// for the rest. Only loop in this case, usually it's one pass through.
|
||||
|
||||
while (true) {
|
||||
size_t size = mediaBuf->size() - offset;
|
||||
|
||||
WVStatus result = WV_GetEsData(mSession, mESSelector, (uint8_t *)mediaBuf->data() + offset,
|
||||
size, bytesRead, auStart, mDts, mPts);
|
||||
size, bytesRead, auStart, mDts, mPts, syncFrame);
|
||||
if (result == WV_Status_End_Of_Media) {
|
||||
mediaBuf->release();
|
||||
return ERROR_END_OF_STREAM;
|
||||
@@ -222,8 +233,16 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
}
|
||||
|
||||
if (bytesRead == 0) {
|
||||
// Didn't get anything, sleep a bit so we don't hog the CPU then
|
||||
// try again.
|
||||
// Didn't get anything, sleep a bit so we don't hog the CPU then try again
|
||||
usleep(10000);
|
||||
continue;
|
||||
}
|
||||
|
||||
#define PCR_HZ 90000
|
||||
keyTime = (int64_t)mPts * 1000000 / PCR_HZ;
|
||||
|
||||
if (seekNextSync && ((keyTime < seekTimeUs) || !syncFrame)) {
|
||||
// drop frames up to next sync if requested
|
||||
usleep(10000);
|
||||
continue;
|
||||
}
|
||||
@@ -249,9 +268,6 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
mediaBuf = newBuffer;
|
||||
}
|
||||
|
||||
#define PCR_HZ 90000
|
||||
int64_t keyTime = (int64_t)mDts * 1000000 / PCR_HZ;
|
||||
|
||||
mediaBuf->meta_data()->clear();
|
||||
mediaBuf->meta_data()->setInt64(kKeyTime, keyTime);
|
||||
|
||||
@@ -277,9 +293,9 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
LOGD("[%p] %s set range_length=%d, get range_length=%d kKeyTime=%lld\n", mediaBuf,
|
||||
LOGD("[%p] %s set range_length=%d, get range_length=%d kKeyTime=%lld sync=%d\n", mediaBuf,
|
||||
(mESSelector == WV_EsSelector_Video ? "video" : "audio"),
|
||||
bytesRead + offset, mediaBuf->range_length(), keyTime);
|
||||
bytesRead + offset, mediaBuf->range_length(), keyTime, syncFrame);
|
||||
#endif
|
||||
|
||||
*buffer = mediaBuf;
|
||||
|
||||
Reference in New Issue
Block a user