Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/MediaStream.cpp

Issue 1362933003: Remove MediaStream label, ended attributes and stop() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
166 if (!iter->get()->ended()) 166 if (!iter->get()->ended())
167 return false; 167 return false;
168 } 168 }
169 for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter) { 169 for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter) {
170 if (!iter->get()->ended()) 170 if (!iter->get()->ended())
171 return false; 171 return false;
172 } 172 }
173 return true; 173 return true;
174 } 174 }
175 175
176 bool MediaStream::ended() const
177 {
178 return m_stopped || m_descriptor->ended();
179 }
180
181 MediaStreamTrackVector MediaStream::getTracks() 176 MediaStreamTrackVector MediaStream::getTracks()
182 { 177 {
183 MediaStreamTrackVector tracks; 178 MediaStreamTrackVector tracks;
184 for (MediaStreamTrackVector::iterator iter = m_audioTracks.begin(); iter != m_audioTracks.end(); ++iter) 179 for (MediaStreamTrackVector::iterator iter = m_audioTracks.begin(); iter != m_audioTracks.end(); ++iter)
185 tracks.append(iter->get()); 180 tracks.append(iter->get());
186 for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter) 181 for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter)
187 tracks.append(iter->get()); 182 tracks.append(iter->get());
188 return tracks; 183 return tracks;
189 } 184 }
190 185
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 MediaStream* MediaStream::clone(ExecutionContext* context) 264 MediaStream* MediaStream::clone(ExecutionContext* context)
270 { 265 {
271 MediaStreamTrackVector tracks; 266 MediaStreamTrackVector tracks;
272 for (MediaStreamTrackVector::iterator iter = m_audioTracks.begin(); iter != m_audioTracks.end(); ++iter) 267 for (MediaStreamTrackVector::iterator iter = m_audioTracks.begin(); iter != m_audioTracks.end(); ++iter)
273 tracks.append((*iter)->clone(context)); 268 tracks.append((*iter)->clone(context));
274 for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter) 269 for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter)
275 tracks.append((*iter)->clone(context)); 270 tracks.append((*iter)->clone(context));
276 return MediaStream::create(context, tracks); 271 return MediaStream::create(context, tracks);
277 } 272 }
278 273
279 void MediaStream::stop()
280 {
281 if (ended())
282 return;
283
284 streamEnded();
285
286 MediaStreamCenter::instance().didStopLocalMediaStream(descriptor());
287 }
288
289 void MediaStream::trackEnded() 274 void MediaStream::trackEnded()
290 { 275 {
291 for (MediaStreamTrackVector::iterator iter = m_audioTracks.begin(); iter != m_audioTracks.end(); ++iter) { 276 for (MediaStreamTrackVector::iterator iter = m_audioTracks.begin(); iter != m_audioTracks.end(); ++iter) {
292 if (!(*iter)->ended()) 277 if (!(*iter)->ended())
293 return; 278 return;
294 } 279 }
295 280
296 for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter) { 281 for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter) {
297 if (!(*iter)->ended()) 282 if (!(*iter)->ended())
298 return; 283 return;
299 } 284 }
300 285
301 streamEnded(); 286 streamEnded();
302 } 287 }
303 288
304 void MediaStream::streamEnded() 289 void MediaStream::streamEnded()
305 { 290 {
306 if (ended()) 291 if (m_stopped || m_descriptor->ended())
307 return; 292 return;
308 293
309 if (active()) { 294 if (active()) {
310 m_descriptor->setActive(false); 295 m_descriptor->setActive(false);
311 scheduleDispatchEvent(Event::create(EventTypeNames::inactive)); 296 scheduleDispatchEvent(Event::create(EventTypeNames::inactive));
312 } 297 }
313 m_descriptor->setEnded(); 298 m_descriptor->setEnded();
314 scheduleDispatchEvent(Event::create(EventTypeNames::ended)); 299 scheduleDispatchEvent(Event::create(EventTypeNames::ended));
315 } 300 }
316 301
317 void MediaStream::contextDestroyed() 302 void MediaStream::contextDestroyed()
318 { 303 {
319 ContextLifecycleObserver::contextDestroyed(); 304 ContextLifecycleObserver::contextDestroyed();
320 m_stopped = true; 305 m_stopped = true;
321 } 306 }
322 307
323 const AtomicString& MediaStream::interfaceName() const 308 const AtomicString& MediaStream::interfaceName() const
324 { 309 {
325 return EventTargetNames::MediaStream; 310 return EventTargetNames::MediaStream;
326 } 311 }
327 312
328 ExecutionContext* MediaStream::executionContext() const 313 ExecutionContext* MediaStream::executionContext() const
329 { 314 {
330 return ContextLifecycleObserver::executionContext(); 315 return ContextLifecycleObserver::executionContext();
331 } 316 }
332 317
333 void MediaStream::addRemoteTrack(MediaStreamComponent* component) 318 void MediaStream::addRemoteTrack(MediaStreamComponent* component)
334 { 319 {
335 ASSERT(component); 320 ASSERT(component);
336 if (ended()) 321 if (m_stopped || m_descriptor->ended())
337 return; 322 return;
338 323
339 MediaStreamTrack* track = MediaStreamTrack::create(executionContext(), compo nent); 324 MediaStreamTrack* track = MediaStreamTrack::create(executionContext(), compo nent);
340 switch (component->source()->type()) { 325 switch (component->source()->type()) {
341 case MediaStreamSource::TypeAudio: 326 case MediaStreamSource::TypeAudio:
342 m_audioTracks.append(track); 327 m_audioTracks.append(track);
343 break; 328 break;
344 case MediaStreamSource::TypeVideo: 329 case MediaStreamSource::TypeVideo:
345 m_videoTracks.append(track); 330 m_videoTracks.append(track);
346 break; 331 break;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 DEFINE_TRACE(MediaStream) 411 DEFINE_TRACE(MediaStream)
427 { 412 {
428 visitor->trace(m_audioTracks); 413 visitor->trace(m_audioTracks);
429 visitor->trace(m_videoTracks); 414 visitor->trace(m_videoTracks);
430 visitor->trace(m_scheduledEvents); 415 visitor->trace(m_scheduledEvents);
431 RefCountedGarbageCollectedEventTargetWithInlineData<MediaStream>::trace(visi tor); 416 RefCountedGarbageCollectedEventTargetWithInlineData<MediaStream>::trace(visi tor);
432 ContextLifecycleObserver::trace(visitor); 417 ContextLifecycleObserver::trace(visitor);
433 } 418 }
434 419
435 } // namespace blink 420 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698