Skip to content
Permalink
Browse files
[MediaStream] .ended shouldn't be part of MediaStream IDL
https://bugs.webkit.org/show_bug.cgi?id=132104

Patch by Praveen R Jadhav <praveen.j@samsung.com> on 2014-04-27
Reviewed by Eric Carlson.

Source/WebCore:
.ended attribute is spec'ed out of MediaStream IDL. Instead, .active
is introduced to handle more scenarios. This patch replaces all 'ended'
attribute calls with corresponding 'active' attributes.

MediaStream-add-remove-tracks.html is updated.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::addTrack): Replaced ended() with active().
(WebCore::MediaStream::removeTrack): setEnded() isn't called. setActive()
is retained which propagates oninactive event.
(WebCore::MediaStream::trackDidEnd): setEnded() isn't called.
(WebCore::MediaStream::removeRemoteSource): Replaced ended() with active().
(WebCore::MediaStream::addRemoteTrack): Replaced ended() with active().
(WebCore::MediaStream::removeRemoteTrack): Replaced ended() with active().
(WebCore::MediaStream::ended): Deleted.
(WebCore::MediaStream::setEnded): Deleted.
(WebCore::MediaStream::streamDidEnd): Deleted.
* Modules/mediastream/MediaStream.h:
* Modules/mediastream/MediaStream.idl:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::didRemoveRemoteStream): Replaced setEnded()
with setActive().
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::MediaStreamPrivate):
(WebCore::MediaStreamPrivate::setActive): Updated comment from bug
https://bugs.webkit.org/show_bug.cgi?id=131973
(WebCore::MediaStreamPrivate::setEnded): Deleted.
* platform/mediastream/MediaStreamPrivate.h:
(WebCore::MediaStreamPrivate::ended): Deleted.

LayoutTests:
.ended is not part of MediaStream IDL. Updated test case.

* fast/mediastream/MediaStream-add-remove-tracks-expected.txt:
* fast/mediastream/MediaStream-add-remove-tracks.html:

Canonical link: https://commits.webkit.org/150277@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
prjadhav authored and webkit-commit-queue committed Apr 28, 2014
1 parent 032e4a1 commit 1270f7d468be061641cfe863dfecbee0b2733b4b
Showing 10 changed files with 64 additions and 74 deletions.
@@ -1,3 +1,15 @@
2014-04-27 Praveen R Jadhav <praveen.j@samsung.com>

[MediaStream] .ended shouldn't be part of MediaStream IDL
https://bugs.webkit.org/show_bug.cgi?id=132104

Reviewed by Eric Carlson.

.ended is not part of MediaStream IDL. Updated test case.

* fast/mediastream/MediaStream-add-remove-tracks-expected.txt:
* fast/mediastream/MediaStream-add-remove-tracks.html:

2014-04-27 Tim Horton <timothy_horton@apple.com>

REGRESSION (167840): Layout Test fast/events/shadow-event-path[-2].html is failing
@@ -47,7 +47,6 @@ PASS stream1.getVideoTracks().length is 2
*** remove all tracks, stream.ended should return true
PASS stream2.getAudioTracks().length is 0
PASS stream2.getVideoTracks().length is 0
PASS stream2.ended is true

*** it should be impossible to add a track after the stream has ended
PASS stream2.addTrack(audioTrack) threw exception Error: InvalidStateError: DOM Exception 11.
@@ -129,7 +129,6 @@
tryRemoveTrack(stream2, stream2.getVideoTracks()[0]);
shouldBe('stream2.getAudioTracks().length', '0');
shouldBe('stream2.getVideoTracks().length', '0');
shouldBeTrue('stream2.ended');

debug("<br>*** it should be impossible to add a track after the stream has ended");
shouldThrow('stream2.addTrack(audioTrack)', '"Error: InvalidStateError: DOM Exception 11"');
@@ -1,3 +1,40 @@
2014-04-27 Praveen R Jadhav <praveen.j@samsung.com>

[MediaStream] .ended shouldn't be part of MediaStream IDL
https://bugs.webkit.org/show_bug.cgi?id=132104

Reviewed by Eric Carlson.

.ended attribute is spec'ed out of MediaStream IDL. Instead, .active
is introduced to handle more scenarios. This patch replaces all 'ended'
attribute calls with corresponding 'active' attributes.

