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

Unified Diff: content/renderer/media/audio_track_recorder.h

Issue 1406113002: Add AudioTrackRecorder for audio component of MediaStream recording. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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
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..35376537456c1896994aff9c9227a1111b5b529e
--- /dev/null
+++ b/content/renderer/media/audio_track_recorder.h
@@ -0,0 +1,60 @@
+// 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
+ : 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_;
+
+ // We need to hold on to the Blink track to remove ourselves on dtor.
+ blink::WebMediaStreamTrack track_;
+
+ // Thin wrapper around the OpusEncoder.
+ scoped_refptr<AudioEncoder> encoder_;
mcasas 2015/10/19 20:02:09 const ? (not 100% sure since you reset() it explic
ajose 2015/10/20 03:21:12 Done.
+
+ const OnEncodedAudioCB& on_encoded_audio_cb_;
+ media::AudioParameters audio_params_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioTrackRecorder);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_

Powered by Google App Engine
This is Rietveld 408576698