Changeset 223406 in webkit


Ignore:
Timestamp:
Oct 16, 2017 7:44:52 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Make RealtimeIncomingVideoSources and RealtimeOutgoingVideoSources port agnostic
https://bugs.webkit.org/show_bug.cgi?id=177869

Patch by Alejandro G. Castro <alex@igalia.com> on 2017-10-16
Reviewed by Youenn Fablet.

Refactor the RealtimeIncomingVideoSource and RealtimeOutgoingVideoSource classes,
move the cocoa specific code to a different class. This way we can use them from
other ports.

No new functionality, just a refactor.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/mediastream/RealtimeIncomingVideoSource.cpp: Moved from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.h. Just the port agnostic parts.
  • platform/mediastream/RealtimeIncomingVideoSource.h: Moved from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.h. DItto
  • platform/mediastream/RealtimeOutgoingVideoSource.cpp: Moved from Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp. Ditto
  • platform/mediastream/RealtimeOutgoingVideoSource.h: Moved from Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h. Ditto
  • platform/mediastream/mac/RealtimeIncomingVideoSourceMac.cpp: Added, it adds the Cocoa specific parts from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.cpp.

(WebCore::RealtimeIncomingVideoSource::create): Moved this function from the base class, it allows avoiding the include.

  • platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h: Added, cocoa dependent code from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.h.

(WebCore::RealtimeOutgoingVideoSource::create): Moved this funtion from the base class, now we can use the Cocoa create without including it in the base class.

  • platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp: Added, cocoa dependent code.
  • platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h: Added, cocoa dependent code.
