| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "modules/mediastream/MediaStreamTrack.h" | 26 #include "modules/mediastream/MediaStreamTrack.h" |
| 27 | 27 |
| 28 #include "bindings/core/v8/ExceptionMessages.h" | 28 #include "bindings/core/v8/ExceptionMessages.h" |
| 29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
| 30 #include "core/dom/ExceptionCode.h" | 30 #include "core/dom/ExceptionCode.h" |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/events/Event.h" | 32 #include "core/events/Event.h" |
| 33 #include "core/frame/Deprecation.h" | 33 #include "core/frame/Deprecation.h" |
| 34 #include "modules/mediastream/MediaConstraintsImpl.h" |
| 34 #include "modules/mediastream/MediaStream.h" | 35 #include "modules/mediastream/MediaStream.h" |
| 35 #include "modules/mediastream/MediaStreamTrackSourcesCallback.h" | 36 #include "modules/mediastream/MediaStreamTrackSourcesCallback.h" |
| 36 #include "modules/mediastream/MediaStreamTrackSourcesRequestImpl.h" | 37 #include "modules/mediastream/MediaStreamTrackSourcesRequestImpl.h" |
| 37 #include "modules/mediastream/UserMediaController.h" | 38 #include "modules/mediastream/UserMediaController.h" |
| 38 #include "platform/mediastream/MediaStreamCenter.h" | 39 #include "platform/mediastream/MediaStreamCenter.h" |
| 39 #include "platform/mediastream/MediaStreamComponent.h" | 40 #include "platform/mediastream/MediaStreamComponent.h" |
| 40 #include "public/platform/WebSourceInfo.h" | 41 #include "public/platform/WebSourceInfo.h" |
| 41 | 42 |
| 42 namespace blink { | 43 namespace blink { |
| 43 | 44 |
| 44 MediaStreamTrack* MediaStreamTrack::create(ExecutionContext* context, MediaStrea
mComponent* component) | 45 MediaStreamTrack* MediaStreamTrack::create(ExecutionContext* context, MediaStrea
mComponent* component) |
| 45 { | 46 { |
| 46 MediaStreamTrack* track = new MediaStreamTrack(context, component); | 47 MediaStreamTrack* track = new MediaStreamTrack(context, component); |
| 47 track->suspendIfNeeded(); | 48 track->suspendIfNeeded(); |
| 48 return track; | 49 return track; |
| 49 } | 50 } |
| 50 | 51 |
| 51 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, MediaStreamCompone
nt* component) | 52 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, MediaStreamCompone
nt* component) |
| 52 : ActiveScriptWrappable(this) | 53 : ActiveScriptWrappable(this) |
| 53 , ActiveDOMObject(context) | 54 , ActiveDOMObject(context) |
| 54 , m_readyState(MediaStreamSource::ReadyStateLive) | 55 , m_readyState(MediaStreamSource::ReadyStateLive) |
| 55 , m_isIteratingRegisteredMediaStreams(false) | 56 , m_isIteratingRegisteredMediaStreams(false) |
| 56 , m_stopped(false) | 57 , m_stopped(false) |
| 57 , m_component(component) | 58 , m_component(component) |
| 59 // The source's constraints aren't yet initialized at creation time. |
| 60 , m_constraints() |
| 58 { | 61 { |
| 59 m_component->source()->addObserver(this); | 62 m_component->source()->addObserver(this); |
| 60 } | 63 } |
| 61 | 64 |
| 62 MediaStreamTrack::~MediaStreamTrack() | 65 MediaStreamTrack::~MediaStreamTrack() |
| 63 { | 66 { |
| 64 } | 67 } |
| 65 | 68 |
| 66 String MediaStreamTrack::kind() const | 69 String MediaStreamTrack::kind() const |
| 67 { | 70 { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 166 } |
| 164 | 167 |
| 165 MediaStreamTrack* MediaStreamTrack::clone(ExecutionContext* context) | 168 MediaStreamTrack* MediaStreamTrack::clone(ExecutionContext* context) |
| 166 { | 169 { |
| 167 MediaStreamComponent* clonedComponent = MediaStreamComponent::create(compone
nt()->source()); | 170 MediaStreamComponent* clonedComponent = MediaStreamComponent::create(compone
nt()->source()); |
| 168 MediaStreamTrack* clonedTrack = MediaStreamTrack::create(context, clonedComp
onent); | 171 MediaStreamTrack* clonedTrack = MediaStreamTrack::create(context, clonedComp
onent); |
| 169 MediaStreamCenter::instance().didCreateMediaStreamTrack(clonedComponent); | 172 MediaStreamCenter::instance().didCreateMediaStreamTrack(clonedComponent); |
| 170 return clonedTrack; | 173 return clonedTrack; |
| 171 } | 174 } |
| 172 | 175 |
| 176 void MediaStreamTrack::getConstraints(MediaTrackConstraints& constraints) |
| 177 { |
| 178 MediaConstraintsImpl::convertConstraints(m_constraints, constraints); |
| 179 } |
| 180 |
| 181 void MediaStreamTrack::setConstraints(const WebMediaConstraints& constraints) |
| 182 { |
| 183 m_constraints = constraints; |
| 184 } |
| 185 |
| 173 bool MediaStreamTrack::ended() const | 186 bool MediaStreamTrack::ended() const |
| 174 { | 187 { |
| 175 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded); | 188 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded); |
| 176 } | 189 } |
| 177 | 190 |
| 178 void MediaStreamTrack::sourceChangedState() | 191 void MediaStreamTrack::sourceChangedState() |
| 179 { | 192 { |
| 180 if (ended()) | 193 if (ended()) |
| 181 return; | 194 return; |
| 182 | 195 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 276 |
| 264 DEFINE_TRACE(MediaStreamTrack) | 277 DEFINE_TRACE(MediaStreamTrack) |
| 265 { | 278 { |
| 266 visitor->trace(m_registeredMediaStreams); | 279 visitor->trace(m_registeredMediaStreams); |
| 267 visitor->trace(m_component); | 280 visitor->trace(m_component); |
| 268 EventTargetWithInlineData::trace(visitor); | 281 EventTargetWithInlineData::trace(visitor); |
| 269 ActiveDOMObject::trace(visitor); | 282 ActiveDOMObject::trace(visitor); |
| 270 } | 283 } |
| 271 | 284 |
| 272 } // namespace blink | 285 } // namespace blink |
| OLD | NEW |