Bug 1037317 - Move GMPBufferType to be a property of GMPVideoFrameEncoded. r=jesup
authorChris Pearce <cpearce@mozilla.com>
Fri, 11 Jul 2014 10:39:10 -0400
changeset 193597 a58ad2a9b06170bb0fa6c2d2af5f4f529298ee6a
parent 193596 bcba40acc0ac6dd9fb287f72a36653bdb166734b
child 193598 1166b5c0e91646128201c4491218d81d9efa44f4
push id27123
push userryanvm@gmail.com
push dateFri, 11 Jul 2014 20:35:05 +0000
treeherdermozilla-central@84bd8d9f4256 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1037317
milestone33.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 1037317 - Move GMPBufferType to be a property of GMPVideoFrameEncoded. r=jesup
content/media/gmp/GMPTypes.ipdlh
content/media/gmp/GMPVideoDecoderChild.cpp
content/media/gmp/GMPVideoDecoderChild.h
content/media/gmp/GMPVideoDecoderParent.cpp
content/media/gmp/GMPVideoDecoderParent.h
content/media/gmp/GMPVideoDecoderProxy.h
content/media/gmp/GMPVideoEncodedFrameImpl.cpp
content/media/gmp/GMPVideoEncodedFrameImpl.h
content/media/gmp/GMPVideoEncoderChild.cpp
content/media/gmp/GMPVideoEncoderChild.h
content/media/gmp/GMPVideoEncoderParent.cpp
content/media/gmp/GMPVideoEncoderParent.h
content/media/gmp/GMPVideoEncoderProxy.h
content/media/gmp/PGMPVideoDecoder.ipdl
content/media/gmp/PGMPVideoEncoder.ipdl
content/media/gmp/gmp-api/gmp-video-decode.h
content/media/gmp/gmp-api/gmp-video-encode.h
content/media/gmp/gmp-api/gmp-video-frame-encoded.h
media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h
--- a/content/media/gmp/GMPTypes.ipdlh
+++ b/content/media/gmp/GMPTypes.ipdlh
@@ -1,24 +1,27 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+using GMPBufferType from "gmp-video-codec.h";
+
 namespace mozilla {
 namespace gmp {
 
 struct GMPVideoEncodedFrameData
 {
   uint32_t mEncodedWidth;
   uint32_t mEncodedHeight;
   uint64_t mTimestamp; // microseconds
   uint64_t mDuration; // microseconds
   uint32_t mFrameType;
   uint32_t mSize;
+  GMPBufferType mBufferType;
   Shmem mBuffer;
   bool mCompleteFrame;
 };
 
 struct GMPPlaneData
 {
   int32_t mSize;
   int32_t mStride;
--- a/content/media/gmp/GMPVideoDecoderChild.cpp
+++ b/content/media/gmp/GMPVideoDecoderChild.cpp
@@ -118,30 +118,28 @@ GMPVideoDecoderChild::RecvInitDecode(con
                             this,
                             aCoreCount);
   return true;
 }
 
 bool
 GMPVideoDecoderChild::RecvDecode(const GMPVideoEncodedFrameData& aInputFrame,
                                  const bool& aMissingFrames,
-                                 const GMPBufferType& aBufferType,
                                  const nsTArray<uint8_t>& aCodecSpecificInfo,
                                  const int64_t& aRenderTimeMs)
 {
   if (!mVideoDecoder) {
     return false;
   }
 
   auto f = new GMPVideoEncodedFrameImpl(aInputFrame, &mVideoHost);
 
   // Ignore any return code. It is OK for this to fail without killing the process.
   mVideoDecoder->Decode(f,
                         aMissingFrames,
-                        aBufferType,
                         aCodecSpecificInfo.Elements(),
                         aCodecSpecificInfo.Length(),
                         aRenderTimeMs);
 
   return true;
 }
 
 bool
--- a/content/media/gmp/GMPVideoDecoderChild.h
+++ b/content/media/gmp/GMPVideoDecoderChild.h
@@ -62,17 +62,16 @@ public:
 
 private:
   // PGMPVideoDecoderChild
   virtual bool RecvInitDecode(const GMPVideoCodec& aCodecSettings,
                               const nsTArray<uint8_t>& aCodecSpecific,
                               const int32_t& aCoreCount) MOZ_OVERRIDE;
   virtual bool RecvDecode(const GMPVideoEncodedFrameData& aInputFrame,
                           const bool& aMissingFrames,
-                          const GMPBufferType& aBufferType,
                           const nsTArray<uint8_t>& aCodecSpecificInfo,
                           const int64_t& aRenderTimeMs) MOZ_OVERRIDE;
   virtual bool RecvChildShmemForPool(Shmem& aFrameBuffer) MOZ_OVERRIDE;
   virtual bool RecvReset() MOZ_OVERRIDE;
   virtual bool RecvDrain() MOZ_OVERRIDE;
   virtual bool RecvDecodingComplete() MOZ_OVERRIDE;
 
   GMPChild* mPlugin;
--- a/content/media/gmp/GMPVideoDecoderParent.cpp
+++ b/content/media/gmp/GMPVideoDecoderParent.cpp
@@ -67,17 +67,16 @@ GMPVideoDecoderParent::InitDecode(const 
 
   // Async IPC, we don't have access to a return value.
   return NS_OK;
 }
 
 nsresult
 GMPVideoDecoderParent::Decode(GMPVideoEncodedFrame* aInputFrame,
                               bool aMissingFrames,
-                              GMPBufferType aBufferType,
                               const nsTArray<uint8_t>& aCodecSpecificInfo,
                               int64_t aRenderTimeMs)
 {
   nsAutoRef<GMPVideoEncodedFrame> autoDestroy(aInputFrame);
 
   if (!mCanSendMessages) {
     NS_WARNING("Trying to use an invalid GMP video decoder!");
     return NS_ERROR_FAILURE;
@@ -95,17 +94,16 @@ GMPVideoDecoderParent::Decode(GMPVideoEn
   // 3* is because we're using 3 buffers per frame for i420 data for now.
   if (NumInUse(kGMPFrameData) > 3*GMPSharedMemManager::kGMPBufLimit ||
       NumInUse(kGMPEncodedData) > GMPSharedMemManager::kGMPBufLimit) {
     return NS_ERROR_FAILURE;
   }
 
   if (!SendDecode(frameData,
                   aMissingFrames,
-                  aBufferType,
                   aCodecSpecificInfo,
                   aRenderTimeMs)) {
     return NS_ERROR_FAILURE;
   }
 
   // Async IPC, we don't have access to a return value.
   return NS_OK;
 }
--- a/content/media/gmp/GMPVideoDecoderParent.h
+++ b/content/media/gmp/GMPVideoDecoderParent.h
@@ -32,17 +32,16 @@ public:
 
   // GMPVideoDecoder
   virtual nsresult InitDecode(const GMPVideoCodec& aCodecSettings,
                               const nsTArray<uint8_t>& aCodecSpecific,
                               GMPVideoDecoderCallback* aCallback,
                               int32_t aCoreCount) MOZ_OVERRIDE;
   virtual nsresult Decode(GMPVideoEncodedFrame* aInputFrame,
                           bool aMissingFrames,
-                          GMPBufferType aBufferType,
                           const nsTArray<uint8_t>& aCodecSpecificInfo,
                           int64_t aRenderTimeMs = -1) MOZ_OVERRIDE;
   virtual nsresult Reset() MOZ_OVERRIDE;
   virtual nsresult Drain() MOZ_OVERRIDE;
   virtual nsresult DecodingComplete() MOZ_OVERRIDE;
 
   // GMPSharedMemManager
   virtual void CheckThread();
--- a/content/media/gmp/GMPVideoDecoderProxy.h
+++ b/content/media/gmp/GMPVideoDecoderProxy.h
@@ -18,17 +18,16 @@
 class GMPVideoDecoderProxy {
 public:
   virtual nsresult InitDecode(const GMPVideoCodec& aCodecSettings,
                               const nsTArray<uint8_t>& aCodecSpecific,
                               GMPVideoDecoderCallback* aCallback,
                               int32_t aCoreCount) = 0;
   virtual nsresult Decode(GMPVideoEncodedFrame* aInputFrame,
                           bool aMissingFrames,
-                          GMPBufferType aBufferType,
                           const nsTArray<uint8_t>& aCodecSpecificInfo,
                           int64_t aRenderTimeMs = -1) = 0;
   virtual nsresult Reset() = 0;
   virtual nsresult Drain() = 0;
   virtual nsresult DecodingComplete() = 0;
 };
 
 #endif
--- a/content/media/gmp/GMPVideoEncodedFrameImpl.cpp
+++ b/content/media/gmp/GMPVideoEncodedFrameImpl.cpp
@@ -14,33 +14,35 @@ namespace gmp {
 GMPVideoEncodedFrameImpl::GMPVideoEncodedFrameImpl(GMPVideoHostImpl* aHost)
 : mEncodedWidth(0),
   mEncodedHeight(0),
   mTimeStamp(0ll),
   mDuration(0ll),
   mFrameType(kGMPDeltaFrame),
   mSize(0),
   mCompleteFrame(false),
-  mHost(aHost)
+  mHost(aHost),
+  mBufferType(GMP_BufferSingle)
 {
   MOZ_ASSERT(aHost);
   aHost->EncodedFrameCreated(this);
 }
 
 GMPVideoEncodedFrameImpl::GMPVideoEncodedFrameImpl(const GMPVideoEncodedFrameData& aFrameData,
                                                    GMPVideoHostImpl* aHost)
 : mEncodedWidth(aFrameData.mEncodedWidth()),
   mEncodedHeight(aFrameData.mEncodedHeight()),
   mTimeStamp(aFrameData.mTimestamp()),
   mDuration(aFrameData.mDuration()),
   mFrameType(static_cast<GMPVideoFrameType>(aFrameData.mFrameType())),
   mSize(aFrameData.mSize()),
   mCompleteFrame(aFrameData.mCompleteFrame()),
   mHost(aHost),
-  mBuffer(aFrameData.mBuffer())
+  mBuffer(aFrameData.mBuffer()),
+  mBufferType(aFrameData.mBufferType())
 {
   MOZ_ASSERT(aHost);
   aHost->EncodedFrameCreated(this);
 }
 
 GMPVideoEncodedFrameImpl::~GMPVideoEncodedFrameImpl()
 {
   DestroyBuffer();
@@ -87,16 +89,17 @@ GMPVideoEncodedFrameImpl::RelinquishFram
   aFrameData.mEncodedWidth() = mEncodedWidth;
   aFrameData.mEncodedHeight() = mEncodedHeight;
   aFrameData.mTimestamp() = mTimeStamp;
   aFrameData.mDuration() = mDuration;
   aFrameData.mFrameType() = mFrameType;
   aFrameData.mSize() = mSize;
   aFrameData.mCompleteFrame() = mCompleteFrame;
   aFrameData.mBuffer() = mBuffer;
+  aFrameData.mBufferType() = mBufferType;
 
   // This method is called right before Shmem is sent to another process.
   // We need to effectively zero out our member copy so that we don't
   // try to delete Shmem we don't own later.
   mBuffer = ipc::Shmem();
 
   return true;
 }
@@ -142,16 +145,17 @@ GMPVideoEncodedFrameImpl::CopyFrame(cons
   }
   mEncodedWidth = f.mEncodedWidth;
   mEncodedHeight = f.mEncodedHeight;
   mTimeStamp = f.mTimeStamp;
   mDuration = f.mDuration;
   mFrameType = f.mFrameType;
   mSize = f.mSize; // already set...
   mCompleteFrame = f.mCompleteFrame;
+  mBufferType = f.mBufferType;
   // Don't copy host, that should have been set properly on object creation via host.
 
   return GMPNoErr;
 }
 
 void
 GMPVideoEncodedFrameImpl::SetEncodedWidth(uint32_t aEncodedWidth)
 {
@@ -285,10 +289,22 @@ GMPVideoEncodedFrameImpl::Buffer()
 }
 
 void
 GMPVideoEncodedFrameImpl::Destroy()
 {
   delete this;
 }
 
+GMPBufferType
+GMPVideoEncodedFrameImpl::BufferType() const
+{
+  return mBufferType;
+}
+
+void
+GMPVideoEncodedFrameImpl::SetBufferType(GMPBufferType aBufferType)
+{
+  mBufferType = aBufferType;
+}
+
 } // namespace gmp
 } // namespace mozilla
--- a/content/media/gmp/GMPVideoEncodedFrameImpl.h
+++ b/content/media/gmp/GMPVideoEncodedFrameImpl.h
@@ -84,28 +84,31 @@ public:
   virtual void     SetAllocatedSize(uint32_t aNewSize) MOZ_OVERRIDE;
   virtual uint32_t AllocatedSize() MOZ_OVERRIDE;
   virtual void     SetSize(uint32_t aSize) MOZ_OVERRIDE;
   virtual uint32_t Size() MOZ_OVERRIDE;
   virtual void     SetCompleteFrame(bool aCompleteFrame) MOZ_OVERRIDE;
   virtual bool     CompleteFrame() MOZ_OVERRIDE;
   virtual const uint8_t* Buffer() const MOZ_OVERRIDE;
   virtual uint8_t* Buffer() MOZ_OVERRIDE;
+  virtual GMPBufferType BufferType() const MOZ_OVERRIDE;
+  virtual void     SetBufferType(GMPBufferType aBufferType) MOZ_OVERRIDE;
   virtual const    GMPEncryptedBufferData* GetDecryptionData() const MOZ_OVERRIDE;
 
 private:
   void DestroyBuffer();
 
   uint32_t mEncodedWidth;
   uint32_t mEncodedHeight;
   uint64_t mTimeStamp;
   uint64_t mDuration;
   GMPVideoFrameType mFrameType;
   uint32_t mSize;
   bool     mCompleteFrame;
   GMPVideoHostImpl* mHost;
   ipc::Shmem mBuffer;
+  GMPBufferType mBufferType;
 };
 
 } // namespace gmp
 } // namespace mozilla
 
 #endif // GMPVideoEncodedFrameImpl_h_
