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

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

Issue 11413078: Tab Audio Capture: Browser-side connect/disconnect functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed WCAIS threading issue (methods called on audio thread). Addressed hclam's review comments. Created 8 years, 1 month 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEB_CONTENTS_AUDIO_INPUT_STREAM_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEB_CONTENTS_AUDIO_INPUT_STREAM_H_
7
8 #include <set>
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h"
13 #include "base/threading/thread_checker.h"
14 #include "content/browser/renderer_host/media/web_contents_capture_util.h"
15 #include "content/common/content_export.h"
16 #include "media/audio/audio_io.h"
17
18 namespace media {
19 class DivertedAudioOutputStream;
20 }
21
22 namespace content {
23
24 class AudioRendererHost;
25
26 class CONTENT_EXPORT WebContentsAudioInputStream
27 : NON_EXPORTED_BASE(public media::AudioInputStream),
28 public base::RefCountedThreadSafe<WebContentsAudioInputStream> {
29 public:
30 // Construct from the a |device_id| string of the form:
31 // "render_process_id:render_view_id"
32 static WebContentsAudioInputStream* Create(const std::string& device_id);
33
34 // media::AudioInputStream implementation
35 virtual bool Open() OVERRIDE;
36 virtual void Start(AudioInputCallback* callback) OVERRIDE;
37 virtual void Stop() OVERRIDE;
38 virtual void Close() OVERRIDE;
39 virtual double GetMaxVolume() OVERRIDE;
40 virtual void SetVolume(double volume) OVERRIDE;
41 virtual double GetVolume() OVERRIDE;
42 virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
43 virtual bool GetAutomaticGainControl() OVERRIDE;
44
45 // Begin pulling data from the given AudioOutputStream. Caller retains
46 // ownership.
47 void AddAudioOutputStream(media::DivertedAudioOutputStream* aos);
48
49 // Stop pulling data from the given AudioOutputStream. After this method
50 // returns, the caller can safely destroy the AOS.
51 void RemoveAudioOutputStream(media::DivertedAudioOutputStream* aos);
52
53 private:
54 friend class base::RefCountedThreadSafe<WebContentsAudioInputStream>;
55
56 enum State {
57 kConstructed,
58 kOpened,
59 kRecording,
60 kClosed
61 };
62
63 WebContentsAudioInputStream(int render_process_id, int render_view_id);
64
65 virtual ~WebContentsAudioInputStream();
66
67 // Called by RenderViewTracker when the the target of the audio mirroring has
68 // changed.
69 void OnTargetChanged(int render_process_id, int render_view_id);
70
71 // Ensures calls to the media::AudioInputStream methods all occur from the
72 // same thread.
73 base::ThreadChecker thread_checker_;
74
75 State state_;
76
77 // Current audio mirroring target.
78 int target_render_process_id_;
79 int target_render_view_id_;
80 scoped_refptr<AudioRendererHost> target_host_;
Alpha Left Google 2012/11/26 22:59:59 Owning AudioRendererHost scares me.. AudioRenderer
miu 2012/11/28 05:05:01 Done.
81
82 // Tracks swapping of render views to maintain mirroring of the correct
83 // render view.
84 scoped_refptr<WebContentsCaptureUtil::RenderViewTracker> tracker_;
85
86 base::Lock streams_lock_;
87 std::set<media::DivertedAudioOutputStream*> streams_;
88
89 DISALLOW_COPY_AND_ASSIGN(WebContentsAudioInputStream);
90 };
91
92 } // namespace content
93
94 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEB_CONTENTS_AUDIO_INPUT_STREAM_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698