Changeset 157733 in webkit
- Timestamp:
- Oct 21, 2013 2:14:37 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r157731 r157733 1 2013-10-21 Thiago de Barros Lacerda <thiago.lacerda@openbossa.org> 2 3 MediaStreamTrack now tracks its own state 4 https://bugs.webkit.org/show_bug.cgi?id=123025 5 6 Reviewed by Jer Noble. 7 8 The spec says that a MediaStreamSource can be shared by different tracks, 9 so a track must have its own state tracking, synchronizing with its MediaStreamSource when 10 the underlying MediaStreamSource changes the readyState. 11 In the old implementation if a user invoked the stop method, its readyState method was still 12 returning the MediaStreamSource state, which was wrong. 13 This also adds a setEnabled method, which can be used to set the state of a track when a 14 remote peer ends it, for instance. 15 16 No new tests needed. 17 18 * Modules/mediastream/MediaStreamTrack.cpp: 19 (WebCore::MediaStreamTrack::readyState): 20 (WebCore::MediaStreamTrack::setState): 21 (WebCore::MediaStreamTrack::stopProducingData): 22 (WebCore::MediaStreamTrack::ended): 23 (WebCore::MediaStreamTrack::sourceStateChanged): 24 (WebCore::MediaStreamTrack::trackDidEnd): 25 * Modules/mediastream/MediaStreamTrack.h: 26 1 27 2013-10-21 Tim Horton <timothy_horton@apple.com> 2 28 -
trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
r157068 r157733 205 205 static NeverDestroyed<AtomicString> newState("new", AtomicString::ConstructFromLiteral); 206 206 207 if (!m_source)208 return newState;209 210 207 if (m_stopped) 211 208 return ended; 212 209 213 switch (m_ source->readyState()) {210 switch (m_readyState) { 214 211 case MediaStreamSource::Live: 215 212 return live; … … 224 221 } 225 222 223 void MediaStreamTrack::setState(MediaStreamSource::ReadyState state) 224 { 225 if (m_readyState == MediaStreamSource::Ended || m_readyState == state) 226 return; 227 228 MediaStreamSource::ReadyState oldState = m_readyState; 229 m_readyState = state; 230 231 if (m_readyState == MediaStreamSource::Live && oldState == MediaStreamSource::New) 232 scheduleEventDispatch(Event::create(eventNames().startedEvent, false, false)); 233 if (m_readyState == MediaStreamSource::Ended && oldState != MediaStreamSource::Ended) 234 scheduleEventDispatch(Event::create(eventNames().endedEvent, false, false)); 235 } 236 226 237 void MediaStreamTrack::getSources(ScriptExecutionContext* context, PassRefPtr<MediaStreamTrackSourcesCallback> callback, ExceptionCode& ec) 227 238 { … … 276 287 // Set m_stopped before stopping the source because that may result in a call to sourceChangedState 277 288 // and we only want to dispatch the 'ended' event if necessary. 289 setState(MediaStreamSource::Ended); 278 290 m_stopped = true; 279 291 m_source->stop(); 280 281 if (m_readyState != MediaStreamSource::Ended)282 scheduleEventDispatch(Event::create(eventNames().endedEvent, false, false));283 292 } 284 293 285 294 bool MediaStreamTrack::ended() const 286 295 { 287 return m_stopped || (m_source && m_source->readyState() == MediaStreamSource::Ended);296 return m_stopped || m_readyState == MediaStreamSource::Ended; 288 297 } 289 298 … … 293 302 return; 294 303 295 MediaStreamSource::ReadyState oldReadyState = m_readyState; 296 m_readyState = m_source->readyState(); 297 298 if (m_readyState >= MediaStreamSource::Live && oldReadyState == MediaStreamSource::New) 299 scheduleEventDispatch(Event::create(eventNames().startedEvent, false, false)); 300 if (m_readyState == MediaStreamSource::Ended && oldReadyState != MediaStreamSource::Ended) 301 scheduleEventDispatch(Event::create(eventNames().endedEvent, false, false)); 304 setState(m_source->readyState()); 302 305 } 303 306 … … 351 354 352 355 client->trackDidEnd(); 356 setState(MediaStreamSource::Ended); 353 357 } 354 358 -
trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h
r157653 r157733 64 64 65 65 const AtomicString& readyState() const; 66 void setState(MediaStreamSource::ReadyState); 66 67 67 68 static void getSources(ScriptExecutionContext*, PassRefPtr<MediaStreamTrackSourcesCallback>, ExceptionCode&);
Note: See TracChangeset
for help on using the changeset viewer.