Location:
trunk/Source/WebCore
Files:
3 added
3 edited
1 copied
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r223338 r223406  
    25402540    platform/mediastream/RTCIceCandidateDescriptor.cpp
    25412541    platform/mediastream/RTCSessionDescriptionDescriptor.cpp
     2542    platform/mediastream/RealtimeIncomingVideoSource.cpp
    25422543    platform/mediastream/RealtimeMediaSource.cpp
    25432544    platform/mediastream/RealtimeMediaSourceCenter.cpp
    25442545    platform/mediastream/RealtimeMediaSourceSettings.cpp
     2546    platform/mediastream/RealtimeOutgoingVideoSource.cpp
    25452547
    25462548    platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
  • trunk/Source/WebCore/ChangeLog

    r223389 r223406  
     12017-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
    1272017-10-16  Manuel Rego Casasnovas  <rego@igalia.com>
    228
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r223332 r223406  
    27432743                5CD9F5681AA0F74600DA45FF /* DFABytecodeInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C3930611AA0F6A90029C816 /* DFABytecodeInterpreter.h */; settings = {ATTRIBUTES = (Private, ); }; };
    27442744                5CDD833D1E4324D900621E92 /* RealtimeOutgoingVideoSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD833B1E4324BB00621E92 /* RealtimeOutgoingVideoSource.cpp */; };
     2745                5CDD833D1E4324D900621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD833B1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp */; };
    27452746                5CDD833E1E4324DC00621E92 /* RealtimeIncomingVideoSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD83391E4324BB00621E92 /* RealtimeIncomingVideoSource.cpp */; };
     2747                5CDD833E1E4324DC00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp */; };
    27462748                5CDD83641E4325A000621E92 /* LibWebRTCDataChannelHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD833F1E43253D00621E92 /* LibWebRTCDataChannelHandler.cpp */; };
    27472749                5CDFA6C81AA4F2DA00EA8746 /* ContentExtensionActions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CDFA6C71AA4F2DA00EA8746 /* ContentExtensionActions.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1069210694                5CDD83391E4324BB00621E92 /* RealtimeIncomingVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeIncomingVideoSource.cpp; sourceTree = "<group>"; };
    1069310695                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>"; };
    1069410698                5CDD833B1E4324BB00621E92 /* RealtimeOutgoingVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeOutgoingVideoSource.cpp; sourceTree = "<group>"; };
    1069510699                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>"; };
    1069610702                5CDD833F1E43253D00621E92 /* LibWebRTCDataChannelHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCDataChannelHandler.cpp; path = libwebrtc/LibWebRTCDataChannelHandler.cpp; sourceTree = "<group>"; };
    1069710703                5CDD83401E43253D00621E92 /* LibWebRTCDataChannelHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCDataChannelHandler.h; path = libwebrtc/LibWebRTCDataChannelHandler.h; sourceTree = "<group>"; };
     
    1655116557                                07FFDE67181AED420072D409 /* MediaStreamTrackPrivate.h */,
    1655216558                                5EBB89381C77BDA400C65D41 /* PeerMediaDescription.h */,
     16559                                5CDD83391E4324BB00621E92 /* RealtimeIncomingVideoSource.cpp */,
     16560                                5CDD833A1E4324BB00621E92 /* RealtimeIncomingVideoSource.h */,
    1655316561                                4A4F656B1AA997F100E38CDD /* RealtimeMediaSource.cpp */,
    1655416562                                4A4F656C1AA997F100E38CDD /* RealtimeMediaSource.h */,
     
    1656016568                                2EC41DE21C0410A300D294FE /* RealtimeMediaSourceSupportedConstraints.cpp */,
    1656116569                                07C1C0E41BFB60ED00BD2256 /* RealtimeMediaSourceSupportedConstraints.h */,
     16570                                5CDD833B1E4324BB00621E92 /* RealtimeOutgoingVideoSource.cpp */,
     16571                                5CDD833C1E4324BB00621E92 /* RealtimeOutgoingVideoSource.h */,
    1656216572                                3135910C1E7DDCB600F30630 /* RTCBundlePolicy.h */,
    1656316573                                07221BA217CF0AD400848E51 /* RTCDataChannelHandler.h */,
     
    1661016620                                41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */,
    1661116621                                41103AA91E39790A00769F03 /* RealtimeIncomingAudioSource.h */,
    16612                                 5CDD83391E4324BB00621E92 /* RealtimeIncomingVideoSource.cpp */,
    16613                                 5CDD833A1E4324BB00621E92 /* RealtimeIncomingVideoSource.h */,
     16622                                5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp */,
     16623                                5CDD833A1E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.h */,
    1661416624                                4A0FFAA31AAF5EF60062803B /* RealtimeMediaSourceCenterMac.cpp */,
    1661516625                                4A0FFAA41AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h */,
    1661616626                                41103AA71E39790A00769F03 /* RealtimeOutgoingAudioSource.cpp */,
    1661716627                                41103AA81E39790A00769F03 /* RealtimeOutgoingAudioSource.h */,
    16618                                 5CDD833B1E4324BB00621E92 /* RealtimeOutgoingVideoSource.cpp */,
    16619                                 5CDD833C1E4324BB00621E92 /* RealtimeOutgoingVideoSource.h */,
     16628                                5CDD833B1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp */,
     16629                                5CDD833C1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.h */,
    1662016630                                07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */,
    1662116631                                07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm */,
     
    3373033740                                41103AAE1E39791000769F03 /* RealtimeIncomingAudioSource.cpp in Sources */,
    3373133741                                5CDD833E1E4324DC00621E92 /* RealtimeIncomingVideoSource.cpp in Sources */,
     33742                                5CDD833E1E4324DC00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp in Sources */,
    3373233743                                4A4F65701AA997F100E38CDD /* RealtimeMediaSource.cpp in Sources */,
    3373333744                                4A0FFAA11AAF5EA20062803B /* RealtimeMediaSourceCenter.cpp in Sources */,
     
    3373733748                                41103AAB1E39791000769F03 /* RealtimeOutgoingAudioSource.cpp in Sources */,
    3373833749                                5CDD833D1E4324D900621E92 /* RealtimeOutgoingVideoSource.cpp in Sources */,
     33750                                5CDD833D1E4324D900621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp in Sources */,
    3373933751                                FD45A95A175D417100C21EC8 /* RectangleShape.cpp in Sources */,
    3374033752                                BCAB418113E356E800D8AAF3 /* Region.cpp in Sources */,
  • trunk/Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.h

    r223389 r223406  
    3838#include <wtf/RetainPtr.h>
    3939
    40 using CMSampleBufferRef = struct opaqueCMSampleBuffer*;
    41 using CVPixelBufferRef = struct __CVBuffer*;
    42 
    4340namespace WebCore {
    4441
    4542class CaptureDevice;
    4643
    47 class RealtimeIncomingVideoSource final : public RealtimeMediaSource, private rtc::VideoSinkInterface<webrtc::VideoFrame> {
     44class RealtimeIncomingVideoSource : public RealtimeMediaSource, private rtc::VideoSinkInterface<webrtc::VideoFrame> {
    4845public:
    4946    static Ref<RealtimeIncomingVideoSource> create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&);
     
    5249    void setSourceTrack(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&);
    5350
    54 private:
     51protected:
    5552    RealtimeIncomingVideoSource(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&);
    5653
     54    RealtimeMediaSourceSettings m_currentSettings;
     55
     56private:
    5757    // RealtimeMediaSource API
    5858    void startProducingData() final;
     
    6262    const RealtimeMediaSourceSettings& settings() const final;
    6363
    64     void processNewSample(CMSampleBufferRef, unsigned, unsigned, MediaSample::VideoRotation);
    65 
    6664    bool applySize(const IntSize&) final { return true; }
    6765
    68     // rtc::VideoSinkInterface
    69     void OnFrame(const webrtc::VideoFrame&) final;
    70 
    71     CVPixelBufferRef pixelBufferFromVideoFrame(const webrtc::VideoFrame&);
    72 
    73     RealtimeMediaSourceSettings m_currentSettings;
    7466    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_DISABLED
    80     size_t m_numberOfFrames { 0 };
    81 #endif
    8267};
    8368
  • trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp

    r223389 r223406  
    3535#include <webrtc/api/video/i420_buffer.h>
    3636#include <webrtc/common_video/libyuv/include/webrtc_libyuv.h>
    37 #include <webrtc/sdk/objc/Framework/Classes/Video/corevideo_frame_buffer.h>
    3837#include <wtf/CurrentTime.h>
    3938#include <wtf/MainThread.h>
    40 
    41 #include "CoreMediaSoftLink.h"
    42 #include "CoreVideoSoftLink.h"
    4339
    4440namespace WebCore {
     
    112108
    113109    updateBlackFramesSending();
    114 }
    115 
    116 bool RealtimeOutgoingVideoSource::GetStats(Stats*)
    117 {
    118     return false;
    119110}
    120111
     
    193184}
    194185
    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_DISABLED
    204     if (!(++m_numberOfFrames % 30))
    205         RELEASE_LOG(MediaStream, "RealtimeOutgoingVideoSource::sendFrame %zu frame", m_numberOfFrames);
    206 #endif
    207 
    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 
    264186} // namespace WebCore
    265187
  • trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h

    r223389 r223406  
    4343namespace WebCore {
    4444
    45 class RealtimeOutgoingVideoSource final : public ThreadSafeRefCounted<RealtimeOutgoingVideoSource>, public webrtc::VideoTrackSourceInterface, private MediaStreamTrackPrivate::Observer {
     45class RealtimeOutgoingVideoSource : public ThreadSafeRefCounted<RealtimeOutgoingVideoSource>, public webrtc::VideoTrackSourceInterface, private MediaStreamTrackPrivate::Observer {
    4646public:
    47     static Ref<RealtimeOutgoingVideoSource> create(Ref<MediaStreamTrackPrivate>&& videoSource) { return adoptRef(*new RealtimeOutgoingVideoSource(WTFMove(videoSource))); }
     47    static Ref<RealtimeOutgoingVideoSource> create(Ref<MediaStreamTrackPrivate>&& videoSource);
    4848    ~RealtimeOutgoingVideoSource() { stop(); }
    4949
     
    5757    void setApplyRotation(bool shouldApplyRotation) { m_shouldApplyRotation = shouldApplyRotation; }
    5858
    59 private:
    60     RealtimeOutgoingVideoSource(Ref<MediaStreamTrackPrivate>&&);
     59protected:
     60    explicit RealtimeOutgoingVideoSource(Ref<MediaStreamTrackPrivate>&&);
    6161
    6262    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
     74private:
    6375    void sendBlackFramesIfNeeded();
    6476    void sendOneBlackFrame();
     
    7385    bool is_screencast() const final { return false; }
    7486    rtc::Optional<bool> needs_denoising() const final { return rtc::Optional<bool>(); }
    75     bool GetStats(Stats*) final;
     87    bool GetStats(Stats*) final { return false; };
    7688
    7789    // MediaSourceInterface API
     
    8597    void sourceMutedChanged();
    8698    void sourceEnabledChanged();
    87     void videoSampleAvailable(MediaSample&);
    8899
    89100    // MediaStreamTrackPrivate::Observer API
     
    91102    void trackEnabledChanged(MediaStreamTrackPrivate&) final { sourceEnabledChanged(); }
    92103    void trackSettingsChanged(MediaStreamTrackPrivate&) final { initializeFromSource(); }
    93     void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample& sample) final { videoSampleAvailable(sample); }
     104    void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) override { }
    94105    void trackEnded(MediaStreamTrackPrivate&) final { }
    95106
    96     Vector<rtc::VideoSinkInterface<webrtc::VideoFrame>*> m_sinks;
    97     webrtc::I420BufferPool m_bufferPool;
    98107    Ref<MediaStreamTrackPrivate> m_videoSource;
    99     bool m_enabled { true };
    100     bool m_muted { false };
    101108    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 };
    105109    bool m_isStopped { false };
    106110    Timer m_blackFrameTimer;
    107111    rtc::scoped_refptr<webrtc::VideoFrameBuffer> m_blackFrame;
    108     bool m_shouldApplyRotation { false };
    109 #if !RELEASE_LOG_DISABLED
    110     size_t m_numberOfFrames { 0 };
    111 #endif
    112112};
    113113
  • trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp

    r223389 r223406  
    1212 *    in the documentation and/or other materials provided with the
    1313 *    distribution.
    14  * 3. Neither the name of Google Inc. nor the names of its contributors
    15  *    may be used to endorse or promote products derived from this
    16  *    software without specific prior written permission.
    1714 *
    1815 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     
    3027
    3128#include "config.h"
    32 #include "RealtimeIncomingVideoSource.h"
     29#include "RealtimeIncomingVideoSourceCocoa.h"
    3330
    3431#if USE(LIBWEBRTC)
     
    4542Ref<RealtimeIncomingVideoSource> RealtimeIncomingVideoSource::create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& trackId)
    4643{
    47     auto source = adoptRef(*new RealtimeIncomingVideoSource(WTFMove(videoTrack), WTFMove(trackId)));
     44    auto source = RealtimeIncomingVideoSourceCocoa::create(WTFMove(videoTrack), WTFMove(trackId));
    4845    source->start();
    49     return source;
     46    return WTFMove(source);
    5047}
    5148
    52 RealtimeIncomingVideoSource::RealtimeIncomingVideoSource(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& videoTrackId)
    53     : RealtimeMediaSource(WTFMove(videoTrackId), RealtimeMediaSource::Type::Video, String())
    54     , m_videoTrack(WTFMove(videoTrack))
     49Ref<RealtimeIncomingVideoSourceCocoa> RealtimeIncomingVideoSourceCocoa::create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& trackId)
    5550{
    56     m_currentSettings.setWidth(640);
    57     m_currentSettings.setHeight(480);
    58     notifyMutedChange(!m_videoTrack);
     51    return adoptRef(*new RealtimeIncomingVideoSourceCocoa(WTFMove(videoTrack), WTFMove(trackId)));
    5952}
    6053
    61 void RealtimeIncomingVideoSource::startProducingData()
     54RealtimeIncomingVideoSourceCocoa::RealtimeIncomingVideoSourceCocoa(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& videoTrackId)
     55    : RealtimeIncomingVideoSource(WTFMove(videoTrack), WTFMove(videoTrackId))
    6256{
    63     if (m_videoTrack)
    64         m_videoTrack->AddOrUpdateSink(this, rtc::VideoSinkWants());
    6557}
    6658
    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)
     59CVPixelBufferRef RealtimeIncomingVideoSourceCocoa::pixelBufferFromVideoFrame(const webrtc::VideoFrame& frame)
    8560{
    8661    if (muted()) {
     
    11186}
    11287
    113 void RealtimeIncomingVideoSource::OnFrame(const webrtc::VideoFrame& frame)
     88void RealtimeIncomingVideoSourceCocoa::OnFrame(const webrtc::VideoFrame& frame)
    11489{
    11590    if (!isProducingData())
     
    11893#if !RELEASE_LOG_DISABLED
    11994    if (!(++m_numberOfFrames % 30))
    120         RELEASE_LOG(MediaStream, "RealtimeIncomingVideoSource::OnFrame %zu frame", m_numberOfFrames);
     95        RELEASE_LOG(MediaStream, "RealtimeIncomingVideoSourceCocoa::OnFrame %zu frame", m_numberOfFrames);
    12196#endif
    12297
     
    174149    }
    175150
    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] {
    178153        protectedThis->processNewSample(sample.get(), width, height, rotation);
    179154    });
    180155}
    181156
    182 void RealtimeIncomingVideoSource::processNewSample(CMSampleBufferRef sample, unsigned width, unsigned height, MediaSample::VideoRotation rotation)
     157void RealtimeIncomingVideoSourceCocoa::processNewSample(CMSampleBufferRef sample, unsigned width, unsigned height, MediaSample::VideoRotation rotation)
    183158{
    184159    m_buffer = sample;
     
    192167}
    193168
    194 const RealtimeMediaSourceCapabilities& RealtimeIncomingVideoSource::capabilities() const
    195 {
    196     return RealtimeMediaSourceCapabilities::emptyCapabilities();
    197 }
    198 
    199 const RealtimeMediaSourceSettings& RealtimeIncomingVideoSource::settings() const
    200 {
    201     return m_currentSettings;
    202 }
    203 
    204169} // namespace WebCore
    205170
  • trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h

    r223389 r223406  
    1212 *    in the documentation and/or other materials provided with the
    1313 *    distribution.
    14  * 3. Neither the name of Ericsson nor the names of its contributors
    15  *    may be used to endorse or promote products derived from this
    16  *    software without specific prior written permission.
    1714 *
    1815 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     
    3330#if USE(LIBWEBRTC)
    3431
    35 #include "LibWebRTCMacros.h"
    36 #include "RealtimeMediaSource.h"
    37 #include <webrtc/api/mediastreaminterface.h>
    38 #include <wtf/RetainPtr.h>
     32#include "RealtimeIncomingVideoSource.h"
    3933
    4034using CMSampleBufferRef = struct opaqueCMSampleBuffer*;
     
    4337namespace WebCore {
    4438
    45 class CaptureDevice;
    46 
    47 class RealtimeIncomingVideoSource final : public RealtimeMediaSource, private rtc::VideoSinkInterface<webrtc::VideoFrame> {
     39class RealtimeIncomingVideoSourceCocoa final : public RealtimeIncomingVideoSource {
    4840public:
    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&&);
    5342
    5443private:
    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&&);
    6445    void processNewSample(CMSampleBufferRef, unsigned, unsigned, MediaSample::VideoRotation);
    65 
    66     bool applySize(const IntSize&) final { return true; }
     46    CVPixelBufferRef pixelBufferFromVideoFrame(const webrtc::VideoFrame&);
    6747
    6848    // rtc::VideoSinkInterface
    6949    void OnFrame(const webrtc::VideoFrame&) final;
    7050
    71     CVPixelBufferRef pixelBufferFromVideoFrame(const webrtc::VideoFrame&);
    72 
    73     RealtimeMediaSourceSettings m_currentSettings;
    74     rtc::scoped_refptr<webrtc::VideoTrackInterface> m_videoTrack;
    7551    RetainPtr<CMSampleBufferRef> m_buffer;
    7652    RetainPtr<CVPixelBufferRef> m_blackFrame;
Note: See TracChangeset for help on using the changeset viewer.