Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 397f3e3

Browse files
rijuchromium-wpt-export-bot
authored andcommitted
[Image Capture] Add exposureTime constraint.
This CL adds exposureTime to ImageCapture API. Spec discussion: w3c/mediacapture-image#199 This was added to the spec in w3c/mediacapture-image#200 Layout tests and mock tests are updated to support the same. Support for Android is added. TEST= run the demo in https://codepen.io/rijuB/pen/eKwLXB use slider to change exposureTime. BUG=823316 Intent to Implement and Ship discussions: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/ls3wQSoHOUY Change-Id: Ic3a546d734c02df31cd8ca08ece01f006ae8d906 Reviewed-on: https://chromium-review.googlesource.com/1136439 Reviewed-by: Kinuko Yasuda <[email protected]> Reviewed-by: Miguel Casas <[email protected]> Reviewed-by: Guido Urdaneta <[email protected]> Commit-Queue: Rijubrata Bhaumik <[email protected]> Cr-Commit-Position: refs/heads/master@{#591946}
1 parent 9d63cfd commit 397f3e3

9 files changed

+102
-53
lines changed

mediacapture-image/ImageCapture-MediaTrackSupportedConstraints.html

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
assert_true(supported_constraints.focusMode);
1313
assert_true(supported_constraints.pointsOfInterest);
1414
assert_true(supported_constraints.exposureCompensation);
15+
assert_true(supported_constraints.exposureTime);
1516
assert_true(supported_constraints.colorTemperature);
1617
assert_true(supported_constraints.iso);
1718
assert_true(supported_constraints.brightness);

mediacapture-image/MediaStreamTrack-applyConstraints-getSettings.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
context.fillRect(0, 0, 10, 10);
1818

