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

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

Issue 2757673005: Image Capture: MediaStreamTrack::applyConstraints() (Closed)
Patch Set: Created 3 years, 9 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
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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR 17 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "modules/mediastream/MediaStreamTrack.h" 26 #include "modules/mediastream/MediaStreamTrack.h"
27 27
28 #include <memory> 28 #include <memory>
29 #include "bindings/core/v8/ExceptionMessages.h" 29 #include "bindings/core/v8/ExceptionMessages.h"
30 #include "bindings/core/v8/ScriptPromiseResolver.h"
31 #include "core/dom/DOMException.h"
30 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
31 #include "core/dom/ExceptionCode.h" 33 #include "core/dom/ExceptionCode.h"
32 #include "core/dom/ExecutionContext.h" 34 #include "core/dom/ExecutionContext.h"
33 #include "core/events/Event.h" 35 #include "core/events/Event.h"
34 #include "core/frame/Deprecation.h" 36 #include "core/frame/Deprecation.h"
35 #include "modules/imagecapture/ImageCapture.h" 37 #include "modules/imagecapture/ImageCapture.h"
36 #include "modules/mediastream/MediaConstraintsImpl.h" 38 #include "modules/mediastream/MediaConstraintsImpl.h"
37 #include "modules/mediastream/MediaStream.h" 39 #include "modules/mediastream/MediaStream.h"
38 #include "modules/mediastream/MediaTrackCapabilities.h" 40 #include "modules/mediastream/MediaTrackCapabilities.h"
41 #include "modules/mediastream/MediaTrackConstraints.h"
39 #include "modules/mediastream/MediaTrackSettings.h" 42 #include "modules/mediastream/MediaTrackSettings.h"
40 #include "modules/mediastream/UserMediaController.h" 43 #include "modules/mediastream/UserMediaController.h"
41 #include "platform/mediastream/MediaStreamCenter.h" 44 #include "platform/mediastream/MediaStreamCenter.h"
42 #include "platform/mediastream/MediaStreamComponent.h" 45 #include "platform/mediastream/MediaStreamComponent.h"
43 #include "public/platform/WebMediaStreamTrack.h" 46 #include "public/platform/WebMediaStreamTrack.h"
44 #include "wtf/Assertions.h" 47 #include "wtf/Assertions.h"
45 48
46 namespace blink { 49 namespace blink {
47 50
48 namespace { 51 namespace {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 case WebMediaStreamTrack::FacingMode::Right: 269 case WebMediaStreamTrack::FacingMode::Right:
267 settings.setFacingMode("right"); 270 settings.setFacingMode("right");
268 break; 271 break;
269 default: 272 default:
270 // None, or unknown facing mode. Ignore. 273 // None, or unknown facing mode. Ignore.
271 break; 274 break;
272 } 275 }
273 } 276 }
274 } 277 }
275 278
279 ScriptPromise MediaStreamTrack::applyConstraints(
280 ScriptState* scriptState,
281 const MediaTrackConstraints& constraints) {
282 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
283 ScriptPromise promise = resolver->promise();
284
285 // |constraints| is an optional argument, which is strange.
286 // TODO(mcasas): remove this provision if |constraints| is not optional:
287 // https://github.com/w3c/mediacapture-main/issues/438
288 if (!constraints.hasAdvanced()) {
289 resolver->resolve();
290 return promise;
291 }
292
293 if (!m_imageCapture) {
294 resolver->reject(
295 DOMException::create(NotFoundError, "Image Capture not found"));
Guido Urdaneta 2017/03/17 00:30:27 Change the error message to something like "Track
mcasas 2017/03/17 00:49:22 Done.
296 return promise;
297 }
298
299 m_imageCapture->setMediaTrackConstraints(resolver, constraints.advanced()[0]);
300 return promise;
301 }
302
276 bool MediaStreamTrack::ended() const { 303 bool MediaStreamTrack::ended() const {
277 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded); 304 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded);
278 } 305 }
279 306
280 void MediaStreamTrack::sourceChangedState() { 307 void MediaStreamTrack::sourceChangedState() {
281 if (ended()) 308 if (ended())
282 return; 309 return;
283 310
284 m_readyState = m_component->source()->getReadyState(); 311 m_readyState = m_component->source()->getReadyState();
285 switch (m_readyState) { 312 switch (m_readyState) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 384
358 DEFINE_TRACE(MediaStreamTrack) { 385 DEFINE_TRACE(MediaStreamTrack) {
359 visitor->trace(m_registeredMediaStreams); 386 visitor->trace(m_registeredMediaStreams);
360 visitor->trace(m_component); 387 visitor->trace(m_component);
361 visitor->trace(m_imageCapture); 388 visitor->trace(m_imageCapture);
362 EventTargetWithInlineData::trace(visitor); 389 EventTargetWithInlineData::trace(visitor);
363 ContextLifecycleObserver::trace(visitor); 390 ContextLifecycleObserver::trace(visitor);
364 } 391 }
365 392
366 } // namespace blink 393 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698