Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 #include "base/time/time.h" | |
| 13 #include "content/public/renderer/media_stream_audio_sink.h" | |
| 14 #include "media/audio/audio_parameters.h" | |
| 15 #include "media/base/audio_bus.h" | |
| 16 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 // TODO(ajose): Need to do any buffering? Use audio_fifo or audio_shifter? | |
| 21 | |
| 22 class CONTENT_EXPORT AudioTrackRecorder | |
|
mcasas
2015/10/21 19:19:52
Need to write documentation here.
| |
| 23 : NON_EXPORTED_BASE(public MediaStreamAudioSink) { | |
| 24 public: | |
| 25 using OnEncodedAudioCB = | |
| 26 base::Callback<void(const media::AudioParameters& params, | |
| 27 scoped_ptr<std::string> encoded_data, | |
| 28 base::TimeTicks capture_timestamp)>; | |
| 29 | |
| 30 AudioTrackRecorder(const blink::WebMediaStreamTrack& track, | |
| 31 const OnEncodedAudioCB& on_encoded_audio_cb); | |
| 32 ~AudioTrackRecorder() override; | |
| 33 | |
| 34 // Implement MediaStreamAudioSink. | |
| 35 void OnSetFormat(const media::AudioParameters& params) override; | |
| 36 void OnData(const media::AudioBus& audio_bus, | |
| 37 base::TimeTicks estimated_capture_time) override; | |
| 38 | |
| 39 private: | |
| 40 friend class AudioTrackRecorderTest; | |
| 41 class AudioEncoder; | |
| 42 | |
| 43 // Used to check that we are destroyed on the same thread we were created. | |
| 44 base::ThreadChecker main_render_thread_checker_; | |
| 45 | |
| 46 // Used to DCHECK that MediaStreamAudioSink's methods are called on the | |
| 47 // capture audio thread. | |
| 48 base::ThreadChecker capture_thread_checker_; | |
| 49 | |
| 50 // We need to hold on to the Blink track to remove ourselves on dtor. | |
| 51 blink::WebMediaStreamTrack track_; | |
| 52 | |
| 53 // Thin wrapper around the OpusEncoder. | |
| 54 const scoped_refptr<AudioEncoder> encoder_; | |
| 55 | |
| 56 const OnEncodedAudioCB& on_encoded_audio_cb_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(AudioTrackRecorder); | |
| 59 }; | |
| 60 | |
| 61 } // namespace content | |
| 62 | |
| 63 #endif // CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_ | |
| OLD | NEW |