MediaStream-add-remove-tracks.html is updated.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::addTrack): Replaced ended() with active().
(WebCore::MediaStream::removeTrack): setEnded() isn't called. setActive()
is retained which propagates oninactive event.
(WebCore::MediaStream::trackDidEnd): setEnded() isn't called.
(WebCore::MediaStream::removeRemoteSource): Replaced ended() with active().
(WebCore::MediaStream::addRemoteTrack): Replaced ended() with active().
(WebCore::MediaStream::removeRemoteTrack): Replaced ended() with active().
(WebCore::MediaStream::ended): Deleted.
(WebCore::MediaStream::setEnded): Deleted.
(WebCore::MediaStream::streamDidEnd): Deleted.
* Modules/mediastream/MediaStream.h:
* Modules/mediastream/MediaStream.idl:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::didRemoveRemoteStream): Replaced setEnded()
with setActive().
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::MediaStreamPrivate):
(WebCore::MediaStreamPrivate::setActive): Updated comment from bug
https://bugs.webkit.org/show_bug.cgi?id=131973
(WebCore::MediaStreamPrivate::setEnded): Deleted.
* platform/mediastream/MediaStreamPrivate.h:
(WebCore::MediaStreamPrivate::ended): Deleted.

2014-04-25 Andy Estes <aestes@apple.com>

[iOS] Stop creating a WKWebResourceQuickLookDelegate for every WebResourceLoader
@@ -114,18 +114,6 @@ MediaStream::~MediaStream()
m_private->setClient(0);
}

bool MediaStream::ended() const
{
return m_private->ended();
}

void MediaStream::setEnded()
{
if (ended())
return;
m_private->setEnded();
}

bool MediaStream::active() const
{
return m_private->active();
@@ -155,7 +143,7 @@ void MediaStream::cloneMediaStreamTrackVector(Vector<RefPtr<MediaStreamTrack>>&

void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode& ec)
{
if (ended()) {
if (!active()) {
ec = INVALID_STATE_ERR;
return;
}
@@ -190,7 +178,7 @@ bool MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack)

void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode& ec)
{
if (ended()) {
if (!active()) {
ec = INVALID_STATE_ERR;
return;
}
@@ -227,10 +215,8 @@ bool MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack)
m_private->removeSource(track->source());

track->removeObserver(this);
if (!m_audioTracks.size() && !m_videoTracks.size()) {
setEnded(); // FIXME : to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
if (!m_audioTracks.size() && !m_videoTracks.size())
setActive(false);
}

return true;
}
@@ -279,20 +265,10 @@ void MediaStream::trackDidEnd()
return;
}

setEnded(); // FIXME : to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104

if (!m_audioTracks.size() && !m_videoTracks.size())
setActive(false);
}

void MediaStream::streamDidEnd()
{
if (ended())
return;

scheduleDispatchEvent(Event::create(eventNames().endedEvent, false, false));
}

