Bug 962309 - Video RTSP support should be disabled in 1.3. r=sworkman, a=1.3+
authorEthan Tseng <ettseng@mozilla.com>
Thu, 30 Jan 2014 08:58:24 +0800
changeset 176141 cbda34620583be867d26e74a6362985fb9648ab6
parent 176140 9b39537be627781478fedf72deb897d39f01c462
child 176142 1a658a2342be3169f81f73dd71f7caa23fc61d0f
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssworkman, 1
bugs962309
milestone28.0a2
Bug 962309 - Video RTSP support should be disabled in 1.3. r=sworkman, a=1.3+
b2g/app/b2g.js
content/media/RtspMediaResource.cpp
content/media/RtspMediaResource.h
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -562,16 +562,17 @@ pref("device.storage.enabled", true);
 // Enable pre-installed applications
 pref("dom.webapps.useCurrentProfile", true);
 
 // Enable system message
 pref("dom.sysmsg.enabled", true);
 pref("media.plugins.enabled", false);
 pref("media.omx.enabled", true);
 pref("media.rtsp.enabled", true);
+pref("media.rtsp.video.enabled", false);
 
 // Disable printing (particularly, window.print())
 pref("dom.disable_window_print", true);
 
 // Disable window.showModalDialog
 pref("dom.disable_window_showModalDialog", true);
 
 // Enable new experimental html forms
--- a/content/media/RtspMediaResource.cpp
+++ b/content/media/RtspMediaResource.cpp
@@ -435,29 +435,65 @@ RtspMediaResource::OnMediaDataAvailable(
   if (mRealTime) {
     time = 0;
   }
   mTrackBuffer[aTrackIdx]->WriteBuffer(data.BeginReading(), length, time,
                                        frameType);
   return NS_OK;
 }
 
+// Bug 962309 - Video RTSP support should be disabled in 1.3
+bool
+RtspMediaResource::IsVideoEnabled()
+{
+  return Preferences::GetBool("media.rtsp.video.enabled", false);
+}
+
+bool
+RtspMediaResource::IsVideo(uint8_t tracks, nsIStreamingProtocolMetaData *meta)
+{
+  bool isVideo = false;
+  for (int i = 0; i < tracks; ++i) {
+    nsCOMPtr<nsIStreamingProtocolMetaData> trackMeta;
+    mMediaStreamController->GetTrackMetaData(i, getter_AddRefs(trackMeta));
+    MOZ_ASSERT(trackMeta);
+    uint32_t w = 0, h = 0;
+    trackMeta->GetWidth(&w);
+    trackMeta->GetHeight(&h);
+    if (w > 0 || h > 0) {
+      isVideo = true;
+      break;
+    }
+  }
+  return isVideo;
+}
+
 nsresult
 RtspMediaResource::OnConnected(uint8_t aTrackIdx,
                                nsIStreamingProtocolMetaData *meta)
 {
   if (mIsConnected) {
     for (uint32_t i = 0 ; i < mTrackBuffer.Length(); ++i) {
       mTrackBuffer[i]->Start();
     }
     return NS_OK;
   }
 
   uint8_t tracks;
   mMediaStreamController->GetTotalTracks(&tracks);
+
+  // If the preference of RTSP video feature is not enabled and the streaming is
+  // 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, NS_DISPATCH_NORMAL);
+    return NS_ERROR_FAILURE;
+  }
   uint64_t duration = 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);
--- a/content/media/RtspMediaResource.h
+++ b/content/media/RtspMediaResource.h
@@ -211,16 +211,18 @@ public:
 protected:
   // Main thread access only.
   // These are called on the main thread by Listener.
   NS_DECL_NSISTREAMINGPROTOCOLLISTENER
 
   nsRefPtr<Listener> mListener;
 
 private:
+  bool IsVideoEnabled();
+  bool IsVideo(uint8_t tracks, nsIStreamingProtocolMetaData *meta);
   // These two members are created at |RtspMediaResource::OnConnected|.
   nsCOMPtr<nsIStreamingProtocolController> mMediaStreamController;
   nsTArray<nsAutoPtr<RtspTrackBuffer>> mTrackBuffer;
 
   // A flag that indicates the |RtspMediaResource::OnConnected| has already been
   // called.
   bool mIsConnected;
   // live stream