Commit 4e40c737 authored by Noah Rose Ledesma's avatar Noah Rose Ledesma Committed by Commit Bot

GMC: Media Session Controller set audio sink IPC

Added media player delegate messages to allow the
|MediaSessionController| to send set audio sink id messages to the renderer.

Bug: 1105169
Change-Id: Idb382bcf6c0457aeeb870cb9475483045acaaf90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2295808
Commit-Queue: Noah Rose Ledesma <noahrose@google.com>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794773}
parent e331af1b
......@@ -4,6 +4,7 @@
#include "content/browser/media/session/media_session_controller.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/media/media_devices_util.h"
#include "content/browser/media/media_web_contents_observer.h"
#include "content/browser/media/session/media_session_impl.h"
......@@ -93,7 +94,23 @@ void MediaSessionController::OnExitPictureInPicture(int player_id) {
void MediaSessionController::OnSetAudioSinkId(
int player_id,
const std::string& raw_device_id) {}
const std::string& raw_device_id) {
// The sink id needs to be hashed before it is suitable for use in the
// renderer process.
auto salt_and_origin = content::GetMediaDeviceSaltAndOrigin(
id_.render_frame_host->GetProcess()->GetID(),
id_.render_frame_host->GetRoutingID());
std::string hashed_sink_id = GetHMACForMediaDeviceID(
salt_and_origin.device_id_salt, salt_and_origin.origin, raw_device_id);
// Grant the renderer the permission to use this audio output device.
static_cast<RenderFrameHostImpl*>(id_.render_frame_host)
->SetAudioOutputDeviceIdForGlobalMediaControls(hashed_sink_id);
id_.render_frame_host->Send(new MediaPlayerDelegateMsg_SetAudioSinkId(
id_.render_frame_host->GetRoutingID(), id_.delegate_id, hashed_sink_id));
}
RenderFrameHost* MediaSessionController::render_frame_host() const {
return id_.render_frame_host;
......
......@@ -74,6 +74,10 @@ IPC_MESSAGE_ROUTED1(MediaPlayerDelegateMsg_EnterPictureInPicture,
IPC_MESSAGE_ROUTED1(MediaPlayerDelegateMsg_ExitPictureInPicture,
int /* delegate_id, distinguishes instances */)
IPC_MESSAGE_ROUTED2(MediaPlayerDelegateMsg_SetAudioSinkId,
int /* delegate_id, distinguishes instances */,
std::string /* sink_id */)
IPC_MESSAGE_ROUTED2(MediaPlayerDelegateMsg_NotifyPowerExperimentState,
int /* delegate_id, distinguishes instances */,
bool /* is experiment starting (true) or stopping? */)
......
......@@ -268,6 +268,8 @@ bool RendererWebMediaPlayerDelegate::OnMessageReceived(
OnMediaDelegateEnterPictureInPicture)
IPC_MESSAGE_HANDLER(MediaPlayerDelegateMsg_ExitPictureInPicture,
OnMediaDelegateExitPictureInPicture)
IPC_MESSAGE_HANDLER(MediaPlayerDelegateMsg_SetAudioSinkId,
OnMediaDelegateSetAudioSink)
IPC_MESSAGE_HANDLER(MediaPlayerDelegateMsg_NotifyPowerExperimentState,
OnMediaDelegatePowerExperimentState)
IPC_MESSAGE_UNHANDLED(return false)
......@@ -397,6 +399,10 @@ void RendererWebMediaPlayerDelegate::OnMediaDelegateExitPictureInPicture(
observer->OnExitPictureInPicture();
}
void RendererWebMediaPlayerDelegate::OnMediaDelegateSetAudioSink(
int player_id,
std::string sink_id) {}
void RendererWebMediaPlayerDelegate::OnMediaDelegatePowerExperimentState(
int player_id,
bool state) {
......
......@@ -105,6 +105,7 @@ class CONTENT_EXPORT RendererWebMediaPlayerDelegate
void OnMediaDelegateBecamePersistentVideo(int player_id, bool value);
void OnMediaDelegateEnterPictureInPicture(int player_id);
void OnMediaDelegateExitPictureInPicture(int player_id);
void OnMediaDelegateSetAudioSink(int player_id, std::string sink_id);
void OnMediaDelegatePowerExperimentState(int player_id, bool state);
// Schedules UpdateTask() to run soon.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment