Changeset 223157 in webkit


Ignore:
Timestamp:
Oct 10, 2017 4:46:05 PM (7 years ago)
Author:
jmarcell@apple.com
Message:

Cherry-pick r222478. rdar://problem/34771020

Location:
branches/safari-604-branch
Files:
2 added
18 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/safari-604-branch/LayoutTests/ChangeLog

    r223107 r223157  
     12017-10-10  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r222478. rdar://problem/34771020
     4
     5    2017-09-25  Youenn Fablet  <youenn@apple.com>
     6
     7            WebRTC video does not resume receiving when switching back to Safari 11 on iOS
     8            https://bugs.webkit.org/show_bug.cgi?id=175472
     9            <rdar://problem/33860863>
     10
     11            Reviewed by Darin Adler.
     12
     13            * webrtc/video-interruption-expected.txt: Added.
     14            * webrtc/video-interruption.html: Added.
     15
    1162017-10-09  Jason Marcell  <jmarcell@apple.com>
    217
  • branches/safari-604-branch/Source/ThirdParty/libwebrtc/ChangeLog

    r219082 r223157  
     12017-10-10  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r222478. rdar://problem/34771020
     4
     5    2017-09-25  Youenn Fablet  <youenn@apple.com>
     6
     7            WebRTC video does not resume receiving when switching back to Safari 11 on iOS
     8            https://bugs.webkit.org/show_bug.cgi?id=175472
     9            <rdar://problem/33860863>
     10
     11            Reviewed by Darin Adler.
     12
     13            Adding a method to disable any decoding/encoding task.
     14            When reenabling the decoder, the decoder will request an I frame after failing the first initial decoding task.
     15
     16            * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.h:
     17            (webrtc::H264VideoToolboxDecoder::SetActive):
     18            * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm:
     19            (webrtc::H264VideoToolboxDecoder::Decode):
     20            * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.h:
     21            * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.mm:
     22            (webrtc::H264VideoToolboxEncoder::Encode):
     23
    1242017-07-03  Andy Estes  <aestes@apple.com>
    225
  • branches/safari-604-branch/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.h

    r218645 r223157  
    4444  const char* ImplementationName() const override;
    4545
     46  void SetActive(bool is_active) { is_active_ = is_active; }
     47
    4648 private:
    4749  int ResetDecompressionSession();
     
    5355  CMVideoFormatDescriptionRef video_format_;
    5456  VTDecompressionSessionRef decompression_session_;
     57  bool is_active_ { true };
    5558};  // H264VideoToolboxDecoder
    5659
  • branches/safari-604-branch/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm

    r218645 r223157  
    9696  RTC_DCHECK(input_image._buffer);
    9797
    98 #if defined(WEBRTC_IOS) && !defined(WEBRTC_WEBKIT_BUILD)
     98#if defined(WEBRTC_IOS)
     99#if !defined(WEBRTC_WEBKIT_BUILD)
    99100  if (![[RTCUIApplicationStatusObserver sharedInstance] isApplicationActive]) {
     101#else
     102  if (!is_active_) {
     103#endif
    100104    // Ignore all decode requests when app isn't active. In this state, the
    101105    // hardware decoder has been invalidated by the OS.
  • branches/safari-604-branch/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.h

    r218699 r223157  
    7070  ScalingSettings GetScalingSettings() const override;
    7171
     72  void SetActive(bool is_active) { is_active_ = is_active; }
     73
    7274 protected:
    7375  virtual int CreateCompressionSession(VTCompressionSessionRef&, VTCompressionOutputCallback, int32_t width, int32_t height, bool useHardwareEncoder = true);
     
    9597  H264BitstreamParser h264_bitstream_parser_;
    9698  std::vector<uint8_t> nv12_scale_buffer_;
     99  bool is_active_ { true };
    97100};  // H264VideoToolboxEncoder
    98101
  • branches/safari-604-branch/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.mm

    r218699 r223157  
    385385    return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
    386386  }
    387 #if defined(WEBRTC_IOS) && !defined(WEBRTC_WEBKIT_BUILD)
    388   if (![[RTCUIApplicationStatusObserver sharedInstance] isApplicationActive]) {
     387
     388#if defined(WEBRTC_IOS)
     389#if !defined(WEBRTC_WEBKIT_BUILD)
     390    if (![[RTCUIApplicationStatusObserver sharedInstance] isApplicationActive]) {
     391#else
     392    if (!is_active_) {
     393#endif
    389394    // Ignore all encode requests when app isn't active. In this state, the
    390395    // hardware encoder has been invalidated by the OS.
  • branches/safari-604-branch/Source/WebCore/ChangeLog

    r223120 r223157  
     12017-10-10  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r222478. rdar://problem/34771020
     4
     5    2017-09-25  Youenn Fablet  <youenn@apple.com>
     6
     7            WebRTC video does not resume receiving when switching back to Safari 11 on iOS
     8            https://bugs.webkit.org/show_bug.cgi?id=175472
     9            <rdar://problem/33860863>
     10
     11            Reviewed by Darin Adler.
     12
     13            Test: webrtc/video-interruption.html and manual testing.
     14
     15            Using new SetActive method from libwebrtc encoder/decoder to enable/disable them based on interuptions.
     16            For that purpose, LibWebRTCProvider is now storing the peer connection factory and keeping track of the encoder/decoder factories.
     17            LibWebRTCProvider is then notified by WebPage when backgrounded/foregrounded.
     18
     19            * WebCore.xcodeproj/project.pbxproj:
     20            * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
     21            (WebCore::staticFactoryAndThreads):
     22            (WebCore::initializePeerConnectionFactoryAndThreads):
     23            (WebCore::LibWebRTCProvider::factory):
     24            (WebCore::LibWebRTCProvider::setPeerConnectionFactory):
     25            (WebCore::LibWebRTCProvider::createPeerConnection):
     26            (WebCore::LibWebRTCProvider::setActive):
     27            (WebCore::LibWebRTCProvider::webRTCAvailable):
     28            (WebCore::LibWebRTCProvider::mayResumePlayback): Deleted.
     29            (WebCore::LibWebRTCProvider::suspendPlayback): Deleted.
     30            * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
     31            * platform/mediastream/libwebrtc/VideoToolBoxDecoderFactory.cpp: Copied from Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.cpp.
     32            (WebCore::VideoToolboxVideoDecoderFactory::setActive):
     33            (WebCore::VideoToolboxVideoDecoderFactory::CreateVideoDecoder):
     34            (WebCore::VideoToolboxVideoDecoderFactory::DestroyVideoDecoder):
     35            * platform/mediastream/libwebrtc/VideoToolBoxDecoderFactory.h: Copied from Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.h.
     36            * platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.cpp:
     37            (WebCore::VideoToolboxVideoEncoderFactory::setActive):
     38            (WebCore::VideoToolboxVideoEncoderFactory::CreateSupportedVideoEncoder):
     39            (WebCore::VideoToolboxVideoEncoderFactory::DestroyVideoEncoder):
     40            * platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.h:
     41            * testing/Internals.cpp:
     42            (WebCore::Internals::resetToConsistentState):
     43            * testing/MockLibWebRTCPeerConnection.cpp:
     44            (WebCore::useRealRTCPeerConnectionFactory):
     45            (WebCore::useMockRTCPeerConnectionFactory):
     46            * testing/MockLibWebRTCPeerConnection.h:
     47
    1482017-10-09  Jason Marcell  <jmarcell@apple.com>
    249
  • branches/safari-604-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r220749 r223157  
    17991799                41D015CA0F4B5C71004A662F /* ContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D015C80F4B5C71004A662F /* ContentType.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18001800                41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D015C90F4B5C71004A662F /* ContentType.cpp */; };
     1801                41D7E5571F73085500E26991 /* VideoToolBoxDecoderFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D7E5551F73085000E26991 /* VideoToolBoxDecoderFactory.cpp */; };
    18011802                41DEFCB51E56C1BD000D9E5F /* JSDOMMapLike.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DEFCB31E56C1B9000D9E5F /* JSDOMMapLike.cpp */; };
    18021803                41DEFCB61E56C1BD000D9E5F /* JSDOMMapLike.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DEFCB41E56C1B9000D9E5F /* JSDOMMapLike.h */; };
     
    94689469                41D015C90F4B5C71004A662F /* ContentType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentType.cpp; sourceTree = "<group>"; };
    94699470                41D51BB21E4E2E8100131A5B /* LibWebRTCAudioFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCAudioFormat.h; path = libwebrtc/LibWebRTCAudioFormat.h; sourceTree = "<group>"; };
     9471                41D7E5541F73085000E26991 /* VideoToolBoxDecoderFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VideoToolBoxDecoderFactory.h; path = libwebrtc/VideoToolBoxDecoderFactory.h; sourceTree = "<group>"; };
     9472                41D7E5551F73085000E26991 /* VideoToolBoxDecoderFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VideoToolBoxDecoderFactory.cpp; path = libwebrtc/VideoToolBoxDecoderFactory.cpp; sourceTree = "<group>"; };
    94709473                41DEFCB21E56C1B9000D9E5F /* JSDOMBindingInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = JSDOMBindingInternals.js; sourceTree = "<group>"; };
    94719474                41DEFCB31E56C1B9000D9E5F /* JSDOMMapLike.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMMapLike.cpp; sourceTree = "<group>"; };
     
    1766317666                                41A1B00D1E52656E007F3769 /* LibWebRTCProvider.cpp */,
    1766417667                                415747441E38699E00E914D8 /* LibWebRTCProvider.h */,
     17668                                41D7E5551F73085000E26991 /* VideoToolBoxDecoderFactory.cpp */,
     17669                                41D7E5541F73085000E26991 /* VideoToolBoxDecoderFactory.h */,
    1766517670                                41CAD71C1EA0905700178164 /* VideoToolBoxEncoderFactory.cpp */,
    1766617671                                41CAD71D1EA0905700178164 /* VideoToolBoxEncoderFactory.h */,
     
    3369733702                                CDE83DB1183C44060031EAA3 /* VideoPlaybackQuality.cpp in Sources */,
    3369833703                                CD9D82791C7B8EE1006FF066 /* VideoTextureCopierCV.cpp in Sources */,
     33704                                41D7E5571F73085500E26991 /* VideoToolBoxDecoderFactory.cpp in Sources */,
    3369933705                                41CAD71E1EA090A100178164 /* VideoToolBoxEncoderFactory.cpp in Sources */,
    3370033706                                CDC939A71E9BDFB100BB768D /* VideoToolboxSoftLink.cpp in Sources */,
  • branches/safari-604-branch/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp

    r218994 r223157  
    3030#include "LibWebRTCAudioModule.h"
    3131#include "Logging.h"
     32#include "VideoToolBoxDecoderFactory.h"
    3233#include "VideoToolBoxEncoderFactory.h"
    3334#include <dlfcn.h>
     
    3637#include <webrtc/p2p/client/basicportallocator.h>
    3738#include <webrtc/pc/peerconnectionfactory.h>
    38 #include <webrtc/sdk/objc/Framework/Classes/VideoToolbox/videocodecfactory.h>
    3939#include <wtf/Function.h>
    4040#include <wtf/NeverDestroyed.h>
     
    4646#if USE(LIBWEBRTC)
    4747struct PeerConnectionFactoryAndThreads : public rtc::MessageHandler {
    48     std::unique_ptr<LibWebRTCAudioModule> audioDeviceModule;
    4948    std::unique_ptr<rtc::Thread> networkThread;
    5049    std::unique_ptr<rtc::Thread> signalingThread;
    51     rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory;
    5250    bool networkThreadWithSocketServer { false };
    53     Function<std::unique_ptr<cricket::WebRtcVideoEncoderFactory>()> encoderFactoryGetter;
    54     Function<std::unique_ptr<cricket::WebRtcVideoDecoderFactory>()> decoderFactoryGetter;
     51    std::unique_ptr<LibWebRTCAudioModule> audioDeviceModule;
    5552
    5653private:
     
    5855};
    5956
     57static void initializePeerConnectionFactoryAndThreads(PeerConnectionFactoryAndThreads& factoryAndThreads)
     58{
     59    ASSERT(!factoryAndThreads.networkThread);
     60
     61#if defined(NDEBUG)
     62#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
     63    rtc::LogMessage::LogToDebug(LogWebRTC.state != WTFLogChannelOn ? rtc::LS_NONE : rtc::LS_INFO);
     64#else
     65    rtc::LogMessage::LogToDebug(rtc::LS_NONE);
     66#endif
     67#else
     68    rtc::LogMessage::LogToDebug(LogWebRTC.state != WTFLogChannelOn ? rtc::LS_WARNING : rtc::LS_INFO);
     69#endif
     70
     71    factoryAndThreads.networkThread = factoryAndThreads.networkThreadWithSocketServer ? rtc::Thread::CreateWithSocketServer() : rtc::Thread::Create();
     72    factoryAndThreads.networkThread->SetName("WebKitWebRTCNetwork", nullptr);
     73    bool result = factoryAndThreads.networkThread->Start();
     74    ASSERT_UNUSED(result, result);
     75
     76    factoryAndThreads.signalingThread = rtc::Thread::Create();
     77    factoryAndThreads.signalingThread->SetName("WebKitWebRTCSignaling", nullptr);
     78
     79    result = factoryAndThreads.signalingThread->Start();
     80    ASSERT(result);
     81
     82    factoryAndThreads.audioDeviceModule = std::make_unique<LibWebRTCAudioModule>();
     83}
     84
    6085static inline PeerConnectionFactoryAndThreads& staticFactoryAndThreads()
    6186{
    6287    static NeverDestroyed<PeerConnectionFactoryAndThreads> factoryAndThreads;
    63 #if PLATFORM(COCOA)
    64     static std::once_flag once;
    65     std::call_once(once, [] {
    66         factoryAndThreads.get().encoderFactoryGetter = []() -> std::unique_ptr<cricket::WebRtcVideoEncoderFactory> { return std::make_unique<VideoToolboxVideoEncoderFactory>(); };
    67         factoryAndThreads.get().decoderFactoryGetter = []() -> std::unique_ptr<cricket::WebRtcVideoDecoderFactory> { return std::make_unique<webrtc::VideoToolboxVideoDecoderFactory>(); };
    68     });
    69 #endif
    7088    return factoryAndThreads.get();
     89}
     90
     91static inline PeerConnectionFactoryAndThreads& getStaticFactoryAndThreads(bool useNetworkThreadWithSocketServer)
     92{
     93    auto& factoryAndThreads = staticFactoryAndThreads();
     94
     95    ASSERT(!factoryAndThreads.networkThread || factoryAndThreads.networkThreadWithSocketServer == useNetworkThreadWithSocketServer);
     96
     97    if (!factoryAndThreads.networkThread) {
     98        factoryAndThreads.networkThreadWithSocketServer = useNetworkThreadWithSocketServer;
     99        initializePeerConnectionFactoryAndThreads(factoryAndThreads);
     100    }
     101    return factoryAndThreads;
    71102}
    72103
     
    98129}
    99130
    100 static void initializePeerConnectionFactoryAndThreads()
    101 {
    102 #if defined(NDEBUG)
    103 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED
    104     rtc::LogMessage::LogToDebug(LogWebRTC.state != WTFLogChannelOn ? rtc::LS_NONE : rtc::LS_INFO);
    105 #else
    106     rtc::LogMessage::LogToDebug(rtc::LS_NONE);
    107 #endif
    108 #else
    109     rtc::LogMessage::LogToDebug(LogWebRTC.state != WTFLogChannelOn ? rtc::LS_WARNING : rtc::LS_INFO);
    110 #endif
    111     auto& factoryAndThreads = staticFactoryAndThreads();
    112 
    113     ASSERT(!factoryAndThreads.factory);
    114 
    115     factoryAndThreads.networkThread = factoryAndThreads.networkThreadWithSocketServer ? rtc::Thread::CreateWithSocketServer() : rtc::Thread::Create();
    116     factoryAndThreads.networkThread->SetName("WebKitWebRTCNetwork", nullptr);
    117     bool result = factoryAndThreads.networkThread->Start();
    118     ASSERT_UNUSED(result, result);
    119 
    120     factoryAndThreads.signalingThread = rtc::Thread::Create();
    121     factoryAndThreads.signalingThread->SetName("WebKitWebRTCSignaling", nullptr);
    122    
    123     result = factoryAndThreads.signalingThread->Start();
    124     ASSERT(result);
    125 
    126     factoryAndThreads.audioDeviceModule = std::make_unique<LibWebRTCAudioModule>();
    127 
    128     std::unique_ptr<cricket::WebRtcVideoEncoderFactory> encoderFactory = factoryAndThreads.encoderFactoryGetter ? factoryAndThreads.encoderFactoryGetter() : nullptr;
    129     std::unique_ptr<cricket::WebRtcVideoDecoderFactory> decoderFactory = factoryAndThreads.decoderFactoryGetter ? factoryAndThreads.decoderFactoryGetter() : nullptr;
    130 
    131     factoryAndThreads.factory = webrtc::CreatePeerConnectionFactory(factoryAndThreads.networkThread.get(), factoryAndThreads.networkThread.get(), factoryAndThreads.signalingThread.get(), factoryAndThreads.audioDeviceModule.get(), encoderFactory.release(), decoderFactory.release());
    132 
    133     ASSERT(factoryAndThreads.factory);
    134 }
    135 
    136131webrtc::PeerConnectionFactoryInterface* LibWebRTCProvider::factory()
    137132{
     133    if (m_factory)
     134        return m_factory.get();
     135
    138136    if (!webRTCAvailable())
    139137        return nullptr;
    140     if (!staticFactoryAndThreads().factory) {
    141         staticFactoryAndThreads().networkThreadWithSocketServer = m_useNetworkThreadWithSocketServer;
    142         initializePeerConnectionFactoryAndThreads();
    143     }
    144     return staticFactoryAndThreads().factory;
    145 }
    146 
    147 void LibWebRTCProvider::setDecoderFactoryGetter(Function<std::unique_ptr<cricket::WebRtcVideoDecoderFactory>()>&& getter)
    148 {
    149     if (!staticFactoryAndThreads().factory)
    150         initializePeerConnectionFactoryAndThreads();
    151 
    152     staticFactoryAndThreads().decoderFactoryGetter = WTFMove(getter);
    153 }
    154 
    155 void LibWebRTCProvider::setEncoderFactoryGetter(Function<std::unique_ptr<cricket::WebRtcVideoEncoderFactory>()>&& getter)
    156 {
    157     if (!staticFactoryAndThreads().factory)
    158         initializePeerConnectionFactoryAndThreads();
    159 
    160     staticFactoryAndThreads().encoderFactoryGetter = WTFMove(getter);
     138
     139    auto& factoryAndThreads = getStaticFactoryAndThreads(m_useNetworkThreadWithSocketServer);
     140
     141    auto decoderFactory = std::make_unique<VideoToolboxVideoDecoderFactory>();
     142    auto encoderFactory = std::make_unique<VideoToolboxVideoEncoderFactory>();
     143
     144    m_decoderFactory = decoderFactory.get();
     145    m_encoderFactory = encoderFactory.get();
     146
     147    m_factory = webrtc::CreatePeerConnectionFactory(factoryAndThreads.networkThread.get(), factoryAndThreads.networkThread.get(), factoryAndThreads.signalingThread.get(), factoryAndThreads.audioDeviceModule.get(), encoderFactory.release(), decoderFactory.release());
     148
     149    return m_factory;
    161150}
    162151
    163152void LibWebRTCProvider::setPeerConnectionFactory(rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>&& factory)
    164153{
    165     if (!staticFactoryAndThreads().factory)
    166         initializePeerConnectionFactoryAndThreads();
    167 
    168     staticFactoryAndThreads().factory = webrtc::PeerConnectionFactoryProxy::Create(staticFactoryAndThreads().signalingThread.get(), WTFMove(factory));
    169 }
    170 
    171 static rtc::scoped_refptr<webrtc::PeerConnectionInterface> createActualPeerConnection(webrtc::PeerConnectionObserver& observer, std::unique_ptr<cricket::BasicPortAllocator>&& portAllocator, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration)
    172 {
    173     ASSERT(staticFactoryAndThreads().factory);
    174 
    175     return staticFactoryAndThreads().factory->CreatePeerConnection(configuration, WTFMove(portAllocator), nullptr, &observer);
     154    m_factory = webrtc::PeerConnectionFactoryProxy::Create(getStaticFactoryAndThreads(m_useNetworkThreadWithSocketServer).signalingThread.get(), WTFMove(factory));
    176155}
    177156
     
    179158{
    180159    // Default WK1 implementation.
    181     auto& factoryAndThreads = staticFactoryAndThreads();
    182     if (!factoryAndThreads.factory) {
    183         staticFactoryAndThreads().networkThreadWithSocketServer = true;
    184         initializePeerConnectionFactoryAndThreads();
    185     }
    186     ASSERT(staticFactoryAndThreads().networkThreadWithSocketServer);
    187 
    188     return createActualPeerConnection(observer, nullptr, WTFMove(configuration));
     160    ASSERT(m_useNetworkThreadWithSocketServer);
     161    auto* factory = this->factory();
     162    if (!factory)
     163        return nullptr;
     164
     165    return m_factory->CreatePeerConnection(configuration, nullptr, nullptr, &observer);
    189166}
    190167
    191168rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer, rtc::NetworkManager& networkManager, rtc::PacketSocketFactory& packetSocketFactory, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration)
    192169{
    193     ASSERT(!staticFactoryAndThreads().networkThreadWithSocketServer);
    194 
    195     auto& factoryAndThreads = staticFactoryAndThreads();
    196     if (!factoryAndThreads.factory)
    197         initializePeerConnectionFactoryAndThreads();
     170    ASSERT(!m_useNetworkThreadWithSocketServer);
     171
     172    auto& factoryAndThreads = getStaticFactoryAndThreads(m_useNetworkThreadWithSocketServer);
    198173
    199174    std::unique_ptr<cricket::BasicPortAllocator> portAllocator;
    200     staticFactoryAndThreads().signalingThread->Invoke<void>(RTC_FROM_HERE, [&]() {
     175    factoryAndThreads.signalingThread->Invoke<void>(RTC_FROM_HERE, [&]() {
    201176        auto basicPortAllocator = std::make_unique<cricket::BasicPortAllocator>(&networkManager, &packetSocketFactory);
    202177        if (!m_enableEnumeratingAllNetworkInterfaces)
     
    205180    });
    206181
    207     return createActualPeerConnection(observer, WTFMove(portAllocator), WTFMove(configuration));
     182    auto* factory = this->factory();
     183    if (!factory)
     184        return nullptr;
     185
     186    return m_factory->CreatePeerConnection(configuration, WTFMove(portAllocator), nullptr, &observer);
    208187}
    209188
    210189#endif // USE(LIBWEBRTC)
    211190
     191void LibWebRTCProvider::setActive(bool value)
     192{
     193#if USE(LIBWEBRTC)
     194    if (m_decoderFactory)
     195        m_decoderFactory->setActive(value);
     196    if (m_encoderFactory)
     197        m_encoderFactory->setActive(value);
     198#else
     199    UNUSED_PARAM(value);
     200#endif
     201}
     202
    212203bool LibWebRTCProvider::webRTCAvailable()
    213204{
  • branches/safari-604-branch/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h

    r218994 r223157  
    4646namespace WebCore {
    4747
     48class VideoToolboxVideoDecoderFactory;
     49class VideoToolboxVideoEncoderFactory;
     50
    4851class WEBCORE_EXPORT LibWebRTCProvider {
    4952public:
     
    5255
    5356    static bool webRTCAvailable();
     57
     58    void setActive(bool);
     59
    5460#if USE(LIBWEBRTC)
    5561    WEBCORE_EXPORT virtual rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver&, webrtc::PeerConnectionInterface::RTCConfiguration&&);
     
    6066    static WEBCORE_EXPORT void callOnWebRTCNetworkThread(Function<void()>&&);
    6167    static WEBCORE_EXPORT void callOnWebRTCSignalingThread(Function<void()>&&);
    62     static WEBCORE_EXPORT void setDecoderFactoryGetter(Function<std::unique_ptr<cricket::WebRtcVideoDecoderFactory>()>&&);
    63     static WEBCORE_EXPORT void setEncoderFactoryGetter(Function<std::unique_ptr<cricket::WebRtcVideoEncoderFactory>()>&&);
    6468
    6569    // Used for mock testing
    66     static void setPeerConnectionFactory(rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>&&);
     70    void setPeerConnectionFactory(rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>&&);
    6771
    6872    void disableEnumeratingAllNetworkInterfaces() { m_enableEnumeratingAllNetworkInterfaces = false; }
     
    7377
    7478    bool m_enableEnumeratingAllNetworkInterfaces { false };
     79    // FIXME: Remove m_useNetworkThreadWithSocketServer member variable and make it a global.
    7580    bool m_useNetworkThreadWithSocketServer { true };
     81
     82    rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> m_factory;
     83    VideoToolboxVideoDecoderFactory* m_decoderFactory { nullptr };
     84    VideoToolboxVideoEncoderFactory* m_encoderFactory { nullptr };
    7685#endif
    7786};
  • branches/safari-604-branch/Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxDecoderFactory.cpp

    r223120 r223157  
    2525
    2626#include "config.h"
    27 #include "VideoToolBoxEncoderFactory.h"
     27#include "VideoToolBoxDecoderFactory.h"
    2828
    2929#if USE(LIBWEBRTC) && PLATFORM(COCOA)
    3030
    31 #include "H264VideoToolBoxEncoder.h"
    32 
    3331namespace WebCore {
    3432
    35 webrtc::VideoEncoder* VideoToolboxVideoEncoderFactory::CreateSupportedVideoEncoder(const cricket::VideoCodec& codec)
     33void VideoToolboxVideoDecoderFactory::setActive(bool isActive)
    3634{
    37     return new H264VideoToolboxEncoder(codec);
     35    if (m_isActive == isActive)
     36        return;
     37
     38    m_isActive = isActive;
     39    for (webrtc::H264VideoToolboxDecoder& decoder : m_decoders)
     40        decoder.SetActive(isActive);
    3841}
    3942
    40 void VideoToolboxVideoEncoderFactory::DestroyVideoEncoder(webrtc::VideoEncoder* encoder)
     43webrtc::VideoDecoder* VideoToolboxVideoDecoderFactory::CreateVideoDecoder(webrtc::VideoCodecType type)
    4144{
    42     delete encoder;
    43     encoder = nullptr;
     45    auto* decoder = webrtc::VideoToolboxVideoDecoderFactory::CreateVideoDecoder(type);
     46    if (decoder)
     47        m_decoders.append(static_cast<webrtc::H264VideoToolboxDecoder&>(*decoder));
     48
     49    return decoder;
     50}
     51
     52void VideoToolboxVideoDecoderFactory::DestroyVideoDecoder(webrtc::VideoDecoder* decoder)
     53{
     54    m_decoders.removeFirstMatching([&] (const auto& item) {
     55        return &item.get() == decoder;
     56    });
     57    webrtc::VideoToolboxVideoDecoderFactory::DestroyVideoDecoder(decoder);
    4458}
    4559
  • branches/safari-604-branch/Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxDecoderFactory.h

    r223120 r223157  
    2929
    3030#include "LibWebRTCMacros.h"
     31#include <webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.h>
    3132#include <webrtc/sdk/objc/Framework/Classes/VideoToolbox/videocodecfactory.h>
     33#include <wtf/Vector.h>
    3234
    3335namespace WebCore {
    3436
    35 class VideoToolboxVideoEncoderFactory final : public webrtc::VideoToolboxVideoEncoderFactory {
     37class VideoToolboxVideoDecoderFactory final : public webrtc::VideoToolboxVideoDecoderFactory {
    3638public:
    37     VideoToolboxVideoEncoderFactory() = default;
     39    VideoToolboxVideoDecoderFactory() = default;
     40
     41    void setActive(bool isActive);
    3842
    3943private:
    40     webrtc::VideoEncoder* CreateSupportedVideoEncoder(const cricket::VideoCodec&) final;
    41     void DestroyVideoEncoder(webrtc::VideoEncoder*) final;
     44    webrtc::VideoDecoder* CreateVideoDecoder(webrtc::VideoCodecType) final;
     45    void DestroyVideoDecoder(webrtc::VideoDecoder*) final;
     46
     47    Vector<std::reference_wrapper<webrtc::H264VideoToolboxDecoder>> m_decoders;
     48    bool m_isActive { true };
    4249};
    4350
  • branches/safari-604-branch/Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.cpp

    r215548 r223157  
    3333namespace WebCore {
    3434
     35void VideoToolboxVideoEncoderFactory::setActive(bool isActive)
     36{
     37    if (m_isActive == isActive)
     38        return;
     39
     40    m_isActive = isActive;
     41    for (H264VideoToolboxEncoder& encoder : m_encoders)
     42        encoder.SetActive(isActive);
     43}
     44
    3545webrtc::VideoEncoder* VideoToolboxVideoEncoderFactory::CreateSupportedVideoEncoder(const cricket::VideoCodec& codec)
    3646{
    37     return new H264VideoToolboxEncoder(codec);
     47    auto* encoder = new H264VideoToolboxEncoder(codec);
     48    m_encoders.append(*encoder);
     49
     50    return encoder;
    3851}
    3952
    4053void VideoToolboxVideoEncoderFactory::DestroyVideoEncoder(webrtc::VideoEncoder* encoder)
    4154{
     55    m_encoders.removeFirstMatching([&] (const auto& item) {
     56        return &item.get() == encoder;
     57    });
     58
    4259    delete encoder;
    43     encoder = nullptr;
    4460}
    4561
  • branches/safari-604-branch/Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.h

    r218645 r223157  
    3030#include "LibWebRTCMacros.h"
    3131#include <webrtc/sdk/objc/Framework/Classes/VideoToolbox/videocodecfactory.h>
     32#include <wtf/Vector.h>
    3233
    3334namespace WebCore {
     35
     36class H264VideoToolboxEncoder;
    3437
    3538class VideoToolboxVideoEncoderFactory final : public webrtc::VideoToolboxVideoEncoderFactory {
     
    3740    VideoToolboxVideoEncoderFactory() = default;
    3841
     42    void setActive(bool isActive);
     43
    3944private:
    4045    webrtc::VideoEncoder* CreateSupportedVideoEncoder(const cricket::VideoCodec&) final;
    4146    void DestroyVideoEncoder(webrtc::VideoEncoder*) final;
     47
     48    Vector<std::reference_wrapper<H264VideoToolboxEncoder>> m_encoders;
     49    bool m_isActive { true };
    4250};
    4351
  • branches/safari-604-branch/Source/WebCore/testing/Internals.cpp

    r223094 r223157  
    466466
    467467#if USE(LIBWEBRTC)
    468     WebCore::useRealRTCPeerConnectionFactory();
     468    WebCore::useRealRTCPeerConnectionFactory(page.libWebRTCProvider());
    469469#endif
    470470
  • branches/safari-604-branch/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp

    r218795 r223157  
    4848}
    4949
    50 void useRealRTCPeerConnectionFactory()
     50void useRealRTCPeerConnectionFactory(LibWebRTCProvider& provider)
    5151{
    5252    auto& factory = getRealPeerConnectionFactory();
    5353    if (!factory)
    5454        return;
    55     LibWebRTCProvider::setPeerConnectionFactory(factory.get());
     55    provider.setPeerConnectionFactory(factory.get());
    5656    factory = nullptr;
    5757}
     
    5959void useMockRTCPeerConnectionFactory(LibWebRTCProvider* provider, const String& testCase)
    6060{
    61     if (provider && !realPeerConnectionFactory()) {
     61    if (!provider)
     62        return;
     63
     64    if (!realPeerConnectionFactory()) {
    6265        auto& factory = getRealPeerConnectionFactory();
    6366        factory = provider->factory();
    6467    }
    65 
    66     LibWebRTCProvider::setPeerConnectionFactory(MockLibWebRTCPeerConnectionFactory::create(String(testCase)));
     68    provider->setPeerConnectionFactory(MockLibWebRTCPeerConnectionFactory::create(String(testCase)));
    6769}
    6870
  • branches/safari-604-branch/Source/WebCore/testing/MockLibWebRTCPeerConnection.h

    r218795 r223157  
    3838
    3939void useMockRTCPeerConnectionFactory(LibWebRTCProvider*, const String&);
    40 void useRealRTCPeerConnectionFactory();
     40void useRealRTCPeerConnectionFactory(LibWebRTCProvider&);
    4141
    4242class MockLibWebRTCPeerConnection : public webrtc::PeerConnectionInterface {
  • branches/safari-604-branch/Source/WebKit/ChangeLog

    r223106 r223157  
     12017-10-10  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r222478. rdar://problem/34771020
     4
     5    2017-09-25  Youenn Fablet  <youenn@apple.com>
     6
     7            WebRTC video does not resume receiving when switching back to Safari 11 on iOS
     8            https://bugs.webkit.org/show_bug.cgi?id=175472
     9            <rdar://problem/33860863>
     10
     11            Reviewed by Darin Adler.
     12
     13            Notifying LibWebRTC of backgrounding/foregrouding.
     14
     15            * WebProcess/WebPage/ios/WebPageIOS.mm:
     16            (WebKit::WebPage::applicationDidEnterBackground):
     17            (WebKit::WebPage::applicationWillEnterForeground):
     18
    1192017-10-09  Jason Marcell  <jmarcell@apple.com>
    220
  • branches/safari-604-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r219934 r223157  
    8787#import <WebCore/HitTestResult.h>
    8888#import <WebCore/KeyboardEvent.h>
     89#import <WebCore/LibWebRTCProvider.h>
    8990#import <WebCore/MainFrame.h>
    9091#import <WebCore/MediaSessionManagerIOS.h>
     
    31233124    m_isSuspendedUnderLock = isSuspendedUnderLock;
    31243125    setLayerTreeStateIsFrozen(true);
     3126
     3127    m_page->libWebRTCProvider().setActive(false);
    31253128}
    31263129
     
    31373140
    31383141    [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationWillEnterForegroundNotification object:nil userInfo:@{@"isSuspendedUnderLock": @(isSuspendedUnderLock)}];
     3142
     3143    m_page->libWebRTCProvider().setActive(true);
    31393144}
    31403145
  • branches/safari-604-branch/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme

    r219487 r223157  
    156156      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
    157157      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
     158      language = ""
    158159      shouldUseLaunchSchemeArgsEnv = "YES">
    159160      <Testables>
     
    175176      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
    176177      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
     178      language = ""
    177179      launchStyle = "0"
    178180      useCustomWorkingDirectory = "NO"
Note: See TracChangeset for help on using the changeset viewer.