Skip to main content

browser_protocol/media/
mod.rs

1//! This domain allows detailed inspection of media elements.
2
3use serde::{Serialize, Deserialize};
4use serde_json::Value as JsonValue;
5
6/// Players will get an ID that is unique within the agent context.
7
8pub type PlayerId = String;
9
10
11pub type Timestamp = f64;
12
13/// Have one type per entry in MediaLogRecord::Type
14/// Corresponds to kMessage
15
16#[derive(Debug, Clone, Serialize, Deserialize, Default)]
17#[serde(rename_all = "camelCase")]
18pub struct PlayerMessage {
19    /// Keep in sync with MediaLogMessageLevel
20    /// We are currently keeping the message level 'error' separate from the
21    /// PlayerError type because right now they represent different things,
22    /// this one being a DVLOG(ERROR) style log message that gets printed
23    /// based on what log level is selected in the UI, and the other is a
24    /// representation of a media::PipelineStatus object. Soon however we're
25    /// going to be moving away from using PipelineStatus for errors and
26    /// introducing a new error type which should hopefully let us integrate
27    /// the error log level into the PlayerError type.
28
29    pub level: String,
30
31    pub message: String,
32}
33
34/// Corresponds to kMediaPropertyChange
35
36#[derive(Debug, Clone, Serialize, Deserialize, Default)]
37#[serde(rename_all = "camelCase")]
38pub struct PlayerProperty {
39
40    pub name: String,
41
42    pub value: String,
43}
44
45/// Corresponds to kMediaEventTriggered
46
47#[derive(Debug, Clone, Serialize, Deserialize, Default)]
48#[serde(rename_all = "camelCase")]
49pub struct PlayerEvent {
50
51    pub timestamp: Timestamp,
52
53    pub value: String,
54}
55
56/// Represents logged source line numbers reported in an error.
57/// NOTE: file and line are from chromium c++ implementation code, not js.
58
59#[derive(Debug, Clone, Serialize, Deserialize, Default)]
60#[serde(rename_all = "camelCase")]
61pub struct PlayerErrorSourceLocation {
62
63    pub file: String,
64
65    pub line: i64,
66}
67
68/// Corresponds to kMediaError
69
70#[derive(Debug, Clone, Serialize, Deserialize, Default)]
71#[serde(rename_all = "camelCase")]
72pub struct PlayerError {
73
74    pub errorType: String,
75    /// Code is the numeric enum entry for a specific set of error codes, such
76    /// as PipelineStatusCodes in media/base/pipeline_status.h
77
78    pub code: i64,
79    /// A trace of where this error was caused / where it passed through.
80
81    pub stack: Vec<PlayerErrorSourceLocation>,
82    /// Errors potentially have a root cause error, ie, a DecoderError might be
83    /// caused by an WindowsError
84
85    pub cause: Vec<PlayerError>,
86    /// Extra data attached to an error, such as an HRESULT, Video Codec, etc.
87
88    pub data: serde_json::Map<String, JsonValue>,
89}
90
91
92#[derive(Debug, Clone, Serialize, Deserialize, Default)]
93#[serde(rename_all = "camelCase")]
94pub struct Player {
95
96    pub playerId: PlayerId,
97
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub domNodeId: Option<crate::dom::BackendNodeId>,
100}