--- a/content/media/gmp/GMPVideoEncoderChild.cpp
+++ b/content/media/gmp/GMPVideoEncoderChild.cpp
@@ -35,30 +35,29 @@ GMPVideoEncoderChild::Init(GMPVideoEncod
 GMPVideoHostImpl&
 GMPVideoEncoderChild::Host()
 {
   return mVideoHost;
 }
 
 void
 GMPVideoEncoderChild::Encoded(GMPVideoEncodedFrame* aEncodedFrame,
-                              GMPBufferType aBufferType,
                               const uint8_t* aCodecSpecificInfo,
                               uint32_t aCodecSpecificInfoLength)
 {
   MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());
 
   auto ef = static_cast<GMPVideoEncodedFrameImpl*>(aEncodedFrame);
 
   GMPVideoEncodedFrameData frameData;
   ef->RelinquishFrameData(frameData);
 
   nsTArray<uint8_t> codecSpecific;
   codecSpecific.AppendElements(aCodecSpecificInfo, aCodecSpecificInfoLength);
-  SendEncoded(frameData, aBufferType, codecSpecific);
+  SendEncoded(frameData, codecSpecific);
 
   aEncodedFrame->Destroy();
 }
 
 void
 GMPVideoEncoderChild::CheckThread()
 {
   MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());
