Bug 1056213 - Window title in "windows or screen to share" list is not updated when navigating to another page. r=rjesup, a=sledru
authorMatthew A. Miller <linuxwolf@outer-planes.net>
Wed, 27 Aug 2014 16:32:28 -0600
changeset 217755 dd1c98e99569dbf17242923dfdc49623fd6a82a5
parent 217754 3e0815b50bae648a62575f84b100d96f7c19e3db
child 217756 cbd4447ae0a5f45d39f6ae4a21b437d45fb3d95c
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrjesup, sledru
bugs1056213
milestone33.0a2
Bug 1056213 - Window title in "windows or screen to share" list is not updated when navigating to another page. r=rjesup, a=sledru
content/media/webrtc/MediaEngineWebRTC.cpp
content/media/webrtc/MediaEngineWebRTC.h
content/media/webrtc/MediaEngineWebRTCVideo.cpp
--- a/content/media/webrtc/MediaEngineWebRTC.cpp
+++ b/content/media/webrtc/MediaEngineWebRTC.cpp
@@ -249,17 +249,18 @@ MediaEngineWebRTC::EnumerateVideoDevices
       // In case a device doesn't set uniqueId!
       strncpy(uniqueId, deviceName, sizeof(uniqueId));
       uniqueId[sizeof(uniqueId)-1] = '\0'; // strncpy isn't safe
     }
 
     nsRefPtr<MediaEngineWebRTCVideoSource> vSource;
     NS_ConvertUTF8toUTF16 uuid(uniqueId);
     if (mVideoSources.Get(uuid, getter_AddRefs(vSource))) {
-      // We've already seen this device, just append.
+      // We've already seen this device, just refresh and append.
+      vSource->Refresh(i);
       aVSources->AppendElement(vSource.get());
     } else {
       vSource = new MediaEngineWebRTCVideoSource(videoEngine, i, aMediaSource);
       mVideoSources.Put(uuid, vSource); // Hashtable takes ownership.
       aVSources->AppendElement(vSource);
     }
   }
 
--- a/content/media/webrtc/MediaEngineWebRTC.h
+++ b/content/media/webrtc/MediaEngineWebRTC.h
@@ -209,16 +209,18 @@ public:
 
     mSnapshotPath = new nsString();
     rv = tmp->GetPath(*mSnapshotPath);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return NS_OK;
   }
 
+  void Refresh(int aIndex);
+
 protected:
   ~MediaEngineWebRTCVideoSource() { Shutdown(); }
 
 private:
   static const unsigned int KMaxDeviceNameLength = 128;
   static const unsigned int KMaxUniqueIdLength = 256;
 
   // Initialize the needed Video engine interfaces.
--- a/content/media/webrtc/MediaEngineWebRTCVideo.cpp
+++ b/content/media/webrtc/MediaEngineWebRTCVideo.cpp
@@ -694,16 +694,35 @@ MediaEngineWebRTCVideoSource::Shutdown()
   mViECapture->Release();
   mViERender->Release();
   mViEBase->Release();
 #endif
   mState = kReleased;
   mInitDone = false;
 }
 
+void MediaEngineWebRTCVideoSource::Refresh(int aIndex) {
+  // NOTE: mCaptureIndex might have changed when allocated!
+  // Use aIndex to update information, but don't change mCaptureIndex!!
+#ifdef MOZ_B2G_CAMERA
+  // Caller looked up this source by uniqueId; since deviceName == uniqueId nothing else changes
+#else
+  // Caller looked up this source by uniqueId, so it shouldn't change
+  const uint32_t KMaxDeviceNameLength = 128;
+  char deviceName[KMaxDeviceNameLength];
+  if (mViECapture->GetCaptureDevice(aIndex,
+                                    deviceName, KMaxDeviceNameLength,
+                                    nullptr, 0)) {
+    return;
+  }
+
+  CopyUTF8toUTF16(deviceName, mDeviceName);
+#endif
+}
+
 #ifdef MOZ_B2G_CAMERA
 
 // All these functions must be run on MainThread!
 void
 MediaEngineWebRTCVideoSource::AllocImpl() {
   MOZ_ASSERT(NS_IsMainThread());
   ReentrantMonitorAutoEnter sync(mCallbackMonitor);