Bug 896353 - Media Recording - Can't record the mediaStream created by AudioContext. r=roc
☠☠ backed out by b64e00a36321 ☠ ☠
authorRandy Lin <rlin@mozilla.com>
Wed, 24 Jul 2013 18:01:52 +0800
changeset 140081 73188e11f7b1fd566b97667d3abfe7742ca509f8
parent 140080 7111c04c11584778d34b4a1762b9978c9d0bf79f
child 140083 5b3e1692ebdeb7d5ab674f5a88fccacde25ea163
push id31589
push userryanvm@gmail.com
push dateFri, 26 Jul 2013 01:59:11 +0000
treeherdermozilla-inbound@13e83433293b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs896353
milestone25.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 896353 - Media Recording - Can't record the mediaStream created by AudioContext. r=roc
content/media/MediaRecorder.cpp
content/media/MediaRecorder.h
--- a/content/media/MediaRecorder.cpp
+++ b/content/media/MediaRecorder.cpp
@@ -111,16 +111,17 @@ public:
 private:
   nsRefPtr<MediaRecorder> mRecorder;
   nsRefPtr<MediaEncoder>  mEncoder;
 };
 
 MediaRecorder::~MediaRecorder()
 {
   if (mTrackUnionStream) {
+    mStreamPort->Destroy();
     mTrackUnionStream->Destroy();
   }
 }
 
 void
 MediaRecorder::Init(JSContext* aCx, nsPIDOMWindow* aOwnerWindow)
 {
   MOZ_ASSERT(aOwnerWindow);
@@ -187,18 +188,17 @@ MediaRecorder::Start(const Optional<int3
   if (mEncodedBufferCache == nullptr) {
     mEncodedBufferCache = new EncodedBufferCache(MAX_ALLOW_MEMORY_BUFFER);
   }
 
   mEncoder = MediaEncoder::CreateEncoder(NS_LITERAL_STRING(""));
   MOZ_ASSERT(mEncoder, "CreateEncoder failed");
 
   mTrackUnionStream->SetAutofinish(true);
-  nsRefPtr<MediaInputPort> port =
-    mTrackUnionStream->AllocateInputPort(mStream->GetStream(), MediaInputPort::FLAG_BLOCK_OUTPUT);
+  mStreamPort = mTrackUnionStream->AllocateInputPort(mStream->GetStream(), MediaInputPort::FLAG_BLOCK_OUTPUT);
 
   if (mEncoder) {
     mTrackUnionStream->AddListener(mEncoder);
   } else {
     aResult.Throw(NS_ERROR_DOM_ABORT_ERR);
   }
 
   if (!mReadThread) {
--- a/content/media/MediaRecorder.h
+++ b/content/media/MediaRecorder.h
@@ -105,16 +105,18 @@ protected:
   // Runnable thread for read data from mediaEncoder. It starts at MediaRecorder::Start() and stops at MediaRecorder::Stop().
   nsCOMPtr<nsIThread> mReadThread;
   // The MediaEncoder object initializes on start() and destroys in ~MediaRecorder.
   nsRefPtr<MediaEncoder> mEncoder;
   // MediaStream passed from js context
   nsRefPtr<DOMMediaStream> mStream;
   // This media stream is used for notifying raw data to encoder and can be blocked.
   nsRefPtr<ProcessedMediaStream> mTrackUnionStream;
+  // This is used for destroing the inputport when destroy the mediaRecorder
+  nsRefPtr<MediaInputPort> mStreamPort;
   // This object creates on start() and destroys in ~MediaRecorder.
   nsAutoPtr<EncodedBufferCache> mEncodedBufferCache;
   // It specifies the container format as well as the audio and video capture formats.
   nsString mMimeType;
   // The interval of timer passed from Start(). On every mTimeSlice milliseconds, if there are buffers store in the EncodedBufferCache,
   // a dataavailable event will be fired.
   int32_t mTimeSlice;
   // The current state of the MediaRecorder object.