--- a/content/media/gmp/GMPVideoEncoderChild.h
+++ b/content/media/gmp/GMPVideoEncoderChild.h
@@ -25,17 +25,16 @@ public:
   GMPVideoEncoderChild(GMPChild* aPlugin);
   virtual ~GMPVideoEncoderChild();
 
   void Init(GMPVideoEncoder* aEncoder);
   GMPVideoHostImpl& Host();
 
   // GMPVideoEncoderCallback
   virtual void Encoded(GMPVideoEncodedFrame* aEncodedFrame,
-                       GMPBufferType aBufferType,
                        const uint8_t* aCodecSpecificInfo,
                        uint32_t aCodecSpecificInfoLength) MOZ_OVERRIDE;
 
   // GMPSharedMemManager
   virtual void CheckThread();
   virtual bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, Shmem* aMem)
   {
 #ifndef SHMEM_ALLOC_IN_CHILD
--- a/content/media/gmp/GMPVideoEncoderParent.cpp
+++ b/content/media/gmp/GMPVideoEncoderParent.cpp
@@ -198,27 +198,26 @@ GMPVideoEncoderParent::ActorDestroy(Acto
 void
 GMPVideoEncoderParent::CheckThread()
 {
   MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());
 }
 
 bool
 GMPVideoEncoderParent::RecvEncoded(const GMPVideoEncodedFrameData& aEncodedFrame,
-                                   const GMPBufferType& aBufferType,
                                    const nsTArray<uint8_t>& aCodecSpecificInfo)
 {
   if (!mCallback) {
     return false;
   }
 
   auto f = new GMPVideoEncodedFrameImpl(aEncodedFrame, &mVideoHost);
 
   // Ignore any return code. It is OK for this to fail without killing the process.
-  mCallback->Encoded(f, aBufferType, aCodecSpecificInfo);
+  mCallback->Encoded(f, aCodecSpecificInfo);
 
   // Return SHM to sender to recycle
   //SendEncodedReturn(aEncodedFrame, aCodecSpecificInfo);
   return true;
 }
 
 bool
 GMPVideoEncoderParent::RecvParentShmemForPool(Shmem& aFrameBuffer)
--- a/content/media/gmp/GMPVideoEncoderParent.h
+++ b/content/media/gmp/GMPVideoEncoderParent.h
@@ -60,17 +60,16 @@ public:
   }
 
 private:
   virtual ~GMPVideoEncoderParent();
 
   // PGMPVideoEncoderParent
   virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   virtual bool RecvEncoded(const GMPVideoEncodedFrameData& aEncodedFrame,
-                           const GMPBufferType& aBufferType,
                            const nsTArray<uint8_t>& aCodecSpecificInfo) MOZ_OVERRIDE;
   virtual bool RecvParentShmemForPool(Shmem& aFrameBuffer) MOZ_OVERRIDE;
   virtual bool AnswerNeedShmem(const uint32_t& aEncodedBufferSize,
                                Shmem* aMem) MOZ_OVERRIDE;
   virtual bool Recv__delete__() MOZ_OVERRIDE;
 
   bool mCanSendMessages;
   GMPParent* mPlugin;
