summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/httplive
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/httplive')
-rw-r--r--media/libstagefright/httplive/LiveDataSource.cpp31
-rw-r--r--media/libstagefright/httplive/LiveDataSource.h3
-rw-r--r--media/libstagefright/httplive/LiveSession.cpp15
3 files changed, 45 insertions, 4 deletions
diff --git a/media/libstagefright/httplive/LiveDataSource.cpp b/media/libstagefright/httplive/LiveDataSource.cpp
index 25e2902..5f5c6d4 100644
--- a/media/libstagefright/httplive/LiveDataSource.cpp
+++ b/media/libstagefright/httplive/LiveDataSource.cpp
@@ -54,9 +54,40 @@ size_t LiveDataSource::countQueuedBuffers() {
return mBufferQueue.size();
}
+ssize_t LiveDataSource::readAtNonBlocking(
+ off64_t offset, void *data, size_t size) {
+ Mutex::Autolock autoLock(mLock);
+
+ if (offset != mOffset) {
+ LOGE("Attempt at reading non-sequentially from LiveDataSource.");
+ return -EPIPE;
+ }
+
+ size_t totalAvailable = 0;
+ for (List<sp<ABuffer> >::iterator it = mBufferQueue.begin();
+ it != mBufferQueue.end(); ++it) {
+ sp<ABuffer> buffer = *it;
+
+ totalAvailable += buffer->size();
+
+ if (totalAvailable >= size) {
+ break;
+ }
+ }
+
+ if (totalAvailable < size) {
+ return mFinalResult == OK ? -EWOULDBLOCK : mFinalResult;
+ }
+
+ return readAt_l(offset, data, size);
+}
+
ssize_t LiveDataSource::readAt(off64_t offset, void *data, size_t size) {
Mutex::Autolock autoLock(mLock);
+ return readAt_l(offset, data, size);
+}
+ssize_t LiveDataSource::readAt_l(off64_t offset, void *data, size_t size) {
if (offset != mOffset) {
LOGE("Attempt at reading non-sequentially from LiveDataSource.");
return -EPIPE;
diff --git a/media/libstagefright/httplive/LiveDataSource.h b/media/libstagefright/httplive/LiveDataSource.h
index a489ec6..b7be637 100644
--- a/media/libstagefright/httplive/LiveDataSource.h
+++ b/media/libstagefright/httplive/LiveDataSource.h
@@ -33,6 +33,7 @@ struct LiveDataSource : public DataSource {
virtual status_t initCheck() const;
virtual ssize_t readAt(off64_t offset, void *data, size_t size);
+ ssize_t readAtNonBlocking(off64_t offset, void *data, size_t size);
void queueBuffer(const sp<ABuffer> &buffer);
void queueEOS(status_t finalResult);
@@ -53,6 +54,8 @@ private:
FILE *mBackupFile;
+ ssize_t readAt_l(off64_t offset, void *data, size_t size);
+
DISALLOW_EVIL_CONSTRUCTORS(LiveDataSource);
};
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 5c4c5df..5b1f14d 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -157,9 +157,16 @@ void LiveSession::onConnect(const sp<AMessage> &msg) {
mBandwidthItems.sort(SortByBandwidth);
- if (mBandwidthItems.size() > 1) {
- // XXX Remove the lowest bitrate stream for now...
- mBandwidthItems.removeAt(0);
+ char value[PROPERTY_VALUE_MAX];
+ if (!property_get("media.httplive.enable-nuplayer", value, NULL)
+ || (strcasecmp(value, "true") && strcmp(value, "1"))) {
+ // The "legacy" player cannot deal with audio format changes,
+ // some streams use different audio encoding parameters for
+ // their lowest bandwidth stream.
+ if (mBandwidthItems.size() > 1) {
+ // XXX Remove the lowest bitrate stream for now...
+ mBandwidthItems.removeAt(0);
+ }
}
}
@@ -421,7 +428,7 @@ void LiveSession::onDownloadNext() {
++mNumRetries;
mLastPlaylistFetchTimeUs = -1;
- postMonitorQueue(1000000ll);
+ postMonitorQueue(3000000ll);
return;
}