From bff07d0b22a5ee2d9f044f6cb5e4be1532017ab0 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Tue, 12 Oct 2010 11:34:37 -0700 Subject: HTTP Live content that are tagged as complete are now seekable. Change-Id: I9d0d2f009f883e5baf3e9de8c5c0aa05760e4bde related-to-bug: 2368598 --- media/libstagefright/include/LiveSource.h | 7 +++++++ media/libstagefright/include/M3UParser.h | 2 ++ media/libstagefright/include/MPEG2TSExtractor.h | 12 ++++++++---- media/libstagefright/include/NuCachedSource2.h | 6 ++++++ 4 files changed, 23 insertions(+), 4 deletions(-) (limited to 'media/libstagefright/include') diff --git a/media/libstagefright/include/LiveSource.h b/media/libstagefright/include/LiveSource.h index 5e89581..55dd45e 100644 --- a/media/libstagefright/include/LiveSource.h +++ b/media/libstagefright/include/LiveSource.h @@ -40,6 +40,11 @@ struct LiveSource : public DataSource { return kWantsPrefetching; } + bool getDuration(int64_t *durationUs) const; + + bool isSeekable() const; + bool seekTo(int64_t seekTimeUs); + protected: virtual ~LiveSource(); @@ -53,6 +58,7 @@ private: AString mMasterURL; AString mURL; status_t mInitCheck; + int64_t mDurationUs; sp mPlaylist; int32_t mFirstItemSequenceNumber; @@ -72,6 +78,7 @@ private: bool switchToNext(); bool loadPlaylist(bool fetchMaster); + void determineSeekability(); DISALLOW_EVIL_CONSTRUCTORS(LiveSource); }; diff --git a/media/libstagefright/include/M3UParser.h b/media/libstagefright/include/M3UParser.h index 69199ab..bd9eebe 100644 --- a/media/libstagefright/include/M3UParser.h +++ b/media/libstagefright/include/M3UParser.h @@ -32,6 +32,7 @@ struct M3UParser : public RefBase { bool isExtM3U() const; bool isVariantPlaylist() const; + bool isComplete() const; sp meta(); @@ -52,6 +53,7 @@ private: AString mBaseURI; bool mIsExtM3U; bool mIsVariantPlaylist; + bool mIsComplete; sp mMeta; Vector mItems; diff --git a/media/libstagefright/include/MPEG2TSExtractor.h b/media/libstagefright/include/MPEG2TSExtractor.h index 1bf4cd1..d83b538 100644 --- a/media/libstagefright/include/MPEG2TSExtractor.h +++ b/media/libstagefright/include/MPEG2TSExtractor.h @@ -15,6 +15,7 @@ struct ATSParser; struct DataSource; struct MPEG2TSSource; struct String8; +struct LiveSource; struct MPEG2TSExtractor : public MediaExtractor { MPEG2TSExtractor(const sp &source); @@ -25,16 +26,19 @@ struct MPEG2TSExtractor : public MediaExtractor { virtual sp getMetaData(); - virtual uint32_t flags() const { - return CAN_PAUSE; - } + virtual uint32_t flags() const; + + void setLiveSource(const sp &liveSource); + void seekTo(int64_t seekTimeUs); private: friend struct MPEG2TSSource; - Mutex mLock; + mutable Mutex mLock; sp mDataSource; + sp mLiveSource; + sp mParser; Vector > mSourceImpls; diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h index 3a20c16..1fb2088 100644 --- a/media/libstagefright/include/NuCachedSource2.h +++ b/media/libstagefright/include/NuCachedSource2.h @@ -42,6 +42,9 @@ struct NuCachedSource2 : public DataSource { size_t cachedSize(); size_t approxDataRemaining(bool *eos); + void suspend(); + void clearCacheAndResume(); + protected: virtual ~NuCachedSource2(); @@ -61,6 +64,7 @@ private: enum { kWhatFetchMore = 'fetc', kWhatRead = 'read', + kWhatSuspend = 'susp', }; sp mSource; @@ -78,10 +82,12 @@ private: sp mAsyncResult; bool mFetching; int64_t mLastFetchTimeUs; + bool mSuspended; void onMessageReceived(const sp &msg); void onFetch(); void onRead(const sp &msg); + void onSuspend(); void fetchInternal(); ssize_t readInternal(off_t offset, void *data, size_t size); -- cgit v1.1