Changeset 223406 in webkit
- Timestamp:
- Oct 16, 2017 7:44:52 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 added
- 3 edited
- 1 copied
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r223338 r223406 2540 2540 platform/mediastream/RTCIceCandidateDescriptor.cpp 2541 2541 platform/mediastream/RTCSessionDescriptionDescriptor.cpp 2542 platform/mediastream/RealtimeIncomingVideoSource.cpp 2542 2543 platform/mediastream/RealtimeMediaSource.cpp 2543 2544 platform/mediastream/RealtimeMediaSourceCenter.cpp 2544 2545 platform/mediastream/RealtimeMediaSourceSettings.cpp 2546 platform/mediastream/RealtimeOutgoingVideoSource.cpp 2545 2547 2546 2548 platform/mediastream/libwebrtc/LibWebRTCProvider.cpp -
trunk/Source/WebCore/ChangeLog
r223389 r223406 1 2017-10-16 Alejandro G. Castro <alex@igalia.com> 2 3 Make RealtimeIncomingVideoSources and RealtimeOutgoingVideoSources port agnostic 4 https://bugs.webkit.org/show_bug.cgi?id=177869 5 6 Reviewed by Youenn Fablet. 7 8 Refactor the RealtimeIncomingVideoSource and RealtimeOutgoingVideoSource classes, 9 move the cocoa specific code to a different class. This way we can use them from 10 other ports. 11 12 No new functionality, just a refactor. 13 14 * CMakeLists.txt: 15 * WebCore.xcodeproj/project.pbxproj: 16 * platform/mediastream/RealtimeIncomingVideoSource.cpp: Moved from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.h. Just the port agnostic parts. 17 * platform/mediastream/RealtimeIncomingVideoSource.h: Moved from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.h. DItto 18 * platform/mediastream/RealtimeOutgoingVideoSource.cpp: Moved from Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp. Ditto 19 * platform/mediastream/RealtimeOutgoingVideoSource.h: Moved from Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h. Ditto 20 * platform/mediastream/mac/RealtimeIncomingVideoSourceMac.cpp: Added, it adds the Cocoa specific parts from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.cpp. 21 (WebCore::RealtimeIncomingVideoSource::create): Moved this function from the base class, it allows avoiding the include. 22 * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h: Added, cocoa dependent code from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.h. 23 (WebCore::RealtimeOutgoingVideoSource::create): Moved this funtion from the base class, now we can use the Cocoa create without including it in the base class. 24 * platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp: Added, cocoa dependent code. 25 * platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h: Added, cocoa dependent code. 26 1 27 2017-10-16 Manuel Rego Casasnovas <rego@igalia.com> 2 28 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r223332 r223406 2743 2743 5CD9F5681AA0F74600DA45FF /* DFABytecodeInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C3930611AA0F6A90029C816 /* DFABytecodeInterpreter.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2744 2744 5CDD833D1E4324D900621E92 /* RealtimeOutgoingVideoSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD833B1E4324BB00621E92 /* RealtimeOutgoingVideoSource.cpp */; }; 2745 5CDD833D1E4324D900621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD833B1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp */; }; 2745 2746 5CDD833E1E4324DC00621E92 /* RealtimeIncomingVideoSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD83391E4324BB00621E92 /* RealtimeIncomingVideoSource.cpp */; }; 2747 5CDD833E1E4324DC00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp */; }; 2746 2748 5CDD83641E4325A000621E92 /* LibWebRTCDataChannelHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD833F1E43253D00621E92 /* LibWebRTCDataChannelHandler.cpp */; }; 2747 2749 5CDFA6C81AA4F2DA00EA8746 /* ContentExtensionActions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CDFA6C71AA4F2DA00EA8746 /* ContentExtensionActions.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 10692 10694 5CDD83391E4324BB00621E92 /* RealtimeIncomingVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeIncomingVideoSource.cpp; sourceTree = "<group>"; }; 10693 10695 5CDD833A1E4324BB00621E92 /* RealtimeIncomingVideoSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeIncomingVideoSource.h; sourceTree = "<group>"; }; 10696 5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeIncomingVideoSourceCocoa.cpp; sourceTree = "<group>"; }; 10697 5CDD833A1E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeIncomingVideoSourceCocoa.h; sourceTree = "<group>"; }; 10694 10698 5CDD833B1E4324BB00621E92 /* RealtimeOutgoingVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeOutgoingVideoSource.cpp; sourceTree = "<group>"; }; 10695 10699 5CDD833C1E4324BB00621E92 /* RealtimeOutgoingVideoSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeOutgoingVideoSource.h; sourceTree = "<group>"; }; 10700 5CDD833B1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeOutgoingVideoSourceCocoa.cpp; sourceTree = "<group>"; }; 10701 5CDD833C1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeOutgoingVideoSourceCocoa.h; sourceTree = "<group>"; }; 10696 10702 5CDD833F1E43253D00621E92 /* LibWebRTCDataChannelHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCDataChannelHandler.cpp; path = libwebrtc/LibWebRTCDataChannelHandler.cpp; sourceTree = "<group>"; }; 10697 10703 5CDD83401E43253D00621E92 /* LibWebRTCDataChannelHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCDataChannelHandler.h; path = libwebrtc/LibWebRTCDataChannelHandler.h; sourceTree = "<group>"; }; … … 16551 16557 07FFDE67181AED420072D409 /* MediaStreamTrackPrivate.h */, 16552 16558 5EBB89381C77BDA400C65D41 /* PeerMediaDescription.h */, 16559 5CDD83391E4324BB00621E92 /* RealtimeIncomingVideoSource.cpp */, 16560 5CDD833A1E4324BB00621E92 /* RealtimeIncomingVideoSource.h */, 16553 16561 4A4F656B1AA997F100E38CDD /* RealtimeMediaSource.cpp */, 16554 16562 4A4F656C1AA997F100E38CDD /* RealtimeMediaSource.h */, … … 16560 16568 2EC41DE21C0410A300D294FE /* RealtimeMediaSourceSupportedConstraints.cpp */, 16561 16569 07C1C0E41BFB60ED00BD2256 /* RealtimeMediaSourceSupportedConstraints.h */, 16570 5CDD833B1E4324BB00621E92 /* RealtimeOutgoingVideoSource.cpp */, 16571 5CDD833C1E4324BB00621E92 /* RealtimeOutgoingVideoSource.h */, 16562 16572 3135910C1E7DDCB600F30630 /* RTCBundlePolicy.h */, 16563 16573 07221BA217CF0AD400848E51 /* RTCDataChannelHandler.h */, … … 16610 16620 41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */, 16611 16621 41103AA91E39790A00769F03 /* RealtimeIncomingAudioSource.h */, 16612 5CDD83391E4324BB00621E 92 /* RealtimeIncomingVideoSource.cpp */,16613 5CDD833A1E4324BB00621E 92 /* RealtimeIncomingVideoSource.h */,16622 5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp */, 16623 5CDD833A1E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.h */, 16614 16624 4A0FFAA31AAF5EF60062803B /* RealtimeMediaSourceCenterMac.cpp */, 16615 16625 4A0FFAA41AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h */, 16616 16626 41103AA71E39790A00769F03 /* RealtimeOutgoingAudioSource.cpp */, 16617 16627 41103AA81E39790A00769F03 /* RealtimeOutgoingAudioSource.h */, 16618 5CDD833B1E4324BB00621 E92 /* RealtimeOutgoingVideoSource.cpp */,16619 5CDD833C1E4324BB00621 E92 /* RealtimeOutgoingVideoSource.h */,16628 5CDD833B1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp */, 16629 5CDD833C1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.h */, 16620 16630 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */, 16621 16631 07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm */, … … 33730 33740 41103AAE1E39791000769F03 /* RealtimeIncomingAudioSource.cpp in Sources */, 33731 33741 5CDD833E1E4324DC00621E92 /* RealtimeIncomingVideoSource.cpp in Sources */, 33742 5CDD833E1E4324DC00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp in Sources */, 33732 33743 4A4F65701AA997F100E38CDD /* RealtimeMediaSource.cpp in Sources */, 33733 33744 4A0FFAA11AAF5EA20062803B /* RealtimeMediaSourceCenter.cpp in Sources */, … … 33737 33748 41103AAB1E39791000769F03 /* RealtimeOutgoingAudioSource.cpp in Sources */, 33738 33749 5CDD833D1E4324D900621E92 /* RealtimeOutgoingVideoSource.cpp in Sources */, 33750 5CDD833D1E4324D900621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp in Sources */, 33739 33751 FD45A95A175D417100C21EC8 /* RectangleShape.cpp in Sources */, 33740 33752 BCAB418113E356E800D8AAF3 /* Region.cpp in Sources */, -
trunk/Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.h
r223389 r223406 38 38 #include <wtf/RetainPtr.h> 39 39 40 using CMSampleBufferRef = struct opaqueCMSampleBuffer*;41 using CVPixelBufferRef = struct __CVBuffer*;42 43 40 namespace WebCore { 44 41 45 42 class CaptureDevice; 46 43 47 class RealtimeIncomingVideoSource final: public RealtimeMediaSource, private rtc::VideoSinkInterface<webrtc::VideoFrame> {44 class RealtimeIncomingVideoSource : public RealtimeMediaSource, private rtc::VideoSinkInterface<webrtc::VideoFrame> { 48 45 public: 49 46 static Ref<RealtimeIncomingVideoSource> create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&); … … 52 49 void setSourceTrack(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&); 53 50 54 pr ivate:51 protected: 55 52 RealtimeIncomingVideoSource(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&); 56 53 54 RealtimeMediaSourceSettings m_currentSettings; 55 56 private: 57 57 // RealtimeMediaSource API 58 58 void startProducingData() final; … … 62 62 const RealtimeMediaSourceSettings& settings() const final; 63 63 64 void processNewSample(CMSampleBufferRef, unsigned, unsigned, MediaSample::VideoRotation);65 66 64 bool applySize(const IntSize&) final { return true; } 67 65 68 // rtc::VideoSinkInterface69 void OnFrame(const webrtc::VideoFrame&) final;70 71 CVPixelBufferRef pixelBufferFromVideoFrame(const webrtc::VideoFrame&);72 73 RealtimeMediaSourceSettings m_currentSettings;74 66 rtc::scoped_refptr<webrtc::VideoTrackInterface> m_videoTrack; 75 RetainPtr<CMSampleBufferRef> m_buffer;76 RetainPtr<CVPixelBufferRef> m_blackFrame;77 int m_blackFrameWidth { 0 };78 int m_blackFrameHeight { 0 };79 #if !RELEASE_LOG_DISABLED80 size_t m_numberOfFrames { 0 };81 #endif82 67 }; 83 68 -
trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp
r223389 r223406 35 35 #include <webrtc/api/video/i420_buffer.h> 36 36 #include <webrtc/common_video/libyuv/include/webrtc_libyuv.h> 37 #include <webrtc/sdk/objc/Framework/Classes/Video/corevideo_frame_buffer.h>38 37 #include <wtf/CurrentTime.h> 39 38 #include <wtf/MainThread.h> 40 41 #include "CoreMediaSoftLink.h"42 #include "CoreVideoSoftLink.h"43 39 44 40 namespace WebCore { … … 112 108 113 109 updateBlackFramesSending(); 114 }115 116 bool RealtimeOutgoingVideoSource::GetStats(Stats*)117 {118 return false;119 110 } 120 111 … … 193 184 } 194 185 195 void RealtimeOutgoingVideoSource::videoSampleAvailable(MediaSample& sample)196 {197 if (!m_sinks.size())198 return;199 200 if (m_muted || !m_enabled)201 return;202 203 #if !RELEASE_LOG_DISABLED204 if (!(++m_numberOfFrames % 30))205 RELEASE_LOG(MediaStream, "RealtimeOutgoingVideoSource::sendFrame %zu frame", m_numberOfFrames);206 #endif207 208 switch (sample.videoRotation()) {209 case MediaSample::VideoRotation::None:210 m_currentRotation = webrtc::kVideoRotation_0;211 break;212 case MediaSample::VideoRotation::UpsideDown:213 m_currentRotation = webrtc::kVideoRotation_180;214 break;215 case MediaSample::VideoRotation::Right:216 m_currentRotation = webrtc::kVideoRotation_90;217 break;218 case MediaSample::VideoRotation::Left:219 m_currentRotation = webrtc::kVideoRotation_270;220 break;221 }222 223 ASSERT(sample.platformSample().type == PlatformSample::CMSampleBufferType);224 auto pixelBuffer = static_cast<CVPixelBufferRef>(CMSampleBufferGetImageBuffer(sample.platformSample().sample.cmSampleBuffer));225 auto pixelFormatType = CVPixelBufferGetPixelFormatType(pixelBuffer);226 227 if (pixelFormatType == kCVPixelFormatType_420YpCbCr8Planar || pixelFormatType == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) {228 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer = new rtc::RefCountedObject<webrtc::CoreVideoFrameBuffer>(pixelBuffer);229 if (m_shouldApplyRotation && m_currentRotation != webrtc::kVideoRotation_0) {230 // FIXME: We should make AVVideoCaptureSource handle the rotation whenever possible.231 // This implementation is inefficient, we should rotate on the CMSampleBuffer directly instead of doing this double allocation.232 auto rotatedBuffer = buffer->ToI420();233 ASSERT(rotatedBuffer);234 buffer = webrtc::I420Buffer::Rotate(*rotatedBuffer, m_currentRotation);235 }236 sendFrame(WTFMove(buffer));237 return;238 }239 240 CVPixelBufferLockBaseAddress(pixelBuffer, 0);241 auto* source = reinterpret_cast<uint8_t*>(CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0));242 243 ASSERT(m_width);244 ASSERT(m_height);245 246 auto newBuffer = m_bufferPool.CreateBuffer(m_width, m_height);247 ASSERT(newBuffer);248 if (!newBuffer) {249 RELEASE_LOG(WebRTC, "RealtimeOutgoingVideoSource::videoSampleAvailable unable to allocate buffer for conversion to YUV");250 return;251 }252 if (pixelFormatType == kCVPixelFormatType_32BGRA)253 webrtc::ConvertToI420(webrtc::VideoType::kARGB, source, 0, 0, m_width, m_height, 0, webrtc::kVideoRotation_0, newBuffer);254 else {255 ASSERT(pixelFormatType == kCVPixelFormatType_32ARGB);256 webrtc::ConvertToI420(webrtc::VideoType::kBGRA, source, 0, 0, m_width, m_height, 0, webrtc::kVideoRotation_0, newBuffer);257 }258 CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);259 if (m_shouldApplyRotation && m_currentRotation != webrtc::kVideoRotation_0)260 newBuffer = webrtc::I420Buffer::Rotate(*newBuffer, m_currentRotation);261 sendFrame(WTFMove(newBuffer));262 }263 264 186 } // namespace WebCore 265 187 -
trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h
r223389 r223406 43 43 namespace WebCore { 44 44 45 class RealtimeOutgoingVideoSource final: public ThreadSafeRefCounted<RealtimeOutgoingVideoSource>, public webrtc::VideoTrackSourceInterface, private MediaStreamTrackPrivate::Observer {45 class RealtimeOutgoingVideoSource : public ThreadSafeRefCounted<RealtimeOutgoingVideoSource>, public webrtc::VideoTrackSourceInterface, private MediaStreamTrackPrivate::Observer { 46 46 public: 47 static Ref<RealtimeOutgoingVideoSource> create(Ref<MediaStreamTrackPrivate>&& videoSource) { return adoptRef(*new RealtimeOutgoingVideoSource(WTFMove(videoSource))); }47 static Ref<RealtimeOutgoingVideoSource> create(Ref<MediaStreamTrackPrivate>&& videoSource); 48 48 ~RealtimeOutgoingVideoSource() { stop(); } 49 49 … … 57 57 void setApplyRotation(bool shouldApplyRotation) { m_shouldApplyRotation = shouldApplyRotation; } 58 58 59 pr ivate:60 RealtimeOutgoingVideoSource(Ref<MediaStreamTrackPrivate>&&);59 protected: 60 explicit RealtimeOutgoingVideoSource(Ref<MediaStreamTrackPrivate>&&); 61 61 62 62 void sendFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&&); 63 64 Vector<rtc::VideoSinkInterface<webrtc::VideoFrame>*> m_sinks; 65 webrtc::I420BufferPool m_bufferPool; 66 67 bool m_enabled { true }; 68 bool m_muted { false }; 69 uint32_t m_width { 0 }; 70 uint32_t m_height { 0 }; 71 bool m_shouldApplyRotation { false }; 72 webrtc::VideoRotation m_currentRotation { webrtc::kVideoRotation_0 }; 73 74 private: 63 75 void sendBlackFramesIfNeeded(); 64 76 void sendOneBlackFrame(); … … 73 85 bool is_screencast() const final { return false; } 74 86 rtc::Optional<bool> needs_denoising() const final { return rtc::Optional<bool>(); } 75 bool GetStats(Stats*) final ;87 bool GetStats(Stats*) final { return false; }; 76 88 77 89 // MediaSourceInterface API … … 85 97 void sourceMutedChanged(); 86 98 void sourceEnabledChanged(); 87 void videoSampleAvailable(MediaSample&);88 99 89 100 // MediaStreamTrackPrivate::Observer API … … 91 102 void trackEnabledChanged(MediaStreamTrackPrivate&) final { sourceEnabledChanged(); } 92 103 void trackSettingsChanged(MediaStreamTrackPrivate&) final { initializeFromSource(); } 93 void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample& sample) final { videoSampleAvailable(sample);}104 void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) override { } 94 105 void trackEnded(MediaStreamTrackPrivate&) final { } 95 106 96 Vector<rtc::VideoSinkInterface<webrtc::VideoFrame>*> m_sinks;97 webrtc::I420BufferPool m_bufferPool;98 107 Ref<MediaStreamTrackPrivate> m_videoSource; 99 bool m_enabled { true };100 bool m_muted { false };101 108 std::optional<RealtimeMediaSourceSettings> m_initialSettings; 102 webrtc::VideoRotation m_currentRotation { webrtc::kVideoRotation_0 };103 uint32_t m_width { 0 };104 uint32_t m_height { 0 };105 109 bool m_isStopped { false }; 106 110 Timer m_blackFrameTimer; 107 111 rtc::scoped_refptr<webrtc::VideoFrameBuffer> m_blackFrame; 108 bool m_shouldApplyRotation { false };109 #if !RELEASE_LOG_DISABLED110 size_t m_numberOfFrames { 0 };111 #endif112 112 }; 113 113 -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp
r223389 r223406 12 12 * in the documentation and/or other materials provided with the 13 13 * distribution. 14 * 3. Neither the name of Google Inc. nor the names of its contributors15 * may be used to endorse or promote products derived from this16 * software without specific prior written permission.17 14 * 18 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 30 27 31 28 #include "config.h" 32 #include "RealtimeIncomingVideoSource .h"29 #include "RealtimeIncomingVideoSourceCocoa.h" 33 30 34 31 #if USE(LIBWEBRTC) … … 45 42 Ref<RealtimeIncomingVideoSource> RealtimeIncomingVideoSource::create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& trackId) 46 43 { 47 auto source = adoptRef(*new RealtimeIncomingVideoSource(WTFMove(videoTrack), WTFMove(trackId)));44 auto source = RealtimeIncomingVideoSourceCocoa::create(WTFMove(videoTrack), WTFMove(trackId)); 48 45 source->start(); 49 return source;46 return WTFMove(source); 50 47 } 51 48 52 RealtimeIncomingVideoSource::RealtimeIncomingVideoSource(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& videoTrackId) 53 : RealtimeMediaSource(WTFMove(videoTrackId), RealtimeMediaSource::Type::Video, String()) 54 , m_videoTrack(WTFMove(videoTrack)) 49 Ref<RealtimeIncomingVideoSourceCocoa> RealtimeIncomingVideoSourceCocoa::create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& trackId) 55 50 { 56 m_currentSettings.setWidth(640); 57 m_currentSettings.setHeight(480); 58 notifyMutedChange(!m_videoTrack); 51 return adoptRef(*new RealtimeIncomingVideoSourceCocoa(WTFMove(videoTrack), WTFMove(trackId))); 59 52 } 60 53 61 void RealtimeIncomingVideoSource::startProducingData() 54 RealtimeIncomingVideoSourceCocoa::RealtimeIncomingVideoSourceCocoa(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& videoTrackId) 55 : RealtimeIncomingVideoSource(WTFMove(videoTrack), WTFMove(videoTrackId)) 62 56 { 63 if (m_videoTrack)64 m_videoTrack->AddOrUpdateSink(this, rtc::VideoSinkWants());65 57 } 66 58 67 void RealtimeIncomingVideoSource::setSourceTrack(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& track) 68 { 69 ASSERT(!m_videoTrack); 70 ASSERT(track); 71 72 m_videoTrack = WTFMove(track); 73 notifyMutedChange(!m_videoTrack); 74 if (isProducingData()) 75 m_videoTrack->AddOrUpdateSink(this, rtc::VideoSinkWants()); 76 } 77 78 void RealtimeIncomingVideoSource::stopProducingData() 79 { 80 if (m_videoTrack) 81 m_videoTrack->RemoveSink(this); 82 } 83 84 CVPixelBufferRef RealtimeIncomingVideoSource::pixelBufferFromVideoFrame(const webrtc::VideoFrame& frame) 59 CVPixelBufferRef RealtimeIncomingVideoSourceCocoa::pixelBufferFromVideoFrame(const webrtc::VideoFrame& frame) 85 60 { 86 61 if (muted()) { … … 111 86 } 112 87 113 void RealtimeIncomingVideoSource ::OnFrame(const webrtc::VideoFrame& frame)88 void RealtimeIncomingVideoSourceCocoa::OnFrame(const webrtc::VideoFrame& frame) 114 89 { 115 90 if (!isProducingData()) … … 118 93 #if !RELEASE_LOG_DISABLED 119 94 if (!(++m_numberOfFrames % 30)) 120 RELEASE_LOG(MediaStream, "RealtimeIncomingVideoSource ::OnFrame %zu frame", m_numberOfFrames);95 RELEASE_LOG(MediaStream, "RealtimeIncomingVideoSourceCocoa::OnFrame %zu frame", m_numberOfFrames); 121 96 #endif 122 97 … … 174 149 } 175 150 176 RefPtr<RealtimeIncomingVideoSource > protectedThis(this);177 callOnMainThread([protectedThis = WTFMove(protectedThis), sample = WTFMove(sample), width, height, rotation] {151 RefPtr<RealtimeIncomingVideoSourceCocoa> protectedThis(this); 152 callOnMainThread([protectedThis = makeRef(*this), sample = WTFMove(sample), width, height, rotation] { 178 153 protectedThis->processNewSample(sample.get(), width, height, rotation); 179 154 }); 180 155 } 181 156 182 void RealtimeIncomingVideoSource ::processNewSample(CMSampleBufferRef sample, unsigned width, unsigned height, MediaSample::VideoRotation rotation)157 void RealtimeIncomingVideoSourceCocoa::processNewSample(CMSampleBufferRef sample, unsigned width, unsigned height, MediaSample::VideoRotation rotation) 183 158 { 184 159 m_buffer = sample; … … 192 167 } 193 168 194 const RealtimeMediaSourceCapabilities& RealtimeIncomingVideoSource::capabilities() const195 {196 return RealtimeMediaSourceCapabilities::emptyCapabilities();197 }198 199 const RealtimeMediaSourceSettings& RealtimeIncomingVideoSource::settings() const200 {201 return m_currentSettings;202 }203 204 169 } // namespace WebCore 205 170 -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h
r223389 r223406 12 12 * in the documentation and/or other materials provided with the 13 13 * distribution. 14 * 3. Neither the name of Ericsson nor the names of its contributors15 * may be used to endorse or promote products derived from this16 * software without specific prior written permission.17 14 * 18 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 33 30 #if USE(LIBWEBRTC) 34 31 35 #include "LibWebRTCMacros.h" 36 #include "RealtimeMediaSource.h" 37 #include <webrtc/api/mediastreaminterface.h> 38 #include <wtf/RetainPtr.h> 32 #include "RealtimeIncomingVideoSource.h" 39 33 40 34 using CMSampleBufferRef = struct opaqueCMSampleBuffer*; … … 43 37 namespace WebCore { 44 38 45 class CaptureDevice; 46 47 class RealtimeIncomingVideoSource final : public RealtimeMediaSource, private rtc::VideoSinkInterface<webrtc::VideoFrame> { 39 class RealtimeIncomingVideoSourceCocoa final : public RealtimeIncomingVideoSource { 48 40 public: 49 static Ref<RealtimeIncomingVideoSource> create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&); 50 ~RealtimeIncomingVideoSource() { stopProducingData(); } 51 52 void setSourceTrack(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&); 41 static Ref<RealtimeIncomingVideoSourceCocoa> create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&); 53 42 54 43 private: 55 RealtimeIncomingVideoSource(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&); 56 57 // RealtimeMediaSource API 58 void startProducingData() final; 59 void stopProducingData() final; 60 61 const RealtimeMediaSourceCapabilities& capabilities() const final; 62 const RealtimeMediaSourceSettings& settings() const final; 63 44 RealtimeIncomingVideoSourceCocoa(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&); 64 45 void processNewSample(CMSampleBufferRef, unsigned, unsigned, MediaSample::VideoRotation); 65 66 bool applySize(const IntSize&) final { return true; } 46 CVPixelBufferRef pixelBufferFromVideoFrame(const webrtc::VideoFrame&); 67 47 68 48 // rtc::VideoSinkInterface 69 49 void OnFrame(const webrtc::VideoFrame&) final; 70 50 71 CVPixelBufferRef pixelBufferFromVideoFrame(const webrtc::VideoFrame&);72 73 RealtimeMediaSourceSettings m_currentSettings;74 rtc::scoped_refptr<webrtc::VideoTrackInterface> m_videoTrack;75 51 RetainPtr<CMSampleBufferRef> m_buffer; 76 52 RetainPtr<CVPixelBufferRef> m_blackFrame;
Note: See TracChangeset
for help on using the changeset viewer.