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

Side by Side Diff: content/renderer/pepper/pepper_platform_audio_input.h

Issue 364123002: [Cross-Site Isolation] Migrate entire MediaStream verticals to be per-RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: It's random enough. + REBASE Created 6 years, 5 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 namespace media { 24 namespace media {
25 class AudioParameters; 25 class AudioParameters;
26 } 26 }
27 27
28 namespace content { 28 namespace content {
29 29
30 class PepperAudioInputHost; 30 class PepperAudioInputHost;
31 class PepperMediaDeviceManager; 31 class PepperMediaDeviceManager;
32 class RenderViewImpl;
33 32
34 // PepperPlatformAudioInput is operated on two threads: the main thread (the 33 // PepperPlatformAudioInput is operated on two threads: the main thread (the
35 // thread on which objects are created) and the I/O thread. All public methods, 34 // thread on which objects are created) and the I/O thread. All public methods,
36 // except the destructor, must be called on the main thread. The notifications 35 // except the destructor, must be called on the main thread. The notifications
37 // to the users of this class (i.e. PepperAudioInputHost) are also sent on the 36 // to the users of this class (i.e. PepperAudioInputHost) are also sent on the
38 // main thread. Internally, this class sends audio input IPC messages and 37 // main thread. Internally, this class sends audio input IPC messages and
39 // receives media::AudioInputIPCDelegate notifications on the I/O thread. 38 // receives media::AudioInputIPCDelegate notifications on the I/O thread.
40 39
41 class PepperPlatformAudioInput 40 class PepperPlatformAudioInput
42 : public media::AudioInputIPCDelegate, 41 : public media::AudioInputIPCDelegate,
43 public base::RefCountedThreadSafe<PepperPlatformAudioInput> { 42 public base::RefCountedThreadSafe<PepperPlatformAudioInput> {
44 public: 43 public:
45 // Factory function, returns NULL on failure. StreamCreated() will be called 44 // Factory function, returns NULL on failure. StreamCreated() will be called
46 // when the stream is created. 45 // when the stream is created.
47 static PepperPlatformAudioInput* Create( 46 static PepperPlatformAudioInput* Create(
48 const base::WeakPtr<RenderViewImpl>& render_view, 47 int render_frame_id,
49 const std::string& device_id, 48 const std::string& device_id,
50 const GURL& document_url, 49 const GURL& document_url,
51 int sample_rate, 50 int sample_rate,
52 int frames_per_buffer, 51 int frames_per_buffer,
53 PepperAudioInputHost* client); 52 PepperAudioInputHost* client);
54 53
55 // Called on main thread. 54 // Called on main thread.
56 void StartCapture(); 55 void StartCapture();
57 void StopCapture(); 56 void StopCapture();
58 // Closes the stream. Make sure to call this before the object is destructed. 57 // Closes the stream. Make sure to call this before the object is destructed.
(...skipping 10 matching lines...) Expand all
69 virtual void OnIPCClosed() OVERRIDE; 68 virtual void OnIPCClosed() OVERRIDE;
70 69
71 protected: 70 protected:
72 virtual ~PepperPlatformAudioInput(); 71 virtual ~PepperPlatformAudioInput();
73 72
74 private: 73 private:
75 friend class base::RefCountedThreadSafe<PepperPlatformAudioInput>; 74 friend class base::RefCountedThreadSafe<PepperPlatformAudioInput>;
76 75
77 PepperPlatformAudioInput(); 76 PepperPlatformAudioInput();
78 77
79 bool Initialize(const base::WeakPtr<RenderViewImpl>& render_view, 78 bool Initialize(int render_frame_id,
80 const std::string& device_id, 79 const std::string& device_id,
81 const GURL& document_url, 80 const GURL& document_url,
82 int sample_rate, 81 int sample_rate,
83 int frames_per_buffer, 82 int frames_per_buffer,
84 PepperAudioInputHost* client); 83 PepperAudioInputHost* client);
85 84
86 // I/O thread backends to above functions. 85 // I/O thread backends to above functions.
87 void InitializeOnIOThread(int session_id); 86 void InitializeOnIOThread(int session_id);
88 void StartCaptureOnIOThread(); 87 void StartCaptureOnIOThread();
89 void StopCaptureOnIOThread(); 88 void StopCaptureOnIOThread();
90 void ShutDownOnIOThread(); 89 void ShutDownOnIOThread();
91 90
92 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); 91 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label);
93 void CloseDevice(); 92 void CloseDevice();
94 void NotifyStreamCreationFailed(); 93 void NotifyStreamCreationFailed();
95 94
95 // Can return NULL if the RenderFrame referenced by |render_frame_id_| has
96 // gone away.
96 PepperMediaDeviceManager* GetMediaDeviceManager(); 97 PepperMediaDeviceManager* GetMediaDeviceManager();
97 98
98 // The client to notify when the stream is created. THIS MUST ONLY BE 99 // The client to notify when the stream is created. THIS MUST ONLY BE
99 // ACCESSED ON THE MAIN THREAD. 100 // ACCESSED ON THE MAIN THREAD.
100 PepperAudioInputHost* client_; 101 PepperAudioInputHost* client_;
101 102
102 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE 103 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE
103 // I/O THREAD. 104 // I/O THREAD.
104 scoped_ptr<media::AudioInputIPC> ipc_; 105 scoped_ptr<media::AudioInputIPC> ipc_;
105 106
106 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; 107 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_;
107 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; 108 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
108 109
109 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. 110 // The frame containing the Pepper widget.
110 base::WeakPtr<RenderViewImpl> render_view_; 111 int render_frame_id_;
111 112
112 // The unique ID to identify the opened device. THIS MUST ONLY BE ACCESSED ON 113 // The unique ID to identify the opened device. THIS MUST ONLY BE ACCESSED ON
113 // THE MAIN THREAD. 114 // THE MAIN THREAD.
114 std::string label_; 115 std::string label_;
115 116
116 // Initialized on the main thread and accessed on the I/O thread afterwards. 117 // Initialized on the main thread and accessed on the I/O thread afterwards.
117 media::AudioParameters params_; 118 media::AudioParameters params_;
118 119
119 // Whether we have tried to create an audio stream. THIS MUST ONLY BE ACCESSED 120 // Whether we have tried to create an audio stream. THIS MUST ONLY BE ACCESSED
120 // ON THE I/O THREAD. 121 // ON THE I/O THREAD.
121 bool create_stream_sent_; 122 bool create_stream_sent_;
122 123
123 // Whether we have a pending request to open a device. We have to make sure 124 // Whether we have a pending request to open a device. We have to make sure
124 // there isn't any pending request before this object goes away. 125 // there isn't any pending request before this object goes away.
125 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. 126 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD.
126 bool pending_open_device_; 127 bool pending_open_device_;
127 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. 128 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD.
128 int pending_open_device_id_; 129 int pending_open_device_id_;
129 130
130 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInput); 131 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInput);
131 }; 132 };
132 133
133 } // namespace content 134 } // namespace content
134 135
135 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_ 136 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_media_device_manager.cc ('k') | content/renderer/pepper/pepper_platform_audio_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698