diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp index 17fe497385..da00571208 100755 --- a/talk/libjingle.gyp +++ b/talk/libjingle.gyp @@ -540,6 +540,7 @@ 'media/devices/yuvframescapturer.h', 'media/sctp/sctpdataengine.cc', 'media/sctp/sctpdataengine.h', + 'media/webrtc/nullwebrtcvideoengine.h', 'media/webrtc/simulcast.cc', 'media/webrtc/simulcast.h', 'media/webrtc/webrtccommon.h', diff --git a/talk/libjingle_tests.gyp b/talk/libjingle_tests.gyp index 3ee120d4e2..cbf25aa0bb 100755 --- a/talk/libjingle_tests.gyp +++ b/talk/libjingle_tests.gyp @@ -96,6 +96,7 @@ 'media/devices/dummydevicemanager_unittest.cc', 'media/devices/filevideocapturer_unittest.cc', 'media/sctp/sctpdataengine_unittest.cc', + 'media/webrtc/nullwebrtcvideoengine_unittest.cc', 'media/webrtc/simulcast_unittest.cc', 'media/webrtc/webrtcmediaengine_unittest.cc', 'media/webrtc/webrtcvideocapturer_unittest.cc', diff --git a/talk/media/webrtc/nullwebrtcvideoengine.h b/talk/media/webrtc/nullwebrtcvideoengine.h new file mode 100644 index 0000000000..8af83a8ab1 --- /dev/null +++ b/talk/media/webrtc/nullwebrtcvideoengine.h @@ -0,0 +1,81 @@ +/* + * libjingle + * Copyright 2016 Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TALK_MEDIA_WEBRTC_NULLWEBRTCVIDEOENGINE_H_ +#define TALK_MEDIA_WEBRTC_NULLWEBRTCVIDEOENGINE_H_ + +#include + +#include "talk/media/base/mediachannel.h" +#include "talk/media/base/mediaengine.h" + +namespace webrtc { + +class Call; + +} // namespace webrtc + + +namespace cricket { + +class VideoMediaChannel; +class WebRtcVideoDecoderFactory; +class WebRtcVideoEncoderFactory; + +// Video engine implementation that does nothing and can be used in +// CompositeMediaEngine. +class NullWebRtcVideoEngine { + public: + NullWebRtcVideoEngine() {} + ~NullWebRtcVideoEngine() {} + + void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory) {} + void SetExternalEncoderFactory(WebRtcVideoEncoderFactory* encoder_factory) {} + + void Init() {} + + const std::vector& codecs() { + return codecs_; + } + + RtpCapabilities GetCapabilities() { + RtpCapabilities capabilities; + return capabilities; + } + + VideoMediaChannel* CreateChannel(webrtc::Call* call, + const VideoOptions& options) { + return nullptr; + } + + private: + std::vector codecs_; +}; + +} // namespace cricket + +#endif // TALK_MEDIA_WEBRTC_NULLWEBRTCVIDEOENGINE_H_ diff --git a/talk/media/webrtc/nullwebrtcvideoengine_unittest.cc b/talk/media/webrtc/nullwebrtcvideoengine_unittest.cc new file mode 100644 index 0000000000..34e4af5e9e --- /dev/null +++ b/talk/media/webrtc/nullwebrtcvideoengine_unittest.cc @@ -0,0 +1,56 @@ +/* + * libjingle + * Copyright 2016 Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "testing/gtest/include/gtest/gtest.h" + +#include "talk/media/webrtc/nullwebrtcvideoengine.h" +#include "talk/media/webrtc/webrtcvoiceengine.h" + +namespace cricket { + +class WebRtcMediaEngineNullVideo + : public CompositeMediaEngine { + public: + WebRtcMediaEngineNullVideo(webrtc::AudioDeviceModule* adm, + WebRtcVideoEncoderFactory* encoder_factory, + WebRtcVideoDecoderFactory* decoder_factory) { + voice_.SetAudioDeviceModule(adm); + video_.SetExternalDecoderFactory(decoder_factory); + video_.SetExternalEncoderFactory(encoder_factory); + } +}; + +// Simple test to check if NullWebRtcVideoEngine implements the methods +// required by CompositeMediaEngine. +TEST(NullWebRtcVideoEngineTest, CheckInterface) { + WebRtcMediaEngineNullVideo engine(nullptr, nullptr, nullptr); + + EXPECT_TRUE(engine.Init(rtc::Thread::Current())); + engine.Terminate(); +} + +} // namespace cricket diff --git a/talk/media/webrtc/webrtcmediaengine.cc b/talk/media/webrtc/webrtcmediaengine.cc index 31e5025a55..a014a0f4dd 100644 --- a/talk/media/webrtc/webrtcmediaengine.cc +++ b/talk/media/webrtc/webrtcmediaengine.cc @@ -29,13 +29,21 @@ #include +#ifdef HAVE_WEBRTC_VIDEO #include "talk/media/webrtc/webrtcvideoengine2.h" +#else +#include "talk/media/webrtc/nullwebrtcvideoengine.h" +#endif #include "talk/media/webrtc/webrtcvoiceengine.h" namespace cricket { class WebRtcMediaEngine2 +#ifdef HAVE_WEBRTC_VIDEO : public CompositeMediaEngine { +#else + : public CompositeMediaEngine { +#endif public: WebRtcMediaEngine2(webrtc::AudioDeviceModule* adm, WebRtcVideoEncoderFactory* encoder_factory, diff --git a/talk/media/webrtc/webrtcvideocapturer_unittest.cc b/talk/media/webrtc/webrtcvideocapturer_unittest.cc index 85db32e7d2..99eb7f249c 100644 --- a/talk/media/webrtc/webrtcvideocapturer_unittest.cc +++ b/talk/media/webrtc/webrtcvideocapturer_unittest.cc @@ -25,6 +25,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_WEBRTC_VIDEO + #include #include #include "talk/media/base/testutils.h" @@ -146,3 +148,5 @@ TEST_F(WebRtcVideoCapturerTest, TestCaptureWithoutInit) { EXPECT_TRUE(capturer_->GetCaptureFormat() == NULL); EXPECT_FALSE(capturer_->IsRunning()); } + +#endif // HAVE_WEBRTC_VIDEO diff --git a/talk/media/webrtc/webrtcvideocapturerfactory.cc b/talk/media/webrtc/webrtcvideocapturerfactory.cc index 9f542bd9c1..e1466fbba4 100755 --- a/talk/media/webrtc/webrtcvideocapturerfactory.cc +++ b/talk/media/webrtc/webrtcvideocapturerfactory.cc @@ -32,12 +32,16 @@ namespace cricket { VideoCapturer* WebRtcVideoDeviceCapturerFactory::Create(const Device& device) { +#ifdef HAVE_WEBRTC_VIDEO rtc::scoped_ptr capturer( new WebRtcVideoCapturer()); if (!capturer->Init(device)) { - return NULL; + return nullptr; } return capturer.release(); +#else + return nullptr; +#endif } } // namespace cricket diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc index 4c357f16c6..ac397975e6 100644 --- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc +++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc @@ -25,6 +25,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_WEBRTC_VIDEO + #include #include #include @@ -3404,3 +3406,5 @@ TEST_F(WebRtcVideoChannel2SimulcastTest, } } // namespace cricket + +#endif // HAVE_WEBRTC_VIDEO