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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 | 129 |
130 bool MediaStream::ended() const | 130 bool MediaStream::ended() const |
131 { | 131 { |
132 return m_stopped || m_descriptor->ended(); | 132 return m_stopped || m_descriptor->ended(); |
133 } | 133 } |
134 | 134 |
135 void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode&
ec) | 135 void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode&
ec) |
136 { | 136 { |
137 if (ended()) { | 137 if (ended()) { |
138 ec = INVALID_STATE_ERR; | 138 ec = InvalidStateError; |
139 return; | 139 return; |
140 } | 140 } |
141 | 141 |
142 if (!prpTrack) { | 142 if (!prpTrack) { |
143 ec = TYPE_MISMATCH_ERR; | 143 ec = TypeMismatchError; |
144 return; | 144 return; |
145 } | 145 } |
146 | 146 |
147 RefPtr<MediaStreamTrack> track = prpTrack; | 147 RefPtr<MediaStreamTrack> track = prpTrack; |
148 | 148 |
149 if (getTrackById(track->id())) | 149 if (getTrackById(track->id())) |
150 return; | 150 return; |
151 | 151 |
152 RefPtr<MediaStreamComponent> component = MediaStreamComponent::create(m_desc
riptor.get(), track->component()->source()); | 152 RefPtr<MediaStreamComponent> component = MediaStreamComponent::create(m_desc
riptor.get(), track->component()->source()); |
153 RefPtr<MediaStreamTrack> newTrack = MediaStreamTrack::create(scriptExecution
Context(), component.get()); | 153 RefPtr<MediaStreamTrack> newTrack = MediaStreamTrack::create(scriptExecution
Context(), component.get()); |
154 | 154 |
155 switch (component->source()->type()) { | 155 switch (component->source()->type()) { |
156 case MediaStreamSource::TypeAudio: | 156 case MediaStreamSource::TypeAudio: |
157 m_audioTracks.append(newTrack); | 157 m_audioTracks.append(newTrack); |
158 break; | 158 break; |
159 case MediaStreamSource::TypeVideo: | 159 case MediaStreamSource::TypeVideo: |
160 m_videoTracks.append(newTrack); | 160 m_videoTracks.append(newTrack); |
161 break; | 161 break; |
162 } | 162 } |
163 | 163 |
164 m_descriptor->addComponent(component.release()); | 164 m_descriptor->addComponent(component.release()); |
165 | 165 |
166 MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor.get(), new
Track->component()); | 166 MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor.get(), new
Track->component()); |
167 } | 167 } |
168 | 168 |
169 void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCo
de& ec) | 169 void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCo
de& ec) |
170 { | 170 { |
171 if (ended()) { | 171 if (ended()) { |
172 ec = INVALID_STATE_ERR; | 172 ec = InvalidStateError; |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 if (!prpTrack) { | 176 if (!prpTrack) { |
177 ec = TYPE_MISMATCH_ERR; | 177 ec = TypeMismatchError; |
178 return; | 178 return; |
179 } | 179 } |
180 | 180 |
181 RefPtr<MediaStreamTrack> track = prpTrack; | 181 RefPtr<MediaStreamTrack> track = prpTrack; |
182 | 182 |
183 size_t pos = notFound; | 183 size_t pos = notFound; |
184 switch (track->component()->source()->type()) { | 184 switch (track->component()->source()->type()) { |
185 case MediaStreamSource::TypeAudio: | 185 case MediaStreamSource::TypeAudio: |
186 pos = m_audioTracks.find(track); | 186 pos = m_audioTracks.find(track); |
187 if (pos != notFound) | 187 if (pos != notFound) |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 events.clear(); | 355 events.clear(); |
356 } | 356 } |
357 | 357 |
358 URLRegistry& MediaStream::registry() const | 358 URLRegistry& MediaStream::registry() const |
359 { | 359 { |
360 return MediaStreamRegistry::registry(); | 360 return MediaStreamRegistry::registry(); |
361 } | 361 } |
362 | 362 |
363 } // namespace WebCore | 363 } // namespace WebCore |
OLD | NEW |