Move base64.h to the proper location.

Move base64.h to the proper location and put redirect header into the
old place to be able to switch downstream users on new location.

Bug: webrtc:8366
Change-Id: I5191fe631d32178d2efd1315ca9abd4250102291
Reviewed-on: https://webrtc-review.googlesource.com/88223
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24069}
diff --git a/LICENSE_THIRD_PARTY b/LICENSE_THIRD_PARTY
index 5bf445d..28a0c93 100644
--- a/LICENSE_THIRD_PARTY
+++ b/LICENSE_THIRD_PARTY
@@ -2,8 +2,6 @@
 party licenses. Paths to the files and associated licenses are collected here.
 
 Files governed by third party licenses:
-rtc_base/base64.cc
-rtc_base/base64.h
 rtc_base/sigslot.cc
 rtc_base/sigslot.h
 common_audio/fft4g.c
@@ -22,26 +20,6 @@
 Individual licenses for each file:
 -------------------------------------------------------------------------------
 Files:
-rtc_base/base64.cc
-rtc_base/base64.h
-
-License:
-//*********************************************************************
-//* Base64 - a simple base64 encoder and decoder.
-//*
-//*     Copyright (c) 1999, Bob Withers - bwit@pobox.com
-//*
-//* This code may be freely used for any purpose, either personal
-//* or commercial, provided the authors copyright notice remains
-//* intact.
-//*
-//* Enhancements by Stanley Yamane:
-//*     o reverse lookup table for the decode function
-//*     o reserve string buffer space in advance
-//*
-//*********************************************************************
--------------------------------------------------------------------------------
-Files:
 rtc_base/sigslot.cc
 rtc_base/sigslot.h
 
diff --git a/media/BUILD.gn b/media/BUILD.gn
index af72a83..04c9cc3 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -236,8 +236,8 @@
     "../modules/video_coding:video_coding",
     "../modules/video_coding:video_coding_utility",
     "../rtc_base:audio_format_to_string",
-    "../rtc_base:base64",
     "../rtc_base:checks",
