Bug 1086198 - [RTSP] The unit of property duration of media element is not in seconds. r=cpearce
authorEthan Tseng <ettseng@mozilla.com>
Tue, 28 Oct 2014 16:42:12 +0800
changeset 239127 0910fa2f279a694e4a0094bc1c19f91723be5552
parent 239126 531fe83851155e2c2a2edf43d211e24f789dde8c
child 239128 7ec631f6e113a164bfe6a542356e6151fde6e663
push id660
push userraliiev@mozilla.com
push dateWed, 18 Feb 2015 20:30:48 +0000
treeherdermozilla-release@49e493494178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1086198
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1086198 - [RTSP] The unit of property duration of media element is not in seconds. r=cpearce
dom/media/RtspMediaResource.cpp
dom/media/RtspMediaResource.h
netwerk/base/public/nsIStreamingProtocolController.idl
--- a/dom/media/RtspMediaResource.cpp
+++ b/dom/media/RtspMediaResource.cpp
@@ -683,24 +683,24 @@ RtspMediaResource::OnConnected(uint8_t a
   // video, we give up moving forward.
   if (!IsVideoEnabled() && IsVideo(tracks, meta)) {
     // Give up, report error to media element.
     nsCOMPtr<nsIRunnable> event =
       NS_NewRunnableMethod(mDecoder, &MediaDecoder::DecodeError);
     NS_DispatchToMainThread(event);
     return NS_ERROR_FAILURE;
   }
-  uint64_t duration = 0;
+  uint64_t durationUs = 0;
   for (int i = 0; i < tracks; ++i) {
     nsCString rtspTrackId("RtspTrack");
     rtspTrackId.AppendInt(i);
     nsCOMPtr<nsIStreamingProtocolMetaData> trackMeta;
     mMediaStreamController->GetTrackMetaData(i, getter_AddRefs(trackMeta));
     MOZ_ASSERT(trackMeta);
-    trackMeta->GetDuration(&duration);
+    trackMeta->GetDuration(&durationUs);
 
     // Here is a heuristic to estimate the slot size.
     // For video track, calculate the width*height.
     // For audio track, use the BUFFER_SLOT_DEFAULT_SIZE because the w*h is 0.
     // Finally clamp them into (BUFFER_SLOT_DEFAULT_SIZE,BUFFER_SLOT_MAX_SIZE)
     uint32_t w, h;
     uint32_t slotSize;
     trackMeta->GetWidth(&w);
@@ -711,22 +711,22 @@ RtspMediaResource::OnConnected(uint8_t a
                                                    i, slotSize));
     mTrackBuffer[i]->Start();
   }
 
   if (!mDecoder) {
     return NS_ERROR_FAILURE;
   }
 
-  // If the duration is 0, imply the stream is live stream.
-  if (duration) {
+  // If the durationUs is 0, imply the stream is live stream.
+  if (durationUs) {
     // Not live stream.
     mRealTime = false;
     mDecoder->SetInfinite(false);
-    mDecoder->SetDuration(duration);
+    mDecoder->SetDuration((double)(durationUs) / USECS_PER_S);
   } else {
     // Live stream.
     // Check the preference "media.realtime_decoder.enabled".
     if (!Preferences::GetBool("media.realtime_decoder.enabled", false)) {
       // Give up, report error to media element.
       nsCOMPtr<nsIRunnable> event =
         NS_NewRunnableMethod(mDecoder, &MediaDecoder::DecodeError);
       NS_DispatchToMainThread(event);
--- a/dom/media/RtspMediaResource.h
+++ b/dom/media/RtspMediaResource.h
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #if !defined(RtspMediaResource_h_)
 #define RtspMediaResource_h_
 
 #include "MediaResource.h"
 #include "mozilla/Monitor.h"
 #include "nsITimer.h"
+#include "VideoUtils.h"
 
 namespace mozilla {
 
 class RtspTrackBuffer;
 
 /* RtspMediaResource
  * RtspMediaResource provides an interface to deliver and control RTSP media
  * data to RtspDecoder.
--- a/netwerk/base/public/nsIStreamingProtocolController.idl
+++ b/netwerk/base/public/nsIStreamingProtocolController.idl
@@ -40,17 +40,17 @@ interface nsIStreamingProtocolMetaData :
     attribute unsigned long width;
 
     /**
      * The height of the resolution.
      */
     attribute unsigned long height;
 
     /**
-     * The duration of the media stream.
+     * The duration of the media stream in units of microseconds.
      */
     attribute unsigned long long duration;
 
     /**
      * The sample rate of the media stream.
      */
     attribute unsigned long sampleRate;