diff options
author | Roger Jönsson <roger1.jonsson@sonymobile.com> | 2013-01-23 18:18:08 +0100 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2013-02-06 13:48:16 -0800 |
commit | 0955986e6c1c27ba752e293246086ea79c49d39c (patch) | |
tree | 916e9f3ecf9f371e8b11d7d04eabaec46f6ad0d9 /media/libstagefright/rtsp | |
parent | 1a37ee3c877165c812734b405f922f6e0d747052 (diff) | |
download | frameworks_av-0955986e6c1c27ba752e293246086ea79c49d39c.zip frameworks_av-0955986e6c1c27ba752e293246086ea79c49d39c.tar.gz frameworks_av-0955986e6c1c27ba752e293246086ea79c49d39c.tar.bz2 |
Avoid rebuffering after RTSP pause
If pausing an RTSP stream, an RTSP Pause request is sent and then
if the stream is immediately resumed again, an RTSP Play request
will be sent to the server.
But the new data after the pause will not be buffered until
Sender Reports have arrived again on both channels.
Meanwhile the player will resume playback and continue consuming
the already existing buffer.
This means that there is a risk that the buffer is emptied while
waiting for sender reports.
This commit simply adds a delay before the RTSP pause request is
sent, allowing some additional RTSP buffering that might be needed
when the stream is resumed again.
Also, if the stream is resumed again before the RTSP pause request
is sent, there is no need for any RTSP pause request, hence it is
omitted.
Change-Id: I928c8bfb5e99a6a146dcda4e51e528973ecbe065
Diffstat (limited to 'media/libstagefright/rtsp')
-rw-r--r-- | media/libstagefright/rtsp/MyHandler.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h index 8f86f3b..5d760d3 100644 --- a/media/libstagefright/rtsp/MyHandler.h +++ b/media/libstagefright/rtsp/MyHandler.h @@ -52,6 +52,8 @@ static int64_t kStartupTimeoutUs = 10000000ll; static int64_t kDefaultKeepAliveTimeoutUs = 60000000ll; +static int64_t kPauseDelayUs = 3000000ll; + namespace android { static void MakeUserAgentString(AString *s) { @@ -137,7 +139,8 @@ struct MyHandler : public AHandler { mSeekable(true), mKeepAliveTimeoutUs(kDefaultKeepAliveTimeoutUs), mKeepAliveGeneration(0), - mPausing(false) { + mPausing(false), + mPauseGeneration(0) { mNetLooper->setName("rtsp net"); mNetLooper->start(false /* runOnCallingThread */, false /* canCallJava */, @@ -215,6 +218,7 @@ struct MyHandler : public AHandler { void seek(int64_t timeUs) { sp<AMessage> msg = new AMessage('seek', id()); msg->setInt64("time", timeUs); + mPauseGeneration++; msg->post(); } @@ -224,11 +228,14 @@ struct MyHandler : public AHandler { void pause() { sp<AMessage> msg = new AMessage('paus', id()); - msg->post(); + mPauseGeneration++; + msg->setInt32("pausecheck", mPauseGeneration); + msg->post(kPauseDelayUs); } void resume() { sp<AMessage> msg = new AMessage('resu', id()); + mPauseGeneration++; msg->post(); } @@ -1024,6 +1031,13 @@ struct MyHandler : public AHandler { case 'paus': { + int32_t generation; + CHECK(msg->findInt32("pausecheck", &generation)); + if (generation != mPauseGeneration) { + ALOGV("Ignoring outdated pause message."); + break; + } + if (!mSeekable) { ALOGW("This is a live stream, ignoring pause request."); break; @@ -1517,6 +1531,7 @@ private: int64_t mKeepAliveTimeoutUs; int32_t mKeepAliveGeneration; bool mPausing; + int32_t mPauseGeneration; Vector<TrackInfo> mTracks; |