1919
const constraints = { advanced : [{ whiteBalanceMode : 'single-shot',
20-
exposureMode : 'continuous',
20+
exposureMode : 'manual',
2121
focusMode : 'single-shot',
2222

2323
pointsOfInterest : [{x : 0.1, y : 0.2},
2424
{x : 0.3, y : 0.4}],
2525

2626
exposureCompensation : 133.77,
27+
// in nano-seconds.
28+
exposureTime : 10000,
2729
colorTemperature : 6000,
2830
iso : 120.0,
2931

@@ -70,6 +72,8 @@
7072

7173
assert_equals(constraints.advanced[0].exposureCompensation,
7274
settings.exposureCompensation, 'exposureCompensation');
75+
assert_equals(constraints.advanced[0].exposureTime,
76+
settings.exposureTime, 'exposureTime');
7377
assert_equals(constraints.advanced[0].colorTemperature,
7478
settings.colorTemperature, 'colorTemperature');
7579
assert_equals(constraints.advanced[0].iso, settings.iso, 'iso');
@@ -91,4 +95,4 @@
9195

9296
}, 'exercises an applyConstraints() - getSettings() cycle');
9397

94-
</script>
98+
</script>

mediacapture-image/MediaStreamTrack-applyConstraints-reject.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
const constraintGenerators = [
4545
capabilities => ({ whiteBalanceMode: 'manual' }),
46-
capabilities => ({ exposureMode: 'manual' }),
46+
capabilities => ({ exposureMode: 'none' }),
4747
capabilities => ({ focusMode: 'continuous' }),
4848
capabilities => ({
4949
exposureCompensation: capabilities.exposureCompensation.max + 1

mediacapture-image/MediaStreamTrack-applyConstraints.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
context.fillRect(0, 0, 10, 10);
2020

2121
const constraints = { advanced : [{ whiteBalanceMode : 'single-shot',
22-
exposureMode : 'continuous',
22+
exposureMode : 'manual',
2323
focusMode : 'single-shot',
2424

2525
pointsOfInterest : [{x : 0.1, y : 0.2},
2626
{x : 0.3, y : 0.4}],
2727

2828
exposureCompensation : 133.77,
29+
exposureTime : 10000,
2930
colorTemperature : 6000,
3031
iso : 120.0,
3132

@@ -90,6 +91,9 @@
9091
assert_equals(constraintsDict.exposureCompensation,
9192
theMock.options().exposureCompensation,
9293
'exposureCompensation');
94+
assert_equals(constraintsDict.exposureTime,
95+
theMock.options().exposureTime,
96+
'exposureTime');
9397
assert_equals(constraintsDict.colorTemperature,
9498
theMock.options().colorTemperature, 'colorTemperature');
9599
assert_equals(constraintsDict.iso, theMock.options().iso, 'iso');

mediacapture-image/MediaStreamTrack-getCapabilities.html

+9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@
7878
assert_equals(capabilities.exposureCompensation.step,
7979
mockCapabilities.exposureCompensation.step);
8080

81+
assert_true(capabilities.exposureTime instanceof
82+
MediaSettingsRange);
83+
assert_equals(capabilities.exposureTime.max,
84+
mockCapabilities.exposureTime.max);
85+
assert_equals(capabilities.exposureTime.min,
86+
mockCapabilities.exposureTime.min);
87+
assert_equals(capabilities.exposureTime.step,
88+
mockCapabilities.exposureTime.step);
89+
8190
assert_true(capabilities.colorTemperature instanceof
8291
MediaSettingsRange);
8392
assert_equals(capabilities.colorTemperature.max,

mediacapture-image/MediaStreamTrack-getConstraints-fast.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
<script>
88

99
const constraints = { whiteBalanceMode : "manual",
10-
exposureMode : "continuous",
10+
exposureMode : "manual",
1111
focusMode : "single-shot",
1212

1313
exposureCompensation : 133.77,
14+
exposureTime : 10000, // in nano-seconds.
1415
colorTemperature : 6000,
1516
iso : 120.0,
1617

mediacapture-image/MediaStreamTrack-getSettings.html

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949

5050
assert_equals(settings.exposureCompensation,
5151
mockSettings.exposureCompensation.current);
52+
assert_equals(settings.exposureTime,
53+
mockSettings.exposureTime.current);
5254
assert_equals(settings.colorTemperature,
5355
mockSettings.colorTemperature.current);
5456
assert_equals(settings.iso, mockSettings.iso.current);

resources/chromium/image_capture.mojom.js

+64-47
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
this.torch = false;
168168
this.pointsOfInterest = null;
169169
this.exposureCompensation = null;
170+
this.exposureTime = null;
170171
this.colorTemperature = null;
171172
this.iso = null;
172173
this.brightness = null;
@@ -194,7 +195,7 @@
194195
return err;
195196

196197
var kVersionSizes = [
197-
{version: 0, numBytes: 160}
198+
{version: 0, numBytes: 168}
198199
];
199200
err = messageValidator.validateStructVersion(offset, kVersionSizes);
200201
if (err !== validator.validationError.NONE)
@@ -249,83 +250,89 @@
249250
return err;
250251

251252

252-
// validate PhotoState.colorTemperature
253+
// validate PhotoState.exposureTime
253254
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 56, Range, false);
254255
if (err !== validator.validationError.NONE)
255256
return err;
256257

257258

258-
// validate PhotoState.iso
259+
// validate PhotoState.colorTemperature
259260
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 64, Range, false);
260261
if (err !== validator.validationError.NONE)
261262
return err;
262263

263264

264-
// validate PhotoState.brightness
265+
// validate PhotoState.iso
265266
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 72, Range, false);
266267
if (err !== validator.validationError.NONE)
267268
return err;
268269

269270

270-
// validate PhotoState.contrast
271+
// validate PhotoState.brightness
271272
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 80, Range, false);
272273
if (err !== validator.validationError.NONE)
273274
return err;
274275

275276

276-
// validate PhotoState.saturation
277+
// validate PhotoState.contrast
277278
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 88, Range, false);
278279
if (err !== validator.validationError.NONE)
279280
return err;
280281

281282

282-
// validate PhotoState.sharpness
283+
// validate PhotoState.saturation
283284
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 96, Range, false);
284285
if (err !== validator.validationError.NONE)
285286
return err;
286287

287288

288-
// validate PhotoState.focusDistance
289+
// validate PhotoState.sharpness
289290
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 104, Range, false);
290291
if (err !== validator.validationError.NONE)
291292
return err;
292293

293294

294-
// validate PhotoState.zoom
295+
// validate PhotoState.focusDistance
295296
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 112, Range, false);
296297
if (err !== validator.validationError.NONE)
297298
return err;
298299

299300

301+
// validate PhotoState.zoom
302+
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 120, Range, false);
303+
if (err !== validator.validationError.NONE)
304+
return err;
305+
306+
300307

