Diff
Modified: trunk/Source/WebCore/ChangeLog (208541 => 208542)
--- trunk/Source/WebCore/ChangeLog 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/ChangeLog 2016-11-10 17:26:22 UTC (rev 208542)
@@ -1,3 +1,54 @@
+2016-11-10 Youenn Fablet <youe...@gmail.com>
+
+ MediaStreamTrack should use more Ref<> and less RefPtr<>
+ https://bugs.webkit.org/show_bug.cgi?id=164560
+
+ Reviewed by Eric Carlson.
+
+ No change of behavior.
+
+ Make MediaStreamTrack take a Ref<>& instead of a reference.
+ Using Ref<>&& instead of RefPtr<>&& in MediaStreamTrackPrivate.
+ Updating constness of some methods accordingly.
+
+ * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+ (WebCore::MediaEndpointPeerConnection::createReceiver):
+ * Modules/mediastream/MediaStreamTrack.cpp:
+ (WebCore::MediaStreamTrack::create):
+ (WebCore::MediaStreamTrack::MediaStreamTrack):
+ (WebCore::MediaStreamTrack::clone):
+ * Modules/mediastream/MediaStreamTrack.h:
+ * Modules/webaudio/MediaStreamAudioSource.cpp:
+ (WebCore::MediaStreamAudioSource::capabilities):
+ (WebCore::MediaStreamAudioSource::settings):
+ * Modules/webaudio/MediaStreamAudioSource.h:
+ * platform/mediastream/MediaEndpoint.cpp:
+ * platform/mediastream/MediaStreamPrivate.cpp:
+ (WebCore::MediaStreamPrivate::create):
+ * platform/mediastream/MediaStreamTrackPrivate.cpp:
+ (WebCore::MediaStreamTrackPrivate::create):
+ (WebCore::MediaStreamTrackPrivate::MediaStreamTrackPrivate):
+ (WebCore::MediaStreamTrackPrivate::clone):
+ * platform/mediastream/MediaStreamTrackPrivate.h:
+ (WebCore::MediaStreamTrackPrivate::setMuted):
+ (WebCore::MediaStreamTrackPrivate::source):
+ * platform/mediastream/RealtimeMediaSource.h:
+ * platform/mediastream/mac/AVMediaCaptureSource.h:
+ * platform/mediastream/mac/AVMediaCaptureSource.mm:
+ (WebCore::AVMediaCaptureSource::initializeSettings):
+ (WebCore::AVMediaCaptureSource::settings):
+ (WebCore::AVMediaCaptureSource::initializeCapabilities):
+ (WebCore::AVMediaCaptureSource::capabilities):
+ * platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h:
+ (WebCore::RealtimeMediaSourceOwr::capabilities):
+ (WebCore::RealtimeMediaSourceOwr::settings):
+ * platform/mock/MockRealtimeMediaSource.cpp:
+ (WebCore::MockRealtimeMediaSource::initializeCapabilities):
+ (WebCore::MockRealtimeMediaSource::capabilities):
+ (WebCore::MockRealtimeMediaSource::initializeSettings):
+ (WebCore::MockRealtimeMediaSource::settings):
+ * platform/mock/MockRealtimeMediaSource.h:
+
2016-11-10 Per Arne Vollan <pvol...@apple.com>
[Win32] Crash in layout tests.
Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp (208541 => 208542)
--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp 2016-11-10 17:26:22 UTC (rev 208542)
@@ -699,8 +699,8 @@
// Create a muted remote source that will be unmuted once media starts arriving.
auto remoteSource = m_mediaEndpoint->createMutedRemoteSource(transceiverMid, sourceType);
- auto remoteTrackPrivate = MediaStreamTrackPrivate::create(WTFMove(remoteSource), trackId);
- auto remoteTrack = MediaStreamTrack::create(*m_peerConnection.scriptExecutionContext(), *remoteTrackPrivate);
+ auto remoteTrackPrivate = MediaStreamTrackPrivate::create(WTFMove(remoteSource), String(trackId));
+ auto remoteTrack = MediaStreamTrack::create(*m_peerConnection.scriptExecutionContext(), WTFMove(remoteTrackPrivate));
return RTCRtpReceiver::create(WTFMove(remoteTrack));
}
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (208541 => 208542)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2016-11-10 17:26:22 UTC (rev 208542)
@@ -48,14 +48,14 @@
namespace WebCore {
-Ref<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack)
+Ref<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext& context, Ref<MediaStreamTrackPrivate>&& privateTrack)
{
- return adoptRef(*new MediaStreamTrack(context, privateTrack));
+ return adoptRef(*new MediaStreamTrack(context, WTFMove(privateTrack)));
}
-MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack)
+MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, Ref<MediaStreamTrackPrivate>&& privateTrack)
: ActiveDOMObject(&context)
- , m_private(privateTrack)
+ , m_private(WTFMove(privateTrack))
, m_weakPtrFactory(this)
{
suspendIfNeeded();
@@ -123,9 +123,9 @@
return m_ended || m_private->ended();
}
-RefPtr<MediaStreamTrack> MediaStreamTrack::clone()
+Ref<MediaStreamTrack> MediaStreamTrack::clone()
{
- return MediaStreamTrack::create(*scriptExecutionContext(), *m_private->clone());
+ return MediaStreamTrack::create(*scriptExecutionContext(), m_private->clone());
}
void MediaStreamTrack::stopProducingData()
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h (208541 => 208542)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2016-11-10 17:26:22 UTC (rev 208542)
@@ -56,7 +56,7 @@
virtual void trackDidEnd() = 0;
};
- static Ref<MediaStreamTrack> create(ScriptExecutionContext&, MediaStreamTrackPrivate&);
+ static Ref<MediaStreamTrack> create(ScriptExecutionContext&, Ref<MediaStreamTrackPrivate>&&);
virtual ~MediaStreamTrack();
const AtomicString& kind() const;
@@ -75,7 +75,7 @@
bool ended() const;
- RefPtr<MediaStreamTrack> clone();
+ Ref<MediaStreamTrack> clone();
void stopProducingData();
RefPtr<MediaTrackConstraints> getConstraints() const;
@@ -85,7 +85,7 @@
void applyConstraints(Ref<MediaConstraints>&&, DOMPromise<void>&&);
void applyConstraints(const MediaConstraints&);
- RealtimeMediaSource& source() const { return m_private->source(); }
+ RealtimeMediaSource& source() { return m_private->source(); }
MediaStreamTrackPrivate& privateTrack() { return m_private.get(); }
AudioSourceProvider* audioSourceProvider();
@@ -101,7 +101,7 @@
using RefCounted<MediaStreamTrack>::deref;
private:
- MediaStreamTrack(ScriptExecutionContext&, MediaStreamTrackPrivate&);
+ MediaStreamTrack(ScriptExecutionContext&, Ref<MediaStreamTrackPrivate>&&);
explicit MediaStreamTrack(MediaStreamTrack&);
void configureTrackRendering();
Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp (208541 => 208542)
--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp 2016-11-10 17:26:22 UTC (rev 208542)
@@ -44,7 +44,7 @@
{
}
-RefPtr<RealtimeMediaSourceCapabilities> MediaStreamAudioSource::capabilities()
+RefPtr<RealtimeMediaSourceCapabilities> MediaStreamAudioSource::capabilities() const
{
// FIXME: implement this.
// https://bugs.webkit.org/show_bug.cgi?id=122430
@@ -52,7 +52,7 @@
return nullptr;
}
-const RealtimeMediaSourceSettings& MediaStreamAudioSource::settings()
+const RealtimeMediaSourceSettings& MediaStreamAudioSource::settings() const
{
// FIXME: implement this.
// https://bugs.webkit.org/show_bug.cgi?id=122430
Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h (208541 => 208542)
--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h 2016-11-10 17:26:22 UTC (rev 208542)
@@ -41,15 +41,15 @@
class AudioBus;
class RealtimeMediaSourceCapabilities;
-class MediaStreamAudioSource : public RealtimeMediaSource {
+class MediaStreamAudioSource final : public RealtimeMediaSource {
public:
static Ref<MediaStreamAudioSource> create();
~MediaStreamAudioSource() { }
- RefPtr<RealtimeMediaSourceCapabilities> capabilities() override;
- const RealtimeMediaSourceSettings& settings() override;
-
+ RefPtr<RealtimeMediaSourceCapabilities> capabilities() const final;
+ const RealtimeMediaSourceSettings& settings() const final;
+
const String& deviceId() const { return m_deviceId; }
void setDeviceId(const String& deviceId) { m_deviceId = deviceId; }
Modified: trunk/Source/WebCore/platform/mediastream/MediaEndpoint.cpp (208541 => 208542)
--- trunk/Source/WebCore/platform/mediastream/MediaEndpoint.cpp 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mediastream/MediaEndpoint.cpp 2016-11-10 17:26:22 UTC (rev 208542)
@@ -38,12 +38,12 @@
namespace WebCore {
-class EmptyRealtimeMediaSource : public RealtimeMediaSource {
+class EmptyRealtimeMediaSource final : public RealtimeMediaSource {
public:
static Ref<EmptyRealtimeMediaSource> create() { return adoptRef(*new EmptyRealtimeMediaSource()); }
- RefPtr<RealtimeMediaSourceCapabilities> capabilities() override { return nullptr; }
- const RealtimeMediaSourceSettings& settings() override { return m_sourceSettings; }
+ RefPtr<RealtimeMediaSourceCapabilities> capabilities() const final { return nullptr; }
+ const RealtimeMediaSourceSettings& settings() const final { return m_sourceSettings; }
private:
EmptyRealtimeMediaSource()
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp (208541 => 208542)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp 2016-11-10 17:26:22 UTC (rev 208542)
@@ -50,11 +50,15 @@
MediaStreamTrackPrivateVector tracks;
tracks.reserveCapacity(audioSources.size() + videoSources.size());
- for (auto source : audioSources)
- tracks.append(MediaStreamTrackPrivate::create(WTFMove(source)));
+ for (auto source : audioSources) {
+ ASSERT(source);
+ tracks.append(MediaStreamTrackPrivate::create(source.releaseNonNull()));
+ }
- for (auto source : videoSources)
- tracks.append(MediaStreamTrackPrivate::create(WTFMove(source)));
+ for (auto source : videoSources) {
+ ASSERT(source);
+ tracks.append(MediaStreamTrackPrivate::create(source.releaseNonNull()));
+ }
return MediaStreamPrivate::create(tracks);
}
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp (208541 => 208542)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp 2016-11-10 17:26:22 UTC (rev 208542)
@@ -37,19 +37,18 @@
namespace WebCore {
-RefPtr<MediaStreamTrackPrivate> MediaStreamTrackPrivate::create(RefPtr<RealtimeMediaSource>&& source)
+Ref<MediaStreamTrackPrivate> MediaStreamTrackPrivate::create(Ref<RealtimeMediaSource>&& source)
{
- return adoptRef(new MediaStreamTrackPrivate(WTFMove(source), createCanonicalUUIDString()));
+ return adoptRef(*new MediaStreamTrackPrivate(WTFMove(source), createCanonicalUUIDString()));
}
-RefPtr<MediaStreamTrackPrivate> MediaStreamTrackPrivate::create(RefPtr<RealtimeMediaSource>&& source, const String& id)
+Ref<MediaStreamTrackPrivate> MediaStreamTrackPrivate::create(Ref<RealtimeMediaSource>&& source, String&& id)
{
- return adoptRef(new MediaStreamTrackPrivate(WTFMove(source), id));
+ return adoptRef(*new MediaStreamTrackPrivate(WTFMove(source), WTFMove(id)));
}
MediaStreamTrackPrivate::MediaStreamTrackPrivate(const MediaStreamTrackPrivate& other)
- : RefCounted()
- , m_source(&other.source())
+ : m_source(other.m_source.copyRef())
, m_id(createCanonicalUUIDString())
, m_isEnabled(other.enabled())
, m_isEnded(other.ended())
@@ -57,10 +56,9 @@
m_source->addObserver(this);
}
-MediaStreamTrackPrivate::MediaStreamTrackPrivate(RefPtr<RealtimeMediaSource>&& source, const String& id)
- : RefCounted()
- , m_source(source)
- , m_id(id)
+MediaStreamTrackPrivate::MediaStreamTrackPrivate(Ref<RealtimeMediaSource>&& source, String&& id)
+ : m_source(WTFMove(source))
+ , m_id(WTFMove(id))
, m_isEnabled(true)
, m_isEnded(false)
{
@@ -132,9 +130,9 @@
observer->trackEnded(*this);
}
-RefPtr<MediaStreamTrackPrivate> MediaStreamTrackPrivate::clone()
+Ref<MediaStreamTrackPrivate> MediaStreamTrackPrivate::clone()
{
- return adoptRef(new MediaStreamTrackPrivate(*this));
+ return adoptRef(*new MediaStreamTrackPrivate(*this));
}
RealtimeMediaSource::Type MediaStreamTrackPrivate::type() const
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h (208541 => 208542)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h 2016-11-10 17:26:22 UTC (rev 208542)
@@ -53,10 +53,10 @@
virtual void trackEnabledChanged(MediaStreamTrackPrivate&) = 0;
virtual void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) { };
};
-
- static RefPtr<MediaStreamTrackPrivate> create(RefPtr<RealtimeMediaSource>&&);
- static RefPtr<MediaStreamTrackPrivate> create(RefPtr<RealtimeMediaSource>&&, const String& id);
+ static Ref<MediaStreamTrackPrivate> create(Ref<RealtimeMediaSource>&&);
+ static Ref<MediaStreamTrackPrivate> create(Ref<RealtimeMediaSource>&&, String&& id);
+
virtual ~MediaStreamTrackPrivate();
const String& id() const { return m_id; }
@@ -69,7 +69,7 @@
bool isProducingData() { return m_source->isProducingData(); }
bool muted() const;
- void setMuted(bool muted) const { m_source->setMuted(muted); }
+ void setMuted(bool muted) { m_source->setMuted(muted); }
bool readonly() const;
bool remote() const;
@@ -77,9 +77,9 @@
bool enabled() const { return m_isEnabled; }
void setEnabled(bool);
- RefPtr<MediaStreamTrackPrivate> clone();
+ Ref<MediaStreamTrackPrivate> clone();
- RealtimeMediaSource& source() const { return *m_source.get(); }
+ RealtimeMediaSource& source() { return m_source.get(); }
RealtimeMediaSource::Type type() const;
void endTrack();
@@ -99,7 +99,7 @@
private:
explicit MediaStreamTrackPrivate(const MediaStreamTrackPrivate&);
- MediaStreamTrackPrivate(RefPtr<RealtimeMediaSource>&&, const String& id);
+ MediaStreamTrackPrivate(Ref<RealtimeMediaSource>&&, String&& id);
// RealtimeMediaSourceObserver
void sourceStopped() final;
@@ -109,7 +109,7 @@
void sourceHasMoreMediaData(MediaSample&) final;
Vector<Observer*> m_observers;
- RefPtr<RealtimeMediaSource> m_source;
+ Ref<RealtimeMediaSource> m_source;
RefPtr<MediaConstraints> m_constraints;
String m_id;
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (208541 => 208542)
--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h 2016-11-10 17:26:22 UTC (rev 208542)
@@ -88,8 +88,8 @@
virtual unsigned fitnessScore() const { return m_fitnessScore; }
virtual void setFitnessScore(const unsigned fitnessScore) { m_fitnessScore = fitnessScore; }
- virtual RefPtr<RealtimeMediaSourceCapabilities> capabilities() = 0;
- virtual const RealtimeMediaSourceSettings& settings() = 0;
+ virtual RefPtr<RealtimeMediaSourceCapabilities> capabilities() const = 0;
+ virtual const RealtimeMediaSourceSettings& settings() const = 0;
using SuccessHandler = std::function<void()>;
using FailureHandler = std::function<void(const String& badConstraint, const String& errorString)>;
Modified: trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h (208541 => 208542)
--- trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h 2016-11-10 17:26:22 UTC (rev 208542)
@@ -53,10 +53,10 @@
virtual void captureOutputDidOutputSampleBufferFromConnection(AVCaptureOutput*, CMSampleBufferRef, AVCaptureConnection*) = 0;
virtual void captureSessionIsRunningDidChange(bool);
-
+
AVCaptureSession *session() const { return m_session.get(); }
- const RealtimeMediaSourceSettings& settings() override;
+ const RealtimeMediaSourceSettings& settings() const override;
void startProducingData() override;
void stopProducingData() override;
@@ -78,7 +78,7 @@
MediaConstraints* constraints() { return m_constraints.get(); }
RealtimeMediaSourceSupportedConstraints& supportedConstraints();
- RefPtr<RealtimeMediaSourceCapabilities> capabilities() override;
+ RefPtr<RealtimeMediaSourceCapabilities> capabilities() const override;
void setVideoSampleBufferDelegate(AVCaptureVideoDataOutput*);
void setAudioSampleBufferDelegate(AVCaptureAudioDataOutput*);
@@ -87,6 +87,9 @@
void setupSession();
void reset() override;
+ void initializeSettings();
+ void initializeCapabilities();
+
RealtimeMediaSourceSettings m_currentSettings;
RealtimeMediaSourceSupportedConstraints m_supportedConstraints;
RetainPtr<WebCoreAVMediaCaptureSourceObserver> m_objcObserver;
Modified: trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm (208541 => 208542)
--- trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm 2016-11-10 17:26:22 UTC (rev 208542)
@@ -163,7 +163,7 @@
[m_session.get() stopRunning];
}
-const RealtimeMediaSourceSettings& AVMediaCaptureSource::settings()
+void AVMediaCaptureSource::initializeSettings()
{
if (m_currentSettings.deviceId().isEmpty())
m_currentSettings.setSupportedConstraits(supportedConstraints());
@@ -170,6 +170,11 @@
m_currentSettings.setDeviceId(id());
updateSettings(m_currentSettings);
+}
+
+const RealtimeMediaSourceSettings& AVMediaCaptureSource::settings() const
+{
+ const_cast<AVMediaCaptureSource&>(*this).initializeSettings();
return m_currentSettings;
}
@@ -184,14 +189,18 @@
return m_supportedConstraints;
}
-RefPtr<RealtimeMediaSourceCapabilities> AVMediaCaptureSource::capabilities()
+void AVMediaCaptureSource::initializeCapabilities()
{
- if (!m_capabilities) {
- m_capabilities = RealtimeMediaSourceCapabilities::create(AVCaptureDeviceManager::singleton().supportedConstraints());
- m_capabilities->setDeviceId(id());
+ m_capabilities = RealtimeMediaSourceCapabilities::create(AVCaptureDeviceManager::singleton().supportedConstraints());
+ m_capabilities->setDeviceId(id());
- initializeCapabilities(*m_capabilities.get());
- }
+ initializeCapabilities(*m_capabilities.get());
+}
+
+RefPtr<RealtimeMediaSourceCapabilities> AVMediaCaptureSource::capabilities() const
+{
+ if (!m_capabilities)
+ const_cast<AVMediaCaptureSource&>(*this).initializeCapabilities();
return m_capabilities;
}
Modified: trunk/Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h (208541 => 208542)
--- trunk/Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h 2016-11-10 17:26:22 UTC (rev 208542)
@@ -72,8 +72,8 @@
setMuted(false);
}
- virtual RefPtr<RealtimeMediaSourceCapabilities> capabilities() { return m_capabilities; }
- virtual const RealtimeMediaSourceSettings& settings() { return m_currentSettings; }
+ virtual RefPtr<RealtimeMediaSourceCapabilities> capabilities() const { return m_capabilities; }
+ virtual const RealtimeMediaSourceSettings& settings() const { return m_currentSettings; }
OwrMediaSource* mediaSource() const { return m_mediaSource; }
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.cpp (208541 => 208542)
--- trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.cpp 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.cpp 2016-11-10 17:26:22 UTC (rev 208542)
@@ -90,19 +90,21 @@
setPersistentID(mockVideoSourcePersistentID());
}
-RefPtr<RealtimeMediaSourceCapabilities> MockRealtimeMediaSource::capabilities()
+void MockRealtimeMediaSource::initializeCapabilities()
{
- if (m_capabilities)
- return m_capabilities;
-
m_capabilities = RealtimeMediaSourceCapabilities::create(supportedConstraints());
m_capabilities->setDeviceId(id());
initializeCapabilities(*m_capabilities.get());
+}
+RefPtr<RealtimeMediaSourceCapabilities> MockRealtimeMediaSource::capabilities() const
+{
+ if (!m_capabilities)
+ const_cast<MockRealtimeMediaSource&>(*this).initializeCapabilities();
return m_capabilities;
}
-const RealtimeMediaSourceSettings& MockRealtimeMediaSource::settings()
+void MockRealtimeMediaSource::initializeSettings()
{
if (m_currentSettings.deviceId().isEmpty()) {
m_currentSettings.setSupportedConstraits(supportedConstraints());
@@ -110,6 +112,11 @@
}
updateSettings(m_currentSettings);
+}
+
+const RealtimeMediaSourceSettings& MockRealtimeMediaSource::settings() const
+{
+ const_cast<MockRealtimeMediaSource&>(*this).initializeSettings();
return m_currentSettings;
}
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.h (208541 => 208542)
--- trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.h 2016-11-10 17:23:01 UTC (rev 208541)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.h 2016-11-10 17:26:22 UTC (rev 208542)
@@ -72,14 +72,15 @@
void startProducingData() override;
void stopProducingData() override;
- RefPtr<RealtimeMediaSourceCapabilities> capabilities() override;
- const RealtimeMediaSourceSettings& settings() override;
+ RefPtr<RealtimeMediaSourceCapabilities> capabilities() const override;
+ const RealtimeMediaSourceSettings& settings() const override;
MediaConstraints& constraints() { return *m_constraints.get(); }
RealtimeMediaSourceSupportedConstraints& supportedConstraints();
private:
-
+ void initializeCapabilities();
+ void initializeSettings();
bool isProducingData() const override { return m_isProducingData; }
RealtimeMediaSourceSettings m_currentSettings;