Merge "Signal an appropriate error even if there are no active streams yet."
This commit is contained in:
committed by
Android (Google) Code Review
commit
d33b3881f7
@@ -41,7 +41,7 @@ NuPlayer::HTTPLiveSource::HTTPLiveSource(
|
||||
mUIDValid(uidValid),
|
||||
mUID(uid),
|
||||
mFlags(0),
|
||||
mEOS(false),
|
||||
mFinalResult(OK),
|
||||
mOffset(0) {
|
||||
if (headers) {
|
||||
mExtraHeaders = *headers;
|
||||
@@ -95,9 +95,9 @@ sp<MetaData> NuPlayer::HTTPLiveSource::getFormat(bool audio) {
|
||||
return source->getFormat();
|
||||
}
|
||||
|
||||
bool NuPlayer::HTTPLiveSource::feedMoreTSData() {
|
||||
if (mEOS) {
|
||||
return false;
|
||||
status_t NuPlayer::HTTPLiveSource::feedMoreTSData() {
|
||||
if (mFinalResult != OK) {
|
||||
return mFinalResult;
|
||||
}
|
||||
|
||||
sp<LiveDataSource> source =
|
||||
@@ -111,12 +111,12 @@ bool NuPlayer::HTTPLiveSource::feedMoreTSData() {
|
||||
break;
|
||||
} else if (n < 0) {
|
||||
if (n != ERROR_END_OF_STREAM) {
|
||||
LOGI("input data EOS reached, error %d", n);
|
||||
LOGI("input data EOS reached, error %ld", n);
|
||||
} else {
|
||||
LOGI("input data EOS reached.");
|
||||
}
|
||||
mTSParser->signalEOS(n);
|
||||
mEOS = true;
|
||||
mFinalResult = n;
|
||||
break;
|
||||
} else {
|
||||
if (buffer[0] == 0x00) {
|
||||
@@ -133,7 +133,7 @@ bool NuPlayer::HTTPLiveSource::feedMoreTSData() {
|
||||
if (err != OK) {
|
||||
LOGE("TS Parser returned error %d", err);
|
||||
mTSParser->signalEOS(err);
|
||||
mEOS = true;
|
||||
mFinalResult = err;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ bool NuPlayer::HTTPLiveSource::feedMoreTSData() {
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return OK;
|
||||
}
|
||||
|
||||
status_t NuPlayer::HTTPLiveSource::dequeueAccessUnit(
|
||||
@@ -172,7 +172,7 @@ status_t NuPlayer::HTTPLiveSource::getDuration(int64_t *durationUs) {
|
||||
status_t NuPlayer::HTTPLiveSource::seekTo(int64_t seekTimeUs) {
|
||||
// We need to make sure we're not seeking until we have seen the very first
|
||||
// PTS timestamp in the whole stream (from the beginning of the stream).
|
||||
while (!mTSParser->PTSTimeDeltaEstablished() && feedMoreTSData()) {
|
||||
while (!mTSParser->PTSTimeDeltaEstablished() && feedMoreTSData() == OK) {
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ struct NuPlayer::HTTPLiveSource : public NuPlayer::Source {
|
||||
|
||||
virtual void start();
|
||||
|
||||
// Returns true iff more data was available, false on EOS.
|
||||
virtual bool feedMoreTSData();
|
||||
virtual status_t feedMoreTSData();
|
||||
|
||||
virtual sp<MetaData> getFormat(bool audio);
|
||||
virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
|
||||
@@ -59,7 +58,7 @@ private:
|
||||
bool mUIDValid;
|
||||
uid_t mUID;
|
||||
uint32_t mFlags;
|
||||
bool mEOS;
|
||||
status_t mFinalResult;
|
||||
off64_t mOffset;
|
||||
sp<ALooper> mLiveLooper;
|
||||
sp<LiveSession> mLiveSession;
|
||||
|
||||
@@ -235,11 +235,17 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
|
||||
instantiateDecoder(true, &mAudioDecoder);
|
||||
}
|
||||
|
||||
if (!mSource->feedMoreTSData()) {
|
||||
status_t err;
|
||||
if ((err = mSource->feedMoreTSData()) != OK) {
|
||||
if (mAudioDecoder == NULL && mVideoDecoder == NULL) {
|
||||
// We're not currently decoding anything (no audio or
|
||||
// video tracks found) and we just ran out of input data.
|
||||
notifyListener(MEDIA_PLAYBACK_COMPLETE, 0, 0);
|
||||
|
||||
if (err == ERROR_END_OF_STREAM) {
|
||||
notifyListener(MEDIA_PLAYBACK_COMPLETE, 0, 0);
|
||||
} else {
|
||||
notifyListener(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -267,7 +273,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
|
||||
audio, codecRequest);
|
||||
|
||||
if (err == -EWOULDBLOCK) {
|
||||
if (mSource->feedMoreTSData()) {
|
||||
if (mSource->feedMoreTSData() == OK) {
|
||||
msg->post();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,9 @@ struct NuPlayer::Source : public RefBase {
|
||||
|
||||
virtual void start() = 0;
|
||||
|
||||
// Returns true iff more data was available, false on EOS.
|
||||
virtual bool feedMoreTSData() = 0;
|
||||
// Returns OK iff more data was available,
|
||||
// an error or ERROR_END_OF_STREAM if not.
|
||||
virtual status_t feedMoreTSData() = 0;
|
||||
|
||||
virtual sp<MetaData> getFormat(bool audio) = 0;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace android {
|
||||
|
||||
NuPlayer::StreamingSource::StreamingSource(const sp<IStreamSource> &source)
|
||||
: mSource(source),
|
||||
mEOS(false) {
|
||||
mFinalResult(OK) {
|
||||
}
|
||||
|
||||
NuPlayer::StreamingSource::~StreamingSource() {
|
||||
@@ -47,9 +47,9 @@ void NuPlayer::StreamingSource::start() {
|
||||
mStreamListener->start();
|
||||
}
|
||||
|
||||
bool NuPlayer::StreamingSource::feedMoreTSData() {
|
||||
if (mEOS) {
|
||||
return false;
|
||||
status_t NuPlayer::StreamingSource::feedMoreTSData() {
|
||||
if (mFinalResult != OK) {
|
||||
return mFinalResult;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < 50; ++i) {
|
||||
@@ -60,7 +60,7 @@ bool NuPlayer::StreamingSource::feedMoreTSData() {
|
||||
if (n == 0) {
|
||||
LOGI("input data EOS reached.");
|
||||
mTSParser->signalEOS(ERROR_END_OF_STREAM);
|
||||
mEOS = true;
|
||||
mFinalResult = ERROR_END_OF_STREAM;
|
||||
break;
|
||||
} else if (n == INFO_DISCONTINUITY) {
|
||||
ATSParser::DiscontinuityType type = ATSParser::DISCONTINUITY_SEEK;
|
||||
@@ -92,14 +92,14 @@ bool NuPlayer::StreamingSource::feedMoreTSData() {
|
||||
LOGE("TS Parser returned error %d", err);
|
||||
|
||||
mTSParser->signalEOS(err);
|
||||
mEOS = true;
|
||||
mFinalResult = err;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return OK;
|
||||
}
|
||||
|
||||
sp<MetaData> NuPlayer::StreamingSource::getFormat(bool audio) {
|
||||
|
||||
@@ -31,8 +31,7 @@ struct NuPlayer::StreamingSource : public NuPlayer::Source {
|
||||
|
||||
virtual void start();
|
||||
|
||||
// Returns true iff more data was available, false on EOS.
|
||||
virtual bool feedMoreTSData();
|
||||
virtual status_t feedMoreTSData();
|
||||
|
||||
virtual sp<MetaData> getFormat(bool audio);
|
||||
virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
|
||||
@@ -42,7 +41,7 @@ protected:
|
||||
|
||||
private:
|
||||
sp<IStreamSource> mSource;
|
||||
bool mEOS;
|
||||
status_t mFinalResult;
|
||||
sp<NuPlayerStreamListener> mStreamListener;
|
||||
sp<ATSParser> mTSParser;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user