Skip to content
Permalink
Browse files

Add aspect/frameRate/sampleRate parameters

  • Loading branch information...
Manishearth committed Feb 13, 2019
1 parent dd7b69b commit caa05948bf250944b259a5a95a8e6ef1db6a947b
@@ -2379,6 +2379,7 @@ def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config):
'crate::dom::bindings::conversions::root_from_handlevalue',
'std::ptr::NonNull',
'crate::dom::bindings::mozmap::MozMap',
'crate::dom::bindings::num::Finite',
'crate::dom::bindings::root::DomRoot',
'crate::dom::bindings::str::ByteString',
'crate::dom::bindings::str::DOMString',
@@ -6,6 +6,7 @@ use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::MediaStreamCon
use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::{self, MediaDevicesMethods};
use crate::dom::bindings::codegen::UnionTypes::BooleanOrMediaTrackConstraints;
use crate::dom::bindings::codegen::UnionTypes::ClampedUnsignedLongOrConstrainULongRange as ConstrainULong;
use crate::dom::bindings::codegen::UnionTypes::DoubleOrConstrainDoubleRange as ConstrainDouble;
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::root::DomRoot;
@@ -69,7 +70,9 @@ fn convert_constraints(js: &BooleanOrMediaTrackConstraints) -> Option<MediaTrack
Some(MediaTrackConstraintSet {
height: convert_culong(&c.parent.height),
width: convert_culong(&c.parent.width),
..Default::default()
aspect: convert_cdouble(&c.parent.aspectRatio),
frame_rate: convert_cdouble(&c.parent.frameRate),
sample_rate: convert_culong(&c.parent.sampleRate),
})
},
}
@@ -94,3 +97,23 @@ fn convert_culong(js: &ConstrainULong) -> Option<Constrain<u32>> {
},
}
}

fn convert_cdouble(js: &ConstrainDouble) -> Option<Constrain<f64>> {
match js {
ConstrainDouble::Double(val) => Some(Constrain::Value(**val)),
ConstrainDouble::ConstrainDoubleRange(ref range) => {
if range.parent.min.is_some() || range.parent.max.is_some() {
Some(Constrain::Range(ConstrainRange {
min: range.parent.min.map(|x| *x),
max: range.parent.max.map(|x| *x),
ideal: range.ideal.map(|x| *x),
}))
} else if let Some(exact) = range.exact {
Some(Constrain::Value(*exact))
} else {
// the unspecified case is treated as all three being none
None
}
},
}
}
@@ -29,15 +29,15 @@ dictionary MediaStreamConstraints {
// (boolean or MediaTrackConstraints) audio = false;
};

// dictionary DoubleRange {
// double max;
// double min;
// };
dictionary DoubleRange {
double max;
double min;
};

// dictionary ConstrainDoubleRange : DoubleRange {
// double exact;
// double ideal;
// };
dictionary ConstrainDoubleRange : DoubleRange {
double exact;
double ideal;
};

dictionary ULongRange {
[Clamp] unsigned long max;
@@ -64,19 +64,19 @@ dictionary MediaTrackConstraints : MediaTrackConstraintSet {
};

typedef ([Clamp] unsigned long or ConstrainULongRange) ConstrainULong;
// typedef (double or ConstrainDoubleRange) ConstrainDouble;
typedef (double or ConstrainDoubleRange) ConstrainDouble;
// typedef (boolean or ConstrainBooleanParameters) ConstrainBoolean;
// typedef (DOMString or sequence<DOMString> or ConstrainDOMStringParameters) ConstrainDOMString;

dictionary MediaTrackConstraintSet {
ConstrainULong width;
ConstrainULong height;
// ConstrainDouble aspectRatio;
// ConstrainDouble frameRate;
ConstrainDouble aspectRatio;
ConstrainDouble frameRate;
// ConstrainDOMString facingMode;
// ConstrainDOMString resizeMode;
// ConstrainDouble volume;
// ConstrainULong sampleRate;
ConstrainULong sampleRate;
// ConstrainULong sampleSize;
// ConstrainBoolean echoCancellation;
// ConstrainBoolean autoGainControl;

0 comments on commit caa0594

Please sign in to comment.
You can’t perform that action at this time.