Changeset 213190 in webkit
- Timestamp:
- Feb 28, 2017 4:07:23 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r213149 r213190 2301 2301 platform/mediastream/SDPProcessorScriptResource.cpp 2302 2302 2303 platform/mediastream/libwebrtc/LibWebRTCProvider.cpp 2304 2303 2305 platform/mock/DeviceOrientationClientMock.cpp 2304 2306 platform/mock/GeolocationClientMock.cpp -
trunk/Source/WebCore/ChangeLog
r213183 r213190 1 2017-02-28 Alex Christensen <achristensen@webkit.org> 2 3 LibWebRTCProvider should check existence of libwebrtc.dylib 4 https://bugs.webkit.org/show_bug.cgi?id=168986 5 <rdar://problem/30735413> 6 7 Reviewed by Youenn Fablet. 8 9 Some configurations of the webrtc tests overwrite the availability of WebRTC in order to test it 10 with MockLibWebRTCPeerConnection. If the dylib can not be found, we can't use it, so we want to 11 fail these tests rather than crashing calling rtc::LogMessage::LogToDebug. 12 13 * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: 14 (WebCore::LibWebRTCMediaEndpoint::doCreateOffer): 15 (WebCore::LibWebRTCMediaEndpoint::doCreateAnswer): 16 * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp: 17 (WebCore::LibWebRTCProvider::factory): 18 (WebCore::LibWebRTCProvider::webRTCAvailable): 19 * platform/mediastream/libwebrtc/LibWebRTCProvider.h: 20 * testing/MockLibWebRTCPeerConnection.cpp: 21 (WebCore::useMockRTCPeerConnectionFactory): 22 (WebCore::MockLibWebRTCPeerConnectionFactory::CreatePeerConnection): 23 1 24 2017-02-28 Tim Horton <timothy_horton@apple.com> 2 25 -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
r213108 r213190 156 156 void LibWebRTCMediaEndpoint::doCreateOffer() 157 157 { 158 if (!LibWebRTCProvider::factory()) { 159 m_peerConnectionBackend.createOfferFailed(Exception { NOT_SUPPORTED_ERR, ASCIILiteral("libwebrtc backend is missing.") }); 160 return; 161 } 162 158 163 m_isInitiator = true; 159 164 auto& senders = m_peerConnectionBackend.connection().getSenders(); 160 165 if (senders.size()) { 161 166 // FIXME: We only support one stream for the moment. 162 auto stream = LibWebRTCProvider::factory() .CreateLocalMediaStream(streamId(m_peerConnectionBackend.connection()));167 auto stream = LibWebRTCProvider::factory()->CreateLocalMediaStream(streamId(m_peerConnectionBackend.connection())); 163 168 for (RTCRtpSender& sender : senders) { 164 169 auto* track = sender.track(); … … 168 173 if (source.type() == RealtimeMediaSource::Audio) { 169 174 auto trackSource = RealtimeOutgoingAudioSource::create(source); 170 auto rtcTrack = LibWebRTCProvider::factory() .CreateAudioTrack(track->id().utf8().data(), trackSource.ptr());175 auto rtcTrack = LibWebRTCProvider::factory()->CreateAudioTrack(track->id().utf8().data(), trackSource.ptr()); 171 176 trackSource->setTrack(rtc::scoped_refptr<webrtc::AudioTrackInterface>(rtcTrack)); 172 177 m_peerConnectionBackend.addAudioSource(WTFMove(trackSource)); … … 174 179 } else { 175 180 auto videoSource = RealtimeOutgoingVideoSource::create(source); 176 auto videoTrack = LibWebRTCProvider::factory() .CreateVideoTrack(track->id().utf8().data(), videoSource.ptr());181 auto videoTrack = LibWebRTCProvider::factory()->CreateVideoTrack(track->id().utf8().data(), videoSource.ptr()); 177 182 m_peerConnectionBackend.addVideoSource(WTFMove(videoSource)); 178 183 stream->AddTrack(WTFMove(videoTrack)); … … 187 192 void LibWebRTCMediaEndpoint::doCreateAnswer() 188 193 { 194 if (!LibWebRTCProvider::factory()) { 195 m_peerConnectionBackend.createAnswerFailed(Exception { NOT_SUPPORTED_ERR, ASCIILiteral("libwebrtc backend is missing.") }); 196 return; 197 } 198 189 199 m_isInitiator = false; 190 200 … … 192 202 if (senders.size()) { 193 203 // FIXME: We only support one stream for the moment. 194 auto stream = LibWebRTCProvider::factory() .CreateLocalMediaStream(streamId(m_peerConnectionBackend.connection()));204 auto stream = LibWebRTCProvider::factory()->CreateLocalMediaStream(streamId(m_peerConnectionBackend.connection())); 195 205 for (RTCRtpSender& sender : senders) { 196 206 auto* track = sender.track(); … … 200 210 if (source.type() == RealtimeMediaSource::Audio) { 201 211 auto trackSource = RealtimeOutgoingAudioSource::create(source); 202 auto rtcTrack = LibWebRTCProvider::factory() .CreateAudioTrack(track->id().utf8().data(), trackSource.ptr());212 auto rtcTrack = LibWebRTCProvider::factory()->CreateAudioTrack(track->id().utf8().data(), trackSource.ptr()); 203 213 trackSource->setTrack(rtc::scoped_refptr<webrtc::AudioTrackInterface>(rtcTrack)); 204 214 m_peerConnectionBackend.addAudioSource(WTFMove(trackSource)); … … 206 216 } else { 207 217 auto videoSource = RealtimeOutgoingVideoSource::create(source); 208 auto videoTrack = LibWebRTCProvider::factory() .CreateVideoTrack(track->id().utf8().data(), videoSource.ptr());218 auto videoTrack = LibWebRTCProvider::factory()->CreateVideoTrack(track->id().utf8().data(), videoSource.ptr()); 209 219 m_peerConnectionBackend.addVideoSource(WTFMove(videoSource)); 210 220 stream->AddTrack(WTFMove(videoTrack)); -
trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
r213167 r213190 28 28 29 29 #if USE(LIBWEBRTC) 30 31 30 #include "LibWebRTCAudioModule.h" 32 31 #include "Logging.h" 32 #include <dlfcn.h> 33 33 #include <webrtc/api/peerconnectionfactory.h> 34 34 #include <webrtc/api/peerconnectionfactoryproxy.h> … … 38 38 #include <wtf/Function.h> 39 39 #include <wtf/NeverDestroyed.h> 40 #endif 40 41 41 42 namespace WebCore { 42 43 44 #if USE(LIBWEBRTC) 43 45 struct PeerConnectionFactoryAndThreads : public rtc::MessageHandler { 44 46 std::unique_ptr<LibWebRTCAudioModule> audioDeviceModule; … … 112 114 } 113 115 114 webrtc::PeerConnectionFactoryInterface &LibWebRTCProvider::factory()116 webrtc::PeerConnectionFactoryInterface* LibWebRTCProvider::factory() 115 117 { 118 if (!webRTCAvailable()) 119 return nullptr; 116 120 if (!staticFactoryAndThreads().factory) 117 121 initializePeerConnectionFactoryAndThreads(); 118 return *staticFactoryAndThreads().factory;122 return staticFactoryAndThreads().factory; 119 123 } 120 124 … … 167 171 return createActualPeerConnection(observer, WTFMove(portAllocator)); 168 172 } 173 #endif // USE(LIBWEBRTC) 174 175 bool LibWebRTCProvider::webRTCAvailable() 176 { 177 #if USE(LIBWEBRTC) 178 static bool available = [] { 179 void* libwebrtcLibrary = dlopen("libwebrtc.dylib", RTLD_LAZY); 180 if (!libwebrtcLibrary) 181 return false; 182 dlclose(libwebrtcLibrary); 183 return true; 184 }(); 185 return available; 186 #else 187 return true; 188 #endif 189 } 169 190 170 191 } // namespace WebCore 171 172 #endif // USE(LIBWEBRTC) -
trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h
r212745 r213190 51 51 virtual ~LibWebRTCProvider() = default; 52 52 53 static bool webRTCAvailable(); 53 54 #if USE(LIBWEBRTC) 54 55 WEBCORE_EXPORT virtual rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver&); … … 57 58 static WEBCORE_EXPORT void callOnWebRTCNetworkThread(Function<void()>&&); 58 59 static WEBCORE_EXPORT void callOnWebRTCSignalingThread(Function<void()>&&); 59 static WEBCORE_EXPORT webrtc::PeerConnectionFactoryInterface &factory();60 static WEBCORE_EXPORT webrtc::PeerConnectionFactoryInterface* factory(); 60 61 // Used for mock testing 61 62 static void setPeerConnectionFactory(rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>&&); -
trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp
r212338 r213190 52 52 if (provider && !realPeerConnectionFactory()) { 53 53 auto& factory = getRealPeerConnectionFactory(); 54 factory = &provider->factory();54 factory = provider->factory(); 55 55 } 56 56 … … 163 163 rtc::scoped_refptr<webrtc::PeerConnectionInterface> MockLibWebRTCPeerConnectionFactory::CreatePeerConnection(const webrtc::PeerConnectionInterface::RTCConfiguration& configuration, std::unique_ptr<cricket::PortAllocator> portAllocator, std::unique_ptr<rtc::RTCCertificateGeneratorInterface> generator, webrtc::PeerConnectionObserver* observer) 164 164 { 165 if (!realPeerConnectionFactory()) 166 return nullptr; 167 165 168 if (m_numberOfRealPeerConnections) { 166 169 auto connection = realPeerConnectionFactory()->CreatePeerConnection(configuration, WTFMove(portAllocator), WTFMove(generator), observer); -
trunk/Source/WebKit2/ChangeLog
r213189 r213190 1 2017-02-28 Alex Christensen <achristensen@webkit.org> 2 3 LibWebRTCProvider should check existence of libwebrtc.dylib 4 https://bugs.webkit.org/show_bug.cgi?id=168986 5 6 Reviewed by Youenn Fablet. 7 8 * Shared/WebPreferencesDefinitions.h: 9 * Shared/WebPreferencesStore.cpp: 10 * UIProcess/WebPreferences.cpp: 11 (WebKit::checkWebRTCAvailability): Deleted. 12 1 13 2017-02-28 Wenson Hsieh <wenson_hsieh@apple.com> 2 14 -
trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h
r212945 r213190 313 313 // wider testing). 314 314 315 // Disable webrtc feature if libwebrtc library is not present316 namespace WebKit {317 bool checkWebRTCAvailability();318 }319 320 315 #define FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(macro) \ 321 316 macro(SpringTimingFunctionEnabled, springTimingFunctionEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "CSS Spring Animations", "CSS Spring Animation prototype") \ … … 329 324 macro(WebAnimationsEnabled, webAnimationsEnabled, Bool, bool, false, "Web Animations", "Web Animations prototype") \ 330 325 macro(WebGL2Enabled, webGL2Enabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "WebGL 2.0", "WebGL 2 prototype") \ 331 macro(PeerConnectionEnabled, peerConnectionEnabled, Bool, bool, checkWebRTCAvailability(), "WebRTC", "Enable WebRTC API") \326 macro(PeerConnectionEnabled, peerConnectionEnabled, Bool, bool, WebCore::LibWebRTCProvider::webRTCAvailable(), "WebRTC", "Enable WebRTC API") \ 332 327 \ 333 328 -
trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp
r204668 r213190 30 30 #include "WebCoreArgumentCoders.h" 31 31 #include "WebPreferencesKeys.h" 32 #include <WebCore/LibWebRTCProvider.h> 32 33 #include <WebCore/Settings.h> 33 34 #include <WebCore/TextEncodingRegistry.h> -
trunk/Source/WebKit2/UIProcess/WebPreferences.cpp
r213074 r213190 30 30 #include "WebPreferencesKeys.h" 31 31 #include "WebProcessPool.h" 32 #include < dlfcn.h>32 #include <WebCore/LibWebRTCProvider.h> 33 33 #include <wtf/NeverDestroyed.h> 34 34 #include <wtf/ThreadingPrimitives.h> … … 197 197 #undef DEFINE_PREFERENCE_GETTER_AND_SETTERS 198 198 199 bool checkWebRTCAvailability()200 {201 #if USE(LIBWEBRTC)202 static bool available = [&] {203 void* libwebrtcLibrary = dlopen("libwebrtc.dylib", RTLD_LAZY);204 if (!libwebrtcLibrary)205 return false;206 dlclose(libwebrtcLibrary);207 return true;208 }();209 return available;210 #else211 return true;212 #endif213 }214 215 199 #define DEFINE_EXPERIMENTAL_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) \ 216 200 void WebPreferences::set##KeyUpper(const Type& value) \
Note: See TracChangeset
for help on using the changeset viewer.