diff options
author | Li Sun <sunli@codeaurora.org> | 2015-08-28 14:40:58 +0800 |
---|---|---|
committer | Satish Kamuju <skamuj@codeaurora.org> | 2015-10-06 17:38:48 +0530 |
commit | 0bb42323c0ec767ba771298f933babdcb51cb41b (patch) | |
tree | cc62acb1ce24fe6a894d3927972e91c5d02fb74d /media/libstagefright/httplive | |
parent | 63edd77ab527f615afc193ea50e15dfcdeb9fe6f (diff) | |
download | frameworks_av-0bb42323c0ec767ba771298f933babdcb51cb41b.zip frameworks_av-0bb42323c0ec767ba771298f933babdcb51cb41b.tar.gz frameworks_av-0bb42323c0ec767ba771298f933babdcb51cb41b.tar.bz2 |
httplive: refactor for HLS customization
Change access modifiers and add overridable methods in HLS stack.
Change-Id: Iae8e77246cc6643735af18617717fba713d0038c
Diffstat (limited to 'media/libstagefright/httplive')
-rw-r--r-- | media/libstagefright/httplive/LiveSession.cpp | 2 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveSession.h | 23 | ||||
-rw-r--r-- | media/libstagefright/httplive/PlaylistFetcher.cpp | 4 | ||||
-rw-r--r-- | media/libstagefright/httplive/PlaylistFetcher.h | 2 |
4 files changed, 21 insertions, 10 deletions
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index 8720c88..1b0b1c5 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -54,7 +54,7 @@ const int64_t LiveSession::kReadyMarkUs = 5000000ll; const int64_t LiveSession::kPrepareMarkUs = 1500000ll; const int64_t LiveSession::kUnderflowMarkUs = 1000000ll; -struct LiveSession::BandwidthEstimator : public RefBase { +struct LiveSession::BandwidthEstimator : public LiveSession::BandwidthBaseEstimator { BandwidthEstimator(); void addBandwidthMeasurement(size_t numBytes, int64_t delayUs); diff --git a/media/libstagefright/httplive/LiveSession.h b/media/libstagefright/httplive/LiveSession.h index 90d56d0..4667c71 100644 --- a/media/libstagefright/httplive/LiveSession.h +++ b/media/libstagefright/httplive/LiveSession.h @@ -73,7 +73,7 @@ struct LiveSession : public AHandler { const sp<IMediaHTTPService> &httpService); int64_t calculateMediaTimeUs(int64_t firstTimeUs, int64_t timeUs, int32_t discontinuitySeq); - status_t dequeueAccessUnit(StreamType stream, sp<ABuffer> *accessUnit); + virtual status_t dequeueAccessUnit(StreamType stream, sp<ABuffer> *accessUnit); status_t getStreamFormat(StreamType stream, sp<AMessage> *format); @@ -117,7 +117,6 @@ protected: virtual void onMessageReceived(const sp<AMessage> &msg); -private: friend struct PlaylistFetcher; enum { @@ -142,6 +141,14 @@ private: static const int64_t kPrepareMarkUs; static const int64_t kUnderflowMarkUs; + struct BandwidthBaseEstimator : public RefBase { + virtual void addBandwidthMeasurement(size_t numBytes, int64_t delayUs) = 0; + virtual bool estimateBandwidth( + int32_t *bandwidth, + bool *isStable = NULL, + int32_t *shortTermBps = NULL) = 0; + }; + struct BandwidthEstimator; struct BandwidthItem { size_t mPlaylistIndex; @@ -201,7 +208,7 @@ private: ssize_t mOrigBandwidthIndex; int32_t mLastBandwidthBps; bool mLastBandwidthStable; - sp<BandwidthEstimator> mBandwidthEstimator; + sp<BandwidthBaseEstimator> mBandwidthEstimator; sp<M3UParser> mPlaylist; int32_t mMaxWidth; @@ -251,10 +258,10 @@ private: KeyedVector<size_t, int64_t> mDiscontinuityAbsStartTimesUs; KeyedVector<size_t, int64_t> mDiscontinuityOffsetTimesUs; - sp<PlaylistFetcher> addFetcher(const char *uri); + virtual sp<PlaylistFetcher> addFetcher(const char *uri); void onConnect(const sp<AMessage> &msg); - void onMasterPlaylistFetched(const sp<AMessage> &msg); + virtual void onMasterPlaylistFetched(const sp<AMessage> &msg); void onSeek(const sp<AMessage> &msg); bool UriIsSameAsIndex( const AString &uri, int32_t index, bool newUri); @@ -284,7 +291,7 @@ private: void onChangeConfiguration2(const sp<AMessage> &msg); void onChangeConfiguration3(const sp<AMessage> &msg); - void swapPacketSource(StreamType stream); + virtual void swapPacketSource(StreamType stream); void tryToFinishBandwidthSwitch(const AString &oldUri); void cancelBandwidthSwitch(bool resume = false); bool checkSwitchProgress( @@ -296,7 +303,7 @@ private: void schedulePollBuffering(); void cancelPollBuffering(); void restartPollBuffering(); - void onPollBuffering(); + virtual void onPollBuffering(); bool checkBuffering(bool &underflow, bool &ready, bool &down, bool &up); void startBufferingIfNecessary(); void stopBufferingIfNecessary(); @@ -304,7 +311,7 @@ private: void finishDisconnect(); - void postPrepared(status_t err); + virtual void postPrepared(status_t err); void postError(status_t err); DISALLOW_EVIL_CONSTRUCTORS(LiveSession); diff --git a/media/libstagefright/httplive/PlaylistFetcher.cpp b/media/libstagefright/httplive/PlaylistFetcher.cpp index 72d832e..5ad29c3 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.cpp +++ b/media/libstagefright/httplive/PlaylistFetcher.cpp @@ -1418,6 +1418,10 @@ void PlaylistFetcher::onDownloadNext() { } } + if (checkSwitchBandwidth()) { + return; + } + ++mSeqNumber; // if adapting, pause after found the next starting point diff --git a/media/libstagefright/httplive/PlaylistFetcher.h b/media/libstagefright/httplive/PlaylistFetcher.h index c8ca457..74cc0dd 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.h +++ b/media/libstagefright/httplive/PlaylistFetcher.h @@ -89,7 +89,6 @@ protected: virtual ~PlaylistFetcher(); virtual void onMessageReceived(const sp<AMessage> &msg); -private: enum { kMaxNumRetries = 5, }; @@ -249,6 +248,7 @@ private: void updateDuration(); void updateTargetDuration(); + virtual bool checkSwitchBandwidth() { return false; } DISALLOW_EVIL_CONSTRUCTORS(PlaylistFetcher); }; |