+    "../rtc_base/third_party/base64",
   ]
 
   sources = [
diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc
index aca853f..715d68f 100644
--- a/media/engine/webrtcvoiceengine.cc
+++ b/media/engine/webrtcvoiceengine.cc
@@ -33,7 +33,6 @@
 #include "modules/audio_processing/aec_dump/aec_dump_factory.h"
 #include "modules/audio_processing/include/audio_processing.h"
 #include "rtc_base/arraysize.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/byteorder.h"
 #include "rtc_base/constructormagic.h"
 #include "rtc_base/helpers.h"
@@ -42,6 +41,7 @@
 #include "rtc_base/stringencode.h"
 #include "rtc_base/strings/audio_format_to_string.h"
 #include "rtc_base/stringutils.h"
+#include "rtc_base/third_party/base64/base64.h"
 #include "rtc_base/trace_event.h"
 #include "system_wrappers/include/field_trial.h"
 #include "system_wrappers/include/metrics.h"
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 869b269..94a3346 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -53,9 +53,9 @@
         ":desktop_capture_mock",
         ":primitives",
         ":screen_drawer",
-        "../../rtc_base:base64",
         "../../rtc_base:rtc_base",
         "../../rtc_base:rtc_base_approved",
+        "../../rtc_base/third_party/base64",
         "../../system_wrappers",
         "../../test:test_support",
         "../../test:video_test_support",
diff --git a/modules/desktop_capture/screen_capturer_integration_test.cc b/modules/desktop_capture/screen_capturer_integration_test.cc
index fdcf67b..3fe38da 100644
--- a/modules/desktop_capture/screen_capturer_integration_test.cc
+++ b/modules/desktop_capture/screen_capturer_integration_test.cc
@@ -24,10 +24,10 @@
 #include "modules/desktop_capture/mock_desktop_capturer_callback.h"
 #include "modules/desktop_capture/rgba_color.h"
 #include "modules/desktop_capture/screen_drawer.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/constructormagic.h"
 #include "rtc_base/logging.h"
+#include "rtc_base/third_party/base64/base64.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
 
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index 5003799..21d8490 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -163,7 +163,6 @@
     "../../api/video:video_frame_i420",
     "../../api/video_codecs:video_codecs_api",
     "../../common_video",
-    "../../rtc_base:base64",
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base",
     "../../rtc_base:rtc_base_approved",
@@ -172,6 +171,7 @@
     "../../rtc_base:sequenced_task_checker",
     "../../rtc_base/experiments:alr_experiment",
     "../../rtc_base/system:fallthrough",
+    "../../rtc_base/third_party/base64",
     "../../rtc_base/time:timestamp_extrapolator",
     "../../system_wrappers",
     "../../system_wrappers:field_trial_api",
diff --git a/modules/video_coding/h264_sprop_parameter_sets.cc b/modules/video_coding/h264_sprop_parameter_sets.cc
index a05a2a7..e858545 100644
--- a/modules/video_coding/h264_sprop_parameter_sets.cc
+++ b/modules/video_coding/h264_sprop_parameter_sets.cc
@@ -13,8 +13,8 @@
 #include <string>
 #include <vector>
 
-#include "rtc_base/base64.h"
 #include "rtc_base/logging.h"
+#include "rtc_base/third_party/base64/base64.h"
 
 namespace {
 
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index 4763001..e62822c 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -85,11 +85,11 @@
     "../api:libjingle_peerconnection_api",
     "../api:ortc_api",
     "../logging:ice_log",
-    "../rtc_base:base64",
     "../rtc_base:checks",
     "../rtc_base:rtc_base",
     "../rtc_base:safe_minmax",
     "../rtc_base:stringutils",
+    "../rtc_base/third_party/base64",
     "../system_wrappers:field_trial_api",
     "../system_wrappers:metrics_api",
     "//third_party/abseil-cpp/absl/memory",
diff --git a/p2p/base/port.cc b/p2p/base/port.cc
index 5beb2bf..9ec9dee 100644
--- a/p2p/base/port.cc
+++ b/p2p/base/port.cc
@@ -18,7 +18,6 @@
 
 #include "absl/memory/memory.h"
 #include "p2p/base/portallocator.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/crc32.h"
 #include "rtc_base/helpers.h"
@@ -28,6 +27,7 @@
 #include "rtc_base/numerics/safe_minmax.h"
 #include "rtc_base/stringencode.h"
 #include "rtc_base/stringutils.h"
+#include "rtc_base/third_party/base64/base64.h"
 
 namespace {
 
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 329d667..5a3329d 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -79,11 +79,11 @@
     "../media:rtc_media_base",
     "../modules/rtp_rtcp:rtp_rtcp_format",
     "../p2p:rtc_p2p",
-    "../rtc_base:base64",
     "../rtc_base:checks",
     "../rtc_base:rtc_base",
     "../rtc_base:rtc_task_queue",
     "../rtc_base:stringutils",
+    "../rtc_base/third_party/base64",
     "../system_wrappers:metrics_api",
     "//third_party/abseil-cpp/absl/memory",
     "//third_party/abseil-cpp/absl/types:optional",
@@ -197,12 +197,12 @@
     "../media:rtc_media_base",
     "../modules/congestion_controller/bbr",
     "../p2p:rtc_p2p",
-    "../rtc_base:base64",
     "../rtc_base:checks",
     "../rtc_base:rtc_base",
     "../rtc_base:rtc_base_approved",
     "../rtc_base:stringutils",
     "../rtc_base/experiments:congestion_controller_experiment",
+    "../rtc_base/third_party/base64",
     "../stats",
     "../system_wrappers",
     "../system_wrappers:field_trial_api",
@@ -478,9 +478,9 @@
       "../api:mock_rtp",
       "../api/units:time_delta",
       "../logging:fake_rtc_event_log",
-      "../rtc_base:base64",
       "../rtc_base:checks",
       "../rtc_base:stringutils",
+      "../rtc_base/third_party/base64",
       "../test:fileutils",
       "//third_party/abseil-cpp/absl/memory",
     ]
diff --git a/pc/mediasession.cc b/pc/mediasession.cc
index 37354b8..23706be 100644
--- a/pc/mediasession.cc
+++ b/pc/mediasession.cc
@@ -27,11 +27,11 @@
 #include "pc/channelmanager.h"
 #include "pc/rtpmediautils.h"
 #include "pc/srtpfilter.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/helpers.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/stringutils.h"
+#include "rtc_base/third_party/base64/base64.h"
 
 namespace {
 
diff --git a/pc/srtpfilter.cc b/pc/srtpfilter.cc
index 91142a5..5ffe342 100644
--- a/pc/srtpfilter.cc
+++ b/pc/srtpfilter.cc
@@ -16,11 +16,11 @@
 
 #include "media/base/rtputils.h"
 #include "pc/srtpsession.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/byteorder.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/stringencode.h"
+#include "rtc_base/third_party/base64/base64.h"
 #include "rtc_base/timeutils.h"
 #include "rtc_base/zero_memory.h"
 
diff --git a/pc/srtptransport.cc b/pc/srtptransport.cc
index 0c5265c..6fd8be3 100644
--- a/pc/srtptransport.cc
+++ b/pc/srtptransport.cc
@@ -18,9 +18,9 @@
 #include "pc/rtptransport.h"
 #include "pc/srtpsession.h"
 #include "rtc_base/asyncpacketsocket.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/copyonwritebuffer.h"
 #include "rtc_base/numerics/safe_conversions.h"
+#include "rtc_base/third_party/base64/base64.h"
 #include "rtc_base/trace_event.h"
 #include "rtc_base/zero_memory.h"
 
diff --git a/pc/statscollector.cc b/pc/statscollector.cc
index 2a59368..14a6c77 100644
--- a/pc/statscollector.cc
+++ b/pc/statscollector.cc
@@ -17,8 +17,8 @@
 
 #include "pc/channel.h"
 #include "pc/peerconnection.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/checks.h"
+#include "rtc_base/third_party/base64/base64.h"
 
 namespace webrtc {
 namespace {
diff --git a/pc/statscollector_unittest.cc b/pc/statscollector_unittest.cc
index f7e30e4..2a2a2dc 100644
--- a/pc/statscollector_unittest.cc
+++ b/pc/statscollector_unittest.cc
@@ -21,8 +21,8 @@
 #include "pc/test/fakepeerconnectionforstats.h"
 #include "pc/test/fakevideotracksource.h"
 #include "pc/videotrack.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/fakesslidentity.h"
+#include "rtc_base/third_party/base64/base64.h"
 #include "test/gtest.h"
 
 using cricket::ConnectionInfo;
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 982d5c4..bb8af91 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -371,7 +371,6 @@
   data_deps = []
   deps = [
     ":atomicops",
-    ":base64",
     ":checks",
     ":criticalsection",
     ":logging",
@@ -390,6 +389,7 @@
     ":type_traits",
     "../:typedefs",
     "system:arch",
+    "third_party/base64",
   ]
 
   sources = [
@@ -495,9 +495,11 @@
 rtc_source_set("base64") {
   visibility = [ "*" ]
   sources = [
-    "base64.cc",
     "base64.h",
   ]
+  deps = [
+    "third_party/base64",
+  ]
 }
 
 rtc_source_set("rtc_task_queue") {
@@ -723,11 +725,11 @@
   libs = []
   defines = []
   deps = [
-    ":base64",
     ":checks",
     ":stringutils",
     "..:webrtc_common",
     "../api:array_view",
+    "third_party/base64",
     "//third_party/abseil-cpp/absl/memory",
     "//third_party/abseil-cpp/absl/types:optional",
   ]
@@ -1160,7 +1162,6 @@
       sources += [ "win/windows_version_unittest.cc" ]
     }
     deps = [
-      ":base64",
       ":checks",
       ":rate_limiter",
       ":rtc_base",
@@ -1177,6 +1178,7 @@
       "../test:fileutils",
       "../test:test_support",
       "memory:unittests",
+      "third_party/base64",
       "//third_party/abseil-cpp/absl/memory",
     ]
   }
diff --git a/rtc_base/base64.h b/rtc_base/base64.h
index bfe2fe6..56ebfc9 100644
--- a/rtc_base/base64.h
+++ b/rtc_base/base64.h
@@ -1,123 +1,14 @@
+/*
+ *  Copyright 2018 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.
+ */
 
-//*********************************************************************
-//* C_Base64 - a simple base64 encoder and decoder.
-//*
-//*     Copyright (c) 1999, Bob Withers - bwit@pobox.com
-//*
-//* This code may be freely used for any purpose, either personal
-//* or commercial, provided the authors copyright notice remains
-//* intact.
-//*********************************************************************
-
-#ifndef RTC_BASE_BASE64_H_
-#define RTC_BASE_BASE64_H_
-
-#include <string>
-#include <vector>
-
-namespace rtc {
-
-class Base64 {
- public:
-  enum DecodeOption {
-    DO_PARSE_STRICT = 1,  // Parse only base64 characters
-    DO_PARSE_WHITE = 2,   // Parse only base64 and whitespace characters
-    DO_PARSE_ANY = 3,     // Parse all characters
-    DO_PARSE_MASK = 3,
-
-    DO_PAD_YES = 4,  // Padding is required
-    DO_PAD_ANY = 8,  // Padding is optional
-    DO_PAD_NO = 12,  // Padding is disallowed
-    DO_PAD_MASK = 12,
-
-    DO_TERM_BUFFER = 16,  // Must termiante at end of buffer
-    DO_TERM_CHAR = 32,    // May terminate at any character boundary
-    DO_TERM_ANY = 48,     // May terminate at a sub-character bit offset
-    DO_TERM_MASK = 48,
-
-    // Strictest interpretation
-    DO_STRICT = DO_PARSE_STRICT | DO_PAD_YES | DO_TERM_BUFFER,
-
-    DO_LAX = DO_PARSE_ANY | DO_PAD_ANY | DO_TERM_CHAR,
-  };
-  typedef int DecodeFlags;
-
-  static bool IsBase64Char(char ch);
-
-  // Get the char next to the |ch| from the Base64Table.
-  // If the |ch| is the last one in the Base64Table then returns
-  // the first one from the table.
-  // Expects the |ch| be a base64 char.
-  // The result will be saved in |next_ch|.
-  // Returns true on success.
-  static bool GetNextBase64Char(char ch, char* next_ch);
-
-  // Determines whether the given string consists entirely of valid base64
-  // encoded characters.
-  static bool IsBase64Encoded(const std::string& str);
-
-  static void EncodeFromArray(const void* data,
-                              size_t len,
-                              std::string* result);
-  static bool DecodeFromArray(const char* data,
-                              size_t len,
-                              DecodeFlags flags,
-                              std::string* result,
-                              size_t* data_used);
-  static bool DecodeFromArray(const char* data,
-                              size_t len,
-                              DecodeFlags flags,
-                              std::vector<char>* result,
-                              size_t* data_used);
-  static bool DecodeFromArray(const char* data,
-                              size_t len,
-                              DecodeFlags flags,
-                              std::vector<uint8_t>* result,
-                              size_t* data_used);
-
-  // Convenience Methods
-  static inline std::string Encode(const std::string& data) {
-    std::string result;
-    EncodeFromArray(data.data(), data.size(), &result);
-    return result;
-  }
-  static inline std::string Decode(const std::string& data, DecodeFlags flags) {
-    std::string result;
-    DecodeFromArray(data.data(), data.size(), flags, &result, nullptr);
-    return result;
-  }
-  static inline bool Decode(const std::string& data,
-                            DecodeFlags flags,
-                            std::string* result,
-                            size_t* data_used) {
-    return DecodeFromArray(data.data(), data.size(), flags, result, data_used);
-  }
-  static inline bool Decode(const std::string& data,
-                            DecodeFlags flags,
-                            std::vector<char>* result,
-                            size_t* data_used) {
-    return DecodeFromArray(data.data(), data.size(), flags, result, data_used);
-  }
-
- private:
-  static const char Base64Table[];
-  static const unsigned char DecodeTable[];
-
-  static size_t GetNextQuantum(DecodeFlags parse_flags,
-                               bool illegal_pads,
-                               const char* data,
-                               size_t len,
-                               size_t* dpos,
-                               unsigned char qbuf[4],
-                               bool* padded);
-  template <typename T>
-  static bool DecodeFromArrayTemplate(const char* data,
-                                      size_t len,
-                                      DecodeFlags flags,
-                                      T* result,
-                                      size_t* data_used);
-};
-
-}  // namespace rtc
-
-#endif  // RTC_BASE_BASE64_H_
+// This is a temporary header file to move origin header from this location
+// to specified in include. Don't use this header directly, use included one
+// instead.
+#include "rtc_base/third_party/base64/base64.h"
diff --git a/rtc_base/base64_unittest.cc b/rtc_base/base64_unittest.cc
index f73b396..4b857f1 100644
--- a/rtc_base/base64_unittest.cc
+++ b/rtc_base/base64_unittest.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "rtc_base/base64.h"
+#include "rtc_base/third_party/base64/base64.h"
 #include "rtc_base/gunit.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/stringutils.h"
diff --git a/rtc_base/helpers.cc b/rtc_base/helpers.cc
index 0260665..b9372b9 100644
--- a/rtc_base/helpers.cc
+++ b/rtc_base/helpers.cc
@@ -15,9 +15,9 @@
 
 #include <openssl/rand.h>
 
-#include "rtc_base/base64.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
+#include "rtc_base/third_party/base64/base64.h"
 #include "rtc_base/timeutils.h"
 
 // Protect against max macro inclusion.
diff --git a/rtc_base/httpcommon.cc b/rtc_base/httpcommon.cc
index 5ac1e42..0e7883d 100644
--- a/rtc_base/httpcommon.cc
+++ b/rtc_base/httpcommon.cc
@@ -21,13 +21,13 @@
 #include <algorithm>
 
 #include "rtc_base/arraysize.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/cryptstring.h"
 #include "rtc_base/httpcommon-inl.h"
 #include "rtc_base/httpcommon.h"
 #include "rtc_base/messagedigest.h"
 #include "rtc_base/socketaddress.h"
+#include "rtc_base/third_party/base64/base64.h"
 #include "rtc_base/zero_memory.h"
 
 namespace rtc {
diff --git a/rtc_base/sslcertificate.cc b/rtc_base/sslcertificate.cc
index d99da60..9a38fc0 100644
--- a/rtc_base/sslcertificate.cc
+++ b/rtc_base/sslcertificate.cc
@@ -15,11 +15,11 @@
 #include <utility>
 
 #include "absl/memory/memory.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/opensslcertificate.h"
 #include "rtc_base/sslfingerprint.h"
+#include "rtc_base/third_party/base64/base64.h"
 
 namespace rtc {
 
diff --git a/rtc_base/sslidentity.cc b/rtc_base/sslidentity.cc
index 94944f9..f286884 100644
--- a/rtc_base/sslidentity.cc
+++ b/rtc_base/sslidentity.cc
@@ -16,11 +16,11 @@
 #include <utility>
 
 #include "absl/memory/memory.h"
-#include "rtc_base/base64.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/opensslidentity.h"
 #include "rtc_base/sslfingerprint.h"
+#include "rtc_base/third_party/base64/base64.h"
 
 namespace rtc {
 
diff --git a/rtc_base/third_party/base64/BUILD.gn b/rtc_base/third_party/base64/BUILD.gn
new file mode 100644
index 0000000..dca47e0
--- /dev/null
+++ b/rtc_base/third_party/base64/BUILD.gn
@@ -0,0 +1,17 @@
+# Copyright (c) 2018 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.
+
+import("../../../webrtc.gni")
+
+rtc_source_set("base64") {
+  visibility = [ "*" ]
+  sources = [
+    "base64.cc",
+    "base64.h",
+  ]
+}
diff --git a/rtc_base/third_party/base64/LICENSE b/rtc_base/third_party/base64/LICENSE
new file mode 100644
index 0000000..4ad21d1
--- /dev/null
+++ b/rtc_base/third_party/base64/LICENSE
@@ -0,0 +1,14 @@
+//*********************************************************************
+//* Base64 - a simple base64 encoder and decoder.
+//*
+//*     Copyright (c) 1999, Bob Withers - bwit@pobox.com
+//*
+//* This code may be freely used for any purpose, either personal
+//* or commercial, provided the authors copyright notice remains
+//* intact.
+//*
+//* Enhancements by Stanley Yamane:
+//*     o reverse lookup table for the decode function
+//*     o reserve string buffer space in advance
+//*
+//*********************************************************************
diff --git a/rtc_base/third_party/base64/README.chromium b/rtc_base/third_party/base64/README.chromium
new file mode 100644
index 0000000..92ba0d3
--- /dev/null
+++ b/rtc_base/third_party/base64/README.chromium
@@ -0,0 +1,11 @@
+Name: A simple base64 encoder and decoder
+Short Name: base64
+URL:
+Version: 0
+Date: 2018-06-20
+License: Custom license
+License File: LICENSE
+Security Critical: yes
+
+Description:
+A simple base64 encoder and decoder
diff --git a/rtc_base/base64.cc b/rtc_base/third_party/base64/base64.cc
similarity index 99%
rename from rtc_base/base64.cc
rename to rtc_base/third_party/base64/base64.cc
index 6add993..53ff6b9 100644
--- a/rtc_base/base64.cc
+++ b/rtc_base/third_party/base64/base64.cc
@@ -14,10 +14,10 @@
 //*
 //*********************************************************************
 
-#include "rtc_base/base64.h"
+#include "rtc_base/third_party/base64/base64.h"
 
-#include <string.h>
 #include <assert.h>
+#include <string.h>
 
 using std::vector;
 
diff --git a/rtc_base/third_party/base64/base64.h b/rtc_base/third_party/base64/base64.h
new file mode 100644
index 0000000..bfe2fe6
--- /dev/null
+++ b/rtc_base/third_party/base64/base64.h
@@ -0,0 +1,123 @@
+
+//*********************************************************************
+//* C_Base64 - a simple base64 encoder and decoder.
+//*
+//*     Copyright (c) 1999, Bob Withers - bwit@pobox.com
+//*
+//* This code may be freely used for any purpose, either personal
+//* or commercial, provided the authors copyright notice remains
+//* intact.
+//*********************************************************************
+
+#ifndef RTC_BASE_BASE64_H_
+#define RTC_BASE_BASE64_H_
+
+#include <string>
+#include <vector>
+
+namespace rtc {
+
+class Base64 {
+ public:
+  enum DecodeOption {
+    DO_PARSE_STRICT = 1,  // Parse only base64 characters
+    DO_PARSE_WHITE = 2,   // Parse only base64 and whitespace characters
+    DO_PARSE_ANY = 3,     // Parse all characters
+    DO_PARSE_MASK = 3,
+
+    DO_PAD_YES = 4,  // Padding is required
+    DO_PAD_ANY = 8,  // Padding is optional
+    DO_PAD_NO = 12,  // Padding is disallowed
+    DO_PAD_MASK = 12,
+
+    DO_TERM_BUFFER = 16,  // Must termiante at end of buffer
+    DO_TERM_CHAR = 32,    // May terminate at any character boundary
+    DO_TERM_ANY = 48,     // May terminate at a sub-character bit offset
+    DO_TERM_MASK = 48,
+
+    // Strictest interpretation
+    DO_STRICT = DO_PARSE_STRICT | DO_PAD_YES | DO_TERM_BUFFER,
+
+    DO_LAX = DO_PARSE_ANY | DO_PAD_ANY | DO_TERM_CHAR,
+  };
+  typedef int DecodeFlags;
+
+  static bool IsBase64Char(char ch);
+
+  // Get the char next to the |ch| from the Base64Table.
+  // If the |ch| is the last one in the Base64Table then returns
+  // the first one from the table.
+  // Expects the |ch| be a base64 char.
+  // The result will be saved in |next_ch|.
+  // Returns true on success.
+  static bool GetNextBase64Char(char ch, char* next_ch);
+
+  // Determines whether the given string consists entirely of valid base64
+  // encoded characters.
+  static bool IsBase64Encoded(const std::string& str);
+
+  static void EncodeFromArray(const void* data,
+                              size_t len,
+                              std::string* result);
+  static bool DecodeFromArray(const char* data,
+                              size_t len,
+                              DecodeFlags flags,
+                              std::string* result,
+                              size_t* data_used);
+  static bool DecodeFromArray(const char* data,
+                              size_t len,
+                              DecodeFlags flags,
+                              std::vector<char>* result,
+                              size_t* data_used);
+  static bool DecodeFromArray(const char* data,
+                              size_t len,
+                              DecodeFlags flags,
+                              std::vector<uint8_t>* result,
+                              size_t* data_used);
+
+  // Convenience Methods
+  static inline std::string Encode(const std::string& data) {
+    std::string result;
+    EncodeFromArray(data.data(), data.size(), &result);
+    return result;
+  }
+  static inline std::string Decode(const std::string& data, DecodeFlags flags) {
+    std::string result;
+    DecodeFromArray(data.data(), data.size(), flags, &result, nullptr);
+    return result;
+  }
+  static inline bool Decode(const std::string& data,
+                            DecodeFlags flags,
+                            std::string* result,
+                            size_t* data_used) {
+    return DecodeFromArray(data.data(), data.size(), flags, result, data_used);
+  }
+  static inline bool Decode(const std::string& data,
+                            DecodeFlags flags,
+                            std::vector<char>* result,
+                            size_t* data_used) {
+    return DecodeFromArray(data.data(), data.size(), flags, result, data_used);
+  }
+
+ private:
+  static const char Base64Table[];
+  static const unsigned char DecodeTable[];
+
+  static size_t GetNextQuantum(DecodeFlags parse_flags,
+                               bool illegal_pads,
+                               const char* data,
+                               size_t len,
+                               size_t* dpos,
+                               unsigned char qbuf[4],
+                               bool* padded);
+  template <typename T>
+  static bool DecodeFromArrayTemplate(const char* data,
+                                      size_t len,
+                                      DecodeFlags flags,
+                                      T* result,
+                                      size_t* data_used);
+};
+
+}  // namespace rtc
+
+#endif  // RTC_BASE_BASE64_H_
diff --git a/tools_webrtc/libs/generate_licenses.py b/tools_webrtc/libs/generate_licenses.py
index aefcaf4..77064f1 100755
--- a/tools_webrtc/libs/generate_licenses.py
+++ b/tools_webrtc/libs/generate_licenses.py
@@ -47,6 +47,7 @@
     'usrsctp': ['third_party/usrsctp/LICENSE'],
     'webrtc': ['LICENSE', 'LICENSE_THIRD_PARTY'],
     'zlib': ['third_party/zlib/LICENSE'],
+    'base64': ['rtc_base/third_party/base64/LICENSE'],
 
     # Compile time dependencies, no license needed:
     'yasm': [],