1 //! Constants identifying the properties of a [`MediaStreamTrack`][media_stream_track] object, 2 //! as defined in the ["Media Capture and Streams"][media_track_supported_constraints] spec. 3 //! 4 //! [media_stream_track]: https://www.w3.org/TR/mediacapture-streams/#mediastreamtrack 5 //! [media_track_supported_constraints]: https://www.w3.org/TR/mediacapture-streams/#dom-mediatracksupportedconstraints 6 7 /// Properties that apply to all device types. 8 pub mod common { 9 /// Names of common properties. 10 pub mod name { 11 /// The identifier of the device generating the content of the track, 12 /// as defined in the [spec][spec]. 13 /// 14 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-deviceid 15 pub const DEVICE_ID: &str = "deviceId"; 16 17 /// The document-unique group identifier for the device generating the content 18 /// of the track, as defined in the [spec][spec]. 19 /// 20 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-groupid 21 pub const GROUP_ID: &str = "groupId"; 22 } 23 24 /// Names of common properties. 25 pub fn names() -> Vec<&'static str> { 26 use self::name::*; 27 28 vec![DEVICE_ID, GROUP_ID] 29 } 30 } 31 32 /// Properties that apply only to audio device types. 33 pub mod audio_only { 34 /// Names of audio-only properties. 35 pub mod name { 36 /// Automatic gain control is often desirable on the input signal recorded 37 /// by the microphone, as defined in the [spec][spec]. 38 /// 39 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-autogaincontrol 40 pub const AUTO_GAIN_CONTROL: &str = "autoGainControl"; 41 42 /// The number of independent channels of sound that the audio data contains, 43 /// i.e. the number of audio samples per sample frame, as defined in the [spec][spec]. 44 /// 45 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-channelcount 46 pub const CHANNEL_COUNT: &str = "channelCount"; 47 48 /// When one or more audio streams is being played in the processes of 49 /// various microphones, it is often desirable to attempt to remove 50 /// all the sound being played from the input signals recorded by the microphones. 51 /// This is referred to as echo cancellation, as defined in the [spec][spec]. 52 /// 53 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-echocancellation 54 pub const ECHO_CANCELLATION: &str = "echoCancellation"; 55 56 /// The latency or latency range, in seconds, as defined in the [spec][spec]. 57 /// 58 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-latency 59 pub const LATENCY: &str = "latency"; 60 61 /// Noise suppression is often desirable on the input signal recorded by the microphone, 62 /// as defined in the [spec][spec]. 63 /// 64 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-noisesuppression 65 pub const NOISE_SUPPRESSION: &str = "noiseSuppression"; 66 67 /// The sample rate in samples per second for the audio data, as defined in the [spec][spec]. 68 /// 69 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-samplerate 70 pub const SAMPLE_RATE: &str = "sampleRate"; 71 72 /// The linear sample size in bits. This constraint can only 73 /// be satisfied for audio devices that produce linear samples, as defined in the [spec][spec]. 74 /// 75 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-samplesize 76 pub const SAMPLE_SIZE: &str = "sampleSize"; 77 } 78 79 /// Names of all audio-only properties. 80 pub fn names() -> Vec<&'static str> { 81 use self::name::*; 82 83 vec![ 84 AUTO_GAIN_CONTROL, 85 CHANNEL_COUNT, 86 ECHO_CANCELLATION, 87 LATENCY, 88 NOISE_SUPPRESSION, 89 SAMPLE_RATE, 90 SAMPLE_SIZE, 91 ] 92 } 93 } 94 95 /// Properties that apply only to video device types. 96 pub mod video_only { 97 /// Names of audio-only properties. 98 pub mod name { 99 /// The exact aspect ratio (width in pixels divided by height in pixels, 100 /// represented as a double rounded to the tenth decimal place), 101 /// as defined in the [spec][spec]. 102 /// 103 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-aspectratio 104 pub const ASPECT_RATIO: &str = "aspectRatio"; 105 106 /// The directions that the camera can face, as seen from the user's perspective, 107 /// as defined in the [spec][spec]. 108 /// 109 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-facingmode 110 pub const FACING_MODE: &str = "facingMode"; 111 112 /// The exact frame rate (frames per second) or frame rate range, 113 /// as defined in the [spec][spec]. 114 /// 115 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-framerate 116 pub const FRAME_RATE: &str = "frameRate"; 117 118 /// The height or height range, in pixels, as defined in the [spec][spec]. 119 /// 120 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-height 121 pub const HEIGHT: &str = "height"; 122 123 /// The width or width range, in pixels, as defined in the [spec][spec]. 124 /// 125 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-width 126 pub const WIDTH: &str = "width"; 127 128 /// The means by which the resolution can be derived by the client, as defined in the [spec][spec]. 129 /// 130 /// In other words, whether the client is allowed to use cropping and downscaling on the camera output. 131 /// 132 /// [spec]: https://www.w3.org/TR/mediacapture-streams/#dfn-resizemode 133 pub const RESIZE_MODE: &str = "resizeMode"; 134 } 135 136 /// Names of all video-only properties. 137 pub fn names() -> Vec<&'static str> { 138 use self::name::*; 139 vec![ 140 ASPECT_RATIO, 141 FACING_MODE, 142 FRAME_RATE, 143 HEIGHT, 144 WIDTH, 145 RESIZE_MODE, 146 ] 147 } 148 } 149 150 /// Names of all properties. 151 pub mod name { 152 pub use super::audio_only::name::*; 153 pub use super::common::name::*; 154 pub use super::video_only::name::*; 155 } 156 157 /// Names of all properties. 158 pub fn names() -> Vec<&'static str> { 159 let mut all = vec![]; 160 all.append(&mut self::common::names()); 161 all.append(&mut self::audio_only::names()); 162 all.append(&mut self::video_only::names()); 163 all 164 } 165