https://bugs.webkit.org/show_bug.cgi?id=120874
Merge blink https://chromium.googlesource.com/chromium/blink/+/
67fcacf13ce922a762d7a1c6fb9e1b8e51e662ea
Patch by Thiago de Barros Lacerda <thiago.lacerda@openbossa.org> 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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155434
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-09-10 Thiago de Barros Lacerda <thiago.lacerda@openbossa.org>
+
+ 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 <akling@apple.com>
toFooElement() should use static_cast, not reinterpret_cast.
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());
}
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();
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));
}
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);
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)
+ {
+ 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 = m_videoComponents.find(component);
- if (pos != notFound)
- m_videoComponents.remove(pos);
+ 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; }