Skip to main content

cdp_protocol/
web_audio.rs

1// Auto-generated from Chrome at version 146.0.7680.165 domain: WebAudio
2#![allow(dead_code)]
3#[allow(unused_imports)]
4use super::types::*;
5#[allow(unused_imports)]
6use derive_builder::Builder;
7#[allow(unused_imports)]
8use serde::{Deserialize, Serialize};
9#[allow(unused_imports)]
10use serde_json::Value as Json;
11pub type GraphObjectId = String;
12pub type NodeType = String;
13pub type ParamType = String;
14#[allow(deprecated)]
15#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
16pub enum ContextType {
17    #[serde(rename = "realtime")]
18    Realtime,
19    #[serde(rename = "offline")]
20    Offline,
21}
22#[allow(deprecated)]
23#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
24pub enum ContextState {
25    #[serde(rename = "suspended")]
26    Suspended,
27    #[serde(rename = "running")]
28    Running,
29    #[serde(rename = "closed")]
30    Closed,
31    #[serde(rename = "interrupted")]
32    Interrupted,
33}
34#[allow(deprecated)]
35#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
36pub enum ChannelCountMode {
37    #[serde(rename = "clamped-max")]
38    ClampedMax,
39    #[serde(rename = "explicit")]
40    Explicit,
41    #[serde(rename = "max")]
42    Max,
43}
44#[allow(deprecated)]
45#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
46pub enum ChannelInterpretation {
47    #[serde(rename = "discrete")]
48    Discrete,
49    #[serde(rename = "speakers")]
50    Speakers,
51}
52#[allow(deprecated)]
53#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
54pub enum AutomationRate {
55    #[serde(rename = "a-rate")]
56    ARate,
57    #[serde(rename = "k-rate")]
58    KRate,
59}
60#[allow(deprecated)]
61#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
62#[builder(setter(into, strip_option))]
63#[serde(rename_all = "camelCase")]
64#[doc = "Fields in AudioContext that change in real-time."]
65pub struct ContextRealtimeData {
66    #[serde(default)]
67    #[doc = "The current context time in second in BaseAudioContext."]
68    pub current_time: JsFloat,
69    #[serde(default)]
70    #[doc = "The time spent on rendering graph divided by render quantum duration,\n and multiplied by 100. 100 means the audio renderer reached the full\n capacity and glitch may occur."]
71    pub render_capacity: JsFloat,
72    #[serde(default)]
73    #[doc = "A running mean of callback interval."]
74    pub callback_interval_mean: JsFloat,
75    #[serde(default)]
76    #[doc = "A running variance of callback interval."]
77    pub callback_interval_variance: JsFloat,
78}
79#[allow(deprecated)]
80#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
81#[builder(setter(into, strip_option))]
82#[serde(rename_all = "camelCase")]
83#[doc = "Protocol object for BaseAudioContext"]
84pub struct BaseAudioContext {
85    pub context_id: GraphObjectId,
86    pub context_type: ContextType,
87    pub context_state: ContextState,
88    #[builder(default)]
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub realtime_data: Option<ContextRealtimeData>,
91    #[serde(default)]
92    #[doc = "Platform-dependent callback buffer size."]
93    pub callback_buffer_size: JsFloat,
94    #[serde(default)]
95    #[doc = "Number of output channels supported by audio hardware in use."]
96    pub max_output_channel_count: JsFloat,
97    #[serde(default)]
98    #[doc = "Context sample rate."]
99    pub sample_rate: JsFloat,
100}
101#[allow(deprecated)]
102#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
103#[builder(setter(into, strip_option))]
104#[serde(rename_all = "camelCase")]
105#[doc = "Protocol object for AudioListener"]
106pub struct AudioListener {
107    pub listener_id: GraphObjectId,
108    pub context_id: GraphObjectId,
109}
110#[allow(deprecated)]
111#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
112#[builder(setter(into, strip_option))]
113#[serde(rename_all = "camelCase")]
114#[doc = "Protocol object for AudioNode"]
115pub struct AudioNode {
116    pub node_id: GraphObjectId,
117    pub context_id: GraphObjectId,
118    pub node_type: NodeType,
119    #[serde(default)]
120    pub number_of_inputs: JsFloat,
121    #[serde(default)]
122    pub number_of_outputs: JsFloat,
123    #[serde(default)]
124    pub channel_count: JsFloat,
125    pub channel_count_mode: ChannelCountMode,
126    pub channel_interpretation: ChannelInterpretation,
127}
128#[allow(deprecated)]
129#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
130#[builder(setter(into, strip_option))]
131#[serde(rename_all = "camelCase")]
132#[doc = "Protocol object for AudioParam"]
133pub struct AudioParam {
134    pub param_id: GraphObjectId,
135    pub node_id: GraphObjectId,
136    pub context_id: GraphObjectId,
137    pub param_type: ParamType,
138    pub rate: AutomationRate,
139    #[serde(default)]
140    pub default_value: JsFloat,
141    #[serde(default)]
142    pub min_value: JsFloat,
143    #[serde(default)]
144    pub max_value: JsFloat,
145}
146#[allow(deprecated)]
147#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
148pub struct Enable(pub Option<Json>);
149#[allow(deprecated)]
150#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
151pub struct Disable(pub Option<Json>);
152#[allow(deprecated)]
153#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
154#[builder(setter(into, strip_option))]
155#[serde(rename_all = "camelCase")]
156#[doc = "Fetch the realtime data from the registered contexts."]
157pub struct GetRealtimeData {
158    pub context_id: GraphObjectId,
159}
160#[allow(deprecated)]
161#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
162#[doc = "Enables the WebAudio domain and starts sending context lifetime events."]
163pub struct EnableReturnObject(pub Option<Json>);
164#[allow(deprecated)]
165#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
166#[doc = "Disables the WebAudio domain."]
167pub struct DisableReturnObject(pub Option<Json>);
168#[allow(deprecated)]
169#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
170#[serde(rename_all = "camelCase")]
171#[doc = "Fetch the realtime data from the registered contexts."]
172pub struct GetRealtimeDataReturnObject {
173    pub realtime_data: ContextRealtimeData,
174}
175#[allow(deprecated)]
176impl Method for Enable {
177    const NAME: &'static str = "WebAudio.enable";
178    type ReturnObject = EnableReturnObject;
179}
180#[allow(deprecated)]
181impl Method for Disable {
182    const NAME: &'static str = "WebAudio.disable";
183    type ReturnObject = DisableReturnObject;
184}
185#[allow(deprecated)]
186impl Method for GetRealtimeData {
187    const NAME: &'static str = "WebAudio.getRealtimeData";
188    type ReturnObject = GetRealtimeDataReturnObject;
189}
190#[allow(dead_code)]
191pub mod events {
192    #[allow(unused_imports)]
193    use super::super::types::*;
194    #[allow(unused_imports)]
195    use derive_builder::Builder;
196    #[allow(unused_imports)]
197    use serde::{Deserialize, Serialize};
198    #[allow(unused_imports)]
199    use serde_json::Value as Json;
200    #[allow(deprecated)]
201    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
202    pub struct ContextCreatedEvent {
203        pub params: ContextCreatedEventParams,
204    }
205    #[allow(deprecated)]
206    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
207    #[serde(rename_all = "camelCase")]
208    pub struct ContextCreatedEventParams {
209        pub context: super::BaseAudioContext,
210    }
211    #[allow(deprecated)]
212    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
213    pub struct ContextWillBeDestroyedEvent {
214        pub params: ContextWillBeDestroyedEventParams,
215    }
216    #[allow(deprecated)]
217    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
218    #[serde(rename_all = "camelCase")]
219    pub struct ContextWillBeDestroyedEventParams {
220        pub context_id: super::GraphObjectId,
221    }
222    #[allow(deprecated)]
223    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
224    pub struct ContextChangedEvent {
225        pub params: ContextChangedEventParams,
226    }
227    #[allow(deprecated)]
228    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
229    #[serde(rename_all = "camelCase")]
230    pub struct ContextChangedEventParams {
231        pub context: super::BaseAudioContext,
232    }
233    #[allow(deprecated)]
234    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
235    pub struct AudioListenerCreatedEvent {
236        pub params: AudioListenerCreatedEventParams,
237    }
238    #[allow(deprecated)]
239    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
240    #[serde(rename_all = "camelCase")]
241    pub struct AudioListenerCreatedEventParams {
242        pub listener: super::AudioListener,
243    }
244    #[allow(deprecated)]
245    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
246    pub struct AudioListenerWillBeDestroyedEvent {
247        pub params: AudioListenerWillBeDestroyedEventParams,
248    }
249    #[allow(deprecated)]
250    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
251    #[serde(rename_all = "camelCase")]
252    pub struct AudioListenerWillBeDestroyedEventParams {
253        pub context_id: super::GraphObjectId,
254        pub listener_id: super::GraphObjectId,
255    }
256    #[allow(deprecated)]
257    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
258    pub struct AudioNodeCreatedEvent {
259        pub params: AudioNodeCreatedEventParams,
260    }
261    #[allow(deprecated)]
262    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
263    #[serde(rename_all = "camelCase")]
264    pub struct AudioNodeCreatedEventParams {
265        pub node: super::AudioNode,
266    }
267    #[allow(deprecated)]
268    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
269    pub struct AudioNodeWillBeDestroyedEvent {
270        pub params: AudioNodeWillBeDestroyedEventParams,
271    }
272    #[allow(deprecated)]
273    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
274    #[serde(rename_all = "camelCase")]
275    pub struct AudioNodeWillBeDestroyedEventParams {
276        pub context_id: super::GraphObjectId,
277        pub node_id: super::GraphObjectId,
278    }
279    #[allow(deprecated)]
280    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
281    pub struct AudioParamCreatedEvent {
282        pub params: AudioParamCreatedEventParams,
283    }
284    #[allow(deprecated)]
285    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
286    #[serde(rename_all = "camelCase")]
287    pub struct AudioParamCreatedEventParams {
288        pub param: super::AudioParam,
289    }
290    #[allow(deprecated)]
291    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
292    pub struct AudioParamWillBeDestroyedEvent {
293        pub params: AudioParamWillBeDestroyedEventParams,
294    }
295    #[allow(deprecated)]
296    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
297    #[serde(rename_all = "camelCase")]
298    pub struct AudioParamWillBeDestroyedEventParams {
299        pub context_id: super::GraphObjectId,
300        pub node_id: super::GraphObjectId,
301        pub param_id: super::GraphObjectId,
302    }
303    #[allow(deprecated)]
304    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
305    pub struct NodesConnectedEvent {
306        pub params: NodesConnectedEventParams,
307    }
308    #[allow(deprecated)]
309    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
310    #[serde(rename_all = "camelCase")]
311    pub struct NodesConnectedEventParams {
312        pub context_id: super::GraphObjectId,
313        pub source_id: super::GraphObjectId,
314        pub destination_id: super::GraphObjectId,
315        #[builder(default)]
316        #[serde(skip_serializing_if = "Option::is_none")]
317        #[serde(default)]
318        pub source_output_index: Option<JsFloat>,
319        #[builder(default)]
320        #[serde(skip_serializing_if = "Option::is_none")]
321        #[serde(default)]
322        pub destination_input_index: Option<JsFloat>,
323    }
324    #[allow(deprecated)]
325    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
326    pub struct NodesDisconnectedEvent {
327        pub params: NodesDisconnectedEventParams,
328    }
329    #[allow(deprecated)]
330    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
331    #[serde(rename_all = "camelCase")]
332    pub struct NodesDisconnectedEventParams {
333        pub context_id: super::GraphObjectId,
334        pub source_id: super::GraphObjectId,
335        pub destination_id: super::GraphObjectId,
336        #[builder(default)]
337        #[serde(skip_serializing_if = "Option::is_none")]
338        #[serde(default)]
339        pub source_output_index: Option<JsFloat>,
340        #[builder(default)]
341        #[serde(skip_serializing_if = "Option::is_none")]
342        #[serde(default)]
343        pub destination_input_index: Option<JsFloat>,
344    }
345    #[allow(deprecated)]
346    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
347    pub struct NodeParamConnectedEvent {
348        pub params: NodeParamConnectedEventParams,
349    }
350    #[allow(deprecated)]
351    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
352    #[serde(rename_all = "camelCase")]
353    pub struct NodeParamConnectedEventParams {
354        pub context_id: super::GraphObjectId,
355        pub source_id: super::GraphObjectId,
356        pub destination_id: super::GraphObjectId,
357        #[builder(default)]
358        #[serde(skip_serializing_if = "Option::is_none")]
359        #[serde(default)]
360        pub source_output_index: Option<JsFloat>,
361    }
362    #[allow(deprecated)]
363    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
364    pub struct NodeParamDisconnectedEvent {
365        pub params: NodeParamDisconnectedEventParams,
366    }
367    #[allow(deprecated)]
368    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
369    #[serde(rename_all = "camelCase")]
370    pub struct NodeParamDisconnectedEventParams {
371        pub context_id: super::GraphObjectId,
372        pub source_id: super::GraphObjectId,
373        pub destination_id: super::GraphObjectId,
374        #[builder(default)]
375        #[serde(skip_serializing_if = "Option::is_none")]
376        #[serde(default)]
377        pub source_output_index: Option<JsFloat>,
378    }
379}