301308

302309
// validate PhotoState.redEyeReduction
303-
err = messageValidator.validateEnum(offset + codec.kStructHeaderSize + 120, RedEyeReduction);
310+
err = messageValidator.validateEnum(offset + codec.kStructHeaderSize + 128, RedEyeReduction);
304311
if (err !== validator.validationError.NONE)
305312
return err;
306313

307314

308315
// validate PhotoState.height
309-
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 128, Range, false);
316+
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 136, Range, false);
310317
if (err !== validator.validationError.NONE)
311318
return err;
312319

313320

314321
// validate PhotoState.width
315-
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 136, Range, false);
322+
err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 144, Range, false);
316323
if (err !== validator.validationError.NONE)
317324
return err;
318325

319326

320327
// validate PhotoState.fillLightMode
321-
err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 144, 4, new codec.Enum(FillLightMode), false, [0], 0);
328+
err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 152, 4, new codec.Enum(FillLightMode), false, [0], 0);
322329
if (err !== validator.validationError.NONE)
323330
return err;
324331

325332
return validator.validationError.NONE;
326333
};
327334

328-
PhotoState.encodedSize = codec.kStructHeaderSize + 152;
335+
PhotoState.encodedSize = codec.kStructHeaderSize + 160;
329336

330337
PhotoState.decode = function(decoder) {
331338
var packed;
@@ -346,6 +353,7 @@
346353
decoder.skip(1);
347354
val.pointsOfInterest = decoder.decodeArrayPointer(new codec.PointerTo(Point2D));
348355
val.exposureCompensation = decoder.decodeStructPointer(Range);
356+
val.exposureTime = decoder.decodeStructPointer(Range);
349357
val.colorTemperature = decoder.decodeStructPointer(Range);
350358
val.iso = decoder.decodeStructPointer(Range);
351359
val.brightness = decoder.decodeStructPointer(Range);
@@ -384,6 +392,7 @@
384392
encoder.skip(1);
385393
encoder.encodeArrayPointer(new codec.PointerTo(Point2D), val.pointsOfInterest);
386394
encoder.encodeStructPointer(Range, val.exposureCompensation);
395+
encoder.encodeStructPointer(Range, val.exposureTime);
387396
encoder.encodeStructPointer(Range, val.colorTemperature);
388397
encoder.encodeStructPointer(Range, val.iso);
389398
encoder.encodeStructPointer(Range, val.brightness);
@@ -466,6 +475,7 @@
466475
this.hasExposureMode = false;
467476
this.hasFocusMode = false;
468477
this.hasExposureCompensation = false;
478+
this.hasExposureTime = false;
469479
this.hasColorTemperature = false;
470480
this.hasIso = false;
471481
this.hasBrightness = false;
@@ -486,6 +496,7 @@
486496
this.focusMode = 0;
487497
this.pointsOfInterest = null;
488498
this.exposureCompensation = 0;
499+
this.exposureTime = 0;
489500
this.colorTemperature = 0;
490501
this.iso = 0;
491502
this.brightness = 0;
@@ -512,7 +523,7 @@
512523
return err;
513524

514525
var kVersionSizes = [
515-
{version: 0, numBytes: 128}
526+
{version: 0, numBytes: 136}
516527
];
517528
err = messageValidator.validateStructVersion(offset, kVersionSizes);
518529
if (err !== validator.validationError.NONE)
@@ -564,11 +575,13 @@
564575

565576

566577

578+
579+
567580

568581

569582

570583
// validate PhotoSettings.fillLightMode
571-
err = messageValidator.validateEnum(offset + codec.kStructHeaderSize + 96, FillLightMode);
584+
err = messageValidator.validateEnum(offset + codec.kStructHeaderSize + 104, FillLightMode);
572585
if (err !== validator.validationError.NONE)
573586
return err;
574587

@@ -581,7 +594,7 @@
581594
return validator.validationError.NONE;
582595
};
583596

