From 9e77e68edf0ef45afc67fad791ac43fb678a3aad Mon Sep 17 00:00:00 2001 From: Vincent Chang Date: Mon, 25 Nov 2013 19:40:22 +0800 Subject: [PATCH] Bug 895753 - Rtsp: Support suspend and resume to media stream server. r=sworkman --- netwerk/protocol/rtsp/rtsp/RTSPSource.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp b/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp index c646532502d..f9b895af413 100644 --- a/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp +++ b/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp @@ -207,7 +207,16 @@ void RTSPSource::performPlay(int64_t playTimeUs) { if (mState == PAUSING) { playTimeUs = mLatestPausedUnit; } - LOGI("performPlay : %lld", playTimeUs); + + int64_t duration = 0; + getDuration(&duration); + MOZ_ASSERT(playTimeUs < duration, + "Should never receive an out of bounds play time!"); + if (playTimeUs >= duration) { + return; + } + + LOGI("performPlay : duration=%lld playTimeUs=%lld", duration, playTimeUs); mState = PLAYING; mHandler->play(playTimeUs); } @@ -238,13 +247,22 @@ void RTSPSource::performSeek(int64_t seekTimeUs) { if (mState != PLAYING && mState != PAUSING) { return; } - LOGI("performSeek: %llu", seekTimeUs); + + int64_t duration = 0; + getDuration(&duration); + MOZ_ASSERT(seekTimeUs < duration, + "Should never receive an out of bounds seek time!"); + if (seekTimeUs >= duration) { + return; + } + for (size_t i = 0; i < mTracks.size(); ++i) { TrackInfo *info = &mTracks.editItemAt(i); info->mLatestPausedUnit = 0; mLatestPausedUnit = 0; } + LOGI("performSeek: %llu", seekTimeUs); mState = SEEKING; mHandler->seek(seekTimeUs); }