summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc42
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h11
-rw-r--r--chrome/common/DEPS1
-rw-r--r--chrome/common/render_messages.h87
-rw-r--r--chrome/common/render_messages_internal.h29
-rw-r--r--media/audio/audio_output.h8
6 files changed, 175 insertions, 3 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index e7634dc..41f593a 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -226,6 +226,13 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ScriptedPrint,
OnScriptedPrint)
#endif
+ IPC_MESSAGE_HANDLER(ViewHostMsg_CreateAudioStream, OnCreateAudioStream)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_StartAudioStream, OnStartAudioStream)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_CloseAudioStream, OnCloseAudioStream)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_NotifyAudioPacketReady,
+ OnNotifyAudioPacketReady)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_GetAudioVolume, OnGetAudioVolume)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SetAudioVolume, OnSetAudioVolume)
IPC_MESSAGE_UNHANDLED(
handled = false)
IPC_END_MESSAGE_MAP_EX()
@@ -751,3 +758,38 @@ void ResourceMessageFilter::OnDnsPrefetch(
const std::vector<std::string>& hostnames) {
chrome_browser_net::DnsPrefetchList(hostnames);
}
+
+void ResourceMessageFilter::OnCreateAudioStream(
+ const IPC::Message& msg, int stream_id,
+ const ViewHostMsg_Audio_CreateStream& params) {
+ // TODO(hclam): call to AudioRendererHost::CreateStream and send a message to
+ // renderer to notify the result.
+}
+
+void ResourceMessageFilter::OnNotifyAudioPacketReady(
+ const IPC::Message& msg, int stream_id) {
+ // TODO(hclam): delegate to AudioRendererHost and handle this message.
+}
+
+void ResourceMessageFilter::OnStartAudioStream(
+ const IPC::Message& msg, int stream_id) {
+ // TODO(hclam): delegate to AudioRendererHost and handle this message.
+}
+
+
+void ResourceMessageFilter::OnCloseAudioStream(
+ const IPC::Message& msg, int stream_id) {
+ // TODO(hclam): delegate to AudioRendererHost and handle this message.
+}
+
+void ResourceMessageFilter::OnGetAudioVolume(
+ const IPC::Message& msg, int stream_id) {
+ // TODO(hclam): delegate to AudioRendererHost and handle this message. Send
+ // a message about the volume.
+}
+
+void ResourceMessageFilter::OnSetAudioVolume(
+ const IPC::Message& msg, int stream_id,
+ double left_channel, double right_channel) {
+ // TODO(hclam): delegate to AudioRendererHost and handle this message.
+}
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 4133353..85ad101 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -31,6 +31,7 @@ class ClipboardService;
class Profile;
class RenderWidgetHelper;
class SpellChecker;
+struct ViewHostMsg_Audio_CreateStream;
struct WebPluginInfo;
namespace printing {
@@ -192,6 +193,16 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
IPC::Message* reply_msg);
#endif
+ // Audio related IPC message handlers.
+ void OnCreateAudioStream(const IPC::Message& msg, int stream_id,
+ const ViewHostMsg_Audio_CreateStream& params);
+ void OnNotifyAudioPacketReady(const IPC::Message& msg, int stream_id);
+ void OnStartAudioStream(const IPC::Message& msg, int stream_id);
+ void OnCloseAudioStream(const IPC::Message& msg, int stream_id);
+ void OnGetAudioVolume(const IPC::Message& msg, int stream_id);
+ void OnSetAudioVolume(const IPC::Message& msg, int stream_id,
+ double left_channel, double right_channel);
+
// We have our own clipboard service because we want to access the clipboard
// on the IO thread instead of forwarding (possibly synchronous) messages to
// the UI thread.
diff --git a/chrome/common/DEPS b/chrome/common/DEPS
index b041492..f4f560b 100644
--- a/chrome/common/DEPS
+++ b/chrome/common/DEPS
@@ -2,6 +2,7 @@ include_rules = [
"+chrome/plugin", # For checking whether we're a plugin process.
"+grit", # For generated headers
"+libxml",
+ "+media/audio",
"+sandbox/src",
"+skia/include",
"+webkit/glue",
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 689918e..c96d787 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -21,6 +21,7 @@
#include "chrome/common/modal_dialog_event.h"
#include "chrome/common/page_transition_types.h"
#include "googleurl/src/gurl.h"
+#include "media/audio/audio_output.h"
#include "net/base/upload_data.h"
#include "net/url_request/url_request_status.h"
#include "webkit/glue/autofill_form.h"
@@ -324,6 +325,23 @@ enum ViewHostMsg_ImeControl {
IME_COMPLETE_COMPOSITION,
};
+// Parameters for creating an audio output stream.
+struct ViewHostMsg_Audio_CreateStream {
+ // Format request for the stream.
+ AudioManager::Format format;
+
+ // Number of channels.
+ int channels;
+
+ // Sampling rate (frequency) of the output stream.
+ int sample_rate;
+
+ // Number of bits per sample;
+ int bits_per_sample;
+
+ // Number of bytes per packet.
+ size_t packet_size;
+};
namespace IPC {
@@ -1587,6 +1605,75 @@ struct ParamTraits<ModalDialogEvent> {
}
};
+// Traits for AudioManager::Format.
+template <>
+struct ParamTraits<AudioManager::Format> {
+ typedef AudioManager::Format param_type;
+ static void Write(Message* m, const param_type& p) {
+ m->WriteInt(p);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ int type;
+ if (!m->ReadInt(iter, &type))
+ return false;
+ *p = static_cast<AudioManager::Format>(type);
+ return true;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ std::wstring format;
+ switch (p) {
+ case AudioManager::AUDIO_PCM_LINEAR:
+ format = L"AUDIO_PCM_LINEAR";
+ break;
+ case AudioManager::AUDIO_PCM_DELTA:
+ format = L"AUDIO_PCM_DELTA";
+ break;
+ case AudioManager::AUDIO_MOCK:
+ format = L"AUDIO_MOCK";
+ break;
+ default:
+ format = L"AUDIO_LAST_FORMAT";
+ break;
+ }
+ LogParam(format, l);
+ }
+};
+
+// Traits for ViewHostMsg_Audio_CreateStream.
+template <>
+struct ParamTraits<ViewHostMsg_Audio_CreateStream> {
+ typedef ViewHostMsg_Audio_CreateStream param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.format);
+ WriteParam(m, p.channels);
+ WriteParam(m, p.sample_rate);
+ WriteParam(m, p.bits_per_sample);
+ WriteParam(m, p.packet_size);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return
+ ReadParam(m, iter, &p->format) &&
+ ReadParam(m, iter, &p->channels) &&
+ ReadParam(m, iter, &p->sample_rate) &&
+ ReadParam(m, iter, &p->bits_per_sample) &&
+ ReadParam(m, iter, &p->packet_size);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"<ViewHostMsg_Audio_CreateStream>(");
+ LogParam(p.format, l);
+ l->append(L", ");
+ LogParam(p.channels, l);
+ l->append(L", ");
+ LogParam(p.sample_rate, l);
+ l->append(L", ");
+ LogParam(p.bits_per_sample, l);
+ l->append(L", ");
+ LogParam(p.packet_size, l);
+ l->append(L")");
+ }
+};
+
+
#if defined(OS_POSIX)
// TODO(port): this shouldn't exist. However, the plugin stuff is really using
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 915f8c7..4310f3f 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1109,4 +1109,33 @@ IPC_BEGIN_MESSAGES(ViewHost)
int /* network error */,
std::string /* proxy list */)
+ // Request that got sent to browser for creating an audio output stream
+ IPC_MESSAGE_ROUTED2(ViewHostMsg_CreateAudioStream,
+ int /* stream_id */,
+ ViewHostMsg_Audio_CreateStream)
+
+ // Tell the browser the audio buffer prepared for stream
+ // (render_view_id, stream_id) is filled and is ready to be consumed.
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_NotifyAudioPacketReady,
+ int /* stream_id */)
+
+ // Start playing the audio stream specified by (render_view_id, stream_id).
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_StartAudioStream,
+ int /* stream_id */)
+
+ // Close an audio stream specified by (render_view_id, stream_id).
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_CloseAudioStream,
+ int /* stream_id */)
+
+ // Get audio volume of the stream specified by (render_view_id, stream_id).
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_GetAudioVolume,
+ int /* stream_id */)
+
+ // Set audio volume of the stream specified by (render_view_id, stream_id).
+ // TODO(hclam): change this to vector if we have channel numbers other than 2.
+ IPC_MESSAGE_ROUTED3(ViewHostMsg_SetAudioVolume,
+ int /* stream_id */,
+ double /* left_channel */,
+ double /* right_channel */)
+
IPC_END_MESSAGES(ViewHost)
diff --git a/media/audio/audio_output.h b/media/audio/audio_output.h
index 7d82500..12ef3d99 100644
--- a/media/audio/audio_output.h
+++ b/media/audio/audio_output.h
@@ -104,9 +104,11 @@ class AudioOutputStream {
class AudioManager {
public:
enum Format {
- AUDIO_PCM_LINEAR, // Pulse code modulation means 'raw' amplitude samples.
- AUDIO_PCM_DELTA, // Delta-encoded pulse code modulation.
- AUDIO_MOCK // Creates a dummy AudioOutputStream object.
+ AUDIO_PCM_LINEAR = 0, // Pulse code modulation means 'raw' amplitude
+ // samples.
+ AUDIO_PCM_DELTA, // Delta-encoded pulse code modulation.
+ AUDIO_MOCK, // Creates a dummy AudioOutputStream object.
+ AUDIO_LAST_FORMAT // Only used for validation of format.
};
// Telephone quality sample rate, mostly for speech-only audio.