web_codecs/video/
color.rs

1#[derive(Debug, Clone)]
2pub struct VideoColorSpaceConfig {
3	inner: web_sys::VideoColorSpaceInit,
4}
5
6impl Default for VideoColorSpaceConfig {
7	fn default() -> Self {
8		Self::new()
9	}
10}
11
12impl VideoColorSpaceConfig {
13	pub fn new() -> Self {
14		Self {
15			inner: web_sys::VideoColorSpaceInit::new(),
16		}
17	}
18
19	pub fn full_range(self, enabled: bool) -> Self {
20		self.inner.set_full_range(enabled);
21		self
22	}
23
24	pub fn matrix(self, matrix: VideoMatrixCoefficients) -> Self {
25		self.inner.set_matrix(matrix);
26		self
27	}
28
29	pub fn primaries(self, primaries: VideoColorPrimaries) -> Self {
30		self.inner.set_primaries(primaries);
31		self
32	}
33
34	pub fn transfer(self, transfer: VideoTransferCharacteristics) -> Self {
35		self.inner.set_transfer(transfer);
36		self
37	}
38}
39
40impl From<&VideoColorSpaceConfig> for web_sys::VideoColorSpaceInit {
41	fn from(this: &VideoColorSpaceConfig) -> Self {
42		this.inner.clone()
43	}
44}
45
46impl From<web_sys::VideoColorSpaceInit> for VideoColorSpaceConfig {
47	fn from(inner: web_sys::VideoColorSpaceInit) -> Self {
48		Self { inner }
49	}
50}
51
52pub type VideoMatrixCoefficients = web_sys::VideoMatrixCoefficients;
53pub type VideoColorPrimaries = web_sys::VideoColorPrimaries;
54pub type VideoTransferCharacteristics = web_sys::VideoTransferCharacteristics;