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

Side by Side Diff: content/renderer/media/audio_track_recorder.h

Issue 1579693006: MediaRecorder: support sampling rate adaption in AudioTrackRecorder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_
6 #define CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_ 6 #define CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 28 matching lines...) Expand all
39 AudioTrackRecorder(const blink::WebMediaStreamTrack& track, 39 AudioTrackRecorder(const blink::WebMediaStreamTrack& track,
40 const OnEncodedAudioCB& on_encoded_audio_cb); 40 const OnEncodedAudioCB& on_encoded_audio_cb);
41 ~AudioTrackRecorder() override; 41 ~AudioTrackRecorder() override;
42 42
43 // Implement MediaStreamAudioSink. 43 // Implement MediaStreamAudioSink.
44 void OnSetFormat(const media::AudioParameters& params) override; 44 void OnSetFormat(const media::AudioParameters& params) override;
45 void OnData(const media::AudioBus& audio_bus, 45 void OnData(const media::AudioBus& audio_bus,
46 base::TimeTicks capture_time) override; 46 base::TimeTicks capture_time) override;
47 47
48 private: 48 private:
49 friend class AudioTrackRecorderTest;
50 class AudioParameters; 49 class AudioParameters;
51 50
52 // Forward declaration of nested class for handling encoding. 51 // Forward declaration of nested class for handling encoding.
53 // See the implementation file for details. 52 // See the implementation file for details.
54 class AudioEncoder; 53 class AudioEncoder;
55 54
56 // Returns the Opus buffer duration in milliseconds, or zero if none will work
57 // for the given |sample_rate|.
58 static int GetOpusBufferDuration(int sample_rate);
59
60 // Used to check that we are destroyed on the same thread we were created on. 55 // Used to check that we are destroyed on the same thread we were created on.
61 base::ThreadChecker main_render_thread_checker_; 56 base::ThreadChecker main_render_thread_checker_;
62 57
63 // Used to check that MediaStreamAudioSink's methods are called on the 58 // Used to check that MediaStreamAudioSink's methods are called on the
64 // capture audio thread. 59 // capture audio thread.
65 base::ThreadChecker capture_thread_checker_; 60 base::ThreadChecker capture_thread_checker_;
66 61
67 // We need to hold on to the Blink track to remove ourselves on destruction. 62 // We need to hold on to the Blink track to remove ourselves on destruction.
68 const blink::WebMediaStreamTrack track_; 63 const blink::WebMediaStreamTrack track_;
69 64
70 // Thin wrapper around OpusEncoder. 65 // Thin wrapper around OpusEncoder.
71 // |encoder_| should be initialized before |encoder_thread_| such that 66 // |encoder_| should be initialized before |encoder_thread_| such that
72 // |encoder_thread_| is destructed first. This, combined with all 67 // |encoder_thread_| is destructed first. This, combined with all
73 // AudioEncoder work (aside from construction and destruction) happening on 68 // AudioEncoder work (aside from construction and destruction) happening on
74 // |encoder_thread_|, should allow us to be sure that all AudioEncoder work is 69 // |encoder_thread_|, should allow us to be sure that all AudioEncoder work is
75 // done by the time we destroy it on ATR's thread. 70 // done by the time we destroy it on ATR's thread.
76 const scoped_refptr<AudioEncoder> encoder_; 71 const scoped_refptr<AudioEncoder> encoder_;
77 // The thread on which |encoder_| works. 72 // The thread on which |encoder_| works.
78 base::Thread encoder_thread_; 73 base::Thread encoder_thread_;
79 74
80 DISALLOW_COPY_AND_ASSIGN(AudioTrackRecorder); 75 DISALLOW_COPY_AND_ASSIGN(AudioTrackRecorder);
81 }; 76 };
82 77
83 } // namespace content 78 } // namespace content
84 79
85 #endif // CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_ 80 #endif // CONTENT_RENDERER_MEDIA_AUDIO_TRACK_RECORDER_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/audio_track_recorder.cc » ('j') | content/renderer/media/audio_track_recorder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698