mUIDValid(uidValid),
mUID(uid),
mFlags(0),
- mEOS(false),
+ mFinalResult(OK),
mOffset(0) {
if (headers) {
mExtraHeaders = *headers;
return source->getFormat();
}
-bool NuPlayer::HTTPLiveSource::feedMoreTSData() {
- if (mEOS) {
- return false;
+status_t NuPlayer::HTTPLiveSource::feedMoreTSData() {
+ if (mFinalResult != OK) {
+ return mFinalResult;
}
sp<LiveDataSource> source =
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) {
if (err != OK) {
LOGE("TS Parser returned error %d", err);
mTSParser->signalEOS(err);
- mEOS = true;
+ mFinalResult = err;
break;
}
}
}
}
- return true;
+ return OK;
}
status_t NuPlayer::HTTPLiveSource::dequeueAccessUnit(
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);
}
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);
bool mUIDValid;
uid_t mUID;
uint32_t mFlags;
- bool mEOS;
+ status_t mFinalResult;
off64_t mOffset;
sp<ALooper> mLiveLooper;
sp<LiveSession> mLiveSession;
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;
}
audio, codecRequest);
if (err == -EWOULDBLOCK) {
- if (mSource->feedMoreTSData()) {
+ if (mSource->feedMoreTSData() == OK) {
msg->post();
}
}
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;
NuPlayer::StreamingSource::StreamingSource(const sp<IStreamSource> &source)
: mSource(source),
- mEOS(false) {
+ mFinalResult(OK) {
}
NuPlayer::StreamingSource::~StreamingSource() {
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) {
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;
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) {
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);
private:
sp<IStreamSource> mSource;
- bool mEOS;
+ status_t mFinalResult;
sp<NuPlayerStreamListener> mStreamListener;
sp<ATSParser> mTSParser;