void MediaStream::setStreamIsActive(bool streamActive)
{
if (streamActive)
@@ -315,7 +291,7 @@ void MediaStream::addRemoteSource(MediaStreamSource* source)
void MediaStream::removeRemoteSource(MediaStreamSource* source)
{
ASSERT(source);
if (ended())
if (!active())
return;

Vector<RefPtr<MediaStreamTrack>>* tracks = trackVectorForType(source->type());
@@ -337,7 +313,7 @@ void MediaStream::removeRemoteSource(MediaStreamSource* source)
void MediaStream::addRemoteTrack(MediaStreamTrackPrivate* privateTrack)
{
ASSERT(privateTrack);
if (ended())
if (!active())
return;

RefPtr<MediaStreamTrack> track;
@@ -363,7 +339,7 @@ void MediaStream::addRemoteTrack(MediaStreamTrackPrivate* privateTrack)
void MediaStream::removeRemoteTrack(MediaStreamTrackPrivate* privateTrack)
{
ASSERT(privateTrack);
if (ended())
if (!active())
return;

RefPtr<MediaStreamTrack> track = getTrackById(privateTrack->id());
@@ -67,11 +67,8 @@ class MediaStream final : public RefCounted<MediaStream>, public URLRegistrable,
Vector<RefPtr<MediaStreamTrack>> getAudioTracks() const { return m_audioTracks; }
Vector<RefPtr<MediaStreamTrack>> getVideoTracks() const { return m_videoTracks; }

bool ended() const;
void setEnded();
PassRefPtr<MediaStream> clone();

DEFINE_ATTRIBUTE_EVENT_LISTENER(ended);
DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack);
DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack);

@@ -109,7 +106,6 @@ class MediaStream final : public RefCounted<MediaStream>, public URLRegistrable,

// MediaStreamPrivateClient
virtual void trackDidEnd() override final;
virtual void streamDidEnd() override final;
virtual void setStreamIsActive(bool) override final;
virtual void addRemoteSource(MediaStreamSource*) override final;
virtual void removeRemoteSource(MediaStreamSource*) override final;
@@ -42,16 +42,12 @@
MediaStreamTrack getTrackById(DOMString trackId);
MediaStream clone();

readonly attribute boolean ended;

attribute EventListener onended;
attribute EventListener onaddtrack;
attribute EventListener onremovetrack;

readonly attribute boolean active;

attribute EventListener onactive;
attribute EventListener oninactive;
attribute EventListener onaddtrack;
attribute EventListener onremovetrack;

// EventTarget interface
void addEventListener(DOMString type,
@@ -651,7 +651,7 @@ void RTCPeerConnection::didRemoveRemoteStream(MediaStreamPrivate* privateStream)

// FIXME: this class shouldn't know that the private stream client is a MediaStream!
RefPtr<MediaStream> stream = static_cast<MediaStream*>(privateStream->client());
stream->setEnded();
stream->setActive(false);

if (m_signalingState == SignalingStateClosed)
return;
@@ -128,7 +128,6 @@ void MediaStreamPrivate::removeRemoteTrack(MediaStreamTrackPrivate* track)
MediaStreamPrivate::MediaStreamPrivate(const String& id, const Vector<RefPtr<MediaStreamSource>>& audioSources, const Vector<RefPtr<MediaStreamSource>>& videoSources)
: m_client(0)
, m_id(id)
, m_ended(false)
, m_isActive(false)
{
ASSERT(m_id.length());
@@ -140,11 +139,6 @@ MediaStreamPrivate::MediaStreamPrivate(const String& id, const Vector<RefPtr<Med

unsigned providedSourcesSize = audioSources.size() + videoSources.size();
unsigned tracksSize = m_audioPrivateTracks.size() + m_videoPrivateTracks.size();
// If sources were provided and no track was added to the MediaStreamPrivate's tracks, this means
// that the tracks were all ended.
// Deprecated. to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
if (providedSourcesSize > 0 && !tracksSize)
m_ended = true;

if (providedSourcesSize > 0 && tracksSize > 0)
m_isActive = true;
@@ -153,7 +147,6 @@ MediaStreamPrivate::MediaStreamPrivate(const String& id, const Vector<RefPtr<Med
MediaStreamPrivate::MediaStreamPrivate(const String& id, const Vector<RefPtr<MediaStreamTrackPrivate>>& audioPrivateTracks, const Vector<RefPtr<MediaStreamTrackPrivate>>& videoPrivateTracks)
: m_client(0)
, m_id(id)
, m_ended(false)
, m_isActive(false)
{
ASSERT(m_id.length());
@@ -165,32 +158,20 @@ MediaStreamPrivate::MediaStreamPrivate(const String& id, const Vector<RefPtr<Med

unsigned providedTracksSize = audioPrivateTracks.size() + videoPrivateTracks.size();
unsigned tracksSize = m_audioPrivateTracks.size() + m_videoPrivateTracks.size();
// If tracks were provided and no one was added to the MediaStreamPrivate's tracks, this means
// that the tracks were all ended
// Deprecated. to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
if (providedTracksSize > 0 && !tracksSize)
m_ended = true;

if (providedTracksSize > 0 && tracksSize > 0)
m_isActive = true;
}

void MediaStreamPrivate::setEnded()
{
if (m_client)
m_client->streamDidEnd();

m_ended = true;
}

void MediaStreamPrivate::setActive(bool active)
{
if (m_isActive != active) {
m_isActive = active;
if (m_isActive == active)
return;

if (m_client)
m_client->setStreamIsActive(active);
}
m_isActive = active;

if (m_client)
m_client->setStreamIsActive(active);
}

void MediaStreamPrivate::addTrack(PassRefPtr<MediaStreamTrackPrivate> prpTrack)
@@ -49,7 +49,6 @@ class MediaStreamPrivateClient : public MediaStreamTrack::Observer {
public:
virtual ~MediaStreamPrivateClient() { }

virtual void streamDidEnd() = 0;
virtual void setStreamIsActive(bool) = 0;
virtual void addRemoteSource(MediaStreamSource*) = 0;
virtual void removeRemoteSource(MediaStreamSource*) = 0;
@@ -87,10 +86,6 @@ class MediaStreamPrivate : public RefCounted<MediaStreamPrivate> {
void addRemoteSource(MediaStreamSource*);
void removeRemoteSource(MediaStreamSource*);

// Deprecated. to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
bool ended() const { return m_ended; }
void setEnded();

bool active() const { return m_isActive; }
void setActive(bool);

@@ -111,7 +106,6 @@ class MediaStreamPrivate : public RefCounted<MediaStreamPrivate> {

Vector<RefPtr<MediaStreamTrackPrivate>> m_audioPrivateTracks;
Vector<RefPtr<MediaStreamTrackPrivate>> m_videoPrivateTracks;
bool m_ended; // Deprecated. to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
bool m_isActive;
};

0 comments on commit 1270f7d

Please sign in to comment.