Fix compilation if HAVE_WEBRTC_VIDEO is not defined.
This CL fixes compiler / linker errors that occur if HAVE_WEBRTC_VIDEO is not defined and introduces a new class NullWebRtcVideoEngine to use in that case. BUG= TEST=remove define HAVE_WEBRTC_VIDEO from talk/build/common.gypi, run gclient runhooks and compile Review URL: https://codereview.webrtc.org/1621453005 Cr-Commit-Position: refs/heads/master@{#11387}
This commit is contained in:
parent
6d49a8ed17
commit
4cb3e3997b
@ -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',
|
||||
|
||||
@ -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',
|
||||
|
||||
81
talk/media/webrtc/nullwebrtcvideoengine.h
Normal file
81
talk/media/webrtc/nullwebrtcvideoengine.h
Normal file
@ -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 <vector>
|
||||
|
||||
#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<VideoCodec>& codecs() {
|
||||
return codecs_;
|
||||
}
|
||||
|
||||
RtpCapabilities GetCapabilities() {
|
||||
RtpCapabilities capabilities;
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
VideoMediaChannel* CreateChannel(webrtc::Call* call,
|
||||
const VideoOptions& options) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<VideoCodec> codecs_;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // TALK_MEDIA_WEBRTC_NULLWEBRTCVIDEOENGINE_H_
|
||||
56
talk/media/webrtc/nullwebrtcvideoengine_unittest.cc
Normal file
56
talk/media/webrtc/nullwebrtcvideoengine_unittest.cc
Normal file
@ -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<WebRtcVoiceEngine, NullWebRtcVideoEngine> {
|
||||
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
|
||||
@ -29,13 +29,21 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#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<WebRtcVoiceEngine, WebRtcVideoEngine2> {
|
||||
#else
|
||||
: public CompositeMediaEngine<WebRtcVoiceEngine, NullWebRtcVideoEngine> {
|
||||
#endif
|
||||
public:
|
||||
WebRtcMediaEngine2(webrtc::AudioDeviceModule* adm,
|
||||
WebRtcVideoEncoderFactory* encoder_factory,
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_WEBRTC_VIDEO
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#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
|
||||
|
||||
@ -32,12 +32,16 @@
|
||||
namespace cricket {
|
||||
|
||||
VideoCapturer* WebRtcVideoDeviceCapturerFactory::Create(const Device& device) {
|
||||
#ifdef HAVE_WEBRTC_VIDEO
|
||||
rtc::scoped_ptr<WebRtcVideoCapturer> capturer(
|
||||
new WebRtcVideoCapturer());
|
||||
if (!capturer->Init(device)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return capturer.release();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_WEBRTC_VIDEO
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@ -3404,3 +3406,5 @@ TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // HAVE_WEBRTC_VIDEO
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user