Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: media/audio/fake_audio_input_stream.h

Issue 734993002: Makes the WebRTC fake device capable of playing audio from a file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: output -> input Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/audio/fake_audio_input_stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/fake_audio_input_stream.h
diff --git a/media/audio/fake_audio_input_stream.h b/media/audio/fake_audio_input_stream.h
index 5f9f804ababa7d3279d930676d6afd267f7d2cd5..1fed3052a91522ef5650efd598d6322d817bc387 100644
--- a/media/audio/fake_audio_input_stream.h
+++ b/media/audio/fake_audio_input_stream.h
@@ -9,23 +9,26 @@
#include <vector>
+#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_parameters.h"
+#include "media/audio/sounds/wav_audio_handler.h"
namespace media {
class AudioBus;
class AudioManagerBase;
+// This class can either generate a beep sound or play audio from a file.
class MEDIA_EXPORT FakeAudioInputStream
: public AudioInputStream {
public:
- static AudioInputStream* MakeFakeStream(AudioManagerBase* manager,
- const AudioParameters& params);
+ static AudioInputStream* MakeFakeStream(
+ AudioManagerBase* manager, const AudioParameters& params);
bool Open() override;
void Start(AudioInputCallback* callback) override;
@@ -52,11 +55,19 @@ class MEDIA_EXPORT FakeAudioInputStream
private:
FakeAudioInputStream(AudioManagerBase* manager,
const AudioParameters& params);
-
~FakeAudioInputStream() override;
void DoCallback();
+ // Opens this stream reading from a |wav_filename| rather than beeping.
+ void OpenInFileMode(const base::FilePath& wav_filename);
+
+ // Returns true if the device is playing from a file; false if we're beeping.
+ bool PlayingFromFile();
+
+ void PlayFileLooping();
+ void PlayBeep();
+
AudioManagerBase* audio_manager_;
AudioInputCallback* callback_;
scoped_ptr<uint8[]> buffer_;
@@ -69,8 +80,10 @@ class MEDIA_EXPORT FakeAudioInputStream
int beep_duration_in_buffers_;
int beep_generated_in_buffers_;
int beep_period_in_frames_;
- int frames_elapsed_;
scoped_ptr<media::AudioBus> audio_bus_;
+ scoped_ptr<uint8[]> wav_file_data_;
+ scoped_ptr<media::WavAudioHandler> wav_audio_handler_;
+ int wav_file_read_pos_;
// Allows us to run tasks on the FakeAudioInputStream instance which are
// bound by its lifetime.
« no previous file with comments | « no previous file | media/audio/fake_audio_input_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698