MediaStreamPrivate::create should take vectors of Ref
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Nov 2016 17:46:10 +0000 (17:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Nov 2016 17:46:10 +0000 (17:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164670

Patch by Youenn Fablet <youenn@apple.com> on 2016-11-14
Reviewed by Sam Weinig.

No change of behavior.

* Modules/webaudio/MediaStreamAudioDestinationNode.cpp:
(WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode):
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::create):
* platform/mediastream/MediaStreamPrivate.h:
* platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
(WebCore::RealtimeMediaSourceCenterMac::createMediaStream):
* platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
(WebCore::RealtimeMediaSourceCenterOwr::mediaSourcesAvailable):
* platform/mock/MockRealtimeMediaSourceCenter.cpp:
(WebCore::MockRealtimeMediaSourceCenter::createMediaStream):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208687 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp
Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp
Source/WebCore/platform/mediastream/MediaStreamPrivate.h
Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp
Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp
Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp

index dc33bb8..1893a8c 100644 (file)
@@ -1,3 +1,24 @@
+2016-11-14  Youenn Fablet  <youenn@apple.com>
+
+        MediaStreamPrivate::create should take vectors of Ref
+        https://bugs.webkit.org/show_bug.cgi?id=164670
+
+        Reviewed by Sam Weinig.
+
+        No change of behavior.
+
+        * Modules/webaudio/MediaStreamAudioDestinationNode.cpp:
+        (WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode):
+        * platform/mediastream/MediaStreamPrivate.cpp:
+        (WebCore::MediaStreamPrivate::create):
+        * platform/mediastream/MediaStreamPrivate.h:
+        * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
+        (WebCore::RealtimeMediaSourceCenterMac::createMediaStream):
+        * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
+        (WebCore::RealtimeMediaSourceCenterOwr::mediaSourcesAvailable):
+        * platform/mock/MockRealtimeMediaSourceCenter.cpp:
+        (WebCore::MockRealtimeMediaSourceCenter::createMediaStream):
+
 2016-11-14  Joanmarie Diggs  <jdiggs@igalia.com>
 
         AX: [ATK] Expose STATE_SINGLE_LINE and STATE_MULTI_LINE for ARIA searchbox role
index 7af3c1c..808db38 100644 (file)
@@ -49,8 +49,9 @@ MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(AudioContext& c
     setNodeType(NodeTypeMediaStreamAudioDestination);
 
     m_source = MediaStreamAudioSource::create();
-    Vector<RefPtr<RealtimeMediaSource>> audioSources(1, m_source);
-    m_stream = MediaStream::create(*context.scriptExecutionContext(), MediaStreamPrivate::create(WTFMove(audioSources), Vector<RefPtr<RealtimeMediaSource>>()));
+    Vector<Ref<RealtimeMediaSource>> audioSources;
+    audioSources.append(*m_source);
+    m_stream = MediaStream::create(*context.scriptExecutionContext(), MediaStreamPrivate::create(audioSources, { }));
 
     m_source->setAudioFormat(numberOfChannels, context.sampleRate());
 
index 6a44298..8071412 100644 (file)
 
 namespace WebCore {
 
-RefPtr<MediaStreamPrivate> MediaStreamPrivate::create(const Vector<RefPtr<RealtimeMediaSource>>& audioSources, const Vector<RefPtr<RealtimeMediaSource>>& videoSources)
+Ref<MediaStreamPrivate> MediaStreamPrivate::create(const Vector<Ref<RealtimeMediaSource>>& audioSources, const Vector<Ref<RealtimeMediaSource>>& videoSources)
 {
     MediaStreamTrackPrivateVector tracks;
-    tracks.reserveCapacity(audioSources.size() + videoSources.size());
+    tracks.reserveInitialCapacity(audioSources.size() + videoSources.size());
 
-    for (auto source : audioSources) {
-        ASSERT(source);
-        tracks.append(MediaStreamTrackPrivate::create(source.releaseNonNull()));
-    }
+    for (auto& source : audioSources)
+        tracks.uncheckedAppend(MediaStreamTrackPrivate::create(source.copyRef()));
 
-    for (auto source : videoSources) {
-        ASSERT(source);
-        tracks.append(MediaStreamTrackPrivate::create(source.releaseNonNull()));
-    }
+    for (auto& source : videoSources)
+        tracks.uncheckedAppend(MediaStreamTrackPrivate::create(source.copyRef()));
 
     return MediaStreamPrivate::create(tracks);
 }
 
-RefPtr<MediaStreamPrivate> MediaStreamPrivate::create(const MediaStreamTrackPrivateVector& tracks)
+Ref<MediaStreamPrivate> MediaStreamPrivate::create(const MediaStreamTrackPrivateVector& tracks)
 {
-    return adoptRef(new MediaStreamPrivate(createCanonicalUUIDString(), tracks));
+    return adoptRef(*new MediaStreamPrivate(createCanonicalUUIDString(), tracks));
 }
 
 MediaStreamPrivate::MediaStreamPrivate(const String& id, const MediaStreamTrackPrivateVector& tracks)
index 387aa67..cde3d5d 100644 (file)
@@ -68,8 +68,8 @@ public:
         virtual void didRemoveTrack(MediaStreamTrackPrivate&) { }
     };
 
-    static RefPtr<MediaStreamPrivate> create(const Vector<RefPtr<RealtimeMediaSource>>& audioSources, const Vector<RefPtr<RealtimeMediaSource>>& videoSources);
-    static RefPtr<MediaStreamPrivate> create(const MediaStreamTrackPrivateVector&);
+    static Ref<MediaStreamPrivate> create(const Vector<Ref<RealtimeMediaSource>>& audioSources, const Vector<Ref<RealtimeMediaSource>>& videoSources);
+    static Ref<MediaStreamPrivate> create(const MediaStreamTrackPrivateVector&);
 
     virtual ~MediaStreamPrivate();
 
index 1f966aa..be7ba11 100644 (file)
@@ -93,8 +93,8 @@ void RealtimeMediaSourceCenterMac::validateRequestConstraints(ValidConstraintsHa
 
 void RealtimeMediaSourceCenterMac::createMediaStream(NewMediaStreamHandler completionHandler, const String& audioDeviceID, const String& videoDeviceID, const MediaConstraints* audioConstraints, const MediaConstraints* videoConstraints)
 {
-    Vector<RefPtr<RealtimeMediaSource>> audioSources;
-    Vector<RefPtr<RealtimeMediaSource>> videoSources;
+    Vector<Ref<RealtimeMediaSource>> audioSources;
+    Vector<Ref<RealtimeMediaSource>> videoSources;
     String invalidConstraint;
 
     if (!audioDeviceID.isEmpty()) {
@@ -105,7 +105,7 @@ void RealtimeMediaSourceCenterMac::createMediaStream(NewMediaStreamHandler compl
 #endif
 
         if (audioSource)
-            audioSources.append(WTFMove(audioSource));
+            audioSources.append(audioSource.releaseNonNull());
     }
     if (!videoDeviceID.isEmpty()) {
         auto videoSource = AVCaptureDeviceManager::singleton().sourceWithUID(videoDeviceID, RealtimeMediaSource::Video, videoConstraints, invalidConstraint);
@@ -114,7 +114,7 @@ void RealtimeMediaSourceCenterMac::createMediaStream(NewMediaStreamHandler compl
             LOG(Media, "RealtimeMediaSourceCenterMac::createMediaStream(%p), video constraints failed to apply: %s", this, invalidConstraint.utf8().data());
 #endif
         if (videoSource)
-            videoSources.append(WTFMove(videoSource));
+            videoSources.append(videoSource.releaseNonNull());
     }
 
     if (videoSources.isEmpty() && audioSources.isEmpty())
index 9877a3e..67c91b8 100644 (file)
@@ -120,8 +120,8 @@ Vector<CaptureDevice> RealtimeMediaSourceCenterOwr::getMediaStreamDevices()
 
 void RealtimeMediaSourceCenterOwr::mediaSourcesAvailable(GList* sources)
 {
-    Vector<RefPtr<RealtimeMediaSource>> audioSources;
-    Vector<RefPtr<RealtimeMediaSource>> videoSources;
+    Vector<Ref<RealtimeMediaSource>> audioSources;
+    Vector<Ref<RealtimeMediaSource>> videoSources;
 
     for (auto item = sources; item; item = item->next) {
         OwrMediaSource* source = OWR_MEDIA_SOURCE(item->data);
@@ -149,16 +149,16 @@ void RealtimeMediaSourceCenterOwr::mediaSourcesAvailable(GList* sources)
             ASSERT_NOT_REACHED();
         }
 
-        RefPtr<RealtimeMediaSourceOwr> mediaSource = adoptRef(new RealtimeMediaSourceOwr(source, id, mediaSourceType, sourceName));
+        auto mediaSource = adoptRef(*new RealtimeMediaSourceOwr(source, id, mediaSourceType, sourceName));
 
         RealtimeMediaSourceOwrMap::iterator sourceIterator = m_sourceMap.find(id);
         if (sourceIterator == m_sourceMap.end())
-            m_sourceMap.add(id, mediaSource);
+            m_sourceMap.add(id, mediaSource.copyRef());
 
         if (mediaType & OWR_MEDIA_TYPE_AUDIO)
-            audioSources.append(mediaSource);
+            audioSources.append(WTFMove(mediaSource));
         else if (mediaType & OWR_MEDIA_TYPE_VIDEO)
-            videoSources.append(mediaSource);
+            videoSources.append(WTFMove(mediaSource));
     }
 
     if (videoSources.isEmpty() && audioSources.isEmpty())
index f7e6af3..bda24d5 100644 (file)
@@ -100,19 +100,19 @@ void MockRealtimeMediaSourceCenter::validateRequestConstraints(ValidConstraintsH
 
 void MockRealtimeMediaSourceCenter::createMediaStream(NewMediaStreamHandler completionHandler, const String& audioDeviceID, const String& videoDeviceID, const MediaConstraints* audioConstraints, const MediaConstraints* videoConstraints)
 {
-    Vector<RefPtr<RealtimeMediaSource>> audioSources;
-    Vector<RefPtr<RealtimeMediaSource>> videoSources;
+    Vector<Ref<RealtimeMediaSource>> audioSources;
+    Vector<Ref<RealtimeMediaSource>> videoSources;
 
     if (audioDeviceID == MockRealtimeMediaSource::mockAudioSourcePersistentID()) {
         auto source = MockRealtimeAudioSource::create(MockRealtimeMediaSource::mockAudioSourceName(), audioConstraints);
         if (source)
-            audioSources.append(source.leakRef());
+            audioSources.append(source.releaseNonNull());
     }
 
     if (videoDeviceID == MockRealtimeMediaSource::mockVideoSourcePersistentID()) {
         auto source = MockRealtimeVideoSource::create(MockRealtimeMediaSource::mockVideoSourceName(), videoConstraints);
         if (source)
-            videoSources.append(source.leakRef());
+            videoSources.append(source.releaseNonNull());
     }
 
     if (videoSources.isEmpty() && audioSources.isEmpty())