| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // AudioInputRendererHost serves audio related requests from audio capturer | 5 // AudioInputRendererHost serves audio related requests from audio capturer |
| 6 // which lives inside the render process and provide access to audio hardware. | 6 // which lives inside the render process and provide access to audio hardware. |
| 7 // | 7 // |
| 8 // OnCreateStream() request is only available in the low latency mode. It will | 8 // OnCreateStream() request is only available in the low latency mode. It will |
| 9 // creates a shared memory, a SyncWriter and a AudioInputController for the | 9 // creates a shared memory, a SyncWriter and a AudioInputController for the |
| 10 // input stream. | 10 // input stream. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #pragma once | 56 #pragma once |
| 57 | 57 |
| 58 #include <map> | 58 #include <map> |
| 59 | 59 |
| 60 #include "base/compiler_specific.h" | 60 #include "base/compiler_specific.h" |
| 61 #include "base/gtest_prod_util.h" | 61 #include "base/gtest_prod_util.h" |
| 62 #include "base/memory/ref_counted.h" | 62 #include "base/memory/ref_counted.h" |
| 63 #include "base/memory/scoped_ptr.h" | 63 #include "base/memory/scoped_ptr.h" |
| 64 #include "base/process.h" | 64 #include "base/process.h" |
| 65 #include "base/shared_memory.h" | 65 #include "base/shared_memory.h" |
| 66 #include "content/browser/browser_message_filter.h" | |
| 67 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h
andler.h" | 66 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h
andler.h" |
| 67 #include "content/public/browser/browser_message_filter.h" |
| 68 #include "content/public/browser/browser_thread.h" | 68 #include "content/public/browser/browser_thread.h" |
| 69 #include "media/audio/audio_input_controller.h" | 69 #include "media/audio/audio_input_controller.h" |
| 70 #include "media/audio/audio_io.h" | 70 #include "media/audio/audio_io.h" |
| 71 #include "media/audio/simple_sources.h" | 71 #include "media/audio/simple_sources.h" |
| 72 | 72 |
| 73 namespace content { | 73 namespace content { |
| 74 class ResourceContext; | 74 class ResourceContext; |
| 75 } | 75 } |
| 76 | 76 |
| 77 class AudioManager; | 77 class AudioManager; |
| 78 struct AudioParameters; | 78 struct AudioParameters; |
| 79 | 79 |
| 80 class CONTENT_EXPORT AudioInputRendererHost | 80 class CONTENT_EXPORT AudioInputRendererHost |
| 81 : public BrowserMessageFilter, | 81 : public content::BrowserMessageFilter, |
| 82 public media::AudioInputController::EventHandler, | 82 public media::AudioInputController::EventHandler, |
| 83 public media_stream::AudioInputDeviceManagerEventHandler { | 83 public media_stream::AudioInputDeviceManagerEventHandler { |
| 84 public: | 84 public: |
| 85 struct AudioEntry { | 85 struct AudioEntry { |
| 86 AudioEntry(); | 86 AudioEntry(); |
| 87 ~AudioEntry(); | 87 ~AudioEntry(); |
| 88 | 88 |
| 89 // The AudioInputController that manages the audio input stream. | 89 // The AudioInputController that manages the audio input stream. |
| 90 scoped_refptr<media::AudioInputController> controller; | 90 scoped_refptr<media::AudioInputController> controller; |
| 91 | 91 |
| 92 // The audio input stream ID in the render view. | 92 // The audio input stream ID in the render view. |
| 93 int stream_id; | 93 int stream_id; |
| 94 | 94 |
| 95 // Shared memory for transmission of the audio data. | 95 // Shared memory for transmission of the audio data. |
| 96 base::SharedMemory shared_memory; | 96 base::SharedMemory shared_memory; |
| 97 | 97 |
| 98 // The synchronous writer to be used by the controller. We have the | 98 // The synchronous writer to be used by the controller. We have the |
| 99 // ownership of the writer. | 99 // ownership of the writer. |
| 100 scoped_ptr<media::AudioInputController::SyncWriter> writer; | 100 scoped_ptr<media::AudioInputController::SyncWriter> writer; |
| 101 | 101 |
| 102 // Set to true after we called Close() for the controller. | 102 // Set to true after we called Close() for the controller. |
| 103 bool pending_close; | 103 bool pending_close; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 // Called from UI thread from the owner of this object. | 106 // Called from UI thread from the owner of this object. |
| 107 explicit AudioInputRendererHost( | 107 explicit AudioInputRendererHost( |
| 108 const content::ResourceContext* resource_context); | 108 const content::ResourceContext* resource_context); |
| 109 | 109 |
| 110 // BrowserMessageFilter implementation. | 110 // content::BrowserMessageFilter implementation. |
| 111 virtual void OnChannelClosing() OVERRIDE; | 111 virtual void OnChannelClosing() OVERRIDE; |
| 112 virtual void OnDestruct() const OVERRIDE; | 112 virtual void OnDestruct() const OVERRIDE; |
| 113 virtual bool OnMessageReceived(const IPC::Message& message, | 113 virtual bool OnMessageReceived(const IPC::Message& message, |
| 114 bool* message_was_ok) OVERRIDE; | 114 bool* message_was_ok) OVERRIDE; |
| 115 | 115 |
| 116 // AudioInputController::EventHandler implementation. | 116 // AudioInputController::EventHandler implementation. |
| 117 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE; | 117 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE; |
| 118 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE; | 118 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE; |
| 119 virtual void OnError(media::AudioInputController* controller, | 119 virtual void OnError(media::AudioInputController* controller, |
| 120 int error_code) OVERRIDE; | 120 int error_code) OVERRIDE; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 AudioEntryMap audio_entries_; | 215 AudioEntryMap audio_entries_; |
| 216 | 216 |
| 217 // A map of session IDs to audio session sources. | 217 // A map of session IDs to audio session sources. |
| 218 typedef std::map<int, int> SessionEntryMap; | 218 typedef std::map<int, int> SessionEntryMap; |
| 219 SessionEntryMap session_entries_; | 219 SessionEntryMap session_entries_; |
| 220 | 220 |
| 221 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); | 221 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ | 224 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ |
| OLD | NEW |