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

Side by Side Diff: content/browser/renderer_host/media/audio_mirroring_manager.h

Issue 11413078: Tab Audio Capture: Browser-side connect/disconnect functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move Diverter interface into audio_io.h. Replace use of singleton with BrowserMainLoop. Created 7 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 | Annotate | Revision Log
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 // AudioMirroringManager is a singleton object that maintains a set of active
6 // audio mirroring destinations and auto-connects/disconnects audio streams
7 // to/from those destinations. It is meant to be used exclusively on the IO
8 // BrowserThread.
9 //
10 // How it works:
11 //
12 // 1. AudioRendererHost gets a CreateStream message from the render process
13 // and, among other things, creates an AudioOutputController to control the
14 // audio data flow between the render and browser processes.
15 // 2. At some point, AudioRendererHost receives an "associate with render
16 // view" message. Among other actions, it registers the
17 // AudioOutputController with AudioMirroringManager (as a Diverter).
18 // 3. A user request to mirror all the audio for a single RenderView is made.
19 // A MirroringDestination is created, and StartMirroring() is called to
20 // begin the mirroring session. This causes AudioMirroringManager to
21 // instruct any matching Diverters to divert their audio data to the
22 // MirroringDestination.
23 //
24 // #2 and #3 above may occur in any order, as it is the job of
25 // AudioMirroringManager to realize when the players can be "matched up."
26
27 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_MIRRORING_MANAGER_H_
28 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_MIRRORING_MANAGER_H_
29
30 #include <map>
31 #include <utility>
32
33 #include "base/basictypes.h"
34 #include "content/common/content_export.h"
35 #include "media/audio/audio_io.h"
36
37 namespace content {
38
39 class CONTENT_EXPORT AudioMirroringManager {
40 public:
41 // Interface for diverting audio data to an alternative AudioOutputStream.
42 typedef media::AudioOutputStream::AudioSourceDiverter Diverter;
43
44 // Interface to be implemented by audio mirroring destinations. See comments
45 // for StartMirroring() and StopMirroring() below.
46 class MirroringDestination {
47 public:
48 // Create a consumer of audio data in the format specified by |params|, and
49 // connect it as an input to mirroring. When Close() is called on the
50 // returned AudioOutputStream, the input is disconnected and the object
51 // becomes invalid.
52 virtual media::AudioOutputStream* AddInput(
53 const media::AudioParameters& params) = 0;
54
55 protected:
56 virtual ~MirroringDestination();
57 };
58
59 AudioMirroringManager();
60
61 virtual ~AudioMirroringManager();
62
63 // Add/Remove a diverter for an audio stream with a known RenderView target
64 // (represented by |render_process_id| + |render_view_id|). Multiple
65 // diverters may be added for the same target. |diverter| must live until
66 // after RemoveDiverter() is called.
67 virtual void AddDiverter(int render_process_id, int render_view_id,
68 Diverter* diverter);
69 virtual void RemoveDiverter(int render_process_id, int render_view_id,
70 Diverter* diverter);
71
72 // Start/stop mirroring all audio output streams associated with a RenderView
73 // target (represented by |render_process_id| + |render_view_id|) to
74 // |destination|. |destination| must live until after StopMirroring() is
75 // called.
76 virtual void StartMirroring(int render_process_id, int render_view_id,
77 MirroringDestination* destination);
78 virtual void StopMirroring(int render_process_id, int render_view_id,
79 MirroringDestination* destination);
80
81 private:
82 // A mirroring target is a RenderView identified by a
83 // <render_process_id, render_view_id> pair.
84 typedef std::pair<int, int> Target;
85
86 // Note: Objects in these maps are not owned.
87 typedef std::multimap<Target, Diverter*> DiverterMap;
88 typedef std::map<Target, MirroringDestination*> SessionMap;
89
90 // Currently-active divertable audio streams.
91 DiverterMap diverters_;
92
93 // Currently-active mirroring sessions.
94 SessionMap sessions_;
95
96 DISALLOW_COPY_AND_ASSIGN(AudioMirroringManager);
97 };
98
99 } // namespace content
100
101 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_MIRRORING_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698