summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/rtsp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-09-01 15:05:28 -0700
committerAndreas Huber <andih@google.com>2010-09-01 15:05:28 -0700
commitc9e894872c298b25fe9d74e68aa1e7287a541ac3 (patch)
tree3b5eba501373e765f359e83e3102af109b0ccd1a /media/libstagefright/rtsp
parentbcbe5af62aad9d1ef64f799fcde58ac9a8adace8 (diff)
downloadframeworks_av-c9e894872c298b25fe9d74e68aa1e7287a541ac3.zip
frameworks_av-c9e894872c298b25fe9d74e68aa1e7287a541ac3.tar.gz
frameworks_av-c9e894872c298b25fe9d74e68aa1e7287a541ac3.tar.bz2
Better support for buffered streaming of rtsp content, if buffer drops below a certain threshold we will temporarily pause playback until we have sufficient data.
Change-Id: Ice8564e902e48c89c9c00f6651c5504b3c41fcad related-to-bug: 2556656
Diffstat (limited to 'media/libstagefright/rtsp')
-rw-r--r--media/libstagefright/rtsp/APacketSource.cpp23
-rw-r--r--media/libstagefright/rtsp/APacketSource.h2
-rw-r--r--media/libstagefright/rtsp/ARTSPController.cpp22
3 files changed, 47 insertions, 0 deletions
diff --git a/media/libstagefright/rtsp/APacketSource.cpp b/media/libstagefright/rtsp/APacketSource.cpp
index 75b4571..b63798f 100644
--- a/media/libstagefright/rtsp/APacketSource.cpp
+++ b/media/libstagefright/rtsp/APacketSource.cpp
@@ -746,4 +746,27 @@ void APacketSource::setNormalPlayTimeMapping(
mNormalPlayTimeBaseUs = normalPlayTimeUs;
}
+int64_t APacketSource::getQueueDurationUs(bool *eos) {
+ Mutex::Autolock autoLock(mLock);
+
+ *eos = (mEOSResult != OK);
+
+ if (mBuffers.size() < 2) {
+ return 0;
+ }
+
+ const sp<ABuffer> first = *mBuffers.begin();
+ const sp<ABuffer> last = *--mBuffers.end();
+
+ int64_t firstTimeUs;
+ CHECK(first->meta()->findInt64("timeUs", &firstTimeUs));
+
+ int64_t lastTimeUs;
+ CHECK(last->meta()->findInt64("timeUs", &lastTimeUs));
+
+ CHECK_GE(lastTimeUs, firstTimeUs);
+
+ return lastTimeUs - firstTimeUs;
+}
+
} // namespace android
diff --git a/media/libstagefright/rtsp/APacketSource.h b/media/libstagefright/rtsp/APacketSource.h
index 3833ab1..076ddc4 100644
--- a/media/libstagefright/rtsp/APacketSource.h
+++ b/media/libstagefright/rtsp/APacketSource.h
@@ -50,6 +50,8 @@ struct APacketSource : public MediaSource {
void setNormalPlayTimeMapping(
uint32_t rtpTime, int64_t normalPlayTimeUs);
+ int64_t getQueueDurationUs(bool *eos);
+
protected:
virtual ~APacketSource();
diff --git a/media/libstagefright/rtsp/ARTSPController.cpp b/media/libstagefright/rtsp/ARTSPController.cpp
index a89946b..4c53639 100644
--- a/media/libstagefright/rtsp/ARTSPController.cpp
+++ b/media/libstagefright/rtsp/ARTSPController.cpp
@@ -143,4 +143,26 @@ int64_t ARTSPController::getNormalPlayTimeUs() {
return mHandler->getNormalPlayTimeUs();
}
+int64_t ARTSPController::getQueueDurationUs(bool *eos) {
+ *eos = true;
+
+ int64_t minQueuedDurationUs = 0;
+ for (size_t i = 0; i < mHandler->countTracks(); ++i) {
+ sp<APacketSource> source = mHandler->getPacketSource(i);
+
+ bool newEOS;
+ int64_t queuedDurationUs = source->getQueueDurationUs(&newEOS);
+
+ if (!newEOS) {
+ *eos = false;
+ }
+
+ if (i == 0 || queuedDurationUs < minQueuedDurationUs) {
+ minQueuedDurationUs = queuedDurationUs;
+ }
+ }
+
+ return minQueuedDurationUs;
+}
+
} // namespace android