Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp

Issue 2804653003: Image Capture: make sure applyConstraints() only works for ImageCapture constraints (Closed)
Patch Set: LayoutTests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Ericsson AB. All rights reserved. 3 * Copyright (C) 2011 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (m_imageCapture) 298 if (m_imageCapture)
299 m_imageCapture->getMediaTrackSettings(settings); 299 m_imageCapture->getMediaTrackSettings(settings);
300 } 300 }
301 301
302 ScriptPromise MediaStreamTrack::applyConstraints( 302 ScriptPromise MediaStreamTrack::applyConstraints(
303 ScriptState* scriptState, 303 ScriptState* scriptState,
304 const MediaTrackConstraints& constraints) { 304 const MediaTrackConstraints& constraints) {
305 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 305 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
306 ScriptPromise promise = resolver->promise(); 306 ScriptPromise promise = resolver->promise();
307 307
308 // |constraints| is an optional argument, which is strange. 308 // TODO(mcasas): Until https://crbug.com/338503 is landed, we only support
309 // TODO(mcasas): remove this provision if |constraints| is not optional: 309 // ImageCapture-related constraints.
310 // https://github.com/w3c/mediacapture-main/issues/438 310 if (!m_imageCapture ||
311 if (!constraints.hasAdvanced()) { 311 m_imageCapture->hasNonImageCaptureConstraints(constraints)) {
312 resolver->resolve(); 312 resolver->reject(DOMException::create(
313 NotSupportedError,
314 "Only Image-Capture constraints supported (https://crbug.com/338503)"));
313 return promise; 315 return promise;
314 } 316 }
315 317
316 if (!m_imageCapture) { 318 // |constraints| empty means "remove/clear all current constraints".
317 resolver->reject(DOMException::create( 319 if (!constraints.hasAdvanced())
318 NotSupportedError, "Track type not currently supported")); 320 m_imageCapture->clearMediaTrackConstraints(resolver);
319 return promise; 321 else
320 } 322 m_imageCapture->setMediaTrackConstraints(resolver, constraints.advanced());
321 323
322 // TODO(mcasas): support more advanced constraints, https://crbug.com/700607.
323 m_imageCapture->setMediaTrackConstraints(resolver, constraints.advanced()[0]);
324 return promise; 324 return promise;
325 } 325 }
326 326
327 bool MediaStreamTrack::ended() const { 327 bool MediaStreamTrack::ended() const {
328 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded); 328 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded);
329 } 329 }
330 330
331 void MediaStreamTrack::sourceChangedState() { 331 void MediaStreamTrack::sourceChangedState() {
332 if (ended()) 332 if (ended())
333 return; 333 return;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 DEFINE_TRACE(MediaStreamTrack) { 409 DEFINE_TRACE(MediaStreamTrack) {
410 visitor->trace(m_registeredMediaStreams); 410 visitor->trace(m_registeredMediaStreams);
411 visitor->trace(m_component); 411 visitor->trace(m_component);
412 visitor->trace(m_imageCapture); 412 visitor->trace(m_imageCapture);
413 EventTargetWithInlineData::trace(visitor); 413 EventTargetWithInlineData::trace(visitor);
414 ContextLifecycleObserver::trace(visitor); 414 ContextLifecycleObserver::trace(visitor);
415 } 415 }
416 416
417 } // namespace blink 417 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698