summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/mpeg2ts
diff options
context:
space:
mode:
authorRoger Jönsson <roger1.jonsson@sonymobile.com>2013-01-21 16:26:41 +0100
committerAndreas Huber <andih@google.com>2013-02-06 13:32:55 -0800
commitb50e83eca302a12f0fced6e7bab1b8617d63deaa (patch)
tree58992eeb6e5b4edef4a76e180c4e99be694754d9 /media/libstagefright/mpeg2ts
parent0df36ec3303c2c6bf9b42c07945ac8bd234153f3 (diff)
downloadframeworks_av-b50e83eca302a12f0fced6e7bab1b8617d63deaa.zip
frameworks_av-b50e83eca302a12f0fced6e7bab1b8617d63deaa.tar.gz
frameworks_av-b50e83eca302a12f0fced6e7bab1b8617d63deaa.tar.bz2
RTSP buffering improvements
Added buffering start and end notifications for RTSP. MEDIA_INFO_BUFFERING_START is sent when buffering is started and MEDIA_INFO_BUFFERING_END is sent when the buffer has filled up. This patch also adds RTSP end of stream handling. EOS is signalled when BYE is received OR when detecting end of stream even if no actual EOS is received. Change-Id: I5cccb6845060ae6afd66d9f735b89da81476cd13
Diffstat (limited to 'media/libstagefright/mpeg2ts')
-rw-r--r--media/libstagefright/mpeg2ts/AnotherPacketSource.cpp20
-rw-r--r--media/libstagefright/mpeg2ts/AnotherPacketSource.h3
2 files changed, 20 insertions, 3 deletions
diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp
index a605a05..3de3a61 100644
--- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp
+++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp
@@ -28,9 +28,12 @@
namespace android {
+const int64_t kNearEOSMarkUs = 2000000ll; // 2 secs
+
AnotherPacketSource::AnotherPacketSource(const sp<MetaData> &meta)
: mIsAudio(false),
mFormat(meta),
+ mLastQueuedTimeUs(0),
mEOSResult(OK) {
const char *mime;
CHECK(meta->findCString(kKeyMIMEType, &mime));
@@ -141,9 +144,8 @@ void AnotherPacketSource::queueAccessUnit(const sp<ABuffer> &buffer) {
return;
}
- int64_t timeUs;
- CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
- ALOGV("queueAccessUnit timeUs=%lld us (%.2f secs)", timeUs, timeUs / 1E6);
+ CHECK(buffer->meta()->findInt64("timeUs", &mLastQueuedTimeUs));
+ ALOGV("queueAccessUnit timeUs=%lld us (%.2f secs)", mLastQueuedTimeUs, mLastQueuedTimeUs / 1E6);
Mutex::Autolock autoLock(mLock);
mBuffers.push_back(buffer);
@@ -171,6 +173,7 @@ void AnotherPacketSource::queueDiscontinuity(
}
mEOSResult = OK;
+ mLastQueuedTimeUs = 0;
sp<ABuffer> buffer = new ABuffer(0);
buffer->meta()->setInt32("discontinuity", static_cast<int32_t>(type));
@@ -247,4 +250,15 @@ status_t AnotherPacketSource::nextBufferTime(int64_t *timeUs) {
return OK;
}
+bool AnotherPacketSource::isFinished(int64_t duration) const {
+ if (duration > 0) {
+ int64_t diff = duration - mLastQueuedTimeUs;
+ if (diff < kNearEOSMarkUs && diff > -kNearEOSMarkUs) {
+ ALOGV("Detecting EOS due to near end");
+ return true;
+ }
+ }
+ return (mEOSResult != OK);
+}
+
} // namespace android
diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.h b/media/libstagefright/mpeg2ts/AnotherPacketSource.h
index d685b98..1db4068 100644
--- a/media/libstagefright/mpeg2ts/AnotherPacketSource.h
+++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.h
@@ -58,6 +58,8 @@ struct AnotherPacketSource : public MediaSource {
status_t dequeueAccessUnit(sp<ABuffer> *buffer);
+ bool isFinished(int64_t duration) const;
+
protected:
virtual ~AnotherPacketSource();
@@ -67,6 +69,7 @@ private:
bool mIsAudio;
sp<MetaData> mFormat;
+ int64_t mLastQueuedTimeUs;
List<sp<ABuffer> > mBuffers;
status_t mEOSResult;