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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 break; | 160 break; |
161 case MediaStreamSource::TypeVideo: | 161 case MediaStreamSource::TypeVideo: |
162 m_descriptor->addVideoComponent(component.release()); | 162 m_descriptor->addVideoComponent(component.release()); |
163 m_videoTracks.append(newTrack); | 163 m_videoTracks.append(newTrack); |
164 break; | 164 break; |
165 } | 165 } |
166 | 166 |
167 MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor.get(), new
Track->component()); | 167 MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor.get(), new
Track->component()); |
168 } | 168 } |
169 | 169 |
170 void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack , ExceptionC
ode& ec) | 170 void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCo
de& ec) |
171 { | 171 { |
172 if (ended()) { | 172 if (ended()) { |
173 ec = INVALID_STATE_ERR; | 173 ec = INVALID_STATE_ERR; |
174 return; | 174 return; |
175 } | 175 } |
176 | 176 |
177 if (!prpTrack) { | 177 if (!prpTrack) { |
178 ec = TYPE_MISMATCH_ERR; | 178 ec = TYPE_MISMATCH_ERR; |
179 return; | 179 return; |
180 } | 180 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 { | 273 { |
274 ASSERT(component && !component->stream()); | 274 ASSERT(component && !component->stream()); |
275 if (ended()) | 275 if (ended()) |
276 return; | 276 return; |
277 | 277 |
278 component->setStream(descriptor()); | 278 component->setStream(descriptor()); |
279 | 279 |
280 RefPtr<MediaStreamTrack> track = MediaStreamTrack::create(scriptExecutionCon
text(), component); | 280 RefPtr<MediaStreamTrack> track = MediaStreamTrack::create(scriptExecutionCon
text(), component); |
281 switch (component->source()->type()) { | 281 switch (component->source()->type()) { |
282 case MediaStreamSource::TypeAudio: | 282 case MediaStreamSource::TypeAudio: |
| 283 m_descriptor->addAudioComponent(component); |
283 m_audioTracks.append(track); | 284 m_audioTracks.append(track); |
284 break; | 285 break; |
285 case MediaStreamSource::TypeVideo: | 286 case MediaStreamSource::TypeVideo: |
| 287 m_descriptor->addVideoComponent(component); |
286 m_videoTracks.append(track); | 288 m_videoTracks.append(track); |
287 break; | 289 break; |
288 } | 290 } |
289 | 291 |
290 scheduleDispatchEvent(MediaStreamTrackEvent::create(eventNames().addtrackEve
nt, false, false, track)); | 292 scheduleDispatchEvent(MediaStreamTrackEvent::create(eventNames().addtrackEve
nt, false, false, track)); |
291 } | 293 } |
292 | 294 |
293 void MediaStream::removeRemoteTrack(MediaStreamComponent* component) | 295 void MediaStream::removeRemoteTrack(MediaStreamComponent* component) |
294 { | 296 { |
295 if (ended()) | 297 if (ended()) |
(...skipping 12 matching lines...) Expand all Loading... |
308 size_t index = notFound; | 310 size_t index = notFound; |
309 for (size_t i = 0; i < tracks->size(); ++i) { | 311 for (size_t i = 0; i < tracks->size(); ++i) { |
310 if ((*tracks)[i]->component() == component) { | 312 if ((*tracks)[i]->component() == component) { |
311 index = i; | 313 index = i; |
312 break; | 314 break; |
313 } | 315 } |
314 } | 316 } |
315 if (index == notFound) | 317 if (index == notFound) |
316 return; | 318 return; |
317 | 319 |
| 320 switch (component->source()->type()) { |
| 321 case MediaStreamSource::TypeAudio: |
| 322 m_descriptor->removeAudioComponent(component); |
| 323 break; |
| 324 case MediaStreamSource::TypeVideo: |
| 325 m_descriptor->removeAudioComponent(component); |
| 326 break; |
| 327 } |
| 328 |
318 RefPtr<MediaStreamTrack> track = (*tracks)[index]; | 329 RefPtr<MediaStreamTrack> track = (*tracks)[index]; |
319 tracks->remove(index); | 330 tracks->remove(index); |
320 scheduleDispatchEvent(MediaStreamTrackEvent::create(eventNames().removetrack
Event, false, false, track)); | 331 scheduleDispatchEvent(MediaStreamTrackEvent::create(eventNames().removetrack
Event, false, false, track)); |
321 } | 332 } |
322 | 333 |
323 void MediaStream::scheduleDispatchEvent(PassRefPtr<Event> event) | 334 void MediaStream::scheduleDispatchEvent(PassRefPtr<Event> event) |
324 { | 335 { |
325 m_scheduledEvents.append(event); | 336 m_scheduledEvents.append(event); |
326 | 337 |
327 if (!m_scheduledEventTimer.isActive()) | 338 if (!m_scheduledEventTimer.isActive()) |
(...skipping 11 matching lines...) Expand all Loading... |
339 Vector<RefPtr<Event> >::iterator it = events.begin(); | 350 Vector<RefPtr<Event> >::iterator it = events.begin(); |
340 for (; it != events.end(); ++it) | 351 for (; it != events.end(); ++it) |
341 dispatchEvent((*it).release()); | 352 dispatchEvent((*it).release()); |
342 | 353 |
343 events.clear(); | 354 events.clear(); |
344 } | 355 } |
345 | 356 |
346 } // namespace WebCore | 357 } // namespace WebCore |
347 | 358 |
348 #endif // ENABLE(MEDIA_STREAM) | 359 #endif // ENABLE(MEDIA_STREAM) |
OLD | NEW |