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, 2012 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2011, 2012 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 m_videoTracks.append(track); | 199 m_videoTracks.append(track); |
200 break; | 200 break; |
201 } | 201 } |
202 track->registerMediaStream(this); | 202 track->registerMediaStream(this); |
203 m_descriptor->addComponent(track->component()); | 203 m_descriptor->addComponent(track->component()); |
204 | 204 |
205 if (!active() && !track->ended()) { | 205 if (!active() && !track->ended()) { |
206 m_descriptor->setActive(true); | 206 m_descriptor->setActive(true); |
207 scheduleDispatchEvent(Event::create(EventTypeNames::active)); | 207 scheduleDispatchEvent(Event::create(EventTypeNames::active)); |
208 } | 208 } |
| 209 scheduleDispatchEvent(MediaStreamTrackEvent::create(EventTypeNames::addtrack
, false, false, track)); |
209 | 210 |
210 MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor, track->co
mponent()); | 211 MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor, track->co
mponent()); |
211 } | 212 } |
212 | 213 |
213 void MediaStream::removeTrack(MediaStreamTrack* track, ExceptionState& exception
State) | 214 void MediaStream::removeTrack(MediaStreamTrack* track, ExceptionState& exception
State) |
214 { | 215 { |
215 if (!track) { | 216 if (!track) { |
216 exceptionState.throwDOMException(TypeMismatchError, "The MediaStreamTrac
k provided is invalid."); | 217 exceptionState.throwDOMException(TypeMismatchError, "The MediaStreamTrac
k provided is invalid."); |
217 return; | 218 return; |
218 } | 219 } |
(...skipping 14 matching lines...) Expand all Loading... |
233 | 234 |
234 if (pos == kNotFound) | 235 if (pos == kNotFound) |
235 return; | 236 return; |
236 track->unregisterMediaStream(this); | 237 track->unregisterMediaStream(this); |
237 m_descriptor->removeComponent(track->component()); | 238 m_descriptor->removeComponent(track->component()); |
238 | 239 |
239 if (active() && emptyOrOnlyEndedTracks()) { | 240 if (active() && emptyOrOnlyEndedTracks()) { |
240 m_descriptor->setActive(false); | 241 m_descriptor->setActive(false); |
241 scheduleDispatchEvent(Event::create(EventTypeNames::inactive)); | 242 scheduleDispatchEvent(Event::create(EventTypeNames::inactive)); |
242 } | 243 } |
| 244 scheduleDispatchEvent(MediaStreamTrackEvent::create(EventTypeNames::removetr
ack, false, false, track)); |
243 | 245 |
244 MediaStreamCenter::instance().didRemoveMediaStreamTrack(m_descriptor, track-
>component()); | 246 MediaStreamCenter::instance().didRemoveMediaStreamTrack(m_descriptor, track-
>component()); |
245 } | 247 } |
246 | 248 |
247 MediaStreamTrack* MediaStream::getTrackById(String id) | 249 MediaStreamTrack* MediaStream::getTrackById(String id) |
248 { | 250 { |
249 for (MediaStreamTrackVector::iterator iter = m_audioTracks.begin(); iter !=
m_audioTracks.end(); ++iter) { | 251 for (MediaStreamTrackVector::iterator iter = m_audioTracks.begin(); iter !=
m_audioTracks.end(); ++iter) { |
250 if ((*iter)->id() == id) | 252 if ((*iter)->id() == id) |
251 return iter->get(); | 253 return iter->get(); |
252 } | 254 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 visitor->trace(m_audioTracks); | 413 visitor->trace(m_audioTracks); |
412 visitor->trace(m_videoTracks); | 414 visitor->trace(m_videoTracks); |
413 visitor->trace(m_descriptor); | 415 visitor->trace(m_descriptor); |
414 visitor->trace(m_scheduledEvents); | 416 visitor->trace(m_scheduledEvents); |
415 RefCountedGarbageCollectedEventTargetWithInlineData<MediaStream>::trace(visi
tor); | 417 RefCountedGarbageCollectedEventTargetWithInlineData<MediaStream>::trace(visi
tor); |
416 ContextLifecycleObserver::trace(visitor); | 418 ContextLifecycleObserver::trace(visitor); |
417 MediaStreamDescriptorClient::trace(visitor); | 419 MediaStreamDescriptorClient::trace(visitor); |
418 } | 420 } |
419 | 421 |
420 } // namespace blink | 422 } // namespace blink |
OLD | NEW |