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

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

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from PS2: AudioInputDevice --> AudioCapturerSource, and refptr foo in WebRtcMedi… Created 4 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_MEDIA_INTERFACE_PROVIDER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_EXTERNAL_MEDIA_STREAM_AUDIO_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_INTERFACE_PROVIDER_H_ 6 #define CONTENT_RENDERER_MEDIA_EXTERNAL_MEDIA_STREAM_AUDIO_SOURCE_H_
7 7
8 #include "base/callback.h" 8 #include "content/renderer/media/media_stream_audio_source.h"
9 #include "base/macros.h" 9
10 #include "base/threading/thread_checker.h" 10 #include "media/base/audio_capturer_source.h"
11 #include "content/common/content_export.h"
12 #include "media/mojo/interfaces/service_factory.mojom.h"
13 #include "mojo/shell/public/interfaces/interface_provider.mojom.h"
14 #include "url/gurl.h"
15 11
16 namespace content { 12 namespace content {
17 13
18 // MediaInterfaceProvider is an implementation of mojo InterfaceProvider that 14 // Represents an externally-provided local or remote source of audio data. This
19 // provides media related services and handles app disconnection automatically. 15 // allows users of the public content::MediaStreamApi to provide a
20 // This class is single threaded. 16 // media::AudioCapturerSource to be used as the source of audio data in the
21 class CONTENT_EXPORT MediaInterfaceProvider 17 // MediaStream framework. Audio data is transported directly to the tracks
22 : public mojo::shell::mojom::InterfaceProvider { 18 // (i.e., there is no audio processing).
19 class CONTENT_EXPORT ExternalMediaStreamAudioSource final
20 : NON_EXPORTED_BASE(public MediaStreamAudioSource),
21 NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback) {
23 public: 22 public:
24 // Callback used to connect to a mojo application. 23 ExternalMediaStreamAudioSource(
25 using ConnectToApplicationCB = 24 scoped_refptr<media::AudioCapturerSource> source,
26 base::Callback<mojo::shell::mojom::InterfaceProviderPtr(const GURL& url)>; 25 int sample_rate,
26 media::ChannelLayout channel_layout,
27 int frames_per_buffer,
28 bool is_remote);
27 29
28 explicit MediaInterfaceProvider( 30 ~ExternalMediaStreamAudioSource() final;
29 const ConnectToApplicationCB& connect_to_app_cb);
30 ~MediaInterfaceProvider() final;
31
32 // InterfaceProvider implementation.
33 void GetInterface(const mojo::String& interface_name,
34 mojo::ScopedMessagePipeHandle pipe) final;
35 31
36 private: 32 private:
37 media::interfaces::ServiceFactory* GetMediaServiceFactory(); 33 // MediaStreamAudioSource implementation.
38 void OnConnectionError(); 34 bool EnsureSourceIsStarted() final;
35 void EnsureSourceIsStopped() final;
39 36
37 // media::AudioCapturerSource::CaptureCallback implementation.
38 void Capture(const media::AudioBus* audio_bus,
39 int audio_delay_milliseconds,
40 double volume,
41 bool key_pressed) final;
42 void OnCaptureError(const std::string& message) final;
43
44 // The external source provided to the constructor.
45 scoped_refptr<media::AudioCapturerSource> source_;
46
47 // In debug builds, check that all methods that could cause object graph
48 // or data flow changes are being called on the main thread.
40 base::ThreadChecker thread_checker_; 49 base::ThreadChecker thread_checker_;
41 ConnectToApplicationCB connect_to_app_cb_;
42 media::interfaces::ServiceFactoryPtr media_service_factory_;
43 50
44 DISALLOW_COPY_AND_ASSIGN(MediaInterfaceProvider); 51 // True once the source has been started successfully.
52 bool was_started_;
53
54 DISALLOW_COPY_AND_ASSIGN(ExternalMediaStreamAudioSource);
45 }; 55 };
46 56
47 } // namespace content 57 } // namespace content
48 58
49 #endif // CONTENT_RENDERER_MEDIA_MEDIA_INTERFACE_PROVIDER_H_ 59 #endif // CONTENT_RENDERER_MEDIA_EXTERNAL_MEDIA_STREAM_AUDIO_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698