Bug 1043531 - Cache PluginID in WebRTCVideoDecoder/Encoder. r=jesup a=sylvestre
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Thu, 24 Jul 2014 20:41:03 +0200
changeset 216193 103b6ab5b984ea64ba5e9328d2f1adebdfc13480
parent 216192 35c982e10670d9e192c9f6a7f343a34b52a02d75
child 216194 e5466a63b5b9c1a68ad31fe47cef55d8a6765dc5
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, sylvestre
bugs1043531
milestone33.0a2
Bug 1043531 - Cache PluginID in WebRTCVideoDecoder/Encoder. r=jesup a=sylvestre
media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h
--- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
@@ -46,16 +46,17 @@ GetGMPLog()
 #define LOG(leve, msg)
 #endif
 
 // Encoder.
 WebrtcGmpVideoEncoder::WebrtcGmpVideoEncoder()
   : mGMP(nullptr)
   , mHost(nullptr)
   , mCallback(nullptr)
+  , mCachedPluginId(0)
 {}
 
 static void
 Encoder_Close_g(GMPVideoEncoderProxy* aGMP)
 {
   aGMP->Close();
 }
 
@@ -350,16 +351,18 @@ WebrtcGmpVideoEncoder::SetRates_g(uint32
 
   return WEBRTC_VIDEO_CODEC_OK;
 }
 
 // GMPVideoEncoderCallback virtual functions.
 void
 WebrtcGmpVideoEncoder::Terminated()
 {
+  mCachedPluginId = PluginID();
+
   // We need to drop our reference to this
   mGMP->Close();
   mGMP = nullptr;
   // Could now notify that it's dead
 }
 
 void
 WebrtcGmpVideoEncoder::Encoded(GMPVideoEncodedFrame* aEncodedFrame,
@@ -425,17 +428,18 @@ WebrtcGmpVideoEncoder::Encoded(GMPVideoE
   }
   aEncodedFrame->Destroy();
 }
 
 // Decoder.
 WebrtcGmpVideoDecoder::WebrtcGmpVideoDecoder() :
   mGMP(nullptr),
   mHost(nullptr),
-  mCallback(nullptr) {}
+  mCallback(nullptr),
+  mCachedPluginId(0) {}
 
 static void
 Decoder_Close_g(GMPVideoDecoderProxy* aGMP)
 {
   aGMP->Close();
 }
 
 WebrtcGmpVideoDecoder::~WebrtcGmpVideoDecoder()
@@ -632,16 +636,18 @@ WebrtcGmpVideoDecoder::Reset()
 {
   // XXX ?
   return WEBRTC_VIDEO_CODEC_OK;
 }
 
 void
 WebrtcGmpVideoDecoder::Terminated()
 {
+  mCachedPluginId = PluginID();
+
   mGMP->Close();
   mGMP = nullptr;
   // Could now notify that it's dead
 }
 
 void
 WebrtcGmpVideoDecoder::Decoded(GMPVideoi420Frame* aDecodedFrame)
 {
--- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h
@@ -40,17 +40,17 @@ class WebrtcGmpVideoEncoder : public Web
 {
 public:
   WebrtcGmpVideoEncoder();
   virtual ~WebrtcGmpVideoEncoder();
 
   // Implement VideoEncoder interface.
   virtual const uint64_t PluginID() MOZ_OVERRIDE
   {
-    return mGMP ? mGMP->ParentID() : 0;
+    return mGMP ? mGMP->ParentID() : mCachedPluginId;
   }
 
   virtual void Terminated() MOZ_OVERRIDE;
 
   virtual int32_t InitEncode(const webrtc::VideoCodec* aCodecSettings,
                              int32_t aNumberOfCores,
                              uint32_t aMaxPayloadSize) MOZ_OVERRIDE;
 
@@ -86,30 +86,31 @@ private:
   virtual int32_t SetRates_g(uint32_t aNewBitRate,
                              uint32_t aFrameRate);
 
   nsCOMPtr<mozIGeckoMediaPluginService> mMPS;
   nsCOMPtr<nsIThread> mGMPThread;
   GMPVideoEncoderProxy* mGMP;
   GMPVideoHost* mHost;
   webrtc::EncodedImageCallback* mCallback;
+  uint64_t mCachedPluginId;
 };
 
 
 class WebrtcGmpVideoDecoder : public WebrtcVideoDecoder,
                               public GMPVideoDecoderCallbackProxy
 {
 public:
   WebrtcGmpVideoDecoder();
   virtual ~WebrtcGmpVideoDecoder();
 
   // Implement VideoDecoder interface.
   virtual const uint64_t PluginID() MOZ_OVERRIDE
   {
-    return mGMP ? mGMP->ParentID() : 0;
+    return mGMP ? mGMP->ParentID() : mCachedPluginId;
   }
 
   virtual void Terminated();
 
   virtual int32_t InitDecode(const webrtc::VideoCodec* aCodecSettings,
                              int32_t aNumberOfCores);
   virtual int32_t Decode(const webrtc::EncodedImage& aInputImage,
                          bool aMissingFrames,
@@ -154,13 +155,14 @@ private:
                            const webrtc::CodecSpecificInfo* aCodecSpecificInfo,
                            int64_t aRenderTimeMs);
 
   nsCOMPtr<mozIGeckoMediaPluginService> mMPS;
   nsCOMPtr<nsIThread> mGMPThread;
   GMPVideoDecoderProxy* mGMP; // Addref is held for us
   GMPVideoHost* mHost;
   webrtc::DecodedImageCallback* mCallback;
+  uint64_t mCachedPluginId;
 };
 
 }
 
 #endif