Chromium Code Reviews| Index: content/renderer/media/audio_track_recorder.h |
| diff --git a/content/renderer/media/audio_track_recorder.h b/content/renderer/media/audio_track_recorder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b4621bd75be26af20f172aecb458442fc356e956 |
| --- /dev/null |
| +++ b/content/renderer/media/audio_track_recorder.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_ |
| +#define CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "base/time/time.h" |
| +#include "content/public/renderer/media_stream_audio_sink.h" |
| +#include "media/audio/audio_parameters.h" |
| +#include "media/base/audio_bus.h" |
| +#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| + |
| +namespace content { |
| + |
| +// TODO(ajose): Need to do any buffering? Use audio_fifo or audio_shifter? |
| + |
| +class CONTENT_EXPORT AudioTrackRecorder |
|
mcasas
2015/10/21 19:19:52
Need to write documentation here.
|
| + : NON_EXPORTED_BASE(public MediaStreamAudioSink) { |
| + public: |
| + using OnEncodedAudioCB = |
| + base::Callback<void(const media::AudioParameters& params, |
| + scoped_ptr<std::string> encoded_data, |
| + base::TimeTicks capture_timestamp)>; |
| + |
| + AudioTrackRecorder(const blink::WebMediaStreamTrack& track, |
| + const OnEncodedAudioCB& on_encoded_audio_cb); |
| + ~AudioTrackRecorder() override; |
| + |
| + // Implement MediaStreamAudioSink. |
| + void OnSetFormat(const media::AudioParameters& params) override; |
| + void OnData(const media::AudioBus& audio_bus, |
| + base::TimeTicks estimated_capture_time) override; |
| + |
| + private: |
| + friend class AudioTrackRecorderTest; |
| + class AudioEncoder; |
| + |
| + // Used to check that we are destroyed on the same thread we were created. |
| + base::ThreadChecker main_render_thread_checker_; |
| + |
| + // Used to DCHECK that MediaStreamAudioSink's methods are called on the |
| + // capture audio thread. |
| + base::ThreadChecker capture_thread_checker_; |
| + |
| + // We need to hold on to the Blink track to remove ourselves on dtor. |
| + blink::WebMediaStreamTrack track_; |
| + |
| + // Thin wrapper around the OpusEncoder. |
| + const scoped_refptr<AudioEncoder> encoder_; |
| + |
| + const OnEncodedAudioCB& on_encoded_audio_cb_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AudioTrackRecorder); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_ |