diff --git a/webrtc/base/basictypes.h b/webrtc/base/basictypes.h index 4c3d5d1e51..6ca09d0e0a 100644 --- a/webrtc/base/basictypes.h +++ b/webrtc/base/basictypes.h @@ -14,10 +14,6 @@ #include // for NULL, size_t #include // for uintptr_t and (u)int_t types. -#ifdef HAVE_CONFIG_H -#include "config.h" // NOLINT -#endif - // Detect compiler is for x86 or x64. #if defined(__x86_64__) || defined(_M_X64) || \ defined(__i386__) || defined(_M_IX86) diff --git a/webrtc/base/logging.h b/webrtc/base/logging.h index e40ca4465f..8c7b3f70e5 100644 --- a/webrtc/base/logging.h +++ b/webrtc/base/logging.h @@ -46,10 +46,6 @@ #ifndef WEBRTC_BASE_LOGGING_H_ #define WEBRTC_BASE_LOGGING_H_ -#ifdef HAVE_CONFIG_H -#include "config.h" // NOLINT -#endif - #include #include #include diff --git a/webrtc/base/network.cc b/webrtc/base/network.cc index 4780e2f88d..0018779470 100644 --- a/webrtc/base/network.cc +++ b/webrtc/base/network.cc @@ -8,10 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include "webrtc/base/network.h" #if defined(WEBRTC_POSIX) diff --git a/webrtc/base/openssladapter.cc b/webrtc/base/openssladapter.cc index 264dae9e28..40c352d643 100644 --- a/webrtc/base/openssladapter.cc +++ b/webrtc/base/openssladapter.cc @@ -27,10 +27,6 @@ #include #include -#if HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - #include "webrtc/base/arraysize.h" #include "webrtc/base/common.h" #include "webrtc/base/logging.h" diff --git a/webrtc/base/opensslstreamadapter.cc b/webrtc/base/opensslstreamadapter.cc index 052e54df9f..8a3044d1a3 100644 --- a/webrtc/base/opensslstreamadapter.cc +++ b/webrtc/base/opensslstreamadapter.cc @@ -8,10 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#if HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - #if HAVE_OPENSSL_SSL_H #include "webrtc/base/opensslstreamadapter.h" diff --git a/webrtc/base/physicalsocketserver.cc b/webrtc/base/physicalsocketserver.cc index 4cea0403df..708499df53 100644 --- a/webrtc/base/physicalsocketserver.cc +++ b/webrtc/base/physicalsocketserver.cc @@ -50,11 +50,6 @@ #include "webrtc/base/winping.h" #include "webrtc/base/win32socketinit.h" -// stm: this will tell us if we are on OSX -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #if defined(WEBRTC_POSIX) #include // for TCP_NODELAY #define IP_MTU 14 // Until this is integrated from linux/in.h to netinet/in.h diff --git a/webrtc/base/proxydetect.cc b/webrtc/base/proxydetect.cc index 30959ca1d3..abb8f0a927 100644 --- a/webrtc/base/proxydetect.cc +++ b/webrtc/base/proxydetect.cc @@ -15,10 +15,6 @@ #include #endif // WEBRTC_WIN -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) #include #include diff --git a/webrtc/base/proxydetect.h b/webrtc/base/proxydetect.h index f9bf5f8734..708c332ae9 100644 --- a/webrtc/base/proxydetect.h +++ b/webrtc/base/proxydetect.h @@ -13,10 +13,6 @@ #include "webrtc/base/proxyinfo.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - namespace rtc { // Auto-detect the proxy server. Returns true if a proxy is configured, // although hostname may be empty if the proxy is not required for diff --git a/webrtc/base/ssladapter.cc b/webrtc/base/ssladapter.cc index 454a56637d..ba24e618ec 100644 --- a/webrtc/base/ssladapter.cc +++ b/webrtc/base/ssladapter.cc @@ -8,10 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#if HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - #include "webrtc/base/ssladapter.h" #include "webrtc/base/sslconfig.h" diff --git a/webrtc/base/sslidentity.cc b/webrtc/base/sslidentity.cc index 3673d74feb..14dfeb7914 100644 --- a/webrtc/base/sslidentity.cc +++ b/webrtc/base/sslidentity.cc @@ -9,10 +9,6 @@ */ // Handling of certificates and keypairs for SSLStreamAdapter's peer mode. -#if HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - #include "webrtc/base/sslidentity.h" #include diff --git a/webrtc/base/sslstreamadapter.cc b/webrtc/base/sslstreamadapter.cc index bcecc037ae..e0fce3ad2f 100644 --- a/webrtc/base/sslstreamadapter.cc +++ b/webrtc/base/sslstreamadapter.cc @@ -8,10 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#if HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - #include "webrtc/base/sslstreamadapter.h" #include "webrtc/base/sslconfig.h" diff --git a/webrtc/base/sslstreamadapterhelper.cc b/webrtc/base/sslstreamadapterhelper.cc new file mode 100644 index 0000000000..ccb689ecce --- /dev/null +++ b/webrtc/base/sslstreamadapterhelper.cc @@ -0,0 +1,140 @@ +/* + * Copyright 2004 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + + +#include + +#include "webrtc/base/sslstreamadapterhelper.h" + +#include "webrtc/base/common.h" +#include "webrtc/base/logging.h" +#include "webrtc/base/stream.h" + +namespace rtc { + +SSLStreamAdapterHelper::SSLStreamAdapterHelper(StreamInterface* stream) + : SSLStreamAdapter(stream), + state_(SSL_NONE), + role_(SSL_CLIENT), + ssl_error_code_(0), // Not meaningful yet + ssl_mode_(SSL_MODE_TLS), + ssl_max_version_(SSL_PROTOCOL_TLS_12) {} + +SSLStreamAdapterHelper::~SSLStreamAdapterHelper() = default; + +void SSLStreamAdapterHelper::SetIdentity(SSLIdentity* identity) { + ASSERT(identity_.get() == NULL); + identity_.reset(identity); +} + +void SSLStreamAdapterHelper::SetServerRole(SSLRole role) { + role_ = role; +} + +int SSLStreamAdapterHelper::StartSSLWithServer(const char* server_name) { + ASSERT(server_name != NULL && server_name[0] != '\0'); + ssl_server_name_ = server_name; + return StartSSL(); +} + +int SSLStreamAdapterHelper::StartSSLWithPeer() { + ASSERT(ssl_server_name_.empty()); + // It is permitted to specify peer_certificate_ only later. + return StartSSL(); +} + +void SSLStreamAdapterHelper::SetMode(SSLMode mode) { + ASSERT(state_ == SSL_NONE); + ssl_mode_ = mode; +} + +void SSLStreamAdapterHelper::SetMaxProtocolVersion(SSLProtocolVersion version) { + ssl_max_version_ = version; +} + +StreamState SSLStreamAdapterHelper::GetState() const { + switch (state_) { + case SSL_WAIT: + case SSL_CONNECTING: + return SS_OPENING; + case SSL_CONNECTED: + return SS_OPEN; + default: + return SS_CLOSED; + }; + // not reached +} + +bool SSLStreamAdapterHelper::GetPeerCertificate(SSLCertificate** cert) const { + if (!peer_certificate_) + return false; + + *cert = peer_certificate_->GetReference(); + return true; +} + +bool SSLStreamAdapterHelper::SetPeerCertificateDigest( + const std::string &digest_alg, + const unsigned char* digest_val, + size_t digest_len) { + ASSERT(peer_certificate_.get() == NULL); + ASSERT(peer_certificate_digest_algorithm_.empty()); + ASSERT(ssl_server_name_.empty()); + size_t expected_len; + + if (!GetDigestLength(digest_alg, &expected_len)) { + LOG(LS_WARNING) << "Unknown digest algorithm: " << digest_alg; + return false; + } + if (expected_len != digest_len) + return false; + + peer_certificate_digest_value_.SetData(digest_val, digest_len); + peer_certificate_digest_algorithm_ = digest_alg; + + return true; +} + +void SSLStreamAdapterHelper::Error(const char* context, int err, bool signal) { + LOG(LS_WARNING) << "SSLStreamAdapterHelper::Error(" + << context << ", " << err << "," << signal << ")"; + state_ = SSL_ERROR; + ssl_error_code_ = err; + Cleanup(); + if (signal) + StreamAdapterInterface::OnEvent(stream(), SE_CLOSE, err); +} + +void SSLStreamAdapterHelper::Close() { + Cleanup(); + ASSERT(state_ == SSL_CLOSED || state_ == SSL_ERROR); + StreamAdapterInterface::Close(); +} + +int SSLStreamAdapterHelper::StartSSL() { + ASSERT(state_ == SSL_NONE); + + if (StreamAdapterInterface::GetState() != SS_OPEN) { + state_ = SSL_WAIT; + return 0; + } + + state_ = SSL_CONNECTING; + int err = BeginSSL(); + if (err) { + Error("BeginSSL", err, false); + return err; + } + + return 0; +} + +} // namespace rtc + diff --git a/webrtc/libjingle/xmpp/xmppsocket.cc b/webrtc/libjingle/xmpp/xmppsocket.cc index 25e03efbe9..fd07828213 100644 --- a/webrtc/libjingle/xmpp/xmppsocket.cc +++ b/webrtc/libjingle/xmpp/xmppsocket.cc @@ -10,10 +10,6 @@ #include "xmppsocket.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include "webrtc/base/logging.h" #include "webrtc/base/thread.h" diff --git a/webrtc/media/base/mediaengine.cc b/webrtc/media/base/mediaengine.cc index 4027137565..fda7fac1a9 100644 --- a/webrtc/media/base/mediaengine.cc +++ b/webrtc/media/base/mediaengine.cc @@ -16,10 +16,6 @@ #include "webrtc/media/engine/webrtcmediaengine.h" #endif // HAVE_WEBRTC_VOICE && HAVE_WEBRTC_VIDEO -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG - namespace cricket { MediaEngineFactory::MediaEngineCreateFunction @@ -45,4 +41,4 @@ webrtc::RtpParameters CreateRtpParametersWithOneEncoding() { return parameters; } -}; // namespace cricket \ No newline at end of file +}; // namespace cricket diff --git a/webrtc/media/engine/webrtcvideocapturer.cc b/webrtc/media/engine/webrtcvideocapturer.cc index e175688e16..a540551059 100644 --- a/webrtc/media/engine/webrtcvideocapturer.cc +++ b/webrtc/media/engine/webrtcvideocapturer.cc @@ -10,10 +10,6 @@ #include "webrtc/media/engine/webrtcvideocapturer.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #include "webrtc/base/arraysize.h" #include "webrtc/base/bind.h" #include "webrtc/base/checks.h" diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc index fbaab675ec..2c7f2216f5 100644 --- a/webrtc/media/engine/webrtcvoiceengine.cc +++ b/webrtc/media/engine/webrtcvoiceengine.cc @@ -8,10 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef HAVE_WEBRTC_VOICE #include "webrtc/media/engine/webrtcvoiceengine.h" diff --git a/webrtc/modules/audio_coding/codecs/g722/g722_decode.c b/webrtc/modules/audio_coding/codecs/g722/g722_decode.c index 952a7d037f..4ebdb58364 100644 --- a/webrtc/modules/audio_coding/codecs/g722/g722_decode.c +++ b/webrtc/modules/audio_coding/codecs/g722/g722_decode.c @@ -7,7 +7,7 @@ * * Copyright (C) 2005 Steve Underwood * - * Despite my general liking of the GPL, I place my own contributions + * Despite my general liking of the GPL, I place my own contributions * to this code in the public domain for the benefit of all mankind - * even the slimy ones who might try to proprietize my work and use it * to my detriment. @@ -30,10 +30,6 @@ /*! \file */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include @@ -125,7 +121,7 @@ static void block4(G722DecoderState *s, int band, int d) s->band[band].d[i] = s->band[band].d[i - 1]; s->band[band].b[i] = s->band[band].bp[i]; } - + for (i = 2; i > 0; i--) { s->band[band].r[i] = s->band[band].r[i - 1]; @@ -201,9 +197,9 @@ size_t WebRtc_g722_decode(G722DecoderState *s, int16_t amp[], static const int wh[3] = {0, -214, 798}; static const int rh2[4] = {2, 1, 2, 1}; static const int qm2[4] = {-7408, -1616, 7408, 1616}; - static const int qm4[16] = + static const int qm4[16] = { - 0, -20456, -12896, -8968, + 0, -20456, -12896, -8968, -6288, -4240, -2584, -1200, 20456, 12896, 8968, 6288, 4240, 2584, 1200, 0 @@ -323,7 +319,7 @@ size_t WebRtc_g722_decode(G722DecoderState *s, int16_t amp[], else if (wd1 > 18432) wd1 = 18432; s->band[0].nb = wd1; - + /* Block 3L, SCALEL */ wd1 = (s->band[0].nb >> 6) & 31; wd2 = 8 - (s->band[0].nb >> 11); @@ -331,7 +327,7 @@ size_t WebRtc_g722_decode(G722DecoderState *s, int16_t amp[], s->band[0].det = wd3 << 2; block4(s, 0, dlowt); - + if (!s->eight_k) { /* Block 2H, INVQAH */ @@ -354,7 +350,7 @@ size_t WebRtc_g722_decode(G722DecoderState *s, int16_t amp[], else if (wd1 > 22528) wd1 = 22528; s->band[1].nb = wd1; - + /* Block 3H, SCALEH */ wd1 = (s->band[1].nb >> 6) & 31; wd2 = 10 - (s->band[1].nb >> 11); diff --git a/webrtc/modules/audio_coding/codecs/g722/g722_encode.c b/webrtc/modules/audio_coding/codecs/g722/g722_encode.c index 01ec127ca1..2bd784bf4a 100644 --- a/webrtc/modules/audio_coding/codecs/g722/g722_encode.c +++ b/webrtc/modules/audio_coding/codecs/g722/g722_encode.c @@ -9,7 +9,7 @@ * * All rights reserved. * - * Despite my general liking of the GPL, I place my own contributions + * Despite my general liking of the GPL, I place my own contributions * to this code in the public domain for the benefit of all mankind - * even the slimy ones who might try to proprietize my work and use it * to my detriment. @@ -30,10 +30,6 @@ /*! \file */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include @@ -122,7 +118,7 @@ static void block4(G722EncoderState *s, int band, int d) s->band[band].d[i] = s->band[band].d[i - 1]; s->band[band].b[i] = s->band[band].bp[i]; } - + for (i = 2; i > 0; i--) { s->band[band].r[i] = s->band[band].r[i - 1]; @@ -311,7 +307,7 @@ size_t WebRtc_g722_encode(G722EncoderState *s, uint8_t g722_data[], s->x[i] = s->x[i + 2]; s->x[22] = amp[j++]; s->x[23] = amp[j++]; - + /* Discard every other QMF output */ sumeven = 0; sumodd = 0; @@ -371,7 +367,7 @@ size_t WebRtc_g722_encode(G722EncoderState *s, uint8_t g722_data[], s->band[0].det = wd3 << 2; block4(s, 0, dlow); - + if (s->eight_k) { /* Just leave the high bits as zero */ diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc index 6e6623cf2b..996a2633f2 100644 --- a/webrtc/pc/channelmanager.cc +++ b/webrtc/pc/channelmanager.cc @@ -10,10 +10,6 @@ #include "webrtc/pc/channelmanager.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include "webrtc/api/mediacontroller.h" diff --git a/webrtc/pc/srtpfilter.cc b/webrtc/pc/srtpfilter.cc index 01db4448d2..e8ea2890ed 100644 --- a/webrtc/pc/srtpfilter.cc +++ b/webrtc/pc/srtpfilter.cc @@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#undef HAVE_CONFIG_H - #include "webrtc/pc/srtpfilter.h" #include