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

Unified Diff: content/browser/media/capture/audio_mirroring_manager.h

Issue 1897953003: Unmute Tab Audio For Desktop Share (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/media/capture/audio_mirroring_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/capture/audio_mirroring_manager.h
diff --git a/content/browser/media/capture/audio_mirroring_manager.h b/content/browser/media/capture/audio_mirroring_manager.h
index a624a0824befa013d4868d12a3c75f50ac8417f6..b98cf018c5922e4023b4f32398da0d583b41568d 100644
--- a/content/browser/media/capture/audio_mirroring_manager.h
+++ b/content/browser/media/capture/audio_mirroring_manager.h
@@ -32,6 +32,7 @@
#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_AUDIO_MIRRORING_MANAGER_H_
#define CONTENT_BROWSER_MEDIA_CAPTURE_AUDIO_MIRRORING_MANAGER_H_
+#include <map>
#include <set>
#include <utility>
#include <vector>
@@ -64,21 +65,33 @@ class CONTENT_EXPORT AudioMirroringManager {
// Asynchronously query whether this MirroringDestination wants to consume
// audio sourced from each of the |candidates|. |results_callback| is run
// to indicate which of them (or none) should have audio routed to this
- // MirroringDestination. |results_callback| must be run on the same thread
- // as the one that called QueryForMatches().
- typedef base::Callback<void(const std::set<SourceFrameRef>&)>
+ // MirroringDestination. The second parameter of |results_callback|
+ // indicates whether the MirroringDestination wants either: 1) exclusive
+ // access to a diverted audio flow versus 2) a duplicate copy of the audio
+ // flow. |results_callback| must be run on the same thread as the one that
+ // called QueryForMatches().
+ typedef base::Callback<void(const std::set<SourceFrameRef>&, bool)>
MatchesCallback;
virtual void QueryForMatches(
const std::set<SourceFrameRef>& candidates,
const MatchesCallback& results_callback) = 0;
// Create a consumer of audio data in the format specified by |params|, and
- // connect it as an input to mirroring. When Close() is called on the
- // returned AudioOutputStream, the input is disconnected and the object
- // becomes invalid.
+ // connect it as an input to mirroring. This is used to provide
+ // MirroringDestination with exclusive access to pull the audio flow from
+ // the source. When Close() is called on the returned AudioOutputStream, the
+ // input is disconnected and the object becomes invalid.
virtual media::AudioOutputStream* AddInput(
const media::AudioParameters& params) = 0;
+ // Create a consumer of audio data in the format specified by |params|, and
+ // connect it as an input to mirroring. This is used to provide
+ // MirroringDestination with duplicate audio data, which is pushed from the
+ // main audio flow. When Close() is called on the returned AudioPushSink,
+ // the input is disconnected and the object becomes invalid.
+ virtual media::AudioPushSink* AddPushInput(
+ const media::AudioParameters& params) = 0;
+
protected:
virtual ~MirroringDestination() {}
};
@@ -120,6 +133,11 @@ class CONTENT_EXPORT AudioMirroringManager {
// destination.
MirroringDestination* destination;
+ // The destinations to which audio stream is duplicated. AudioPushSink is
+ // owned by the Diverter, but AudioMirroringManager must guarantee
+ // StopDuplicating() is called to release them.
+ std::map<MirroringDestination*, media::AudioPushSink*> duplications;
+
StreamRoutingState(const SourceFrameRef& source_frame,
Diverter* stream_diverter);
StreamRoutingState(const StreamRoutingState& other);
@@ -136,17 +154,35 @@ class CONTENT_EXPORT AudioMirroringManager {
const std::set<SourceFrameRef>& candidates);
// MirroringDestination query callback. |matches| contains all RenderFrame
- // sources that will be diverted to |destination|. If |add_only| is false,
- // then any Diverters currently routed to |destination| but not found in
- // |matches| will be stopped.
+ // sources that will be diverted or duplicated to |destination|.
+ // If |add_only| is false, then any audio flows currently routed to
+ // |destination| but not found in |matches| will be stopped.
+ // If |is_duplicate| is true, the audio data flow will be duplicated to the
+ // destination instead of diverted.
void UpdateRoutesToDestination(MirroringDestination* destination,
bool add_only,
- const std::set<SourceFrameRef>& matches);
+ const std::set<SourceFrameRef>& matches,
+ bool is_duplicate);
+
+ // |matches| contains all RenderFrame sources that will be diverted to
+ // |destination|. If |add_only| is false, then any Diverters currently routed
+ // to |destination| but not found in |matches| will be stopped.
+ void UpdateRoutesToDivertDestination(MirroringDestination* destination,
+ bool add_only,
+ const std::set<SourceFrameRef>& matches);
+
+ // |matches| contains all RenderFrame sources that will be duplicated to
+ // |destination|. If |add_only| is false, then any Diverters currently
+ // duplicating to |destination| but not found in |matches| will be stopped.
+ void UpdateRoutesToDuplicateDestination(
+ MirroringDestination* destination,
+ bool add_only,
+ const std::set<SourceFrameRef>& matches);
// Starts diverting audio to the |new_destination|, if not NULL. Otherwise,
// stops diverting audio.
- static void ChangeRoute(StreamRoutingState* route,
- MirroringDestination* new_destination);
+ static void RouteDivertedFlow(StreamRoutingState* route,
+ MirroringDestination* new_destination);
// Routing table. Contains one entry for each Diverter.
StreamRoutes routes_;
« no previous file with comments | « no previous file | content/browser/media/capture/audio_mirroring_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698