Title: [155434] trunk/Source/WebCore
- Revision
- 155434
- Author
- [email protected]
- Date
- 2013-09-10 06:30:10 -0700 (Tue, 10 Sep 2013)
Log Message
MediaStream API: Enhance MediaStreamDescriptor add/remove component
https://bugs.webkit.org/show_bug.cgi?id=120874
Merge blink https://chromium.googlesource.com/chromium/blink/+/67fcacf13ce922a762d7a1c6fb9e1b8e51e662ea
Patch by Thiago de Barros Lacerda <[email protected]> on 2013-09-10
Reviewed by Eric Carlson.
No new tests needed.
* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::addTrack):
(WebCore::MediaStream::removeTrack):
(WebCore::MediaStream::addRemoteTrack):
(WebCore::MediaStream::removeRemoteTrack):
* platform/mediastream/MediaStreamDescriptor.h:
(WebCore::MediaStreamDescriptor::addRemoteTrack):
(WebCore::MediaStreamDescriptor::removeRemoteTrack):
(WebCore::MediaStreamDescriptor::addComponent):
(WebCore::MediaStreamDescriptor::removeComponent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (155433 => 155434)
--- trunk/Source/WebCore/ChangeLog 2013-09-10 13:11:46 UTC (rev 155433)
+++ trunk/Source/WebCore/ChangeLog 2013-09-10 13:30:10 UTC (rev 155434)
@@ -1,3 +1,25 @@
+2013-09-10 Thiago de Barros Lacerda <[email protected]>
+
+ MediaStream API: Enhance MediaStreamDescriptor add/remove component
+ https://bugs.webkit.org/show_bug.cgi?id=120874
+
+ Merge blink https://chromium.googlesource.com/chromium/blink/+/67fcacf13ce922a762d7a1c6fb9e1b8e51e662ea
+
+ Reviewed by Eric Carlson.
+
+ No new tests needed.
+
+ * Modules/mediastream/MediaStream.cpp:
+ (WebCore::MediaStream::addTrack):
+ (WebCore::MediaStream::removeTrack):
+ (WebCore::MediaStream::addRemoteTrack):
+ (WebCore::MediaStream::removeRemoteTrack):
+ * platform/mediastream/MediaStreamDescriptor.h:
+ (WebCore::MediaStreamDescriptor::addRemoteTrack):
+ (WebCore::MediaStreamDescriptor::removeRemoteTrack):
+ (WebCore::MediaStreamDescriptor::addComponent):
+ (WebCore::MediaStreamDescriptor::removeComponent):
+
2013-09-10 Andreas Kling <[email protected]>
toFooElement() should use static_cast, not reinterpret_cast.
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp (155433 => 155434)
--- trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp 2013-09-10 13:11:46 UTC (rev 155433)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp 2013-09-10 13:30:10 UTC (rev 155434)
@@ -155,15 +155,14 @@
switch (component->source()->type()) {
case MediaStreamSource::TypeAudio:
- m_descriptor->addAudioComponent(component.release());
m_audioTracks.append(newTrack);
break;
case MediaStreamSource::TypeVideo:
- m_descriptor->addVideoComponent(component.release());
m_videoTracks.append(newTrack);
break;
}
+ m_descriptor->addComponent(component.release());
MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor.get(), newTrack->component());
}
@@ -181,25 +180,25 @@
RefPtr<MediaStreamTrack> track = prpTrack;
+ size_t pos = notFound;
switch (track->component()->source()->type()) {
- case MediaStreamSource::TypeAudio: {
- size_t pos = m_audioTracks.find(track);
- if (pos != notFound) {
+ case MediaStreamSource::TypeAudio:
+ pos = m_audioTracks.find(track);
+ if (pos != notFound)
m_audioTracks.remove(pos);
- m_descriptor->removeAudioComponent(track->component());
- }
break;
- }
- case MediaStreamSource::TypeVideo: {
- size_t pos = m_videoTracks.find(track);
- if (pos != notFound) {
+ case MediaStreamSource::TypeVideo:
+ pos = m_videoTracks.find(track);
+ if (pos != notFound)
m_videoTracks.remove(pos);
- m_descriptor->removeVideoComponent(track->component());
- }
break;
}
- }
+ if (pos == notFound)
+ return;
+
+ m_descriptor->removeComponent(track->component());
+
if (!m_audioTracks.size() && !m_videoTracks.size())
m_descriptor->setEnded();
@@ -280,14 +279,13 @@
RefPtr<MediaStreamTrack> track = MediaStreamTrack::create(scriptExecutionContext(), component);
switch (component->source()->type()) {
case MediaStreamSource::TypeAudio:
- m_descriptor->addAudioComponent(component);
m_audioTracks.append(track);
break;
case MediaStreamSource::TypeVideo:
- m_descriptor->addVideoComponent(component);
m_videoTracks.append(track);
break;
}
+ m_descriptor->addComponent(component);
scheduleDispatchEvent(MediaStreamTrackEvent::create(eventNames().addtrackEvent, false, false, track));
}
@@ -317,14 +315,7 @@
if (index == notFound)
return;
- switch (component->source()->type()) {
- case MediaStreamSource::TypeAudio:
- m_descriptor->removeAudioComponent(component);
- break;
- case MediaStreamSource::TypeVideo:
- m_descriptor->removeAudioComponent(component);
- break;
- }
+ m_descriptor->removeComponent(component);
RefPtr<MediaStreamTrack> track = (*tracks)[index];
tracks->remove(index);
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamDescriptor.h (155433 => 155434)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamDescriptor.h 2013-09-10 13:11:46 UTC (rev 155433)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamDescriptor.h 2013-09-10 13:30:10 UTC (rev 155434)
@@ -74,36 +74,57 @@
unsigned numberOfAudioComponents() const { return m_audioComponents.size(); }
MediaStreamComponent* audioComponent(unsigned index) const { return m_audioComponents[index].get(); }
- void addAudioComponent(PassRefPtr<MediaStreamComponent> component) { m_audioComponents.append(component); }
- void removeAudioComponent(MediaStreamComponent* component)
- {
- size_t pos = m_audioComponents.find(component);
- if (pos != notFound)
- m_audioComponents.remove(pos);
- }
void addRemoteTrack(MediaStreamComponent* component)
{
if (m_client)
m_client->addRemoteTrack(component);
+ else
+ addComponent(component);
}
void removeRemoteTrack(MediaStreamComponent* component)
{
if (m_client)
m_client->removeRemoteTrack(component);
+ else
+ removeComponent(component);
}
unsigned numberOfVideoComponents() const { return m_videoComponents.size(); }
MediaStreamComponent* videoComponent(unsigned index) const { return m_videoComponents[index].get(); }
- void addVideoComponent(PassRefPtr<MediaStreamComponent> component) { m_videoComponents.append(component); }
- void removeVideoComponent(MediaStreamComponent* component)
+
+ void addComponent(PassRefPtr<MediaStreamComponent> component)
{
- size_t pos = m_videoComponents.find(component);
- if (pos != notFound)
- m_videoComponents.remove(pos);
+ switch (component->source()->type()) {
+ case MediaStreamSource::TypeAudio:
+ if (m_audioComponents.find(component) == notFound)
+ m_audioComponents.append(component);
+ break;
+ case MediaStreamSource::TypeVideo:
+ if (m_videoComponents.find(component) == notFound)
+ m_videoComponents.append(component);
+ break;
+ }
}
+ void removeComponent(PassRefPtr<MediaStreamComponent> component)
+ {
+ size_t pos = notFound;
+ switch (component->source()->type()) {
+ case MediaStreamSource::TypeAudio:
+ pos = m_audioComponents.find(component);
+ if (pos != notFound)
+ m_audioComponents.remove(pos);
+ break;
+ case MediaStreamSource::TypeVideo:
+ pos = m_videoComponents.find(component);
+ if (pos != notFound)
+ m_videoComponents.remove(pos);
+ break;
+ }
+ }
+
bool ended() const { return m_ended; }
void setEnded() { m_ended = true; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes