| OLD | NEW |
| 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 "bindings/core/v8/ExceptionMessages.h" | 29 #include "bindings/core/v8/ExceptionMessages.h" |
| 29 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 30 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
| 31 #include "core/dom/ExecutionContext.h" | 32 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/events/Event.h" | 33 #include "core/events/Event.h" |
| 33 #include "core/frame/Deprecation.h" | 34 #include "core/frame/Deprecation.h" |
| 35 #include "modules/imagecapture/ImageCapture.h" |
| 34 #include "modules/mediastream/MediaConstraintsImpl.h" | 36 #include "modules/mediastream/MediaConstraintsImpl.h" |
| 35 #include "modules/mediastream/MediaStream.h" | 37 #include "modules/mediastream/MediaStream.h" |
| 38 #include "modules/mediastream/MediaTrackCapabilities.h" |
| 36 #include "modules/mediastream/MediaTrackSettings.h" | 39 #include "modules/mediastream/MediaTrackSettings.h" |
| 37 #include "modules/mediastream/UserMediaController.h" | 40 #include "modules/mediastream/UserMediaController.h" |
| 38 #include "platform/mediastream/MediaStreamCenter.h" | 41 #include "platform/mediastream/MediaStreamCenter.h" |
| 39 #include "platform/mediastream/MediaStreamComponent.h" | 42 #include "platform/mediastream/MediaStreamComponent.h" |
| 40 #include "public/platform/WebMediaStreamTrack.h" | 43 #include "public/platform/WebMediaStreamTrack.h" |
| 41 #include "wtf/Assertions.h" | 44 #include "wtf/Assertions.h" |
| 42 #include <memory> | |
| 43 | 45 |
| 44 namespace blink { | 46 namespace blink { |
| 45 | 47 |
| 46 namespace { | 48 namespace { |
| 47 static const char kContentHintStringNone[] = ""; | 49 static const char kContentHintStringNone[] = ""; |
| 48 static const char kContentHintStringAudioSpeech[] = "speech"; | 50 static const char kContentHintStringAudioSpeech[] = "speech"; |
| 49 static const char kContentHintStringAudioMusic[] = "music"; | 51 static const char kContentHintStringAudioMusic[] = "music"; |
| 50 static const char kContentHintStringVideoMotion[] = "motion"; | 52 static const char kContentHintStringVideoMotion[] = "motion"; |
| 51 static const char kContentHintStringVideoDetail[] = "detail"; | 53 static const char kContentHintStringVideoDetail[] = "detail"; |
| 52 } // namespace | 54 } // namespace |
| 53 | 55 |
| 54 MediaStreamTrack* MediaStreamTrack::create(ExecutionContext* context, | 56 MediaStreamTrack* MediaStreamTrack::create(ExecutionContext* context, |
| 55 MediaStreamComponent* component) { | 57 MediaStreamComponent* component) { |
| 56 return new MediaStreamTrack(context, component); | 58 return new MediaStreamTrack(context, component); |
| 57 } | 59 } |
| 58 | 60 |
| 59 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, | 61 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, |
| 60 MediaStreamComponent* component) | 62 MediaStreamComponent* component) |
| 61 : ContextLifecycleObserver(context), | 63 : ContextLifecycleObserver(context), |
| 62 m_readyState(MediaStreamSource::ReadyStateLive), | 64 m_readyState(MediaStreamSource::ReadyStateLive), |
| 63 m_isIteratingRegisteredMediaStreams(false), | 65 m_isIteratingRegisteredMediaStreams(false), |
| 64 m_stopped(false), | 66 m_stopped(false), |
| 65 m_component(component), | 67 m_component(component), |
| 66 // The source's constraints aren't yet initialized at creation time. | 68 // The source's constraints aren't yet initialized at creation time. |
| 67 m_constraints() { | 69 m_constraints() { |
| 68 m_component->source()->addObserver(this); | 70 m_component->source()->addObserver(this); |
| 71 |
| 72 if (m_component->source() && |
| 73 m_component->source()->type() == MediaStreamSource::TypeVideo) { |
| 74 // ImageCapture::create() only throws if |this| track is not of video type. |
| 75 NonThrowableExceptionState exceptionState; |
| 76 m_imageCapture = ImageCapture::create(context, this, exceptionState); |
| 77 } |
| 69 } | 78 } |
| 70 | 79 |
| 71 MediaStreamTrack::~MediaStreamTrack() {} | 80 MediaStreamTrack::~MediaStreamTrack() {} |
| 72 | 81 |
| 73 String MediaStreamTrack::kind() const { | 82 String MediaStreamTrack::kind() const { |
| 74 DEFINE_STATIC_LOCAL(String, audioKind, ("audio")); | 83 DEFINE_STATIC_LOCAL(String, audioKind, ("audio")); |
| 75 DEFINE_STATIC_LOCAL(String, videoKind, ("video")); | 84 DEFINE_STATIC_LOCAL(String, videoKind, ("video")); |
| 76 | 85 |
| 77 switch (m_component->source()->type()) { | 86 switch (m_component->source()->type()) { |
| 78 case MediaStreamSource::TypeAudio: | 87 case MediaStreamSource::TypeAudio: |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 214 } |
| 206 | 215 |
| 207 void MediaStreamTrack::getConstraints(MediaTrackConstraints& constraints) { | 216 void MediaStreamTrack::getConstraints(MediaTrackConstraints& constraints) { |
| 208 MediaConstraintsImpl::convertConstraints(m_constraints, constraints); | 217 MediaConstraintsImpl::convertConstraints(m_constraints, constraints); |
| 209 } | 218 } |
| 210 | 219 |
| 211 void MediaStreamTrack::setConstraints(const WebMediaConstraints& constraints) { | 220 void MediaStreamTrack::setConstraints(const WebMediaConstraints& constraints) { |
| 212 m_constraints = constraints; | 221 m_constraints = constraints; |
| 213 } | 222 } |
| 214 | 223 |
| 224 void MediaStreamTrack::getCapabilities(MediaTrackCapabilities& capabilities) { |
| 225 if (m_imageCapture) |
| 226 capabilities = m_imageCapture->getMediaTrackCapabilities(); |
| 227 } |
| 228 |
| 215 void MediaStreamTrack::getSettings(MediaTrackSettings& settings) { | 229 void MediaStreamTrack::getSettings(MediaTrackSettings& settings) { |
| 216 WebMediaStreamTrack::Settings platformSettings; | 230 WebMediaStreamTrack::Settings platformSettings; |
| 217 m_component->getSettings(platformSettings); | 231 m_component->getSettings(platformSettings); |
| 218 if (platformSettings.hasFrameRate()) { | 232 if (platformSettings.hasFrameRate()) { |
| 219 settings.setFrameRate(platformSettings.frameRate); | 233 settings.setFrameRate(platformSettings.frameRate); |
| 220 } | 234 } |
| 221 if (platformSettings.hasWidth()) { | 235 if (platformSettings.hasWidth()) { |
| 222 settings.setWidth(platformSettings.width); | 236 settings.setWidth(platformSettings.width); |
| 223 } | 237 } |
| 224 if (platformSettings.hasHeight()) { | 238 if (platformSettings.hasHeight()) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 return EventTargetNames::MediaStreamTrack; | 351 return EventTargetNames::MediaStreamTrack; |
| 338 } | 352 } |
| 339 | 353 |
| 340 ExecutionContext* MediaStreamTrack::getExecutionContext() const { | 354 ExecutionContext* MediaStreamTrack::getExecutionContext() const { |
| 341 return ContextLifecycleObserver::getExecutionContext(); | 355 return ContextLifecycleObserver::getExecutionContext(); |
| 342 } | 356 } |
| 343 | 357 |
| 344 DEFINE_TRACE(MediaStreamTrack) { | 358 DEFINE_TRACE(MediaStreamTrack) { |
| 345 visitor->trace(m_registeredMediaStreams); | 359 visitor->trace(m_registeredMediaStreams); |
| 346 visitor->trace(m_component); | 360 visitor->trace(m_component); |
| 361 visitor->trace(m_imageCapture); |
| 347 EventTargetWithInlineData::trace(visitor); | 362 EventTargetWithInlineData::trace(visitor); |
| 348 ContextLifecycleObserver::trace(visitor); | 363 ContextLifecycleObserver::trace(visitor); |
| 349 } | 364 } |
| 350 | 365 |
| 351 } // namespace blink | 366 } // namespace blink |
| OLD | NEW |