Bug 805596: Incorrect audio rates used for fake audio streams r=anant
authorRandell Jesup <rjesup@jesup.org>
Thu, 25 Oct 2012 20:14:47 -0400
changeset 111491 b36eeabe85b53fcca595a20615e2cb57dfc65526
parent 111490 1e1c57c06adb32de93095d2f6b6b52e9317de25a
child 111492 58c8080a1a7c35e71fa839959bfe12baadb9baa0
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersanant
bugs805596
milestone19.0a1
Bug 805596: Incorrect audio rates used for fake audio streams r=anant
content/media/webrtc/MediaEngineDefault.cpp
--- a/content/media/webrtc/MediaEngineDefault.cpp
+++ b/content/media/webrtc/MediaEngineDefault.cpp
@@ -12,17 +12,18 @@
 #include "ImageTypes.h"
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidBridge.h"
 #include "nsISupportsUtils.h"
 #endif
 
 #define CHANNELS 1
-#define RATE USECS_PER_S
+#define VIDEO_RATE USECS_PER_S
+#define AUDIO_RATE 16000
 
 namespace mozilla {
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(MediaEngineDefaultVideoSource, nsITimerCallback)
 /**
  * Default video source.
  */
 
@@ -127,17 +128,17 @@ MediaEngineDefaultVideoSource::Start(Sou
 
   // SetData copies data, so we can free the frame
   mImage->SetData(data);
   PR_Free(frame);
 
   // AddTrack takes ownership of segment
   VideoSegment *segment = new VideoSegment();
   segment->AppendFrame(image.forget(), USECS_PER_S / DEFAULT_FPS, gfxIntSize(DEFAULT_WIDTH, DEFAULT_HEIGHT));
-  mSource->AddTrack(aID, RATE, 0, segment);
+  mSource->AddTrack(aID, VIDEO_RATE, 0, segment);
 
   // We aren't going to add any more tracks
   mSource->AdvanceKnownTracksTime(STREAM_TIME_MAX);
 
   // Remember TrackID so we can end it later
   mTrackID = aID;
 
   // Start timer for subsequent frames
@@ -279,17 +280,17 @@ MediaEngineDefaultAudioSource::Start(Sou
     return NS_ERROR_FAILURE;
   }
 
   mSource = aStream;
 
   // AddTrack will take ownership of segment
   AudioSegment* segment = new AudioSegment();
   segment->Init(CHANNELS);
-  mSource->AddTrack(aID, RATE, 0, segment);
+  mSource->AddTrack(aID, AUDIO_RATE, 0, segment);
 
   // We aren't going to add any more tracks
   mSource->AdvanceKnownTracksTime(STREAM_TIME_MAX);
 
   // Remember TrackID so we can finish later
   mTrackID = aID;
 
   // 1 Audio frame per Video frame
@@ -325,17 +326,17 @@ MediaEngineDefaultAudioSource::Snapshot(
    return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 MediaEngineDefaultAudioSource::Notify(nsITimer* aTimer)
 {
   AudioSegment segment;
   segment.Init(CHANNELS);
-  segment.InsertNullDataAtStart(1);
+  segment.InsertNullDataAtStart(AUDIO_RATE/100); // 10ms of fake data
 
   mSource->AppendToTrack(mTrackID, &segment);
 
   return NS_OK;
 }
 
 void
 MediaEngineDefault::EnumerateVideoDevices(nsTArray<nsRefPtr<MediaEngineVideoSource> >* aVSources) {