diff --git a/content/media/video/public/nsChannelToPipeListener.h b/content/media/video/public/nsChannelToPipeListener.h index 167d3b58bb77..6be1d8e7b704 100644 --- a/content/media/video/public/nsChannelToPipeListener.h +++ b/content/media/video/public/nsChannelToPipeListener.h @@ -67,9 +67,7 @@ class nsChannelToPipeListener : public nsIStreamListener NS_DECL_NSISTREAMLISTENER public: - // If aSeeking is PR_TRUE then this listener was created as part of a - // seek request and is expecting a byte range partial result. - nsChannelToPipeListener(nsMediaDecoder* aDecoder, PRBool aSeeking = PR_FALSE); + nsChannelToPipeListener(nsMediaDecoder* aDecoder); nsresult Init(); nsresult GetInputStream(nsIInputStream** aStream); void Stop(); @@ -97,9 +95,6 @@ private: // Total bytes transferred so far PRInt64 mTotalBytes; - - // PR_TRUE if this listener is expecting a byte range request result - PRPackedBool mSeeking; }; #endif diff --git a/content/media/video/public/nsMediaDecoder.h b/content/media/video/public/nsMediaDecoder.h index cd48cc912ebb..6d510eec5a04 100644 --- a/content/media/video/public/nsMediaDecoder.h +++ b/content/media/video/public/nsMediaDecoder.h @@ -142,12 +142,6 @@ class nsMediaDecoder : public nsIObserver // Set the size of the video file in bytes. virtual void SetTotalBytes(PRInt64 aBytes) = 0; - // Set a flag indicating whether seeking is supported - virtual void SetSeekable(PRBool aSeekable) = 0; - - // Return PR_TRUE if seeking is supported. - virtual PRBool GetSeekable() = 0; - // Called when the HTML DOM element is bound. virtual void ElementAvailable(nsHTMLMediaElement* anElement); diff --git a/content/media/video/public/nsOggDecoder.h b/content/media/video/public/nsOggDecoder.h index 716682eea710..606c0361b1e5 100644 --- a/content/media/video/public/nsOggDecoder.h +++ b/content/media/video/public/nsOggDecoder.h @@ -338,12 +338,6 @@ class nsOggDecoder : public nsMediaDecoder // Get the size of the media file in bytes. Called on the main thread only. virtual void SetTotalBytes(PRInt64 aBytes); - // Set a flag indicating whether seeking is supported - virtual void SetSeekable(PRBool aSeekable); - - // Return PR_TRUE if seeking is supported. - virtual PRBool GetSeekable(); - protected: // Change to a new play state. This updates the mState variable and // notifies any thread blocking on this objects monitor of the @@ -455,10 +449,6 @@ private: // True if we are registered with the observer service for shutdown. PRPackedBool mNotifyOnShutdown; - // True if the media resource is seekable (server supports byte range - // requests). - PRPackedBool mSeekable; - /****** * The following member variables can be accessed from any thread. ******/ diff --git a/content/media/video/src/nsChannelToPipeListener.cpp b/content/media/video/src/nsChannelToPipeListener.cpp index 4a0f0c6fb427..2834402c4853 100644 --- a/content/media/video/src/nsChannelToPipeListener.cpp +++ b/content/media/video/src/nsChannelToPipeListener.cpp @@ -42,17 +42,11 @@ #include "nsChannelToPipeListener.h" #include "nsICachingChannel.h" -#define HTTP_OK_CODE 200 -#define HTTP_PARTIAL_RESPONSE_CODE 206 - -nsChannelToPipeListener::nsChannelToPipeListener( - nsMediaDecoder* aDecoder, - PRBool aSeeking) : +nsChannelToPipeListener::nsChannelToPipeListener(nsMediaDecoder* aDecoder) : mDecoder(aDecoder), mIntervalStart(0), mIntervalEnd(0), - mTotalBytes(0), - mSeeking(aSeeking) + mTotalBytes(0) { } @@ -104,25 +98,10 @@ nsresult nsChannelToPipeListener::OnStartRequest(nsIRequest* aRequest, nsISuppor if (hc) { PRUint32 responseStatus = 0; hc->GetResponseStatus(&responseStatus); - if (mSeeking && responseStatus == HTTP_OK_CODE) { - // If we get an OK response but we were seeking, - // and therefore expecting a partial response of - // HTTP_PARTIAL_RESPONSE_CODE, tell the decoder - // we don't support seeking. - mDecoder->SetSeekable(PR_FALSE); - } - else if (!mSeeking && - (responseStatus == HTTP_OK_CODE || - responseStatus == HTTP_PARTIAL_RESPONSE_CODE)) { - // We weren't seeking and got a valid response status, - // set the length of the content. + if (responseStatus == 200) { PRInt32 cl = 0; hc->GetContentLength(&cl); mDecoder->SetTotalBytes(cl); - - // If we get an HTTP_OK_CODE response to our byte range - // request, then we don't support seeking. - mDecoder->SetSeekable(responseStatus == HTTP_PARTIAL_RESPONSE_CODE); } } diff --git a/content/media/video/src/nsMediaStream.cpp b/content/media/video/src/nsMediaStream.cpp index 0c0f3773fbd9..e9b874e3f19d 100644 --- a/content/media/video/src/nsMediaStream.cpp +++ b/content/media/video/src/nsMediaStream.cpp @@ -425,16 +425,6 @@ nsresult nsHttpStreamStrategy::Open(nsIStreamListener **aStreamListener) *aStreamListener = mListener; NS_ADDREF(*aStreamListener); } else { - // Use a byte range request from the start of the resource. - // This enables us to detect if the stream supports byte range - // requests, and therefore seeking, early. - nsCOMPtr hc = do_QueryInterface(mChannel); - if (hc) { - hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"), - NS_LITERAL_CSTRING("bytes=0-"), - PR_FALSE); - } - rv = mChannel->AsyncOpen(mListener, nsnull); NS_ENSURE_SUCCESS(rv, rv); } @@ -535,7 +525,7 @@ public: hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rangeString, PR_FALSE); } - mListener = new nsChannelToPipeListener(mDecoder, PR_TRUE); + mListener = new nsChannelToPipeListener(mDecoder); NS_ENSURE_TRUE(mListener, NS_ERROR_OUT_OF_MEMORY); mResult = mListener->Init(); diff --git a/content/media/video/src/nsOggDecoder.cpp b/content/media/video/src/nsOggDecoder.cpp index 83cec8becc78..3476def63b1a 100644 --- a/content/media/video/src/nsOggDecoder.cpp +++ b/content/media/video/src/nsOggDecoder.cpp @@ -35,7 +35,6 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -#include #include "prlog.h" #include "prmem.h" #include "nsIFrame.h" @@ -268,18 +267,6 @@ public: // monitor must be obtained before calling this. float GetCurrentTime(); - // Called from the main thread to get the duration. The decoder monitor - // must be obtained before calling this. It is in units of milliseconds. - PRInt64 GetDuration(); - - // Called from the main thread to set the content length of the media - // resource. The decoder monitor must be obtained before calling this. - void SetContentLength(PRInt64 aLength); - - // Called from the main thread to set whether the media resource can - // be seeked. The decoder monitor must be obtained before calling this. - void SetSeekable(PRBool aSeekable); - // Get and set the audio volume. The decoder monitor must be // obtained before calling this. float GetVolume(); @@ -440,20 +427,6 @@ private: // monitor. float mVolume; - // Duration of the media resource. It is accessed from the decoder and main - // threads. Synchronised via decoder monitor. It is in units of - // milliseconds. - PRInt64 mDuration; - - // Content Length of the media resource if known. If it is -1 then the - // size is unknown. Accessed from the decoder and main threads. Synchronised - // via decoder monitor. - PRInt64 mContentLength; - - // PR_TRUE if the media resource can be seeked. Accessed from the decoder - // and main threads. Synchronised via decoder monitor. - PRPackedBool mSeekable; - // PR_TRUE if an event to notify about a change in the playback // position has been queued, but not yet run. It is set to PR_FALSE when // the event is run. This allows coalescing of these events as they can be @@ -482,9 +455,6 @@ nsOggDecodeStateMachine::nsOggDecodeStateMachine(nsOggDecoder* aDecoder, nsChann mSeekTime(0.0), mCurrentFrameTime(0.0), mVolume(1.0), - mDuration(-1), - mContentLength(-1), - mSeekable(PR_TRUE), mPositionChangeQueued(PR_FALSE) { } @@ -803,23 +773,6 @@ float nsOggDecodeStateMachine::GetCurrentTime() return mCurrentFrameTime; } -PRInt64 nsOggDecodeStateMachine::GetDuration() -{ - // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "GetDuration() called without acquiring decoder monitor"); - return mDuration; -} - -void nsOggDecodeStateMachine::SetContentLength(PRInt64 aLength) -{ - // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "SetContentLength() called without acquiring decoder monitor"); - mContentLength = aLength; -} - -void nsOggDecodeStateMachine::SetSeekable(PRBool aSeekable) -{ - // NS_ASSERTION(PR_InMonitor(mDecoder->GetMonitor()), "SetSeekable() called without acquiring decoder monitor"); - mSeekable = aSeekable; -} void nsOggDecodeStateMachine::Shutdown() { @@ -1091,12 +1044,12 @@ void nsOggDecodeStateMachine::LoadOggHeaders() oggplay_get_audio_channels(mPlayer, i, &mAudioChannels); LOG(PR_LOG_DEBUG, ("samplerate: %d, channels: %d", mAudioRate, mAudioChannels)); } - + if (oggplay_set_track_active(mPlayer, i) < 0) { LOG(PR_LOG_ERROR, ("Could not set track %d active", i)); } } - + if (mVideoTrack == -1) { oggplay_set_callback_num_frames(mPlayer, mAudioTrack, OGGPLAY_FRAMES_PER_CALLBACK); mCallbackPeriod = 1.0 / (float(mAudioRate) / OGGPLAY_FRAMES_PER_CALLBACK); @@ -1105,27 +1058,6 @@ void nsOggDecodeStateMachine::LoadOggHeaders() oggplay_use_buffer(mPlayer, OGGPLAY_BUFFER_SIZE); - // Get the duration from the Ogg file. We only do this if the - // content length of the resource is known as we need to seek - // to the end of the file to get the last time field. We also - // only do this if the resource is seekable. - { - nsAutoMonitor mon(mDecoder->GetMonitor()); - if (mState != DECODER_STATE_SHUTDOWN && - mContentLength >= 0 && - mSeekable) { - // Don't hold the monitor during the duration - // call as it can issue seek requests - // and blocks until these are completed. - mon.Exit(); - PRInt64 d = oggplay_get_duration(mPlayer); - mon.Enter(); - mDuration = d; - } - if (mState == DECODER_STATE_SHUTDOWN) - return; - } - // Inform the element that we've loaded the Ogg metadata nsCOMPtr metadataLoadedEvent = NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, MetadataLoaded); @@ -1165,13 +1097,10 @@ void nsOggDecoder::SetVolume(float volume) float nsOggDecoder::GetDuration() { - nsAutoMonitor mon(mMonitor); - PRInt64 d = mDecodeStateMachine ? mDecodeStateMachine->GetDuration() : -1; - if (d >= 0) { - return static_cast(d) / 1000.0; - } - - return std::numeric_limits::quiet_NaN(); + // Currently not implemented. Video Spec says to return + // NaN if unknown. + // TODO: return NaN + return 0.0; } nsOggDecoder::nsOggDecoder() : @@ -1180,9 +1109,8 @@ nsOggDecoder::nsOggDecoder() : mCurrentTime(0.0), mInitialVolume(0.0), mRequestedSeekTime(-1.0), - mContentLength(-1), + mContentLength(0), mNotifyOnShutdown(PR_FALSE), - mSeekable(PR_TRUE), mReader(0), mMonitor(0), mPlayState(PLAY_STATE_PAUSED), @@ -1273,11 +1201,6 @@ nsresult nsOggDecoder::Load(nsIURI* aURI, nsIChannel* aChannel, NS_ENSURE_SUCCESS(rv, rv); mDecodeStateMachine = new nsOggDecodeStateMachine(this, mReader); - { - nsAutoMonitor mon(mMonitor); - mDecodeStateMachine->SetContentLength(mContentLength); - mDecodeStateMachine->SetSeekable(mSeekable); - } ChangeState(PLAY_STATE_LOADING); @@ -1450,10 +1373,6 @@ PRInt64 nsOggDecoder::GetTotalBytes() void nsOggDecoder::SetTotalBytes(PRInt64 aBytes) { mContentLength = aBytes; - if (mDecodeStateMachine) { - nsAutoMonitor mon(mMonitor); - mDecodeStateMachine->SetContentLength(aBytes); - } } void nsOggDecoder::UpdateBytesDownloaded(PRUint64 aBytes) @@ -1621,18 +1540,3 @@ void nsOggDecoder::PlaybackPositionChanged() mElement->DispatchSimpleEvent(NS_LITERAL_STRING("timeupdate")); } } - -void nsOggDecoder::SetSeekable(PRBool aSeekable) -{ - mSeekable = aSeekable; - if (mDecodeStateMachine) { - nsAutoMonitor mon(mMonitor); - mDecodeStateMachine->SetSeekable(aSeekable); - } -} - -PRBool nsOggDecoder::GetSeekable() -{ - return mSeekable; -} - diff --git a/content/media/video/test/Makefile.in b/content/media/video/test/Makefile.in index 9742952b46f3..bd7141fced73 100644 --- a/content/media/video/test/Makefile.in +++ b/content/media/video/test/Makefile.in @@ -49,7 +49,6 @@ _TEST_FILES = test_autoplay.html \ test_controls.html \ test_currentTime.html \ test_defaultPlaybackRate.html \ - test_duration1.html \ test_ended1.html \ test_ended2.html \ test_networkState.html \ diff --git a/content/media/video/test/test_duration1.html b/content/media/video/test/test_duration1.html deleted file mode 100644 index a78449c167a5..000000000000 --- a/content/media/video/test/test_duration1.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - Media test: seek test 1 - - - - - - -
-
-
- -