| 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 12 matching lines...) Expand all  Loading... | 
|   23  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |   23  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
|   24  */ |   24  */ | 
|   25  |   25  | 
|   26 #include "config.h" |   26 #include "config.h" | 
|   27 #include "modules/mediastream/MediaStream.h" |   27 #include "modules/mediastream/MediaStream.h" | 
|   28  |   28  | 
|   29 #if ENABLE(MEDIA_STREAM) |   29 #if ENABLE(MEDIA_STREAM) | 
|   30  |   30  | 
|   31 #include "core/dom/Event.h" |   31 #include "core/dom/Event.h" | 
|   32 #include "core/dom/ExceptionCode.h" |   32 #include "core/dom/ExceptionCode.h" | 
|   33 #include "core/platform/UUID.h" |  | 
|   34 #include "core/platform/mediastream/MediaStreamCenter.h" |   33 #include "core/platform/mediastream/MediaStreamCenter.h" | 
|   35 #include "core/platform/mediastream/MediaStreamSource.h" |   34 #include "core/platform/mediastream/MediaStreamSource.h" | 
|   36 #include "modules/mediastream/MediaStreamTrackEvent.h" |   35 #include "modules/mediastream/MediaStreamTrackEvent.h" | 
|   37  |   36  | 
|   38 namespace WebCore { |   37 namespace WebCore { | 
|   39  |   38  | 
|   40 static bool containsSource(MediaStreamSourceVector& sourceVector, MediaStreamSou
     rce* source) |   39 static bool containsSource(MediaStreamSourceVector& sourceVector, MediaStreamSou
     rce* source) | 
|   41 { |   40 { | 
|   42     for (size_t i = 0; i < sourceVector.size(); ++i) { |   41     for (size_t i = 0; i < sourceVector.size(); ++i) { | 
|   43         if (source->id() == sourceVector[i]->id()) |   42         if (source->id() == sourceVector[i]->id()) | 
|   44             return true; |   43             return true; | 
|   45     } |   44     } | 
|   46     return false; |   45     return false; | 
|   47 } |   46 } | 
|   48  |   47  | 
|   49 static void processTrack(MediaStreamTrack* track, MediaStreamSourceVector& sourc
     eVector) |   48 static void processTrack(MediaStreamTrack* track, MediaStreamSourceVector& sourc
     eVector) | 
|   50 { |   49 { | 
|   51     if (track->ended()) |   50     if (track->ended()) | 
|   52         return; |   51         return; | 
|   53  |   52  | 
|   54     MediaStreamSource* source = track->component()->source(); |   53     MediaStreamSource* source = track->component()->source(); | 
|   55     if (!containsSource(sourceVector, source)) |   54     if (!containsSource(sourceVector, source)) | 
|   56         sourceVector.append(source); |   55         sourceVector.append(source); | 
|   57 } |   56 } | 
|   58  |   57  | 
|   59 static PassRefPtr<MediaStream> createFromSourceVectors(ScriptExecutionContext* c
     ontext, const MediaStreamSourceVector& audioSources, const MediaStreamSourceVect
     or& videoSources) |   58 static PassRefPtr<MediaStream> createFromSourceVectors(ScriptExecutionContext* c
     ontext, const MediaStreamSourceVector& audioSources, const MediaStreamSourceVect
     or& videoSources) | 
|   60 { |   59 { | 
|   61     RefPtr<MediaStreamDescriptor> descriptor = MediaStreamDescriptor::create(cre
     ateCanonicalUUIDString(), audioSources, videoSources); |   60     RefPtr<MediaStreamDescriptor> descriptor = MediaStreamDescriptor::create(aud
     ioSources, videoSources); | 
|   62     MediaStreamCenter::instance().didCreateMediaStream(descriptor.get()); |   61     MediaStreamCenter::instance().didCreateMediaStream(descriptor.get()); | 
|   63  |   62  | 
|   64     return MediaStream::create(context, descriptor.release()); |   63     return MediaStream::create(context, descriptor.release()); | 
|   65 } |   64 } | 
|   66  |   65  | 
|   67 PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context) |   66 PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context) | 
|   68 { |   67 { | 
|   69     MediaStreamSourceVector audioSources; |   68     MediaStreamSourceVector audioSources; | 
|   70     MediaStreamSourceVector videoSources; |   69     MediaStreamSourceVector videoSources; | 
|   71  |   70  | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  214     } |  213     } | 
|  215  |  214  | 
|  216     for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != 
     m_videoTracks.end(); ++iter) { |  215     for (MediaStreamTrackVector::iterator iter = m_videoTracks.begin(); iter != 
     m_videoTracks.end(); ++iter) { | 
|  217         if ((*iter)->id() == id) |  216         if ((*iter)->id() == id) | 
|  218             return (*iter).get(); |  217             return (*iter).get(); | 
|  219     } |  218     } | 
|  220  |  219  | 
|  221     return 0; |  220     return 0; | 
|  222 } |  221 } | 
|  223  |  222  | 
 |  223 void MediaStream::stop() | 
 |  224 { | 
 |  225     if (ended()) | 
 |  226         return; | 
 |  227  | 
 |  228     MediaStreamCenter::instance().didStopLocalMediaStream(descriptor()); | 
 |  229  | 
 |  230     streamEnded(); | 
 |  231 } | 
 |  232  | 
|  224 void MediaStream::trackEnded() |  233 void MediaStream::trackEnded() | 
|  225 { |  234 { | 
|  226     for (size_t i = 0; i < m_audioTracks.size(); ++i) |  235     for (size_t i = 0; i < m_audioTracks.size(); ++i) | 
|  227         if (!m_audioTracks[i]->ended()) |  236         if (!m_audioTracks[i]->ended()) | 
|  228             return; |  237             return; | 
|  229  |  238  | 
|  230     for (size_t i = 0; i < m_videoTracks.size(); ++i) |  239     for (size_t i = 0; i < m_videoTracks.size(); ++i) | 
|  231         if (!m_videoTracks[i]->ended()) |  240         if (!m_videoTracks[i]->ended()) | 
|  232             return; |  241             return; | 
|  233  |  242  | 
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  342     Vector<RefPtr<Event> >::iterator it = events.begin(); |  351     Vector<RefPtr<Event> >::iterator it = events.begin(); | 
|  343     for (; it != events.end(); ++it) |  352     for (; it != events.end(); ++it) | 
|  344         dispatchEvent((*it).release()); |  353         dispatchEvent((*it).release()); | 
|  345  |  354  | 
|  346     events.clear(); |  355     events.clear(); | 
|  347 } |  356 } | 
|  348  |  357  | 
|  349 } // namespace WebCore |  358 } // namespace WebCore | 
|  350  |  359  | 
|  351 #endif // ENABLE(MEDIA_STREAM) |  360 #endif // ENABLE(MEDIA_STREAM) | 
| OLD | NEW |