| 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 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 MediaStreamTrack* MediaStreamTrack::clone(ScriptState* scriptState) { | 209 MediaStreamTrack* MediaStreamTrack::clone(ScriptState* scriptState) { |
| 210 // TODO(pbos): Make sure m_readyState and m_stopped carries over on cloned | 210 // TODO(pbos): Make sure m_readyState and m_stopped carries over on cloned |
| 211 // tracks. | 211 // tracks. |
| 212 MediaStreamComponent* clonedComponent = component()->clone(); | 212 MediaStreamComponent* clonedComponent = component()->clone(); |
| 213 MediaStreamTrack* clonedTrack = MediaStreamTrack::create( | 213 MediaStreamTrack* clonedTrack = MediaStreamTrack::create( |
| 214 scriptState->getExecutionContext(), clonedComponent); | 214 scriptState->getExecutionContext(), clonedComponent); |
| 215 MediaStreamCenter::instance().didCreateMediaStreamTrack(clonedComponent); | 215 MediaStreamCenter::instance().didCreateMediaStreamTrack(clonedComponent); |
| 216 return clonedTrack; | 216 return clonedTrack; |
| 217 } | 217 } |
| 218 | 218 |
| 219 void MediaStreamTrack::getConstraints(MediaTrackConstraints& constraints) { | |
| 220 MediaConstraintsImpl::convertConstraints(m_constraints, constraints); | |
| 221 } | |
| 222 | |
| 223 void MediaStreamTrack::setConstraints(const WebMediaConstraints& constraints) { | 219 void MediaStreamTrack::setConstraints(const WebMediaConstraints& constraints) { |
| 224 m_constraints = constraints; | 220 m_constraints = constraints; |
| 225 } | 221 } |
| 226 | 222 |
| 227 void MediaStreamTrack::getCapabilities(MediaTrackCapabilities& capabilities) { | 223 void MediaStreamTrack::getCapabilities(MediaTrackCapabilities& capabilities) { |
| 228 if (m_imageCapture) | 224 if (m_imageCapture) |
| 229 capabilities = m_imageCapture->getMediaTrackCapabilities(); | 225 capabilities = m_imageCapture->getMediaTrackCapabilities(); |
| 230 } | 226 } |
| 231 | 227 |
| 228 void MediaStreamTrack::getConstraints(MediaTrackConstraints& constraints) { |
| 229 MediaConstraintsImpl::convertConstraints(m_constraints, constraints); |
| 230 |
| 231 if (!m_imageCapture) |
| 232 return; |
| 233 HeapVector<MediaTrackConstraintSet> vector; |
| 234 if (constraints.hasAdvanced()) |
| 235 vector = constraints.advanced(); |
| 236 // TODO(mcasas): consider consolidating this code in MediaContraintsImpl. |
| 237 auto imageCaptureConstraints = m_imageCapture->getMediaTrackConstraints(); |
| 238 // TODO(mcasas): add |torch|, https://crbug.com/700607. |
| 239 if (imageCaptureConstraints.hasWhiteBalanceMode() || |
| 240 imageCaptureConstraints.hasExposureMode() || |
| 241 imageCaptureConstraints.hasFocusMode() || |
| 242 imageCaptureConstraints.hasExposureCompensation() || |
| 243 imageCaptureConstraints.hasColorTemperature() || |
| 244 imageCaptureConstraints.hasIso() || |
| 245 imageCaptureConstraints.hasBrightness() || |
| 246 imageCaptureConstraints.hasContrast() || |
| 247 imageCaptureConstraints.hasSaturation() || |
| 248 imageCaptureConstraints.hasSharpness() || |
| 249 imageCaptureConstraints.hasZoom()) { |
| 250 // Add image capture constraints, if any, as another entry to advanced(). |
| 251 vector.emplace_back(imageCaptureConstraints); |
| 252 constraints.setAdvanced(vector); |
| 253 } |
| 254 } |
| 255 |
| 232 void MediaStreamTrack::getSettings(MediaTrackSettings& settings) { | 256 void MediaStreamTrack::getSettings(MediaTrackSettings& settings) { |
| 233 WebMediaStreamTrack::Settings platformSettings; | 257 WebMediaStreamTrack::Settings platformSettings; |
| 234 m_component->getSettings(platformSettings); | 258 m_component->getSettings(platformSettings); |
| 235 if (platformSettings.hasFrameRate()) { | 259 if (platformSettings.hasFrameRate()) |
| 236 settings.setFrameRate(platformSettings.frameRate); | 260 settings.setFrameRate(platformSettings.frameRate); |
| 237 } | 261 if (platformSettings.hasWidth()) |
| 238 if (platformSettings.hasWidth()) { | |
| 239 settings.setWidth(platformSettings.width); | 262 settings.setWidth(platformSettings.width); |
| 240 } | 263 if (platformSettings.hasHeight()) |
| 241 if (platformSettings.hasHeight()) { | |
| 242 settings.setHeight(platformSettings.height); | 264 settings.setHeight(platformSettings.height); |
| 243 } | |
| 244 if (RuntimeEnabledFeatures::mediaCaptureDepthEnabled() && | 265 if (RuntimeEnabledFeatures::mediaCaptureDepthEnabled() && |
| 245 m_component->source()->type() == MediaStreamSource::TypeVideo) { | 266 m_component->source()->type() == MediaStreamSource::TypeVideo) { |
| 246 if (platformSettings.hasVideoKind()) | 267 if (platformSettings.hasVideoKind()) |
| 247 settings.setVideoKind(platformSettings.videoKind); | 268 settings.setVideoKind(platformSettings.videoKind); |
| 248 if (platformSettings.hasDepthNear()) | 269 if (platformSettings.hasDepthNear()) |
| 249 settings.setDepthNear(platformSettings.depthNear); | 270 settings.setDepthNear(platformSettings.depthNear); |
| 250 if (platformSettings.hasDepthFar()) | 271 if (platformSettings.hasDepthFar()) |
| 251 settings.setDepthFar(platformSettings.depthFar); | 272 settings.setDepthFar(platformSettings.depthFar); |
| 252 if (platformSettings.hasFocalLengthX()) | 273 if (platformSettings.hasFocalLengthX()) |
| 253 settings.setFocalLengthX(platformSettings.focalLengthX); | 274 settings.setFocalLengthX(platformSettings.focalLengthX); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 resolver->resolve(); | 310 resolver->resolve(); |
| 290 return promise; | 311 return promise; |
| 291 } | 312 } |
| 292 | 313 |
| 293 if (!m_imageCapture) { | 314 if (!m_imageCapture) { |
| 294 resolver->reject(DOMException::create( | 315 resolver->reject(DOMException::create( |
| 295 NotSupportedError, "Track type not currently supported")); | 316 NotSupportedError, "Track type not currently supported")); |
| 296 return promise; | 317 return promise; |
| 297 } | 318 } |
| 298 | 319 |
| 320 // TODO(mcasas): support more advanced constraints, https://crbug.com/700607. |
| 299 m_imageCapture->setMediaTrackConstraints(resolver, constraints.advanced()[0]); | 321 m_imageCapture->setMediaTrackConstraints(resolver, constraints.advanced()[0]); |
| 300 return promise; | 322 return promise; |
| 301 } | 323 } |
| 302 | 324 |
| 303 bool MediaStreamTrack::ended() const { | 325 bool MediaStreamTrack::ended() const { |
| 304 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded); | 326 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded); |
| 305 } | 327 } |
| 306 | 328 |
| 307 void MediaStreamTrack::sourceChangedState() { | 329 void MediaStreamTrack::sourceChangedState() { |
| 308 if (ended()) | 330 if (ended()) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 406 |
| 385 DEFINE_TRACE(MediaStreamTrack) { | 407 DEFINE_TRACE(MediaStreamTrack) { |
| 386 visitor->trace(m_registeredMediaStreams); | 408 visitor->trace(m_registeredMediaStreams); |
| 387 visitor->trace(m_component); | 409 visitor->trace(m_component); |
| 388 visitor->trace(m_imageCapture); | 410 visitor->trace(m_imageCapture); |
| 389 EventTargetWithInlineData::trace(visitor); | 411 EventTargetWithInlineData::trace(visitor); |
| 390 ContextLifecycleObserver::trace(visitor); | 412 ContextLifecycleObserver::trace(visitor); |
| 391 } | 413 } |
| 392 | 414 |
| 393 } // namespace blink | 415 } // namespace blink |
| OLD | NEW |