sl4f_lib/media_session/
commands.rs1use crate::media_session::facade::MediaSessionFacade;
6use crate::server::Facade;
7use anyhow::{bail, Error};
8use async_trait::async_trait;
9use serde_json::{to_value, Value};
10
11#[async_trait(?Send)]
12impl Facade for MediaSessionFacade {
14 async fn handle_request(&self, method: String, _args: Value) -> Result<Value, Error> {
15 match method.as_ref() {
16 "WatchActiveSessionStatus" => {
17 let result = self.watch_active_session_status().await?;
18 Ok(to_value(result)?)
19 }
20 "PublishMockPlayer" => {
21 let result = self.publish_mock_player().await?;
22 Ok(to_value(result)?)
23 }
24 "StopMockPlayer" => {
25 let result = self.stop_mock_player().await?;
26 Ok(to_value(result)?)
27 }
28 "ListReceivedRequests" => {
29 let result = self.list_received_requests().await?;
30 Ok(to_value(result)?)
31 }
32 _ => bail!("Invalid MediaSessionFacade FIDL method: {:?}", method),
33 }
34 }
35}