From 982371ec6aebb5459d2465036aa86dbb816e5640 Mon Sep 17 00:00:00 2001 From: "hclam@chromium.org" Date: Mon, 16 Feb 2009 21:52:32 +0000 Subject: IPC messages definitions for audio related requests from renderer to browser. Defined IPC messages that maps to methods exposed by AudioRendererHost that serves audio related requests. Also with handlers in ResourceMessageFilter for the newly added IPC messages. Review URL: http://codereview.chromium.org/21340 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9864 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/DEPS | 1 + chrome/common/render_messages.h | 87 ++++++++++++++++++++++++++++++++ chrome/common/render_messages_internal.h | 29 +++++++++++ 3 files changed, 117 insertions(+) (limited to 'chrome/common') 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 { } }; +// Traits for AudioManager::Format. +template <> +struct ParamTraits { + 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(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 { + 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"("); + 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) -- cgit v1.1