Skip to content

Commit

Permalink
Remove MediaStreamDescriptor and call/use WebMediaStream directly (at…
Browse files Browse the repository at this point in the history
…tempt #3)

Previous attempts: https://codereview.chromium.org/16366004/ , https://codereview.chromium.org/16865014/

BUG=

Review URL: https://chromiumcodereview.appspot.com/17063005

git-svn-id: svn://svn.chromium.org/blink/trunk@152913 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
[email protected] committed Jun 22, 2013
1 parent 15f0594 commit 8e7c7ab
Show file tree
Hide file tree
Showing 34 changed files with 359 additions and 223 deletions.
2 changes: 1 addition & 1 deletion Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void WebMediaPlayerClientImpl::loadRequested()

void WebMediaPlayerClientImpl::loadInternal()
{
m_isMediaStream = WebCore::MediaStreamRegistry::registry().lookupMediaStreamDescriptor(m_url.string());
m_isMediaStream = !(WebCore::MediaStreamRegistry::registry().lookupWebMediaStream(m_url.string()).isNull());

#if ENABLE(WEB_AUDIO)
m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
Expand Down
3 changes: 1 addition & 2 deletions Source/WebKit/chromium/src/WebMediaStreamRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include "WebMediaStreamRegistry.h"

#include "core/platform/mediastream/MediaStreamDescriptor.h"
#include "modules/mediastream/MediaStreamRegistry.h"
#include "public/platform/WebMediaStream.h"
#include "public/platform/WebString.h"
Expand All @@ -45,7 +44,7 @@ namespace WebKit {

WebMediaStream WebMediaStreamRegistry::lookupMediaStreamDescriptor(const WebURL& url)
{
return WebMediaStream(MediaStreamRegistry::registry().lookupMediaStreamDescriptor(KURL(url).string()));
return WebMediaStream(MediaStreamRegistry::registry().lookupWebMediaStream(KURL(url).string()));
}

} // namespace WebKit
7 changes: 3 additions & 4 deletions Source/WebKit/chromium/src/WebUserMediaRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "WebSecurityOrigin.h"
#include "core/dom/Document.h"
#include "core/platform/mediastream/MediaConstraints.h"
#include "core/platform/mediastream/MediaStreamDescriptor.h"
#include "core/platform/mediastream/MediaStreamSource.h"
#include "modules/mediastream/UserMediaRequest.h"
#include "weborigin/SecurityOrigin.h"
Expand Down Expand Up @@ -102,10 +101,10 @@ WebDocument WebUserMediaRequest::ownerDocument() const
return WebDocument(m_private->ownerDocument());
}

void WebUserMediaRequest::requestSucceeded(const WebMediaStream& streamDescriptor)
void WebUserMediaRequest::requestSucceeded(const WebMediaStream& webStream)
{
ASSERT(!isNull() && !streamDescriptor.isNull());
m_private->succeed(streamDescriptor);
ASSERT(!isNull() && !webStream.isNull());
m_private->succeed(webStream);
}

void WebUserMediaRequest::requestFailed(const WebString& description)
Expand Down
5 changes: 3 additions & 2 deletions Source/core/core.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -3015,8 +3015,6 @@
'platform/mediastream/MediaStreamCenter.h',
'platform/mediastream/MediaStreamComponent.cpp',
'platform/mediastream/MediaStreamComponent.h',
'platform/mediastream/MediaStreamDescriptor.cpp',
'platform/mediastream/MediaStreamDescriptor.h',
'platform/mediastream/MediaStreamSource.cpp',
'platform/mediastream/MediaStreamSource.h',
'platform/mediastream/RTCConfiguration.h',
Expand Down Expand Up @@ -3608,6 +3606,9 @@
'platform/chromium/support/WebHTTPLoadInfo.cpp',
'platform/chromium/support/WebMediaConstraints.cpp',
'platform/chromium/support/WebMediaStream.cpp',
'platform/chromium/support/WebMediaStreamClient.h',
'platform/chromium/support/WebMediaStreamPrivate.cpp',
'platform/chromium/support/WebMediaStreamPrivate.h',
'platform/chromium/support/WebMediaStreamSource.cpp',
'platform/chromium/support/WebMediaStreamSourcesRequest.cpp',
'platform/chromium/support/WebMediaStreamTrack.cpp',
Expand Down
2 changes: 1 addition & 1 deletion Source/core/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ void HTMLMediaElement::loadResource(const KURL& initialURL, ContentType& content

LOG(Media, "HTMLMediaElement::loadResource - m_currentSrc -> %s", urlForLoggingMedia(m_currentSrc).utf8().data());

if (MediaStreamRegistry::registry().lookupMediaStreamDescriptor(url.string()))
if (!(MediaStreamRegistry::registry().lookupWebMediaStream(url.string()).isNull()))
removeBehaviorRestriction(RequireUserGestureForRateChangeRestriction);

if (m_sendProgressEvents)
Expand Down
89 changes: 65 additions & 24 deletions Source/core/platform/chromium/support/WebMediaStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include "public/platform/WebMediaStream.h"

#include "core/platform/UUID.h"
#include "core/platform/chromium/support/WebMediaStreamPrivate.h"
#include "core/platform/mediastream/MediaStreamComponent.h"
#include "core/platform/mediastream/MediaStreamDescriptor.h"
#include "core/platform/mediastream/MediaStreamSource.h"
#include "public/platform/WebMediaStreamSource.h"
#include "public/platform/WebMediaStreamTrack.h"
Expand All @@ -43,7 +43,7 @@ namespace WebKit {

namespace {

class ExtraDataContainer : public MediaStreamDescriptor::ExtraData {
class ExtraDataContainer : public WebMediaStreamPrivate::ExtraData {
public:
ExtraDataContainer(WebMediaStream::ExtraData* extraData) : m_extraData(adoptPtr(extraData)) { }

Expand All @@ -55,13 +55,8 @@ class ExtraDataContainer : public MediaStreamDescriptor::ExtraData {

} // namespace

WebMediaStream::WebMediaStream(const PassRefPtr<WebCore::MediaStreamDescriptor>& mediaStreamDescriptor)
: m_private(mediaStreamDescriptor)
{
}

WebMediaStream::WebMediaStream(WebCore::MediaStreamDescriptor* mediaStreamDescriptor)
: m_private(mediaStreamDescriptor)
WebMediaStream::WebMediaStream(WebMediaStreamPrivate* stream)
: m_private(stream)
{
}

Expand All @@ -82,7 +77,7 @@ WebString WebMediaStream::id() const

WebMediaStream::ExtraData* WebMediaStream::extraData() const
{
RefPtr<MediaStreamDescriptor::ExtraData> data = m_private->extraData();
RefPtr<WebMediaStreamPrivate::ExtraData> data = m_private->extraData();
if (!data)
return 0;
return static_cast<ExtraDataContainer*>(data.get())->extraData();
Expand Down Expand Up @@ -111,32 +106,78 @@ void WebMediaStream::videoTracks(WebVector<WebMediaStreamTrack>& webTracks) cons
webTracks.swap(result);
}

void WebMediaStream::addTrack(const WebMediaStreamTrack& track)
unsigned WebMediaStream::numberOfAudioComponents() const
{
return m_private->numberOfAudioComponents();
}

WebCore::MediaStreamComponent* WebMediaStream::audioComponent(unsigned index) const
{
return m_private->audioComponent(index);
}

unsigned WebMediaStream::numberOfVideoComponents() const
{
return m_private->numberOfVideoComponents();
}

WebCore::MediaStreamComponent* WebMediaStream::videoComponent(unsigned index) const
{
return m_private->videoComponent(index);
}

void WebMediaStream::addComponent(WebCore::MediaStreamComponent* component)
{
ASSERT(!isNull());
m_private->addRemoteTrack(track);
m_private->addComponent(component);
}

void WebMediaStream::removeTrack(const WebMediaStreamTrack& track)
void WebMediaStream::removeComponent(WebCore::MediaStreamComponent* component)
{
ASSERT(!isNull());
m_private->removeRemoteTrack(track);
m_private->removeComponent(component);
}

void WebMediaStream::trackEnded()
{
m_private->client()->trackEnded();
}

void WebMediaStream::streamEnded()
{
m_private->client()->streamEnded();
}

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

void WebMediaStream::setEnded()
{
m_private->setEnded();
}

WebMediaStream& WebMediaStream::operator=(const PassRefPtr<WebCore::MediaStreamDescriptor>& mediaStreamDescriptor)
WebMediaStreamClient* WebMediaStream::client()
{
m_private = mediaStreamDescriptor;
return *this;
return m_private->client();
}

WebMediaStream::operator PassRefPtr<WebCore::MediaStreamDescriptor>() const
void WebMediaStream::setClient(WebMediaStreamClient* client)
{
m_private->setClient(client);
}

void WebMediaStream::addTrack(const WebMediaStreamTrack& track)
{
return m_private.get();
ASSERT(!isNull());
m_private->addRemoteTrack(track);
}

WebMediaStream::operator WebCore::MediaStreamDescriptor*() const
void WebMediaStream::removeTrack(const WebMediaStreamTrack& track)
{
return m_private.get();
ASSERT(!isNull());
m_private->removeRemoteTrack(track);
}

void WebMediaStream::initialize(const WebString& label, const WebVector<WebMediaStreamSource>& audioSources, const WebVector<WebMediaStreamSource>& videoSources)
Expand All @@ -150,12 +191,12 @@ void WebMediaStream::initialize(const WebString& label, const WebVector<WebMedia
MediaStreamSource* source = videoSources[i];
video.append(MediaStreamComponent::create(source->id(), source));
}
m_private = MediaStreamDescriptor::create(label, audio, video);
m_private = WebMediaStreamPrivate::create(label, audio, video);
}

void WebMediaStream::initialize(const WebVector<WebMediaStreamTrack>& audioTracks, const WebVector<WebMediaStreamTrack>& videoTracks)
{
initialize(createCanonicalUUIDString(), audioTracks, videoTracks);
initialize(WebCore::createCanonicalUUIDString(), audioTracks, videoTracks);
}

void WebMediaStream::initialize(const WebString& label, const WebVector<WebMediaStreamTrack>& audioTracks, const WebVector<WebMediaStreamTrack>& videoTracks)
Expand All @@ -169,7 +210,7 @@ void WebMediaStream::initialize(const WebString& label, const WebVector<WebMedia
MediaStreamComponent* component = videoTracks[i];
video.append(component);
}
m_private = MediaStreamDescriptor::create(label, audio, video);
m_private = WebMediaStreamPrivate::create(label, audio, video);
}

void WebMediaStream::assign(const WebMediaStream& other)
Expand Down
50 changes: 50 additions & 0 deletions Source/core/platform/chromium/support/WebMediaStreamClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Ericsson nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef WebMediaStreamClient_h
#define WebMediaStreamClient_h

#include "core/platform/mediastream/MediaStreamComponent.h"

namespace WebKit {

class WebMediaStreamClient {
public:
virtual ~WebMediaStreamClient() { }

virtual void trackEnded() = 0;
virtual void streamEnded() = 0;
virtual void addRemoteTrack(WebCore::MediaStreamComponent*) = 0;
virtual void removeRemoteTrack(WebCore::MediaStreamComponent*) = 0;
};

} // namespace WebKit

#endif // WebMediaStreamClient_h
Loading

0 comments on commit 8e7c7ab

Please sign in to comment.