| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 166 } |
| 167 | 167 |
| 168 void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionState
& exceptionState) | 168 void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionState
& exceptionState) |
| 169 { | 169 { |
| 170 if (ended()) { | 170 if (ended()) { |
| 171 exceptionState.throwDOMException(InvalidStateError, "The MediaStream is
finished."); | 171 exceptionState.throwDOMException(InvalidStateError, "The MediaStream is
finished."); |
| 172 return; | 172 return; |
| 173 } | 173 } |
| 174 | 174 |
| 175 if (!prpTrack) { | 175 if (!prpTrack) { |
| 176 exceptionState.throwDOMException(TypeMismatchError, "The MediaStreamTrac
k provided is invalid."); | 176 exceptionState.throwDOMException(TypeError, "The MediaStreamTrack provid
ed is invalid."); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 | 179 |
| 180 RefPtr<MediaStreamTrack> track = prpTrack; | 180 RefPtr<MediaStreamTrack> track = prpTrack; |
| 181 | 181 |
| 182 if (getTrackById(track->id())) | 182 if (getTrackById(track->id())) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 switch (track->component()->source()->type()) { | 185 switch (track->component()->source()->type()) { |
| 186 case MediaStreamSource::TypeAudio: | 186 case MediaStreamSource::TypeAudio: |
| 187 m_audioTracks.append(track); | 187 m_audioTracks.append(track); |
| 188 break; | 188 break; |
| 189 case MediaStreamSource::TypeVideo: | 189 case MediaStreamSource::TypeVideo: |
| 190 m_videoTracks.append(track); | 190 m_videoTracks.append(track); |
| 191 break; | 191 break; |
| 192 } | 192 } |
| 193 track->addObserver(this); | 193 track->addObserver(this); |
| 194 m_descriptor->addComponent(track->component()); | 194 m_descriptor->addComponent(track->component()); |
| 195 MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor.get(), tra
ck->component()); | 195 MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor.get(), tra
ck->component()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionSt
ate& exceptionState) | 198 void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionSt
ate& exceptionState) |
| 199 { | 199 { |
| 200 if (ended()) { | 200 if (ended()) { |
| 201 exceptionState.throwDOMException(InvalidStateError, "The MediaStream is
finished."); | 201 exceptionState.throwDOMException(InvalidStateError, "The MediaStream is
finished."); |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 | 204 |
| 205 if (!prpTrack) { | 205 if (!prpTrack) { |
| 206 exceptionState.throwDOMException(TypeMismatchError, "The MediaStreamTrac
k provided is invalid."); | 206 exceptionState.throwDOMException(TypeError, "The MediaStreamTrack provid
ed is invalid."); |
| 207 return; | 207 return; |
| 208 } | 208 } |
| 209 | 209 |
| 210 RefPtr<MediaStreamTrack> track = prpTrack; | 210 RefPtr<MediaStreamTrack> track = prpTrack; |
| 211 | 211 |
| 212 size_t pos = kNotFound; | 212 size_t pos = kNotFound; |
| 213 switch (track->component()->source()->type()) { | 213 switch (track->component()->source()->type()) { |
| 214 case MediaStreamSource::TypeAudio: | 214 case MediaStreamSource::TypeAudio: |
| 215 pos = m_audioTracks.find(track); | 215 pos = m_audioTracks.find(track); |
| 216 if (pos != kNotFound) | 216 if (pos != kNotFound) |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 387 |
| 388 events.clear(); | 388 events.clear(); |
| 389 } | 389 } |
| 390 | 390 |
| 391 URLRegistry& MediaStream::registry() const | 391 URLRegistry& MediaStream::registry() const |
| 392 { | 392 { |
| 393 return MediaStreamRegistry::registry(); | 393 return MediaStreamRegistry::registry(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 } // namespace WebCore | 396 } // namespace WebCore |
| OLD | NEW |