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

Side by Side 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 unified diff | Download patch
OLDNEW
(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
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 // We need to hold on to the Blink track to remove ourselves on dtor.
47 blink::WebMediaStreamTrack track_;
48
49 // Thin wrapper around the OpusEncoder.
50 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.
51
52 const OnEncodedAudioCB& on_encoded_audio_cb_;
53 media::AudioParameters audio_params_;
54
55 DISALLOW_COPY_AND_ASSIGN(AudioTrackRecorder);
56 };
57
58 } // namespace content
59
60 #endif // CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698