584-
PhotoSettings.encodedSize = codec.kStructHeaderSize + 120;
597+
PhotoSettings.encodedSize = codec.kStructHeaderSize + 128;
585598

586599
PhotoSettings.decode = function(decoder) {
587600
var packed;
@@ -593,29 +606,31 @@
593606
val.hasExposureMode = (packed >> 1) & 1 ? true : false;
594607
val.hasFocusMode = (packed >> 2) & 1 ? true : false;
595608
val.hasExposureCompensation = (packed >> 3) & 1 ? true : false;
596-
val.hasColorTemperature = (packed >> 4) & 1 ? true : false;
597-
val.hasIso = (packed >> 5) & 1 ? true : false;
598-
val.hasBrightness = (packed >> 6) & 1 ? true : false;
599-
val.hasContrast = (packed >> 7) & 1 ? true : false;
609+
val.hasExposureTime = (packed >> 4) & 1 ? true : false;
610+
val.hasColorTemperature = (packed >> 5) & 1 ? true : false;
611+
val.hasIso = (packed >> 6) & 1 ? true : false;
612+
val.hasBrightness = (packed >> 7) & 1 ? true : false;
600613
packed = decoder.readUint8();
601-
val.hasSaturation = (packed >> 0) & 1 ? true : false;
602-
val.hasSharpness = (packed >> 1) & 1 ? true : false;
603-
val.hasFocusDistance = (packed >> 2) & 1 ? true : false;
604-
val.hasZoom = (packed >> 3) & 1 ? true : false;
605-
val.hasTorch = (packed >> 4) & 1 ? true : false;
606-
val.torch = (packed >> 5) & 1 ? true : false;
607-
val.hasFillLightMode = (packed >> 6) & 1 ? true : false;
608-
val.hasWidth = (packed >> 7) & 1 ? true : false;
614+
val.hasContrast = (packed >> 0) & 1 ? true : false;
615+
val.hasSaturation = (packed >> 1) & 1 ? true : false;
616+
val.hasSharpness = (packed >> 2) & 1 ? true : false;
617+
val.hasFocusDistance = (packed >> 3) & 1 ? true : false;
618+
val.hasZoom = (packed >> 4) & 1 ? true : false;
619+
val.hasTorch = (packed >> 5) & 1 ? true : false;
620+
val.torch = (packed >> 6) & 1 ? true : false;
621+
val.hasFillLightMode = (packed >> 7) & 1 ? true : false;
609622
packed = decoder.readUint8();
610-
val.hasHeight = (packed >> 0) & 1 ? true : false;
611-
val.hasRedEyeReduction = (packed >> 1) & 1 ? true : false;
612-
val.redEyeReduction = (packed >> 2) & 1 ? true : false;
623+
val.hasWidth = (packed >> 0) & 1 ? true : false;
624+
val.hasHeight = (packed >> 1) & 1 ? true : false;
625+
val.hasRedEyeReduction = (packed >> 2) & 1 ? true : false;
626+
val.redEyeReduction = (packed >> 3) & 1 ? true : false;
613627
decoder.skip(1);
614628
val.whiteBalanceMode = decoder.decodeStruct(codec.Int32);
615629
val.exposureMode = decoder.decodeStruct(codec.Int32);
616630
val.focusMode = decoder.decodeStruct(codec.Int32);
617631
val.pointsOfInterest = decoder.decodeArrayPointer(new codec.PointerTo(Point2D));
618632
val.exposureCompensation = decoder.decodeStruct(codec.Double);
633+
val.exposureTime = decoder.decodeStruct(codec.Double);
619634
val.colorTemperature = decoder.decodeStruct(codec.Double);
620635
val.iso = decoder.decodeStruct(codec.Double);
621636
val.brightness = decoder.decodeStruct(codec.Double);
@@ -643,32 +658,34 @@
643658
packed |= (val.hasExposureMode & 1) << 1
644659
packed |= (val.hasFocusMode & 1) << 2
645660
packed |= (val.hasExposureCompensation & 1) << 3
646-
packed |= (val.hasColorTemperature & 1) << 4
647-
packed |= (val.hasIso & 1) << 5
648-
packed |= (val.hasBrightness & 1) << 6
649-
packed |= (val.hasContrast & 1) << 7
661+
packed |= (val.hasExposureTime & 1) << 4
662+
packed |= (val.hasColorTemperature & 1) << 5
663+
packed |= (val.hasIso & 1) << 6
664+
packed |= (val.hasBrightness & 1) << 7
650665
encoder.writeUint8(packed);
651666
packed = 0;
652-
packed |= (val.hasSaturation & 1) << 0
653-
packed |= (val.hasSharpness & 1) << 1
654-
packed |= (val.hasFocusDistance & 1) << 2
655-
packed |= (val.hasZoom & 1) << 3
656-
packed |= (val.hasTorch & 1) << 4
657-
packed |= (val.torch & 1) << 5
658-
packed |= (val.hasFillLightMode & 1) << 6
659-
packed |= (val.hasWidth & 1) << 7
667+
packed |= (val.hasContrast & 1) << 0
668+
packed |= (val.hasSaturation & 1) << 1
669+
packed |= (val.hasSharpness & 1) << 2
670+
packed |= (val.hasFocusDistance & 1) << 3
671+
packed |= (val.hasZoom & 1) << 4
672+
packed |= (val.hasTorch & 1) << 5
673+
packed |= (val.torch & 1) << 6
674+
packed |= (val.hasFillLightMode & 1) << 7
660675
encoder.writeUint8(packed);
661676
packed = 0;
662-
packed |= (val.hasHeight & 1) << 0
663-
packed |= (val.hasRedEyeReduction & 1) << 1
664-
packed |= (val.redEyeReduction & 1) << 2
677+
packed |= (val.hasWidth & 1) << 0
678+
packed |= (val.hasHeight & 1) << 1
679+
packed |= (val.hasRedEyeReduction & 1) << 2
680+
packed |= (val.redEyeReduction & 1) << 3
665681
encoder.writeUint8(packed);
666682
encoder.skip(1);
667683
encoder.encodeStruct(codec.Int32, val.whiteBalanceMode);
668684
encoder.encodeStruct(codec.Int32, val.exposureMode);
669685
encoder.encodeStruct(codec.Int32, val.focusMode);
670686
encoder.encodeArrayPointer(new codec.PointerTo(Point2D), val.pointsOfInterest);
671687
encoder.encodeStruct(codec.Double, val.exposureCompensation);
688+
encoder.encodeStruct(codec.Double, val.exposureTime);
672689
encoder.encodeStruct(codec.Double, val.colorTemperature);
673690
encoder.encodeStruct(codec.Double, val.iso);
674691
encoder.encodeStruct(codec.Double, val.brightness);

0 commit comments

Comments
 (0)