--- a/content/media/gmp/GMPVideoEncoderProxy.h
+++ b/content/media/gmp/GMPVideoEncoderProxy.h
@@ -9,17 +9,16 @@
 #include "nsTArray.h"
 #include "gmp-video-encode.h"
 #include "gmp-video-frame-i420.h"
 #include "gmp-video-frame-encoded.h"
 
 class GMPVideoEncoderCallbackProxy {
 public:
   virtual void Encoded(GMPVideoEncodedFrame* aEncodedFrame,
-                       GMPBufferType aBufferType,
                        const nsTArray<uint8_t>& aCodecSpecificInfo) = 0;
 };
 
 // A proxy to GMPVideoEncoder in the child process.
 // GMPVideoEncoderParent exposes this to users the GMP.
 // This enables Gecko to pass nsTArrays to the child GMP and avoid
 // an extra copy when doing so.
 class GMPVideoEncoderProxy {
--- a/content/media/gmp/PGMPVideoDecoder.ipdl
+++ b/content/media/gmp/PGMPVideoDecoder.ipdl
@@ -2,33 +2,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PGMP;
 include GMPTypes;
 
 using GMPVideoCodec from "gmp-video-codec.h";
-using GMPBufferType from "gmp-video-codec.h";
 
 include "GMPMessageUtils.h";
 
 namespace mozilla {
 namespace gmp {
 
 intr protocol PGMPVideoDecoder
 {
   manager PGMP;
 child:
   async InitDecode(GMPVideoCodec aCodecSettings,
                    uint8_t[] aCodecSpecific,
                    int32_t aCoreCount);
   async Decode(GMPVideoEncodedFrameData aInputFrame,
                bool aMissingFrames,
-               GMPBufferType aBufferType,
                uint8_t[] aCodecSpecificInfo,
                int64_t aRenderTimeMs);
   async Reset();
   async Drain();
   async DecodingComplete();
   async ChildShmemForPool(Shmem aFrameBuffer);
 
 parent:
--- a/content/media/gmp/PGMPVideoEncoder.ipdl
+++ b/content/media/gmp/PGMPVideoEncoder.ipdl
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PGMP;
 include GMPTypes;
 
 using GMPVideoCodec from "gmp-video-codec.h";
 using GMPVideoFrameType from "gmp-video-frame-encoded.h";
-using GMPBufferType from "gmp-video-codec.h";
 
 include "GMPMessageUtils.h";
 
 namespace mozilla {
 namespace gmp {
 
 intr protocol PGMPVideoEncoder
 {
@@ -30,17 +29,16 @@ child:
   async SetRates(uint32_t aNewBitRate, uint32_t aFrameRate);
   async SetPeriodicKeyFrames(bool aEnable);
   async EncodingComplete();
   async ChildShmemForPool(Shmem aEncodedBuffer);
 
 parent:
   async __delete__();
   async Encoded(GMPVideoEncodedFrameData aEncodedFrame,
-                GMPBufferType aBufferType,
                 uint8_t[] aCodecSpecificInfo);
   async ParentShmemForPool(Shmem aFrameBuffer);
   // MUST be intr - if sync and we create a new Shmem, when the returned
   // Shmem is received in the Child it will fail to Deserialize
   intr NeedShmem(uint32_t aEncodedBufferSize) returns (Shmem aMem);
 };
 
 } // namespace gmp
--- a/content/media/gmp/gmp-api/gmp-video-decode.h
+++ b/content/media/gmp/gmp-api/gmp-video-decode.h
@@ -79,26 +79,24 @@ public:
                             int32_t aCoreCount) = 0;
 
   // Decode encoded frame (as a part of a video stream). The decoded frame
   // will be returned to the user through the decode complete callback.
   //
   // - aInputFrame: Frame to decode. Call Destroy() on frame when it's decoded.
   // - aMissingFrames: True if one or more frames have been lost since the
   //                   previous decode call.
-  // - aBufferType : type of frame to encode
   // - aCodecSpecificInfo : codec specific data, pointer to a
   //                        GMPCodecSpecificInfo structure appropriate for
   //                        this codec type.
   // - aCodecSpecificInfoLength : number of bytes in aCodecSpecificInfo
   // - renderTimeMs : System time to render in milliseconds. Only used by
   //                  decoders with internal rendering.
   virtual GMPErr Decode(GMPVideoEncodedFrame* aInputFrame,
                         bool aMissingFrames,
-                        GMPBufferType aBufferType,
                         const uint8_t* aCodecSpecificInfo,
                         uint32_t aCodecSpecificInfoLength,
                         int64_t aRenderTimeMs = -1) = 0;
 
   // Reset decoder state and prepare for a new call to Decode(...).
   // Flushes the decoder pipeline.
   // The decoder should enqueue a task to run ResetComplete() on the main
   // thread once the reset has finished.
--- a/content/media/gmp/gmp-api/gmp-video-encode.h
+++ b/content/media/gmp/gmp-api/gmp-video-encode.h
@@ -44,17 +44,16 @@
 
 // ALL METHODS MUST BE CALLED ON THE MAIN THREAD
 class GMPVideoEncoderCallback
 {
 public:
   virtual ~GMPVideoEncoderCallback() {}
 
   virtual void Encoded(GMPVideoEncodedFrame* aEncodedFrame,
-                       GMPBufferType aBufferType,
                        const uint8_t* aCodecSpecificInfo,
                        uint32_t aCodecSpecificInfoLength) = 0;
 };
 
 // ALL METHODS MUST BE CALLED ON THE MAIN THREAD
 class GMPVideoEncoder
 {
 public:
--- a/content/media/gmp/gmp-api/gmp-video-frame-encoded.h
+++ b/content/media/gmp/gmp-api/gmp-video-frame-encoded.h
@@ -32,16 +32,17 @@
  */
 
 #ifndef GMP_VIDEO_FRAME_ENCODED_h_
 #define GMP_VIDEO_FRAME_ENCODED_h_
 
 #include <stdint.h>
 #include "gmp-decryption.h"
 #include "gmp-video-frame.h"
+#include "gmp-video-codec.h"
 
 enum GMPVideoFrameType
 {
   kGMPKeyFrame = 0,
   kGMPDeltaFrame = 1,
   kGMPGoldenFrame = 2,
   kGMPAltRefFrame = 3,
   kGMPSkipFrame = 4
@@ -81,14 +82,17 @@ public:
   virtual void     SetAllocatedSize(uint32_t aNewSize) = 0;
   virtual uint32_t AllocatedSize() = 0;
   virtual void     SetSize(uint32_t aSize) = 0;
   virtual uint32_t Size() = 0;
   virtual void     SetCompleteFrame(bool aCompleteFrame) = 0;
   virtual bool     CompleteFrame() = 0;
   virtual const uint8_t* Buffer() const = 0;
   virtual uint8_t*       Buffer() = 0;
+  virtual GMPBufferType  BufferType() const = 0;
+  virtual void     SetBufferType(GMPBufferType aBufferType) = 0;
+
   // Get data describing how this frame is encrypted, or nullptr if the
   // frame is not encrypted.
   virtual const GMPEncryptedBufferData* GetDecryptionData() const = 0;
 };
 
 #endif // GMP_VIDEO_FRAME_ENCODED_h_
--- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
@@ -312,35 +312,36 @@ WebrtcGmpVideoEncoder::SetRates_g(uint32
   }
 
   return WEBRTC_VIDEO_CODEC_OK;
 }
 
 // GMPVideoEncoderCallback virtual functions.
 void
 WebrtcGmpVideoEncoder::Encoded(GMPVideoEncodedFrame* aEncodedFrame,
-                               GMPBufferType aBufferType,
                                const nsTArray<uint8_t>& aCodecSpecificInfo)
 {
   if (mCallback) { // paranoia
     webrtc::VideoFrameType ft;
     GmpFrameTypeToWebrtcFrameType(aEncodedFrame->FrameType(), &ft);
     uint32_t timestamp = (aEncodedFrame->TimeStamp() * 90ll + 999)/1000;
 
-    LOGD(("GMP Encoded: %llu, type %d, len %d", aEncodedFrame->TimeStamp(), aBufferType,
+    LOGD(("GMP Encoded: %llu, type %d, len %d",
+         aEncodedFrame->TimeStamp(),
+         aEncodedFrame->BufferType(),
          aEncodedFrame->Size()));
 
     // Right now makes one Encoded() callback per unit
     // XXX convert to FragmentationHeader format (array of offsets and sizes plus a buffer) in
     // combination with H264 packetization changes in webrtc/trunk code
     uint8_t *buffer = aEncodedFrame->Buffer();
     uint8_t *end = aEncodedFrame->Buffer() + aEncodedFrame->Size();
     uint32_t size;
     while (buffer < end) {
-      switch (aBufferType) {
+      switch (aEncodedFrame->BufferType()) {
         case GMP_BufferSingle:
           size = aEncodedFrame->Size();
           break;
         case GMP_BufferLength8:
           size = *buffer++;
           break;
         case GMP_BufferLength16:
           // presumes we can do unaligned loads
@@ -357,34 +358,33 @@ WebrtcGmpVideoEncoder::Encoded(GMPVideoE
           break;
         case GMP_BufferLength32:
           // presumes we can do unaligned loads
           size = *(reinterpret_cast<uint32_t*>(buffer));
           buffer += 4;
           break;
         default:
           // really that it's not in the enum; gives more readable error
-          MOZ_ASSERT(aBufferType != GMP_BufferSingle);
+          MOZ_ASSERT(aEncodedFrame->BufferType() != GMP_BufferSingle);
           aEncodedFrame->Destroy();
           return;
       }
       webrtc::EncodedImage unit(buffer, size, size);
       unit._frameType = ft;
       unit._timeStamp = timestamp;
       unit._completeFrame = true;
 
       mCallback->Encoded(unit, nullptr, nullptr);
 
       buffer += size;
     }
   }
   aEncodedFrame->Destroy();
 }
 
-
 // Decoder.
 WebrtcGmpVideoDecoder::WebrtcGmpVideoDecoder() :
   mGMPThread(nullptr),
   mGMP(nullptr),
   mHost(nullptr),
   mCallback(nullptr) {}
 
 int32_t
@@ -499,16 +499,17 @@ WebrtcGmpVideoDecoder::Decode_g(const we
 
   // XXX It'd be wonderful not to have to memcpy the encoded data!
   memcpy(frame->Buffer()+4, aInputImage._buffer+4, frame->Size()-4);
 
   frame->SetEncodedWidth(aInputImage._encodedWidth);
   frame->SetEncodedHeight(aInputImage._encodedHeight);
   frame->SetTimeStamp((aInputImage._timeStamp * 1000ll)/90); // rounds down
   frame->SetCompleteFrame(aInputImage._completeFrame);
+  frame->SetBufferType(GMP_BufferLength32);
 
   GMPVideoFrameType ft;
   int32_t ret = WebrtcFrameTypeToGmpFrameType(aInputImage._frameType, &ft);
   if (ret != WEBRTC_VIDEO_CODEC_OK) {
     return ret;
   }
 
   // Bug XXXXXX: Set codecSpecific info
@@ -517,17 +518,16 @@ WebrtcGmpVideoDecoder::Decode_g(const we
   info.mCodecType = kGMPVideoCodecH264;
   info.mCodecSpecific.mH264.mSimulcastIdx = 0;
   nsTArray<uint8_t> codecSpecificInfo;
   codecSpecificInfo.AppendElements((uint8_t*)&info, sizeof(GMPCodecSpecificInfo));
 
   LOGD(("GMP Decode: %llu, len %d", frame->TimeStamp(), aInputImage._length));
   nsresult rv = mGMP->Decode(frame,
                              aMissingFrames,
-                             GMP_BufferLength32,
                              codecSpecificInfo,
                              aRenderTimeMs);
   if (NS_FAILED(rv)) {
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
 
   return WEBRTC_VIDEO_CODEC_OK;
 }
--- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h
@@ -61,17 +61,16 @@ public:
   virtual int32_t SetChannelParameters(uint32_t aPacketLoss,
                                        int aRTT) MOZ_OVERRIDE;
 
   virtual int32_t SetRates(uint32_t aNewBitRate,
                            uint32_t aFrameRate) MOZ_OVERRIDE;
 
   // GMPVideoEncoderCallback virtual functions.
   virtual void Encoded(GMPVideoEncodedFrame* aEncodedFrame,
-                       GMPBufferType aBufferType,
                        const nsTArray<uint8_t>& aCodecSpecificInfo) MOZ_OVERRIDE;
 
 
 private:
   virtual int32_t InitEncode_g(const webrtc::VideoCodec* aCodecSettings,
                                int32_t aNumberOfCores,
                                uint32_t aMaxPayloadSize);