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

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

Issue 1966043006: Revert of MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 (c) 2012 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_WEBAUDIO_MEDIA_STREAM_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_WEBAUDIO_MEDIA_STREAM_SOURCE_H_
7
8 #include <memory>
9
10 #include "base/time/time.h"
11 #include "content/renderer/media/media_stream_audio_source.h"
12 #include "media/base/audio_bus.h"
13 #include "media/base/audio_push_fifo.h"
14 #include "third_party/WebKit/public/platform/WebAudioDestinationConsumer.h"
15 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
16 #include "third_party/WebKit/public/platform/WebVector.h"
17
18 namespace content {
19
20 // Implements the WebAudioDestinationConsumer interface to provide a source of
21 // audio data (i.e., the output from a graph of WebAudio nodes) to one or more
22 // MediaStreamAudioTracks. Audio data is transported directly to the tracks in
23 // 10 ms chunks.
24 class WebAudioMediaStreamSource final
25 : NON_EXPORTED_BASE(public MediaStreamAudioSource),
26 public blink::WebAudioDestinationConsumer {
27 public:
28 explicit WebAudioMediaStreamSource(blink::WebMediaStreamSource* blink_source);
29
30 ~WebAudioMediaStreamSource() override;
31
32 private:
33 // WebAudioDestinationConsumer implementation.
34 //
35 // Note: Blink ensures setFormat() and consumeAudio() are not called
36 // concurrently across threads, but these methods could be called on any
37 // thread.
38 void setFormat(size_t number_of_channels, float sample_rate) override;
39 void consumeAudio(const blink::WebVector<const float*>& audio_data,
40 size_t number_of_frames) override;
41
42 // Called by AudioPushFifo zero or more times during the call to
43 // consumeAudio(). Delivers audio data with the required buffer size to the
44 // tracks.
45 void DeliverRebufferedAudio(const media::AudioBus& audio_bus,
46 int frame_delay);
47
48 // MediaStreamAudioSource implementation.
49 bool EnsureSourceIsStarted() final;
50 void EnsureSourceIsStopped() final;
51
52 // In debug builds, check that all methods that could cause object graph
53 // or data flow changes are being called on the main thread.
54 base::ThreadChecker thread_checker_;
55
56 // True while this WebAudioMediaStreamSource is registered with
57 // |blink_source_| and is consuming audio.
58 bool is_registered_consumer_;
59
60 // A wrapper used for providing audio to |fifo_|.
61 std::unique_ptr<media::AudioBus> wrapper_bus_;
62
63 // Takes in the audio data passed to consumeAudio() and re-buffers it into 10
64 // ms chunks for the tracks. This ensures each chunk of audio delivered to
65 // the tracks has the required buffer size, regardless of the amount of audio
66 // provided via each consumeAudio() call.
67 media::AudioPushFifo fifo_;
68
69 // Used to pass the reference timestamp between DeliverDecodedAudio() and
70 // DeliverRebufferedAudio().
71 base::TimeTicks current_reference_time_;
72
73 // This object registers with a blink::WebMediaStreamSource. We keep track of
74 // that in order to be able to deregister before stopping this source.
75 blink::WebMediaStreamSource blink_source_;
76
77 DISALLOW_COPY_AND_ASSIGN(WebAudioMediaStreamSource);
78 };
79
80 } // namespace content
81
82 #endif // CONTENT_RENDERER_MEDIA_WEBAUDIO_MEDIA_STREAM_SOURCE_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webaudio_capturer_source.cc ('k') | content/renderer/media/webaudio_media_stream_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698