Bug 1319489 - Remove MOZILLA_EXTERNAL_LINKAGE; r=jesup
authorDan Minor <dminor@mozilla.com>
Mon, 02 Jan 2017 08:09:03 -0500
changeset 372839 f03319359207676556b5b7f354d4e245c5ee0a9c
parent 372838 062be1b8915fe66089bfd66b028c81fa767f952b
child 372840 ee41fa1c5b0e873e1a43d7941fdd83d0fa572708
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1319489
milestone54.0a1
Bug 1319489 - Remove MOZILLA_EXTERNAL_LINKAGE; r=jesup MozReview-Commit-ID: G98qrMnJ0lK
media/webrtc/signaling/gtest/moz.build
media/webrtc/signaling/gtest/sdp_unittests.cpp
media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
media/webrtc/signaling/src/media-conduit/AudioConduit.h
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
--- a/media/webrtc/signaling/gtest/moz.build
+++ b/media/webrtc/signaling/gtest/moz.build
@@ -1,18 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # TODO: bug 1172551 - get these tests working on iOS
 if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'uikit':
-    DEFINES['MOZILLA_EXTERNAL_LINKAGE'] = True
-
     LOCAL_INCLUDES += [
       '/ipc/chromium/src',
       '/media/mtransport',
       '/media/webrtc/',
       '/media/webrtc/signaling/src/common/time_profiling',
       '/media/webrtc/signaling/src/peerconnection',
     ]
 
--- a/media/webrtc/signaling/gtest/sdp_unittests.cpp
+++ b/media/webrtc/signaling/gtest/sdp_unittests.cpp
@@ -12,18 +12,16 @@
 #define GTEST_HAS_RTTI 0
 #include "gtest/gtest.h"
 
 #include "nspr.h"
 #include "nss.h"
 #include "ssl.h"
 
 #include "nsThreadUtils.h"
-#include "PeerConnectionImpl.h"
-#include "PeerConnectionCtx.h"
 
 #include "signaling/src/sdp/SipccSdpParser.h"
 #include "signaling/src/sdp/SdpMediaSection.h"
 #include "signaling/src/sdp/SdpAttribute.h"
 
 extern "C" {
 #include "signaling/src/sdp/sipcc/sdp.h"
 #include "signaling/src/sdp/sipcc/sdp_private.h"
@@ -53,17 +51,16 @@ class SdpTest : public ::testing::Test {
     }
 
     void SetUp() {
       final_level_ = 0;
       sdp_ptr_ = nullptr;
     }
 
     static void TearDownTestCase() {
-      PeerConnectionCtx::Destroy();
     }
 
     void ResetSdp() {
       if (!sdp_ptr_) {
         sdp_free_description(sdp_ptr_);
       }
 
       sdp_media_e supported_media[] = {
--- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
+++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
@@ -182,22 +182,20 @@ void ConfigWebRtcLog(mozilla::LogLevel l
     nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir));
     if (NS_SUCCEEDED(rv)) {
       tempDir->AppendNative(default_log_name);
       tempDir->GetNativePath(aLogFile);
     }
   }
 #endif
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (XRE_IsParentProcess()) {
     // Capture the final choice for the trace setting.
     mozilla::Preferences::SetCString("media.webrtc.debug.log_file", aLogFile);
   }
-#endif
   return;
 }
 
 void StartWebRtcLog(uint32_t log_level)
 {
   if (gWebRtcTraceLoggingOn && log_level != 0) {
     return;
   }
@@ -276,22 +274,20 @@ void ConfigAecLog(nsCString &aAECLogDir)
     if (NS_SUCCEEDED(rv)) {
       if (aAECLogDir.IsEmpty()) {
         tempDir->GetNativePath(aAECLogDir);
       }
     }
   }
 #endif
   webrtc::Trace::set_aec_debug_filename(aAECLogDir.get());
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (XRE_IsParentProcess()) {
     // Capture the final choice for the aec_log_dir setting.
     mozilla::Preferences::SetCString("media.webrtc.debug.aec_log_dir", aAECLogDir);
   }
-#endif
 }
 
 void StartAecLog()
 {
   if (webrtc::Trace::aec_debug()) {
     return;
   }
   uint32_t trace_mask = 0;
--- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
@@ -13,20 +13,18 @@
 
 #include "AudioConduit.h"
 #include "nsCOMPtr.h"
 #include "mozilla/Services.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsThreadUtils.h"
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "Latency.h"
 #include "mozilla/Telemetry.h"
-#endif
 
 #include "webrtc/common.h"
 #include "webrtc/modules/audio_processing/include/audio_processing.h"
 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
 #include "webrtc/voice_engine/include/voe_dtmf.h"
 #include "webrtc/voice_engine/include/voe_errors.h"
 #include "webrtc/voice_engine/voice_engine_impl.h"
 #include "webrtc/system_wrappers/include/clock.h"
@@ -453,28 +451,26 @@ WebrtcAudioConduit::ConfigureSendMediaCo
           mChannel,
           codecConfig->mMaxPlaybackRate) == -1) {
       CSFLogError(logTag, "%s SetOpusMaxPlaybackRate Failed %d ", __FUNCTION__,
                   mPtrVoEBase->LastError());
       return kMediaConduitUnknownError;
     }
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // TEMPORARY - see bug 694814 comment 2
   nsresult rv;
   nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
   if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
 
     if (branch) {
       branch->GetIntPref("media.peerconnection.capture_delay", &mCaptureDelay);
     }
   }
-#endif
 
   condError = StartTransmitting();
   if (condError != kMediaConduitNoError) {
     return condError;
   }
 
   {
     MutexAutoLock lock(mCodecMutex);
@@ -613,22 +609,20 @@ WebrtcAudioConduit::SendAudioFrame(const
 
   // if transmission is not started .. conduit cannot insert frames
   if(!mEngineTransmitting)
   {
     CSFLogError(logTag, "%s Engine not transmitting ", __FUNCTION__);
     return kMediaConduitSessionNotInited;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
-    if (MOZ_LOG_TEST(GetLatencyLog(), LogLevel::Debug)) {
-      struct Processing insert = { TimeStamp::Now(), 0 };
-      mProcessing.AppendElement(insert);
-    }
-#endif
+  if (MOZ_LOG_TEST(GetLatencyLog(), LogLevel::Debug)) {
+    struct Processing insert = { TimeStamp::Now(), 0 };
+    mProcessing.AppendElement(insert);
+  }
 
   capture_delay = mCaptureDelay;
   //Insert the samples
   if(mPtrVoEXmedia->ExternalRecordingInsertData(audio_data,
                                                 lengthSamples,
                                                 samplingFreqHz,
                                                 capture_delay) == -1)
   {
@@ -707,35 +701,32 @@ WebrtcAudioConduit::GetAudioFrame(int16_
   mSamples += lengthSamples;
   if (mSamples >= mLastSyncLog + samplingFreqHz) {
     int jitter_buffer_delay_ms;
     int playout_buffer_delay_ms;
     int avsync_offset_ms;
     if (GetAVStats(&jitter_buffer_delay_ms,
                    &playout_buffer_delay_ms,
                    &avsync_offset_ms)) {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
       if (avsync_offset_ms < 0) {
         Telemetry::Accumulate(Telemetry::WEBRTC_AVSYNC_WHEN_VIDEO_LAGS_AUDIO_MS,
                               -avsync_offset_ms);
       } else {
         Telemetry::Accumulate(Telemetry::WEBRTC_AVSYNC_WHEN_AUDIO_LAGS_VIDEO_MS,
                               avsync_offset_ms);
       }
-#endif
       CSFLogError(logTag,
                   "A/V sync: sync delta: %dms, audio jitter delay %dms, playout delay %dms",
                   avsync_offset_ms, jitter_buffer_delay_ms, playout_buffer_delay_ms);
     } else {
       CSFLogError(logTag, "A/V sync: GetAVStats failed");
     }
     mLastSyncLog = mSamples;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (MOZ_LOG_TEST(GetLatencyLog(), LogLevel::Debug)) {
     if (mProcessing.Length() > 0) {
       unsigned int now;
       mPtrVoEVideoSync->GetPlayoutTimestamp(mChannel, now);
       if (static_cast<uint32_t>(now) != mLastTimestamp) {
         mLastTimestamp = static_cast<uint32_t>(now);
         // Find the block that includes this timestamp in the network input
         while (mProcessing.Length() > 0) {
@@ -748,38 +739,35 @@ WebrtcAudioConduit::GetAudioFrame(int16_
             LogTime(AsyncLatencyLogger::AudioRecvRTP, ((uint64_t) this), delta);
             break;
           }
           mProcessing.RemoveElementAt(0);
         }
       }
     }
   }
-#endif
   CSFLogDebug(logTag,"%s GetAudioFrame:Got samples: length %d ",__FUNCTION__,
                                                                lengthSamples);
   return kMediaConduitNoError;
 }
 
 // Transport Layer Callbacks
 MediaConduitErrorCode
 WebrtcAudioConduit::ReceivedRTPPacket(const void *data, int len)
 {
   CSFLogDebug(logTag,  "%s : channel %d", __FUNCTION__, mChannel);
 
   if(mEngineReceiving)
   {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     if (MOZ_LOG_TEST(GetLatencyLog(), LogLevel::Debug)) {
       // timestamp is at 32 bits in ([1])
       struct Processing insert = { TimeStamp::Now(),
                                    ntohl(static_cast<const uint32_t *>(data)[1]) };
       mProcessing.AppendElement(insert);
     }
-#endif
 
     // XXX we need to get passed the time the packet was received
     if(mPtrVoENetwork->ReceivedRTPPacket(mChannel, data, len) == -1)
     {
       int error = mPtrVoEBase->LastError();
       CSFLogError(logTag, "%s RTP Processing Error %d", __FUNCTION__, error);
       if(error == VE_RTP_RTCP_MODULE_ERROR)
       {
@@ -902,28 +890,26 @@ WebrtcAudioConduit::StartReceiving()
 // Called on AudioGUM or MSG thread
 bool
 WebrtcAudioConduit::SendRtp(const uint8_t* data,
                             size_t len,
                             const webrtc::PacketOptions& options)
 {
   CSFLogDebug(logTag,  "%s: len %lu", __FUNCTION__, (unsigned long)len);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (MOZ_LOG_TEST(GetLatencyLog(), LogLevel::Debug)) {
     if (mProcessing.Length() > 0) {
       TimeStamp started = mProcessing[0].mTimeStamp;
       mProcessing.RemoveElementAt(0);
       mProcessing.RemoveElementAt(0); // 20ms packetization!  Could automate this by watching sizes
       TimeDuration t = TimeStamp::Now() - started;
       int64_t delta = t.ToMilliseconds();
       LogTime(AsyncLatencyLogger::AudioSendRTP, ((uint64_t) this), delta);
     }
   }
-#endif
   ReentrantMonitorAutoEnter enter(mTransportMonitor);
   // XXX(pkerr) - the PacketOptions are being ignored. This parameter was added along
   // with the Call API update in the webrtc.org codebase.
   // The only field in it is the packet_id, which is used when the header
   // extension for TransportSequenceNumber is being used, which we don't.
   (void)options;
   if(mTransmitterTransport &&
      (mTransmitterTransport->SendRtpPacket(data, len) == NS_OK))
--- a/media/webrtc/signaling/src/media-conduit/AudioConduit.h
+++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.h
@@ -170,19 +170,17 @@ public:
                       mTransmitterTransport(nullptr),
                       mReceiverTransport(nullptr),
                       mEngineTransmitting(false),
                       mEngineReceiving(false),
                       mChannel(-1),
                       mDtmfEnabled(false),
                       mCodecMutex("AudioConduit codec db"),
                       mCaptureDelay(150),
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
                       mLastTimestamp(0),
-#endif // MOZILLA_INTERNAL_API
                       mSamples(0),
                       mLastSyncLog(0)
   {
   }
 
   virtual ~WebrtcAudioConduit();
 
   MediaConduitErrorCode Init();
@@ -298,19 +296,17 @@ private:
   RecvCodecList    mRecvCodecList;
 
   Mutex mCodecMutex; // protects mCurSendCodecConfig
   nsAutoPtr<AudioCodecConfig> mCurSendCodecConfig;
 
   // Current "capture" delay (really output plus input delay)
   int32_t mCaptureDelay;
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   uint32_t mLastTimestamp;
-#endif // MOZILLA_INTERNAL_API
 
   uint32_t mSamples;
   uint32_t mLastSyncLog;
 };
 
 } // end namespace
 
 #endif
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -37,19 +37,17 @@
 #ifdef MOZ_WEBRTC_OMX
 #include "OMXCodecWrapper.h"
 #include "OMXVideoCodec.h"
 #endif
 
 #ifdef MOZ_WEBRTC_MEDIACODEC
 #include "MediaCodecVideoCodec.h"
 #endif
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "WebrtcGmpVideoCodec.h"
-#endif
 
 // for ntohs
 #ifdef _MSC_VER
 #include "Winsock2.h"
 #else
 #include <netinet/in.h>
 #endif
 
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -9,51 +9,47 @@
 
 #include "MediaStreamGraphImpl.h"
 
 #include <math.h>
 
 #include "nspr.h"
 #include "srtp.h"
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "VideoSegment.h"
 #include "Layers.h"
 #include "LayersLogging.h"
 #include "ImageTypes.h"
 #include "ImageContainer.h"
 #include "DOMMediaStream.h"
 #include "MediaStreamTrack.h"
 #include "MediaStreamListener.h"
 #include "MediaStreamVideoSink.h"
 #include "VideoUtils.h"
 #include "VideoStreamTrack.h"
 #ifdef WEBRTC_GONK
 #include "GrallocImages.h"
 #include "mozilla/layers/GrallocTextureClient.h"
 #endif
-#endif
 
 #include "nsError.h"
 #include "AudioSegment.h"
 #include "MediaSegment.h"
 #include "MediaPipelineFilter.h"
 #include "databuffer.h"
 #include "transportflow.h"
 #include "transportlayer.h"
 #include "transportlayerdtls.h"
 #include "transportlayerice.h"
 #include "runnable_utils.h"
 #include "libyuv/convert.h"
 #include "mozilla/SharedThreadPool.h"
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "mozilla/PeerIdentity.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TaskQueue.h"
-#endif
 #include "mozilla/gfx/Point.h"
 #include "mozilla/gfx/Types.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "mozilla/Sprintf.h"
 
 #include "webrtc/common_types.h"
 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
@@ -72,17 +68,16 @@ using namespace mozilla::dom;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
 // Logging context
 MOZ_MTLOG_MODULE("mediapipeline")
 
 namespace mozilla {
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 class VideoConverterListener
 {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoConverterListener)
 
   virtual void OnVideoFrameConverted(unsigned char* aVideoFrame,
                                      unsigned int aVideoFrameLength,
                                      unsigned short aWidth,
@@ -460,47 +455,39 @@ protected:
   uint32_t mThrottleCount;
   uint32_t mThrottleRecord;
 #endif
 
   // mMutex guards the below variables.
   Mutex mMutex;
   nsTArray<RefPtr<VideoConverterListener>> mListeners;
 };
-#endif
 
 // An async inserter for audio data, to avoid running audio codec encoders
 // on the MSG/input audio thread.  Basically just bounces all the audio
 // data to a single audio processing/input queue.  We could if we wanted to
 // use multiple threads and a TaskQueue.
 class AudioProxyThread
 {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AudioProxyThread)
 
   explicit AudioProxyThread(AudioSessionConduit *aConduit)
     : mConduit(aConduit)
   {
     MOZ_ASSERT(mConduit);
     MOZ_COUNT_CTOR(AudioProxyThread);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     // Use only 1 thread; also forces FIFO operation
     // We could use multiple threads, but that may be dicier with the webrtc.org
     // code.  If so we'd need to use TaskQueues like the videoframe converter
     RefPtr<SharedThreadPool> pool =
       SharedThreadPool::Get(NS_LITERAL_CSTRING("AudioProxy"), 1);
 
     mThread = pool.get();
-#else
-    nsCOMPtr<nsIThread> thread;
-    if (!NS_WARN_IF(NS_FAILED(NS_NewNamedThread("AudioProxy", getter_AddRefs(thread))))) {
-      mThread = thread;
-    }
-#endif
   }
 
   // called on mThread
   void InternalProcessAudioChunk(
     TrackRate rate,
     AudioChunk& chunk,
     bool enabled) {
 
@@ -1228,21 +1215,19 @@ public:
                                             ConduitDeleteEvent(conduit_.forget()));
       MOZ_ASSERT(!NS_FAILED(rv),"Could not dispatch conduit shutdown to main");
       if (NS_FAILED(rv)) {
         MOZ_CRASH();
       }
     } else {
       conduit_ = nullptr;
     }
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     if (converter_) {
       converter_->Shutdown();
     }
-#endif
   }
 
   // Dispatches setting the internal TrackID to TRACK_INVALID to the media
   // graph thread to keep it in sync with other MediaStreamGraph operations
   // like RemoveListener() and AddListener(). The TrackID will be updated on
   // the next NewData() callback.
   void UnsetTrackId(MediaStreamGraphImpl* graph);
 
@@ -1251,17 +1236,16 @@ public:
 
   // These are needed since nested classes don't have access to any particular
   // instance of the parent
   void SetAudioProxy(const RefPtr<AudioProxyThread>& proxy)
   {
     audio_processing_ = proxy;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   void SetVideoFrameConverter(const RefPtr<VideoFrameConverter>& converter)
   {
     converter_ = converter;
   }
 
   void OnVideoFrameConverted(unsigned char* aVideoFrame,
                              unsigned int aVideoFrameLength,
                              unsigned short aWidth,
@@ -1274,17 +1258,16 @@ public:
       aVideoFrame, aVideoFrameLength, aWidth, aHeight, aVideoType, aCaptureTime);
   }
 
   void OnVideoFrameConverted(webrtc::VideoFrame& aVideoFrame)
   {
     MOZ_ASSERT(conduit_->type() == MediaSessionConduit::VIDEO);
     static_cast<VideoSessionConduit*>(conduit_.get())->SendVideoFrame(aVideoFrame);
   }
-#endif
 
   // Implement MediaStreamTrackListener
   void NotifyQueuedChanges(MediaStreamGraph* aGraph,
                            StreamTime aTrackOffset,
                            const MediaSegment& aQueuedMedia) override;
 
   // Implement DirectMediaStreamTrackListener
   void NotifyRealtimeTrackData(MediaStreamGraph* aGraph,
@@ -1302,19 +1285,17 @@ private:
     MutexAutoLock lock(mMutex);
     track_id_ = track_id_external_ = TRACK_INVALID;
   }
 
   void NewData(const MediaSegment& media, TrackRate aRate = 0);
 
   RefPtr<MediaSessionConduit> conduit_;
   RefPtr<AudioProxyThread> audio_processing_;
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   RefPtr<VideoFrameConverter> converter_;
-#endif
 
   // May be TRACK_INVALID until we see data from the track
   TrackID track_id_; // this is the current TrackID this listener is attached to
   Mutex mMutex;
   // protected by mMutex
   // May be TRACK_INVALID until we see data from the track
   TrackID track_id_external_; // this is queried from other threads
 
@@ -1323,17 +1304,16 @@ private:
   // enabled is true if the media access control permits sending
   // actual content; when false you get black/silence
   mozilla::Atomic<bool> enabled_;
 
   // Written and read on the MediaStreamGraph thread
   bool direct_connect_;
 };
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 // Implements VideoConverterListener for MediaPipeline.
 //
 // We pass converted frames on to MediaPipelineTransmit::PipelineListener
 // where they are further forwarded to VideoConduit.
 // MediaPipelineTransmit calls Detach() during shutdown to ensure there is
 // no cyclic dependencies between us and PipelineListener.
 class MediaPipelineTransmit::VideoFrameFeeder
   : public VideoConverterListener
@@ -1385,17 +1365,16 @@ protected:
   virtual ~VideoFrameFeeder()
   {
     MOZ_COUNT_DTOR(VideoFrameFeeder);
   }
 
   RefPtr<PipelineListener> listener_;
   Mutex mutex_;
 };
-#endif
 
 MediaPipelineTransmit::MediaPipelineTransmit(
     const std::string& pc,
     nsCOMPtr<nsIEventTarget> main_thread,
     nsCOMPtr<nsIEventTarget> sts_thread,
     dom::MediaStreamTrack* domtrack,
     const std::string& track_id,
     int level,
@@ -1407,38 +1386,34 @@ MediaPipelineTransmit::MediaPipelineTran
                 conduit, rtp_transport, rtcp_transport, filter),
   listener_(new PipelineListener(conduit)),
   domtrack_(domtrack)
 {
   if (!IsVideo()) {
     audio_processing_ = MakeAndAddRef<AudioProxyThread>(static_cast<AudioSessionConduit*>(conduit.get()));
     listener_->SetAudioProxy(audio_processing_);
   }
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   else { // Video
     // For video we send frames to an async VideoFrameConverter that calls
     // back to a VideoFrameFeeder that feeds I420 frames to VideoConduit.
 
     feeder_ = MakeAndAddRef<VideoFrameFeeder>(listener_);
 
     converter_ = MakeAndAddRef<VideoFrameConverter>();
     converter_->AddListener(feeder_);
 
     listener_->SetVideoFrameConverter(converter_);
   }
-#endif
 }
 
 MediaPipelineTransmit::~MediaPipelineTransmit()
 {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (feeder_) {
     feeder_->Detach();
   }
-#endif
 }
 
 nsresult MediaPipelineTransmit::Init() {
   AttachToTrack(track_id_);
 
   return MediaPipeline::Init();
 }
 
@@ -1487,17 +1462,16 @@ void MediaPipelineTransmit::AttachToTrac
 }
 
 bool
 MediaPipelineTransmit::IsVideo() const
 {
   return !!domtrack_->AsVideoStreamTrack();
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 void MediaPipelineTransmit::UpdateSinkIdentity_m(MediaStreamTrack* track,
                                                  nsIPrincipal* principal,
                                                  const PeerIdentity* sinkIdentity) {
   ASSERT_ON_THREAD(main_thread_);
 
   if (track != nullptr && track != domtrack_) {
     // If a track is specified, then it might not be for this pipeline,
     // since we receive notifications for all tracks on the PC.
@@ -1514,17 +1488,16 @@ void MediaPipelineTransmit::UpdateSinkId
     const PeerIdentity* trackIdentity = domtrack_->GetPeerIdentity();
     if (sinkIdentity && trackIdentity) {
       enableTrack = (*sinkIdentity == *trackIdentity);
     }
   }
 
   listener_->SetEnabled(enableTrack);
 }
-#endif
 
 void
 MediaPipelineTransmit::DetachMedia()
 {
   ASSERT_ON_THREAD(main_thread_);
   if (domtrack_) {
     if (domtrack_->AsAudioStreamTrack()) {
       domtrack_->RemoveDirectListener(listener_);
@@ -1549,23 +1522,19 @@ nsresult MediaPipelineTransmit::Transpor
     listener_->SetActive(true);
   }
 
   return NS_OK;
 }
 
 nsresult MediaPipelineTransmit::ReplaceTrack(MediaStreamTrack& domtrack) {
   // MainThread, checked in calls we make
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsString nsTrackId;
   domtrack.GetId(nsTrackId);
   std::string track_id(NS_ConvertUTF16toUTF8(nsTrackId).get());
-#else
-  std::string track_id = domtrack.GetId();
-#endif
   MOZ_MTLOG(ML_DEBUG, "Reattaching pipeline " << description_ << " to track "
             << static_cast<void *>(&domtrack)
             << " track " << track_id << " conduit type=" <<
             (conduit_->type() == MediaSessionConduit::AUDIO ?"audio":"video"));
 
   DetachMedia();
   domtrack_ = &domtrack; // Detach clears it
   // Unsets the track id after RemoveListener() takes effect.
@@ -1796,24 +1765,22 @@ NewData(const MediaSegment& media, Track
   // See bug 784517
   if (media.GetType() == MediaSegment::AUDIO) {
     MOZ_RELEASE_ASSERT(aRate > 0);
 
     AudioSegment* audio = const_cast<AudioSegment *>(static_cast<const AudioSegment*>(&media));
     for(AudioSegment::ChunkIterator iter(*audio); !iter.IsEnded(); iter.Next()) {
       audio_processing_->QueueAudioChunk(aRate, *iter, enabled_);
     }
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   } else {
     VideoSegment* video = const_cast<VideoSegment *>(static_cast<const VideoSegment*>(&media));
     VideoSegment::ChunkIterator iter(*video);
     for(VideoSegment::ChunkIterator iter(*video); !iter.IsEnded(); iter.Next()) {
       converter_->QueueVideoChunk(*iter, !enabled_);
     }
-#endif // MOZILLA_EXTERNAL_LINKAGE
   }
 }
 
 void MediaPipelineTransmit::PipelineListener::
 SetCurrentFrames(const VideoSegment& aSegment)
 {
   NewData(aSegment);
 }
@@ -1839,36 +1806,32 @@ class GenericReceiveCallback : public Tr
   void TrackAdded(TrackTicks time);
 
  private:
   RefPtr<GenericReceiveListener> listener_;
 };
 
 // Add a listener on the MSG thread using the MSG command queue
 static void AddListener(MediaStream* source, MediaStreamListener* listener) {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   class Message : public ControlMessage {
    public:
     Message(MediaStream* stream, MediaStreamListener* listener)
       : ControlMessage(stream),
         listener_(listener) {}
 
     virtual void Run() override {
       mStream->AddListenerImpl(listener_.forget());
     }
    private:
     RefPtr<MediaStreamListener> listener_;
   };
 
   MOZ_ASSERT(listener);
 
   source->GraphImpl()->AppendMessage(MakeUnique<Message>(source, listener));
-#else
-  source->AddListener(listener);
-#endif
 }
 
 class GenericReceiveListener : public MediaStreamListener
 {
  public:
   GenericReceiveListener(SourceMediaStream *source, TrackID track_id)
     : source_(source),
       track_id_(track_id),
@@ -2115,26 +2078,23 @@ public:
       width_(0),
       height_(0),
 #if defined(MOZILLA_INTERNAL_API)
       image_container_(),
       image_(),
 #endif
       monitor_("Video PipelineListener")
   {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     image_container_ =
       LayerManager::CreateImageContainer(ImageContainer::ASYNCHRONOUS);
-#endif
   }
 
   // Implement MediaStreamListener
   void NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) override
   {
-  #if defined(MOZILLA_INTERNAL_API)
     ReentrantMonitorAutoEnter enter(monitor_);
 
     RefPtr<Image> image = image_;
     StreamTime delta = desired_time - played_ticks_;
 
     // Don't append if we've already provided a frame that supposedly
     // goes past the current aDesiredTime Doing so means a negative
     // delta and thus messes up handling of the graph
@@ -2145,17 +2105,16 @@ public:
       // Handle track not actually added yet or removed/finished
       if (source_->AppendToTrack(track_id_, &segment)) {
         played_ticks_ = desired_time;
       } else {
         MOZ_MTLOG(ML_ERROR, "AppendToTrack failed");
         return;
       }
     }
-  #endif
   }
 
   // Accessors for external writes from the renderer
   void FrameSizeChange(unsigned int width,
                        unsigned int height,
                        unsigned int number_of_streams) {
     ReentrantMonitorAutoEnter enter(monitor_);
 
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
@@ -27,19 +27,17 @@
 #define WEBRTC_DEFAULT_SAMPLE_RATE 32000
 
 class nsIPrincipal;
 
 namespace mozilla {
 class MediaPipelineFilter;
 class PeerIdentity;
 class AudioProxyThread;
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 class VideoFrameConverter;
-#endif
 
 namespace dom {
   class MediaStreamTrack;
 } // namespace dom
 
 class SourceMediaStream;
 
 // A class that represents the pipeline of audio and video
@@ -314,24 +312,22 @@ public:
   // Initialize (stuff here may fail)
   nsresult Init() override;
 
   virtual void AttachToTrack(const std::string& track_id);
 
   // written and used from MainThread
   bool IsVideo() const override;
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // When the principal of the domtrack changes, it calls through to here
   // so that we can determine whether to enable track transmission.
   // `track` has to be null or equal `domtrack_` for us to apply the update.
   virtual void UpdateSinkIdentity_m(dom::MediaStreamTrack* track,
                                     nsIPrincipal* principal,
                                     const PeerIdentity* sinkIdentity);
-#endif
 
   // Called on the main thread.
   void DetachMedia() override;
 
   // Override MediaPipeline::TransportReady.
   nsresult TransportReady_s(TransportInfo &info) override;
 
   // Replace a track with a different one
@@ -345,20 +341,18 @@ public:
   class VideoFrameFeeder;
 
  protected:
   ~MediaPipelineTransmit();
 
  private:
   RefPtr<PipelineListener> listener_;
   RefPtr<AudioProxyThread> audio_processing_;
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   RefPtr<VideoFrameFeeder> feeder_;
   RefPtr<VideoFrameConverter> converter_;
-#endif
   dom::MediaStreamTrack* domtrack_;
 };
 
 
 // A specialization of pipeline for reading from the network and
 // rendering video.
 class MediaPipelineReceive : public MediaPipeline {
  public:
--- a/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp
+++ b/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp
@@ -14,31 +14,27 @@
 #include "transportlayer.h"
 #include "transportlayerdtls.h"
 #include "transportlayerice.h"
 
 #include "signaling/src/jsep/JsepTrack.h"
 #include "signaling/src/jsep/JsepTransport.h"
 #include "signaling/src/common/PtrVector.h"
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "MediaStreamTrack.h"
 #include "nsIPrincipal.h"
 #include "nsIDocument.h"
 #include "mozilla/Preferences.h"
 #include "MediaEngine.h"
-#endif
 
 #ifdef MOZILLA_INTERNAL_API
 #include "mozilla/Preferences.h"
 #endif
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "WebrtcGmpVideoCodec.h"
-#endif
 
 #include <stdlib.h>
 
 namespace mozilla {
 
 MOZ_MTLOG_MODULE("MediaPipelineFactory")
 
 static nsresult
@@ -377,23 +373,21 @@ MediaPipelineFactory::GetTransportParame
   return NS_OK;
 }
 
 nsresult
 MediaPipelineFactory::CreateOrUpdateMediaPipeline(
     const JsepTrackPair& aTrackPair,
     const JsepTrack& aTrack)
 {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // The GMP code is all the way on the other side of webrtc.org, and it is not
   // feasible to plumb this information all the way through. So, we set it (for
   // the duration of this call) in a global variable. This allows the GMP code
   // to report errors to the PC.
   WebrtcGmpPCHandleSetter setter(mPC->GetHandle());
-#endif
 
   MOZ_ASSERT(aTrackPair.mRtpTransport);
 
   bool receiving = aTrack.GetDirection() == sdp::kRecv;
 
   size_t level;
   RefPtr<TransportFlow> rtpFlow;
   RefPtr<TransportFlow> rtcpFlow;
@@ -633,28 +627,26 @@ MediaPipelineFactory::CreateMediaPipelin
       track,
       aTrack.GetTrackId(),
       aLevel,
       aConduit,
       aRtpFlow,
       aRtcpFlow,
       aFilter);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // implement checking for peerIdentity (where failure == black/silence)
   nsIDocument* doc = mPC->GetWindow()->GetExtantDoc();
   if (doc) {
     pipeline->UpdateSinkIdentity_m(track,
                                    doc->NodePrincipal(),
                                    mPC->GetPeerIdentity());
   } else {
     MOZ_MTLOG(ML_ERROR, "Cannot initialize pipeline without attached doc");
     return NS_ERROR_FAILURE; // Don't remove this till we know it's safe.
   }
-#endif
 
   rv = pipeline->Init();
   if (NS_FAILED(rv)) {
     MOZ_MTLOG(ML_ERROR, "Couldn't initialize sending pipeline");
     return rv;
   }
 
   rv = stream->StorePipeline(aTrack.GetTrackId(),
@@ -893,17 +885,16 @@ MediaPipelineFactory::GetOrCreateVideoCo
 
   return NS_OK;
 }
 
 nsresult
 MediaPipelineFactory::ConfigureVideoCodecMode(const JsepTrack& aTrack,
                                               VideoSessionConduit& aConduit)
 {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   RefPtr<LocalSourceStreamInfo> stream =
     mPCMedia->GetLocalStreamByTrackId(aTrack.GetTrackId());
 
   //get video track
   RefPtr<mozilla::dom::MediaStreamTrack> track =
     stream->GetTrackById(aTrack.GetTrackId());
 
   RefPtr<mozilla::dom::VideoStreamTrack> videotrack =
@@ -931,14 +922,13 @@ MediaPipelineFactory::ConfigureVideoCode
   }
 
   auto error = aConduit.ConfigureCodecMode(mode);
   if (error) {
     MOZ_MTLOG(ML_ERROR, "ConfigureCodecMode failed: " << error);
     return NS_ERROR_FAILURE;
   }
 
-#endif
   return NS_OK;
 }
 
 
 } // namespace mozilla
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp
@@ -7,21 +7,19 @@
 #include "PeerConnectionImpl.h"
 #include "PeerConnectionCtx.h"
 #include "runnable_utils.h"
 #include "prcvar.h"
 
 #include "mozilla/Telemetry.h"
 #include "browser_logging/WebRtcLog.h"
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "mozilla/dom/RTCPeerConnectionBinding.h"
 #include "mozilla/Preferences.h"
 #include <mozilla/Types.h>
-#endif
 
 #include "nsNetCID.h" // NS_SOCKETTRANSPORTSERVICE_CONTRACTID
 #include "nsServiceManagerUtils.h" // do_GetService
 #include "nsIObserverService.h"
 #include "nsIObserver.h"
 #include "nsIIOService.h" // NS_IOSERVICE_*
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
@@ -185,17 +183,16 @@ void PeerConnectionCtx::Destroy() {
     gInstance->Cleanup();
     delete gInstance;
     gInstance = nullptr;
   }
 
   StopWebRtcLog();
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 typedef Vector<nsAutoPtr<RTCStatsQuery>> RTCStatsQueries;
 
 // Telemetry reporting every second after start of first call.
 // The threading model around the media pipelines is weird:
 // - The pipelines are containers,
 // - containers that are only safe on main thread, with members only safe on STS,
 // - hence the there and back again approach.
 
@@ -357,44 +354,41 @@ PeerConnectionCtx::EverySecondTelemetryC
   }
   if (!queries->empty()) {
     rv = RUN_ON_THREAD(stsThread,
                        WrapRunnableNM(&EverySecondTelemetryCallback_s, queries),
                        NS_DISPATCH_NORMAL);
     NS_ENSURE_SUCCESS_VOID(rv);
   }
 }
-#endif
 
 void
 PeerConnectionCtx::UpdateNetworkState(bool online) {
   auto ctx = GetInstance();
   if (ctx->mPeerConnections.empty()) {
     return;
   }
   for (auto pc : ctx->mPeerConnections) {
     pc.second->UpdateNetworkState(online);
   }
 }
 
 nsresult PeerConnectionCtx::Initialize() {
   initGMP();
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   mTelemetryTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
   MOZ_ASSERT(mTelemetryTimer);
   nsresult rv = mTelemetryTimer->SetTarget(gMainThread);
   NS_ENSURE_SUCCESS(rv, rv);
   mTelemetryTimer->InitWithFuncCallback(EverySecondTelemetryCallback_m, this, 1000,
                                         nsITimer::TYPE_REPEATING_PRECISE_CAN_SKIP);
 
   if (XRE_IsContentProcess()) {
     WebrtcGlobalChild::Create();
   }
-#endif // MOZILLA_INTERNAL_API
 
   return NS_OK;
 }
 
 static void GMPReady_m() {
   if (PeerConnectionCtx::isActive()) {
     PeerConnectionCtx::GetInstance()->onGMPReady();
   }
@@ -437,21 +431,19 @@ nsresult PeerConnectionCtx::Cleanup() {
   mQueuedJSEPOperations.Clear();
   mGMPService = nullptr;
   return NS_OK;
 }
 
 PeerConnectionCtx::~PeerConnectionCtx() {
     // ensure mTelemetryTimer ends on main thread
   MOZ_ASSERT(NS_IsMainThread());
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (mTelemetryTimer) {
     mTelemetryTimer->Cancel();
   }
-#endif
 };
 
 void PeerConnectionCtx::queueJSEPOperation(nsIRunnable* aOperation) {
   mQueuedJSEPOperations.AppendElement(aOperation);
 }
 
 void PeerConnectionCtx::onGMPReady() {
   mGMPReady = true;
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h
@@ -2,19 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef peerconnectionctx_h___h__
 #define peerconnectionctx_h___h__
 
 #include <string>
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "WebrtcGlobalChild.h"
-#endif
 
 #include "mozilla/Attributes.h"
 #include "mozilla/StaticPtr.h"
 #include "PeerConnectionImpl.h"
 #include "mozIGeckoMediaPluginService.h"
 #include "nsIRunnable.h"
 
 namespace mozilla {
@@ -50,22 +48,20 @@ class PeerConnectionCtx {
 
   static void UpdateNetworkState(bool online);
 
   // Make these classes friend so that they can access mPeerconnections.
   friend class PeerConnectionImpl;
   friend class PeerConnectionWrapper;
   friend class mozilla::dom::WebrtcGlobalInformation;
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // WebrtcGlobalInformation uses this; we put it here so we don't need to
   // create another shutdown observer class.
   mozilla::dom::Sequence<mozilla::dom::RTCStatsReportInternal>
     mStatsForClosedPeerConnections;
-#endif
 
   const std::map<const std::string, PeerConnectionImpl *>& mGetPeerConnections();
  private:
   // We could make these available only via accessors but it's too much trouble.
   std::map<const std::string, PeerConnectionImpl *> mPeerConnections;
 
   PeerConnectionCtx() :  mGMPReady(false) {}
   // This is a singleton, so don't copy construct it, etc.
@@ -76,25 +72,23 @@ class PeerConnectionCtx {
   nsresult Initialize();
   nsresult Cleanup();
 
   void initGMP();
 
   static void
   EverySecondTelemetryCallback_m(nsITimer* timer, void *);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsCOMPtr<nsITimer> mTelemetryTimer;
 
 public:
   // TODO(jib): If we ever enable move semantics on std::map...
   //std::map<nsString,nsAutoPtr<mozilla::dom::RTCStatsReportInternal>> mLastReports;
   nsTArray<nsAutoPtr<mozilla::dom::RTCStatsReportInternal>> mLastReports;
 private:
-#endif
 
   // We cannot form offers/answers properly until the Gecko Media Plugin stuff
   // has been initted, which is a complicated mess of thread dispatches,
   // including sync dispatches to main. So, we need to be able to queue up
   // offer creation (or SetRemote, when we're the answerer) until all of this is
   // ready to go, since blocking on this init is just begging for deadlock.
   nsCOMPtr<mozIGeckoMediaPluginService> mGMPService;
   bool mGMPReady;
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -44,17 +44,16 @@
 
 #include "signaling/src/jsep/JsepTrack.h"
 #include "signaling/src/jsep/JsepSession.h"
 #include "signaling/src/jsep/JsepSessionImpl.h"
 
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Sprintf.h"
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #ifdef XP_WIN
 // We need to undef the MS macro for nsIDocument::CreateEvent
 #ifdef CreateEvent
 #undef CreateEvent
 #endif
 #endif // XP_WIN
 
 #include "nsIDocument.h"
@@ -95,18 +94,16 @@
 #include "nsIScriptGlobalObject.h"
 #include "MediaStreamGraph.h"
 #include "DOMMediaStream.h"
 #include "rlogconnector.h"
 #include "WebrtcGlobalInformation.h"
 #include "mozilla/dom/Event.h"
 #include "nsIDOMCustomEvent.h"
 #include "mozilla/EventDispatcher.h"
-#endif
-
 #include "mozilla/net/DataChannelProtocol.h"
 
 #include "MediaStreamGraphImpl.h"
 
 #ifdef XP_WIN
 // We need to undef the MS macro again in case the windows include file
 // got imported after we included nsIDocument.h
 #ifdef CreateEvent
@@ -148,19 +145,17 @@ namespace {
 // BaseErrorResult directly.  Please do not let me see _anyone_ doing this
 // without really careful review from someone who knows what they are doing.
 class JSErrorResult :
     public binding_danger::TErrorResult<binding_danger::JustAssertCleanupPolicy>
 {
 public:
   ~JSErrorResult()
   {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     SuppressException();
-#endif
   }
 };
 
 // The WrapRunnable() macros copy passed-in args and passes them to the function
 // later on the other thread. ErrorResult cannot be passed like this because it
 // disallows copy-semantics.
 //
 // This WrappableJSErrorResult hack solves this by not actually copying the
@@ -185,17 +180,16 @@ public:
   operator JSErrorResult &() { return *mRv; }
   operator ErrorResult &() { return *mRv; }
 private:
   mozilla::UniquePtr<JSErrorResult> mRv;
   bool isCopy;
 };
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 static nsresult InitNSSInContent()
 {
   NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_NOT_SAME_THREAD);
 
   if (!XRE_IsContentProcess()) {
     MOZ_ASSERT_UNREACHABLE("Must be called in content process");
     return NS_ERROR_FAILURE;
   }
@@ -216,57 +210,52 @@ static nsresult InitNSSInContent()
   }
 
   mozilla::psm::DisableMD5();
 
   nssStarted = true;
 
   return NS_OK;
 }
-#endif // MOZILLA_INTERNAL_API
 
 namespace mozilla {
   class DataChannel;
 }
 
 class nsIDOMDataChannel;
 
 // XXX Workaround for bug 998092 to maintain the existing broken semantics
 template<>
 struct nsISupportsWeakReference::COMTypeInfo<nsSupportsWeakReference, void> {
   static const nsIID kIID;
 };
 const nsIID nsISupportsWeakReference::COMTypeInfo<nsSupportsWeakReference, void>::kIID = NS_ISUPPORTSWEAKREFERENCE_IID;
 
 namespace mozilla {
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 RTCStatsQuery::RTCStatsQuery(bool internal) :
   failed(false),
   internalStats(internal),
   grabAllLevels(false) {
 }
 
 RTCStatsQuery::~RTCStatsQuery() {
   MOZ_ASSERT(NS_IsMainThread());
 }
 
-#endif
 
 NS_IMPL_ISUPPORTS0(PeerConnectionImpl)
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 bool
 PeerConnectionImpl::WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto,
                                JS::MutableHandle<JSObject*> aReflector)
 {
   return PeerConnectionImplBinding::Wrap(aCx, this, aGivenProto, aReflector);
 }
-#endif
 
 bool PCUuidGenerator::Generate(std::string* idp) {
   nsresult rv;
 
   if(!mGenerator) {
     mGenerator = do_GetService("@mozilla.org/uuid-generator;1", &rv);
     if (NS_FAILED(rv)) {
       return false;
@@ -285,107 +274,93 @@ bool PCUuidGenerator::Generate(std::stri
   id.ToProvidedString(buffer);
   idp->assign(buffer);
 
   return true;
 }
 
 bool IsPrivateBrowsing(nsPIDOMWindowInner* aWindow)
 {
-#if defined(MOZILLA_EXTERNAL_LINKAGE)
-  return false;
-#else
   if (!aWindow) {
     return false;
   }
 
   nsIDocument *doc = aWindow->GetExtantDoc();
   if (!doc) {
     return false;
   }
 
   nsILoadContext *loadContext = doc->GetLoadContext();
   return loadContext && loadContext->UsePrivateBrowsing();
-#endif
 }
 
 PeerConnectionImpl::PeerConnectionImpl(const GlobalObject* aGlobal)
 : mTimeCard(MOZ_LOG_TEST(logModuleInfo,LogLevel::Error) ?
             create_timecard() : nullptr)
   , mSignalingState(PCImplSignalingState::SignalingStable)
   , mIceConnectionState(PCImplIceConnectionState::New)
   , mIceGatheringState(PCImplIceGatheringState::New)
   , mDtlsConnected(false)
   , mWindow(nullptr)
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   , mCertificate(nullptr)
-#else
-  , mIdentity(nullptr)
-#endif
   , mPrivacyRequested(false)
   , mSTSThread(nullptr)
   , mAllowIceLoopback(false)
   , mAllowIceLinkLocal(false)
   , mForceIceTcp(false)
   , mMedia(nullptr)
   , mUuidGen(MakeUnique<PCUuidGenerator>())
   , mNumAudioStreams(0)
   , mNumVideoStreams(0)
   , mHaveConfiguredCodecs(false)
   , mHaveDataStream(false)
   , mAddCandidateErrorCount(0)
   , mTrickle(true) // TODO(ekr@rtfm.com): Use pref
   , mNegotiationNeeded(false)
   , mPrivateWindow(false)
 {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   MOZ_ASSERT(NS_IsMainThread());
   auto log = RLogConnector::CreateInstance();
   if (aGlobal) {
     mWindow = do_QueryInterface(aGlobal->GetAsSupports());
     if (IsPrivateBrowsing(mWindow)) {
       mPrivateWindow = true;
       log->EnterPrivateMode();
     }
   }
-#endif
   CSFLogInfo(logTag, "%s: PeerConnectionImpl constructor for %s",
              __FUNCTION__, mHandle.c_str());
   STAMP_TIMECARD(mTimeCard, "Constructor Completed");
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   mAllowIceLoopback = Preferences::GetBool(
     "media.peerconnection.ice.loopback", false);
   mAllowIceLinkLocal = Preferences::GetBool(
     "media.peerconnection.ice.link_local", false);
   mForceIceTcp = Preferences::GetBool(
     "media.peerconnection.ice.force_ice_tcp", false);
-#endif
   memset(mMaxReceiving, 0, sizeof(mMaxReceiving));
   memset(mMaxSending, 0, sizeof(mMaxSending));
 }
 
 PeerConnectionImpl::~PeerConnectionImpl()
 {
   if (mTimeCard) {
     STAMP_TIMECARD(mTimeCard, "Destructor Invoked");
     print_timecard(mTimeCard);
     destroy_timecard(mTimeCard);
     mTimeCard = nullptr;
   }
   // This aborts if not on main thread (in Debug builds)
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (mPrivateWindow) {
     auto * log = RLogConnector::GetInstance();
     if (log) {
       log->ExitPrivateMode();
     }
     mPrivateWindow = false;
   }
-#endif
   if (PeerConnectionCtx::isActive()) {
     PeerConnectionCtx::GetInstance()->mPeerConnections.erase(mHandle);
   } else {
     CSFLogError(logTag, "PeerConnectionCtx is already gone. Ignoring...");
   }
 
   CSFLogInfo(logTag, "%s: PeerConnectionImpl destructor invoked for %s",
              __FUNCTION__, mHandle.c_str());
@@ -431,17 +406,16 @@ PeerConnectionImpl::CreateRemoteSourceSt
 
   RefPtr<RemoteSourceStreamInfo> remote;
   remote = new RemoteSourceStreamInfo(stream.forget(), mMedia, aStreamID);
   *aInfo = remote;
 
   return NS_OK;
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 /**
  * In JS, an RTCConfiguration looks like this:
  *
  * { "iceServers": [ { url:"stun:stun.example.org" },
  *                   { url:"turn:turn.example.org?transport=udp",
  *                     username: "jib", credential:"mypass"} ] }
  *
  * This function converts that into an internal PeerConnectionConfiguration
@@ -583,17 +557,16 @@ PeerConnectionConfiguration::AddIceServe
     } else {
       if (!addStunServer(host.get(), port, transport.get())) {
         return NS_ERROR_FAILURE;
       }
     }
   }
   return NS_OK;
 }
-#endif
 
 nsresult
 PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
                                nsGlobalWindow* aWindow,
                                const PeerConnectionConfiguration& aConfiguration,
                                nsISupports* aThread)
 {
   nsresult res;
@@ -607,59 +580,52 @@ PeerConnectionImpl::Initialize(PeerConne
   CheckThread();
 
   mPCObserver = do_GetWeakReference(&aObserver);
 
   // Find the STS thread
 
   mSTSThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &res);
   MOZ_ASSERT(mSTSThread);
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 
   // Initialize NSS if we are in content process. For chrome process, NSS should already
   // been initialized.
   if (XRE_IsParentProcess()) {
     // This code interferes with the C++ unit test startup code.
     nsCOMPtr<nsISupports> nssDummy = do_GetService("@mozilla.org/psm;1", &res);
     NS_ENSURE_SUCCESS(res, res);
   } else {
     NS_ENSURE_SUCCESS(res = InitNSSInContent(), res);
   }
 
   // Currently no standalone unit tests for DataChannel,
   // which is the user of mWindow
   MOZ_ASSERT(aWindow);
   mWindow = aWindow->AsInner();
   NS_ENSURE_STATE(mWindow);
-#endif // MOZILLA_INTERNAL_API
 
   PRTime timestamp = PR_Now();
   // Ok if we truncate this.
   char temp[128];
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsAutoCString locationCStr;
 
   if (nsCOMPtr<nsIDOMLocation> location = mWindow->GetLocation()) {
     nsAutoString locationAStr;
     location->ToString(locationAStr);
 
     CopyUTF16toUTF8(locationAStr, locationCStr);
   }
 
   SprintfLiteral(temp,
                  "%" PRIu64 " (id=%" PRIu64 " url=%s)",
                  static_cast<uint64_t>(timestamp),
                  static_cast<uint64_t>(mWindow ? mWindow->WindowID() : 0),
                  locationCStr.get() ? locationCStr.get() : "NULL");
 
-#else
-  SprintfLiteral(temp, "%" PRIu64, static_cast<uint64_t>(timestamp));
-#endif // MOZILLA_INTERNAL_API
-
   mName = temp;
 
   // Generate a random handle
   unsigned char handle_bin[8];
   SECStatus rv;
   rv = PK11_GenerateRandom(handle_bin, sizeof(handle_bin));
   if (rv != SECSuccess) {
     MOZ_CRASH();
@@ -727,47 +693,28 @@ PeerConnectionImpl::Initialize(PeerConne
                                         mMedia->ice_ctx()->pwd());
   if (NS_FAILED(res)) {
     CSFLogError(logTag, "%s: Couldn't set ICE credentials, res=%u",
                          __FUNCTION__,
                          static_cast<unsigned>(res));
     return res;
   }
 
-#if defined(MOZILLA_EXTERNAL_LINKAGE)
-  {
-    mIdentity = DtlsIdentity::Generate();
-    if (!mIdentity) {
-      return NS_ERROR_FAILURE;
-    }
-
-    std::vector<uint8_t> fingerprint;
-    res = CalculateFingerprint(DtlsIdentity::DEFAULT_HASH_ALGORITHM,
-                               &fingerprint);
-    NS_ENSURE_SUCCESS(res, res);
-
-    res = mJsepSession->AddDtlsFingerprint(DtlsIdentity::DEFAULT_HASH_ALGORITHM,
-                                           fingerprint);
-    NS_ENSURE_SUCCESS(res, res);
-  }
-#endif
-
   res = mJsepSession->SetBundlePolicy(aConfiguration.getBundlePolicy());
   if (NS_FAILED(res)) {
     CSFLogError(logTag, "%s: Couldn't set bundle policy, res=%u, error=%s",
                         __FUNCTION__,
                         static_cast<unsigned>(res),
                         mJsepSession->GetLastError().c_str());
     return res;
   }
 
   return NS_OK;
 }
 
-#ifndef MOZILLA_EXTERNAL_LINKAGE
 void
 PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
                                nsGlobalWindow& aWindow,
                                const RTCConfiguration& aConfiguration,
                                nsISupports* aThread,
                                ErrorResult &rv)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -787,19 +734,17 @@ PeerConnectionImpl::Initialize(PeerConne
     rv.Throw(res);
   }
 
   if (!aConfiguration.mPeerIdentity.IsEmpty()) {
     mPeerIdentity = new PeerIdentity(aConfiguration.mPeerIdentity);
     mPrivacyRequested = true;
   }
 }
-#endif
-
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
+
 void
 PeerConnectionImpl::SetCertificate(mozilla::dom::RTCCertificate& aCertificate)
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
   MOZ_ASSERT(!mCertificate, "This can only be called once");
   mCertificate = &aCertificate;
 
   std::vector<uint8_t> fingerprint;
@@ -821,29 +766,23 @@ PeerConnectionImpl::SetCertificate(mozil
 }
 
 const RefPtr<mozilla::dom::RTCCertificate>&
 PeerConnectionImpl::Certificate() const
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
   return mCertificate;
 }
-#endif
 
 RefPtr<DtlsIdentity>
 PeerConnectionImpl::Identity() const
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   MOZ_ASSERT(mCertificate);
   return mCertificate->CreateDtlsIdentity();
-#else
-  RefPtr<DtlsIdentity> id = mIdentity;
-  return id;
-#endif
 }
 
 class CompareCodecPriority {
   public:
     void SetPreferredCodec(int32_t preferredCodec) {
       // This pref really ought to be a string, preferably something like
       // "H264" or "VP8" instead of a payload type.
       // Bug 1101259.
@@ -913,22 +852,17 @@ class ConfigureCodec {
         if (encode->ReserveOMXCodec() && decode->ReserveOMXCodec()) {
           CSFLogDebug( logTag, "%s: H264 hardware codec available", __FUNCTION__);
           mHardwareH264Supported = true;
         }
       }
 
 #endif // MOZ_WEBRTC_OMX
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
       mSoftwareH264Enabled = PeerConnectionCtx::GetInstance()->gmpHasH264();
-#else
-      // For unit-tests
-      mSoftwareH264Enabled = true;
-#endif
 
       mH264Enabled = mHardwareH264Supported || mSoftwareH264Enabled;
 
       branch->GetIntPref("media.navigator.video.h264.level", &mH264Level);
       mH264Level &= 0xFF;
 
       branch->GetIntPref("media.navigator.video.h264.max_br", &mH264MaxBr);
 
@@ -1146,32 +1080,30 @@ PeerConnectionImpl::ConfigureJsepSession
 // Data channels won't work without a window, so in order for the C++ unit
 // tests to work (it doesn't have a window available) we ifdef the following
 // two implementations.
 NS_IMETHODIMP
 PeerConnectionImpl::EnsureDataConnection(uint16_t aNumstreams)
 {
   PC_AUTO_ENTER_API_CALL(false);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (mDataConnection) {
     CSFLogDebug(logTag,"%s DataConnection already connected",__FUNCTION__);
     // Ignore the request to connect when already connected.  This entire
     // implementation is temporary.  Ignore aNumstreams as it's merely advisory
     // and we increase the number of streams dynamically as needed.
     return NS_OK;
   }
   mDataConnection = new DataChannelConnection(this);
   if (!mDataConnection->Init(5000, aNumstreams, true)) {
     CSFLogError(logTag,"%s DataConnection Init Failed",__FUNCTION__);
     return NS_ERROR_FAILURE;
   }
   CSFLogDebug(logTag,"%s DataChannelConnection %p attached to %s",
               __FUNCTION__, (void*) mDataConnection.get(), mHandle.c_str());
-#endif
   return NS_OK;
 }
 
 nsresult
 PeerConnectionImpl::GetDatachannelParameters(
     uint32_t* channels,
     uint16_t* localport,
     uint16_t* remoteport,
@@ -1302,17 +1234,16 @@ PeerConnectionImpl::InitializeDataChanne
   uint16_t level = 0;
   nsresult rv = GetDatachannelParameters(&channels, &localport, &remoteport, &level);
 
   if (NS_FAILED(rv)) {
     CSFLogDebug(logTag, "%s: We did not negotiate datachannel", __FUNCTION__);
     return NS_OK;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (channels > MAX_NUM_STREAMS) {
     channels = MAX_NUM_STREAMS;
   }
 
   rv = EnsureDataConnection(channels);
   if (NS_SUCCEEDED(rv)) {
     // use the specified TransportFlow
     RefPtr<TransportFlow> flow = mMedia->GetTransportFlow(level, false).get();
@@ -1324,57 +1255,51 @@ PeerConnectionImpl::InitializeDataChanne
                                                    remoteport)) {
         return NS_OK;
       }
     }
     // If we inited the DataConnection, call Destroy() before releasing it
     mDataConnection->Destroy();
   }
   mDataConnection = nullptr;
-#endif
   return NS_ERROR_FAILURE;
 }
 
 already_AddRefed<nsDOMDataChannel>
 PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel,
                                       const nsAString& aProtocol,
                                       uint16_t aType,
                                       bool ordered,
                                       uint16_t aMaxTime,
                                       uint16_t aMaxNum,
                                       bool aExternalNegotiated,
                                       uint16_t aStream,
                                       ErrorResult &rv)
 {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   RefPtr<nsDOMDataChannel> result;
   rv = CreateDataChannel(aLabel, aProtocol, aType, ordered,
                          aMaxTime, aMaxNum, aExternalNegotiated,
                          aStream, getter_AddRefs(result));
   return result.forget();
-#else
-  return nullptr;
-#endif
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel,
                                       const nsAString& aProtocol,
                                       uint16_t aType,
                                       bool ordered,
                                       uint16_t aMaxTime,
                                       uint16_t aMaxNum,
                                       bool aExternalNegotiated,
                                       uint16_t aStream,
                                       nsDOMDataChannel** aRetval)
 {
   PC_AUTO_ENTER_API_CALL(false);
   MOZ_ASSERT(aRetval);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   RefPtr<DataChannel> dataChannel;
   DataChannelConnection::Type theType =
     static_cast<DataChannelConnection::Type>(aType);
 
   nsresult rv = EnsureDataConnection(WEBRTC_DATACHANNEL_STREAMS_DEFAULT);
   if (NS_FAILED(rv)) {
     return rv;
   }
@@ -1418,17 +1343,16 @@ PeerConnectionImpl::CreateDataChannel(co
     OnNegotiationNeeded();
   }
   nsIDOMDataChannel *retval;
   rv = NS_NewDOMDataChannel(dataChannel.forget(), mWindow, &retval);
   if (NS_FAILED(rv)) {
     return rv;
   }
   *aRetval = static_cast<nsDOMDataChannel*>(retval);
-#endif
   return NS_OK;
 }
 
 // do_QueryObjectReferent() - Helps get PeerConnectionObserver from nsWeakPtr.
 //
 // nsWeakPtr deals in XPCOM interfaces, while webidl bindings are concrete objs.
 // TODO: Turn this into a central (template) function somewhere (Bug 939178)
 //
@@ -1448,45 +1372,42 @@ do_QueryObjectReferent(nsIWeakReference*
     return nullptr;
   }
   RefPtr<nsSupportsWeakReference> tmp2 = do_QueryObject(tmp);
   RefPtr<PeerConnectionObserver> tmp3 = static_cast<PeerConnectionObserver*>(&*tmp2);
   return tmp3.forget();
 }
 
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 // Not a member function so that we don't need to keep the PC live.
 static void NotifyDataChannel_m(RefPtr<nsIDOMDataChannel> aChannel,
                                 RefPtr<PeerConnectionObserver> aObserver)
 {
   MOZ_ASSERT(NS_IsMainThread());
   JSErrorResult rv;
   RefPtr<nsDOMDataChannel> channel = static_cast<nsDOMDataChannel*>(&*aChannel);
   aObserver->NotifyDataChannel(*channel, rv);
   NS_DataChannelAppReady(aChannel);
 }
-#endif
 
 void
 PeerConnectionImpl::NotifyDataChannel(already_AddRefed<DataChannel> aChannel)
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
 
   // XXXkhuey this is completely fucked up.  We can't use RefPtr<DataChannel>
   // here because DataChannel's AddRef/Release are non-virtual and not visible
   // if !MOZILLA_INTERNAL_API, but this function leaks the DataChannel if
   // !MOZILLA_INTERNAL_API because it never transfers the ref to
   // NS_NewDOMDataChannel.
   DataChannel* channel = aChannel.take();
   MOZ_ASSERT(channel);
 
   CSFLogDebug(logTag, "%s: channel: %p", __FUNCTION__, channel);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsCOMPtr<nsIDOMDataChannel> domchannel;
   nsresult rv = NS_NewDOMDataChannel(already_AddRefed<DataChannel>(channel),
                                      mWindow, getter_AddRefs(domchannel));
   NS_ENSURE_SUCCESS_VOID(rv);
 
   mHaveDataStream = true;
 
   RefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
@@ -1494,24 +1415,22 @@ PeerConnectionImpl::NotifyDataChannel(al
     return;
   }
 
   RUN_ON_THREAD(mThread,
                 WrapRunnableNM(NotifyDataChannel_m,
                                domchannel.get(),
                                pco),
                 NS_DISPATCH_NORMAL);
-#endif
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::CreateOffer(const RTCOfferOptions& aOptions)
 {
   JsepOfferOptions options;
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // convert the RTCOfferOptions to JsepOfferOptions
   if (aOptions.mOfferToReceiveAudio.WasPassed()) {
     options.mOfferToReceiveAudio =
       mozilla::Some(size_t(aOptions.mOfferToReceiveAudio.Value()));
   }
 
   if (aOptions.mOfferToReceiveVideo.WasPassed()) {
     options.mOfferToReceiveVideo =
@@ -1519,17 +1438,16 @@ PeerConnectionImpl::CreateOffer(const RT
   }
 
   options.mIceRestart = mozilla::Some(aOptions.mIceRestart);
 
   if (aOptions.mMozDontOfferDataChannel.WasPassed()) {
     options.mDontOfferDataChannel =
       mozilla::Some(aOptions.mMozDontOfferDataChannel.Value());
   }
-#endif
   return CreateOffer(options);
 }
 
 static void DeferredCreateOffer(const std::string& aPcHandle,
                                 const JsepOfferOptions& aOptions) {
   PeerConnectionWrapper wrapper(aPcHandle);
 
   if (wrapper.impl()) {
@@ -1763,20 +1681,18 @@ PeerConnectionImpl::SetLocalDescription(
   JSErrorResult rv;
   RefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
   if (!pco) {
     return NS_OK;
   }
 
   STAMP_TIMECARD(mTimeCard, "Set Local Description");
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   bool isolated = mMedia->AnyLocalTrackHasPeerIdentity();
   mPrivacyRequested = mPrivacyRequested || isolated;
-#endif
 
   mLocalRequestedSDP = aSDP;
 
   JsepSdpType sdpType;
   switch (aAction) {
     case IPeerConnection::kActionOffer:
       sdpType = mozilla::kJsepSdpOffer;
       break;
@@ -1833,17 +1749,16 @@ static void DeferredSetRemote(const std:
     }
     wrapper.impl()->SetRemoteDescription(aAction, aSdp.c_str());
   }
 }
 
 static void StartTrack(MediaStream* aSource,
                        TrackID aTrackId,
                        nsAutoPtr<MediaSegment>&& aSegment) {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   class Message : public ControlMessage {
    public:
     Message(MediaStream* aStream,
             TrackID aTrack,
             nsAutoPtr<MediaSegment>&& aSegment)
       : ControlMessage(aStream),
         track_id_(aTrack),
         segment_(aSegment) {}
@@ -1881,17 +1796,16 @@ static void StartTrack(MediaStream* aSou
     TrackID track_id_;
     nsAutoPtr<MediaSegment> segment_;
   };
 
   aSource->GraphImpl()->AppendMessage(
       MakeUnique<Message>(aSource, aTrackId, Move(aSegment)));
   CSFLogInfo(logTag, "Dispatched track-add for track id %u on stream %p",
              aTrackId, aSource);
-#endif
 }
 
 
 nsresult
 PeerConnectionImpl::CreateNewRemoteTracks(RefPtr<PeerConnectionObserver>& aPco)
 {
   JSErrorResult jrv;
 
@@ -1933,26 +1847,21 @@ PeerConnectionImpl::CreateNewRemoteTrack
             kInternalError,
             ObString("AddRemoteStream failed"),
             jrv);
         return nrv;
       }
 
       CSFLogDebug(logTag, "Added remote stream %s", info->GetId().c_str());
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
       info->GetMediaStream()->AssignId(NS_ConvertUTF8toUTF16(streamId.c_str()));
       info->GetMediaStream()->SetLogicalStreamStartTime(
           info->GetMediaStream()->GetPlaybackStream()->GetCurrentTime());
-#else
-      info->GetMediaStream()->AssignId((streamId));
-#endif
     }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     Sequence<OwningNonNull<DOMMediaStream>> streams;
     if (!streams.AppendElement(OwningNonNull<DOMMediaStream>(
             *info->GetMediaStream()),
             fallible)) {
       MOZ_ASSERT(false);
       return NS_ERROR_FAILURE;
     }
 
@@ -1964,73 +1873,64 @@ PeerConnectionImpl::CreateNewRemoteTrack
     MOZ_ASSERT(doc);
     if (mDtlsConnected && !PrivacyRequested()) {
       principal = doc->NodePrincipal();
     } else {
       // we're either certain that we need isolation for the streams, OR
       // we're not sure and we can fix the stream in SetDtlsConnected
       principal =  nsNullPrincipal::CreateWithInheritedAttributes(doc->NodePrincipal());
     }
-#endif
 
     // We need to select unique ids, just use max + 1
     TrackID maxTrackId = 0;
     {
       nsTArray<RefPtr<dom::MediaStreamTrack>> domTracks;
       info->GetMediaStream()->GetTracks(domTracks);
       for (auto& track : domTracks) {
         maxTrackId = std::max(maxTrackId, track->mTrackID);
       }
     }
 
     for (RefPtr<JsepTrack>& track : tracks) {
       std::string webrtcTrackId(track->GetTrackId());
       if (!info->HasTrack(webrtcTrackId)) {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
         RefPtr<RemoteTrackSource> source =
           new RemoteTrackSource(principal, nsString());
-#else
-        RefPtr<MediaStreamTrackSource> source = new MediaStreamTrackSource();
-#endif
         TrackID trackID = ++maxTrackId;
         RefPtr<MediaStreamTrack> domTrack;
         nsAutoPtr<MediaSegment> segment;
         if (track->GetMediaType() == SdpMediaSection::kAudio) {
           domTrack =
             info->GetMediaStream()->CreateDOMTrack(trackID,
                                                    MediaSegment::AUDIO,
                                                    source);
           info->GetMediaStream()->AddTrackInternal(domTrack);
           segment = new AudioSegment;
         } else {
           domTrack =
             info->GetMediaStream()->CreateDOMTrack(trackID,
                                                    MediaSegment::VIDEO,
                                                    source);
           info->GetMediaStream()->AddTrackInternal(domTrack);
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
           segment = new VideoSegment;
-#endif
         }
 
         StartTrack(info->GetMediaStream()->GetInputStream()->AsSourceStream(),
                    trackID, Move(segment));
         info->AddTrack(webrtcTrackId, domTrack);
         CSFLogDebug(logTag, "Added remote track %s/%s",
                     info->GetId().c_str(), webrtcTrackId.c_str());
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
         domTrack->AssignId(NS_ConvertUTF8toUTF16(webrtcTrackId.c_str()));
         aPco->OnAddTrack(*domTrack, streams, jrv);
         if (jrv.Failed()) {
           CSFLogError(logTag, ": OnAddTrack(%s) failed! Error: %u",
                       webrtcTrackId.c_str(),
                       jrv.ErrorCodeAsInt());
         }
-#endif
       }
     }
 
     if (newStream) {
       aPco->OnAddStream(*info->GetMediaStream(), jrv);
       if (jrv.Failed()) {
         CSFLogError(logTag, ": OnAddStream() failed! Error: %u",
                     jrv.ErrorCodeAsInt());
@@ -2160,28 +2060,25 @@ PeerConnectionImpl::SetRemoteDescription
     if (NS_FAILED(nrv)) {
       // aPco was already notified, just return early.
       return NS_OK;
     }
 
     RemoveOldRemoteTracks(pco);
 
     pco->OnSetRemoteDescriptionSuccess(jrv);
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     startCallTelem();
-#endif
   }
 
   UpdateSignalingState(sdpType == mozilla::kJsepSdpRollback);
   return NS_OK;
 }
 
 // WebRTC uses highres time relative to the UNIX epoch (Jan 1, 1970, UTC).
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 nsresult
 PeerConnectionImpl::GetTimeSinceEpoch(DOMHighResTimeStamp *result) {
   MOZ_ASSERT(NS_IsMainThread());
   Performance *perf = mWindow->GetPerformance();
   NS_ENSURE_TRUE(perf && perf->Timing(), NS_ERROR_UNEXPECTED);
   *result = perf->Now() + perf->Timing()->NavigationStart();
   return NS_OK;
 }
@@ -2197,40 +2094,37 @@ public:
     mTransportStats.Construct();
     mIceComponentStats.Construct();
     mIceCandidatePairStats.Construct();
     mIceCandidateStats.Construct();
     mCodecStats.Construct();
     mTimestamp.Construct(now);
   }
 };
-#endif
 
 NS_IMETHODIMP
 PeerConnectionImpl::GetStats(MediaStreamTrack *aSelector) {
   PC_AUTO_ENTER_API_CALL(true);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (!mMedia) {
     // Since we zero this out before the d'tor, we should check.
     return NS_ERROR_UNEXPECTED;
   }
 
   nsAutoPtr<RTCStatsQuery> query(new RTCStatsQuery(false));
 
   nsresult rv = BuildStatsQuery_m(aSelector, query.get());
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   RUN_ON_THREAD(mSTSThread,
                 WrapRunnableNM(&PeerConnectionImpl::GetStatsForPCObserver_s,
                                mHandle,
                                query),
                 NS_DISPATCH_NORMAL);
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, unsigned short aLevel) {
   PC_AUTO_ENTER_API_CALL(true);
 
   if (mForceIceTcp && std::string::npos != std::string(aCandidate).find(" UDP ")) {
@@ -2243,31 +2137,29 @@ PeerConnectionImpl::AddIceCandidate(cons
   if (!pco) {
     return NS_OK;
   }
 
   STAMP_TIMECARD(mTimeCard, "Add Ice Candidate");
 
   CSFLogDebug(logTag, "AddIceCandidate: %s", aCandidate);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // When remote candidates are added before our ICE ctx is up and running
   // (the transition to New is async through STS, so this is not impossible),
   // we won't record them as trickle candidates. Is this what we want?
   if(!mIceStartTime.IsNull()) {
     TimeDuration timeDelta = TimeStamp::Now() - mIceStartTime;
     if (mIceConnectionState == PCImplIceConnectionState::Failed) {
       Telemetry::Accumulate(Telemetry::WEBRTC_ICE_LATE_TRICKLE_ARRIVAL_TIME,
                             timeDelta.ToMilliseconds());
     } else {
       Telemetry::Accumulate(Telemetry::WEBRTC_ICE_ON_TIME_TRICKLE_ARRIVAL_TIME,
                             timeDelta.ToMilliseconds());
     }
   }
-#endif
 
   nsresult res = mJsepSession->AddRemoteIceCandidate(aCandidate, aMid, aLevel);
 
   if (NS_SUCCEEDED(res)) {
     // We do not bother PCMedia about this before offer/answer concludes.
     // Once offer/answer concludes, PCMedia will extract these candidates from
     // the remote SDP.
     if (mSignalingState == PCImplSignalingState::SignalingStable) {
@@ -2313,17 +2205,16 @@ PeerConnectionImpl::UpdateNetworkState(b
 
 NS_IMETHODIMP
 PeerConnectionImpl::CloseStreams() {
   PC_AUTO_ENTER_API_CALL(false);
 
   return NS_OK;
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 nsresult
 PeerConnectionImpl::SetPeerIdentity(const nsAString& aPeerIdentity)
 {
   PC_AUTO_ENTER_API_CALL(true);
   MOZ_ASSERT(!aPeerIdentity.IsEmpty());
 
   // once set, this can't be changed
   if (mPeerIdentity) {
@@ -2337,77 +2228,64 @@ PeerConnectionImpl::SetPeerIdentity(cons
       CSFLogInfo(logTag, "Can't update principal on streams; document gone");
       return NS_ERROR_FAILURE;
     }
     MediaStreamTrack* allTracks = nullptr;
     mMedia->UpdateSinkIdentity_m(allTracks, doc->NodePrincipal(), mPeerIdentity);
   }
   return NS_OK;
 }
-#endif
 
 nsresult
 PeerConnectionImpl::SetDtlsConnected(bool aPrivacyRequested)
 {
   PC_AUTO_ENTER_API_CALL(false);
 
   // For this, as with mPrivacyRequested, once we've connected to a peer, we
   // fixate on that peer.  Dealing with multiple peers or connections is more
   // than this run-down wreck of an object can handle.
   // Besides, this is only used to say if we have been connected ever.
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (!mPrivacyRequested && !aPrivacyRequested && !mDtlsConnected) {
     // now we know that privacy isn't needed for sure
     nsIDocument* doc = GetWindow()->GetExtantDoc();
     if (!doc) {
       CSFLogInfo(logTag, "Can't update principal on streams; document gone");
       return NS_ERROR_FAILURE;
     }
     mMedia->UpdateRemoteStreamPrincipals_m(doc->NodePrincipal());
   }
-#endif
   mDtlsConnected = true;
   mPrivacyRequested = mPrivacyRequested || aPrivacyRequested;
   return NS_OK;
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 void
 PeerConnectionImpl::PrincipalChanged(MediaStreamTrack* aTrack) {
   nsIDocument* doc = GetWindow()->GetExtantDoc();
   if (doc) {
     mMedia->UpdateSinkIdentity_m(aTrack, doc->NodePrincipal(), mPeerIdentity);
   } else {
     CSFLogInfo(logTag, "Can't update sink principal; document gone");
   }
 }
-#endif
 
 std::string
 PeerConnectionImpl::GetTrackId(const MediaStreamTrack& aTrack)
 {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsString wideTrackId;
   aTrack.GetId(wideTrackId);
   return NS_ConvertUTF16toUTF8(wideTrackId).get();
-#else
-  return aTrack.GetId();
-#endif
 }
 
 std::string
 PeerConnectionImpl::GetStreamId(const DOMMediaStream& aStream)
 {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsString wideStreamId;
   aStream.GetId(wideStreamId);
   return NS_ConvertUTF16toUTF8(wideStreamId).get();
-#else
-  return aStream.GetId();
-#endif
 }
 
 void
 PeerConnectionImpl::OnMediaError(const std::string& aError)
 {
   CSFLogError(logTag, "Encountered media error! %s", aError.c_str());
   // TODO: Let content know about this somehow.
 }
@@ -2436,36 +2314,32 @@ PeerConnectionImpl::AddTrack(MediaStream
   if (NS_FAILED(res)) {
     return res;
   }
 
   CSFLogDebug(logTag, "Added track (%s) to stream %s",
                       trackId.c_str(), streamId.c_str());
 
   aTrack.AddPrincipalChangeObserver(this);
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   PrincipalChanged(&aTrack);
-#endif
 
   if (aTrack.AsAudioStreamTrack()) {
     res = AddTrackToJsepSession(SdpMediaSection::kAudio, streamId, trackId);
     if (NS_FAILED(res)) {
       return res;
     }
     mNumAudioStreams++;
   }
 
   if (aTrack.AsVideoStreamTrack()) {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     if (!Preferences::GetBool("media.peerconnection.video.enabled", true)) {
       // Before this code was moved, this would silently ignore just like it
       // does now. Is this actually what we want to do?
       return NS_OK;
     }
-#endif
 
     res = AddTrackToJsepSession(SdpMediaSection::kVideo, streamId, trackId);
     if (NS_FAILED(res)) {
       return res;
     }
     mNumVideoStreams++;
   }
   OnNegotiationNeeded();
@@ -2491,27 +2365,25 @@ PeerConnectionImpl::SelectSsrc(MediaStre
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::RemoveTrack(MediaStreamTrack& aTrack) {
   PC_AUTO_ENTER_API_CALL(true);
 
   std::string trackId = PeerConnectionImpl::GetTrackId(aTrack);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsString wideTrackId;
   aTrack.GetId(wideTrackId);
   for (size_t i = 0; i < mDTMFStates.Length(); ++i) {
     if (mDTMFStates[i].mTrackId == wideTrackId) {
       mDTMFStates[i].mSendTimer->Cancel();
       mDTMFStates.RemoveElementAt(i);
       break;
     }
   }
-#endif
 
   RefPtr<LocalSourceStreamInfo> info = media()->GetLocalStreamByTrackId(trackId);
 
   if (!info) {
     CSFLogError(logTag, "%s: Unknown stream", __FUNCTION__);
     return NS_ERROR_INVALID_ARG;
   }
 
@@ -2548,17 +2420,16 @@ static int GetDTMFToneCode(uint16_t c)
   MOZ_ASSERT(i);
   return i - DTMF_TONECODES;
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::InsertDTMF(mozilla::dom::RTCRtpSender& sender,
                                const nsAString& tones, uint32_t duration,
                                uint32_t interToneGap) {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   PC_AUTO_ENTER_API_CALL(false);
 
   // Check values passed in from PeerConnection.js
   MOZ_ASSERT(duration >= 40, "duration must be at least 40");
   MOZ_ASSERT(duration <= 6000, "duration must be at most 6000");
   MOZ_ASSERT(interToneGap >= 30, "interToneGap must be at least 30");
 
   JSErrorResult jrv;
@@ -2607,24 +2478,22 @@ PeerConnectionImpl::InsertDTMF(mozilla::
 
   state->mTones = tones;
   state->mDuration = duration;
   state->mInterToneGap = interToneGap;
   if (!state->mTones.IsEmpty()) {
     state->mSendTimer->InitWithFuncCallback(DTMFSendTimerCallback_m, state, 0,
                                             nsITimer::TYPE_ONE_SHOT);
   }
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::GetDTMFToneBuffer(mozilla::dom::RTCRtpSender& sender,
                                       nsAString& outToneBuffer) {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   PC_AUTO_ENTER_API_CALL(false);
 
   JSErrorResult jrv;
 
   // Retrieve track
   RefPtr<MediaStreamTrack> mst = sender.GetTrack(jrv);
   if (jrv.Failed()) {
     NS_WARNING("Failed to retrieve track for RTCRtpSender!");
@@ -2636,46 +2505,42 @@ PeerConnectionImpl::GetDTMFToneBuffer(mo
 
   // Attempt to locate state for the DTMFSender
   for (auto& dtmfState : mDTMFStates) {
     if (dtmfState.mTrackId == senderTrackId) {
       outToneBuffer = dtmfState.mTones;
       break;
     }
   }
-#endif
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::ReplaceTrack(MediaStreamTrack& aThisTrack,
                                  MediaStreamTrack& aWithTrack) {
   PC_AUTO_ENTER_API_CALL(true);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsString trackId;
   aThisTrack.GetId(trackId);
 
   for (size_t i = 0; i < mDTMFStates.Length(); ++i) {
     if (mDTMFStates[i].mTrackId == trackId) {
       mDTMFStates[i].mSendTimer->Cancel();
       mDTMFStates.RemoveElementAt(i);
       break;
     }
   }
-#endif
 
   RefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
   if (!pco) {
     return NS_ERROR_UNEXPECTED;
   }
   JSErrorResult jrv;
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (&aThisTrack == &aWithTrack) {
     pco->OnReplaceTrackSuccess(jrv);
     if (jrv.Failed()) {
       CSFLogError(logTag, "Error firing replaceTrack success callback");
       return NS_ERROR_UNEXPECTED;
     }
     return NS_OK;
   }
@@ -2690,17 +2555,16 @@ PeerConnectionImpl::ReplaceTrack(MediaSt
                              ObString(mJsepSession->GetLastError().c_str()),
                              jrv);
     if (jrv.Failed()) {
       CSFLogError(logTag, "Error firing replaceTrack success callback");
       return NS_ERROR_UNEXPECTED;
     }
     return NS_OK;
   }
-#endif
   std::string origTrackId = PeerConnectionImpl::GetTrackId(aThisTrack);
   std::string newTrackId = PeerConnectionImpl::GetTrackId(aWithTrack);
 
   RefPtr<LocalSourceStreamInfo> info =
     media()->GetLocalStreamByTrackId(origTrackId);
   if (!info) {
     CSFLogError(logTag, "Could not find stream from trackId");
     return NS_ERROR_UNEXPECTED;
@@ -2740,19 +2604,17 @@ PeerConnectionImpl::ReplaceTrack(MediaSt
     if (jrv.Failed()) {
       CSFLogError(logTag, "Error firing replaceTrack error callback");
       return NS_ERROR_UNEXPECTED;
     }
     return NS_OK;
   }
   aThisTrack.RemovePrincipalChangeObserver(this);
   aWithTrack.AddPrincipalChangeObserver(this);
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   PrincipalChanged(&aWithTrack);
-#endif
 
   // We update the media pipelines here so we can apply different codec
   // settings for different sources (e.g. screensharing as opposed to camera.)
   // TODO: We should probably only do this if the source has in fact changed.
 
   if (NS_FAILED((rv = mMedia->UpdateMediaPipelines(*mJsepSession)))) {
     CSFLogError(logTag, "Error Updating MediaPipelines");
     return rv;
@@ -2762,17 +2624,16 @@ PeerConnectionImpl::ReplaceTrack(MediaSt
   if (jrv.Failed()) {
     CSFLogError(logTag, "Error firing replaceTrack success callback");
     return NS_ERROR_UNEXPECTED;
   }
 
   return NS_OK;
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 NS_IMETHODIMP
 PeerConnectionImpl::SetParameters(MediaStreamTrack& aTrack,
                                   const RTCRtpParameters& aParameters) {
   PC_AUTO_ENTER_API_CALL(true);
 
   std::vector<JsepTrack::JsConstraints> constraints;
   if (aParameters.mEncodings.WasPassed()) {
     for (auto& encoding : aParameters.mEncodings.Value()) {
@@ -2784,17 +2645,16 @@ PeerConnectionImpl::SetParameters(MediaS
         constraint.constraints.maxBr = encoding.mMaxBitrate.Value();
       }
       constraint.constraints.scaleDownBy = encoding.mScaleResolutionDownBy;
       constraints.push_back(constraint);
     }
   }
   return SetParameters(aTrack, constraints);
 }
-#endif
 
 nsresult
 PeerConnectionImpl::SetParameters(
     MediaStreamTrack& aTrack,
     const std::vector<JsepTrack::JsConstraints>& aConstraints)
 {
   std::string trackId = PeerConnectionImpl::GetTrackId(aTrack);
   RefPtr<LocalSourceStreamInfo> info = media()->GetLocalStreamByTrackId(trackId);
@@ -2802,17 +2662,16 @@ PeerConnectionImpl::SetParameters(
     CSFLogError(logTag, "%s: Unknown stream", __FUNCTION__);
     return NS_ERROR_INVALID_ARG;
   }
   std::string streamId = info->GetId();
 
   return mJsepSession->SetParameters(streamId, trackId, aConstraints);
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 NS_IMETHODIMP
 PeerConnectionImpl::GetParameters(MediaStreamTrack& aTrack,
                                   RTCRtpParameters& aOutParameters) {
   PC_AUTO_ENTER_API_CALL(true);
 
   std::vector<JsepTrack::JsConstraints> constraints;
   nsresult rv = GetParameters(aTrack, &constraints);
   if (NS_FAILED(rv)) {
@@ -2823,17 +2682,16 @@ PeerConnectionImpl::GetParameters(MediaS
     RTCRtpEncodingParameters encoding;
     encoding.mRid.Construct(NS_ConvertASCIItoUTF16(constraint.rid.c_str()));
     encoding.mMaxBitrate.Construct(constraint.constraints.maxBr);
     encoding.mScaleResolutionDownBy = constraint.constraints.scaleDownBy;
     aOutParameters.mEncodings.Value().AppendElement(Move(encoding), fallible);
   }
   return NS_OK;
 }
-#endif
 
 nsresult
 PeerConnectionImpl::GetParameters(
     MediaStreamTrack& aTrack,
     std::vector<JsepTrack::JsConstraints>* aOutConstraints)
 {
   std::string trackId = PeerConnectionImpl::GetTrackId(aTrack);
   RefPtr<LocalSourceStreamInfo> info = media()->GetLocalStreamByTrackId(trackId);
@@ -2849,21 +2707,17 @@ PeerConnectionImpl::GetParameters(
 nsresult
 PeerConnectionImpl::CalculateFingerprint(
     const std::string& algorithm,
     std::vector<uint8_t>* fingerprint) const {
   uint8_t buf[DtlsIdentity::HASH_ALGORITHM_MAX_LENGTH];
   size_t len = 0;
 
   MOZ_ASSERT(fingerprint);
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   const UniqueCERTCertificate& cert = mCertificate->Certificate();
-#else
-  const UniqueCERTCertificate& cert = mIdentity->cert();
-#endif
   nsresult rv = DtlsIdentity::ComputeFingerprint(cert, algorithm,
                                                  &buf[0], sizeof(buf),
                                                  &len);
   if (NS_FAILED(rv)) {
     CSFLogError(logTag, "Unable to calculate certificate fingerprint, rv=%u",
                         static_cast<unsigned>(rv));
     return rv;
   }
@@ -2871,19 +2725,17 @@ PeerConnectionImpl::CalculateFingerprint
   fingerprint->assign(buf, buf + len);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::GetFingerprint(char** fingerprint)
 {
   MOZ_ASSERT(fingerprint);
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   MOZ_ASSERT(mCertificate);
-#endif
   std::vector<uint8_t> fp;
   nsresult rv = CalculateFingerprint(DtlsIdentity::DEFAULT_HASH_ALGORITHM, &fp);
   NS_ENSURE_SUCCESS(rv, rv);
   std::ostringstream os;
   os << DtlsIdentity::DEFAULT_HASH_ALGORITHM << ' '
      << SdpFingerprintAttributeList::FormatFingerprint(fp);
   std::string fpStr = os.str();
 
@@ -2991,17 +2843,16 @@ PeerConnectionImpl::PluginCrash(uint32_t
   // fire an event to the DOM window if this is "ours"
   bool result = mMedia ? mMedia->AnyCodecHasPluginID(aPluginID) : false;
   if (!result) {
     return false;
   }
 
   CSFLogError(logTag, "%s: Our plugin %llu crashed", __FUNCTION__, static_cast<unsigned long long>(aPluginID));
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
   if (!doc) {
     NS_WARNING("Couldn't get document for PluginCrashed event!");
     return true;
   }
 
   PluginCrashedEventInit init;
   init.mPluginID = aPluginID;
@@ -3013,29 +2864,27 @@ PeerConnectionImpl::PluginCrash(uint32_t
 
   RefPtr<PluginCrashedEvent> event =
     PluginCrashedEvent::Constructor(doc, NS_LITERAL_STRING("PluginCrashed"), init);
 
   event->SetTrusted(true);
   event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
 
   EventDispatcher::DispatchDOMEvent(mWindow, nullptr, event, nullptr, nullptr);
-#endif
 
   return true;
 }
 
 void
 PeerConnectionImpl::RecordEndOfCallTelemetry() const
 {
   if (!mJsepSession) {
     return;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // Bitmask used for WEBRTC/LOOP_CALL_TYPE telemetry reporting
   static const uint32_t kAudioTypeMask = 1;
   static const uint32_t kVideoTypeMask = 2;
   static const uint32_t kDataChannelTypeMask = 4;
 
   // Report end-of-call Telemetry
   if (mJsepSession->GetNegotiations() > 0) {
     Telemetry::Accumulate(Telemetry::WEBRTC_RENEGOTIATIONS,
@@ -3063,17 +2912,16 @@ PeerConnectionImpl::RecordEndOfCallTelem
       mMaxReceiving[SdpMediaSection::MediaType::kVideo]) {
     type |= kVideoTypeMask;
   }
   if (mMaxSending[SdpMediaSection::MediaType::kApplication]) {
     type |= kDataChannelTypeMask;
   }
   Telemetry::Accumulate(Telemetry::WEBRTC_CALL_TYPE,
                         type);
-#endif
 }
 
 nsresult
 PeerConnectionImpl::CloseInt()
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
 
   for (auto& dtmfState : mDTMFStates) {
@@ -3088,55 +2936,51 @@ PeerConnectionImpl::CloseInt()
     RecordLongtermICEStatistics();
   }
   RecordEndOfCallTelemetry();
   CSFLogInfo(logTag, "%s: Closing PeerConnectionImpl %s; "
              "ending call", __FUNCTION__, mHandle.c_str());
   if (mJsepSession) {
     mJsepSession->Close();
   }
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (mDataConnection) {
     CSFLogInfo(logTag, "%s: Destroying DataChannelConnection %p for %s",
                __FUNCTION__, (void *) mDataConnection.get(), mHandle.c_str());
     mDataConnection->Destroy();
     mDataConnection = nullptr; // it may not go away until the runnables are dead
   }
-#endif
   ShutdownMedia();
 
   // DataConnection will need to stay alive until all threads/runnables exit
 
   return NS_OK;
 }
 
 void
 PeerConnectionImpl::ShutdownMedia()
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
 
   if (!mMedia)
     return;
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // before we destroy references to local tracks, detach from them
   for(uint32_t i = 0; i < media()->LocalStreamsLength(); ++i) {
     LocalSourceStreamInfo *info = media()->GetLocalStreamByIndex(i);
     for (const auto& pair : info->GetMediaStreamTracks()) {
       pair.second->RemovePrincipalChangeObserver(this);
     }
   }
 
   // End of call to be recorded in Telemetry
   if (!mStartTime.IsNull()){
     TimeDuration timeDelta = TimeStamp::Now() - mStartTime;
     Telemetry::Accumulate(Telemetry::WEBRTC_CALL_DURATION,
                           timeDelta.ToSeconds());
   }
-#endif
 
   // Forget the reference so that we can transfer it to
   // SelfDestruct().
   mMedia.forget().take()->SelfDestruct();
 }
 
 void
 PeerConnectionImpl::SetSignalingState_m(PCImplSignalingState aSignalingState,
@@ -3410,47 +3254,44 @@ PeerConnectionImpl::SendLocalIceCandidat
       WrapRunnableNM(&SendLocalIceCandidateToContentImpl,
                      mPCObserver,
                      level,
                      mid,
                      candidate),
       NS_DISPATCH_NORMAL);
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 static bool isDone(PCImplIceConnectionState state) {
   return state != PCImplIceConnectionState::Checking &&
          state != PCImplIceConnectionState::New;
 }
 
 static bool isSucceeded(PCImplIceConnectionState state) {
   return state == PCImplIceConnectionState::Connected ||
          state == PCImplIceConnectionState::Completed;
 }
 
 static bool isFailed(PCImplIceConnectionState state) {
   return state == PCImplIceConnectionState::Failed;
 }
-#endif
 
 void PeerConnectionImpl::IceConnectionStateChange(
     NrIceCtx* ctx,
     NrIceCtx::ConnectionState state) {
   PC_AUTO_ENTER_API_CALL_VOID_RETURN(false);
 
   CSFLogDebug(logTag, "%s", __FUNCTION__);
 
   auto domState = toDomIceConnectionState(state);
   if (domState == mIceConnectionState) {
     // no work to be done since the states are the same.
     // this can happen during ICE rollback situations.
     return;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   if (!isDone(mIceConnectionState) && isDone(domState)) {
     // mIceStartTime can be null if going directly from New to Closed, in which
     // case we don't count it as a success or a failure.
     if (!mIceStartTime.IsNull()){
       TimeDuration timeDelta = TimeStamp::Now() - mIceStartTime;
       if (isSucceeded(domState)) {
         Telemetry::Accumulate(Telemetry::WEBRTC_ICE_SUCCESS_TIME,
                               timeDelta.ToMilliseconds());
@@ -3465,17 +3306,16 @@ void PeerConnectionImpl::IceConnectionSt
           Telemetry::WEBRTC_ICE_ADD_CANDIDATE_ERRORS_GIVEN_SUCCESS,
           mAddCandidateErrorCount);
     } else if (isFailed(domState)) {
       Telemetry::Accumulate(
           Telemetry::WEBRTC_ICE_ADD_CANDIDATE_ERRORS_GIVEN_FAILURE,
           mAddCandidateErrorCount);
     }
   }
-#endif
 
   mIceConnectionState = domState;
 
   if (mIceConnectionState == PCImplIceConnectionState::Connected ||
       mIceConnectionState == PCImplIceConnectionState::Completed ||
       mIceConnectionState == PCImplIceConnectionState::Failed) {
     if (mMedia->IsIceRestarting()) {
       FinalizeIceRestart();
@@ -3484,20 +3324,18 @@ void PeerConnectionImpl::IceConnectionSt
 
   // Would be nice if we had a means of converting one of these dom enums
   // to a string that wasn't almost as much text as this switch statement...
   switch (mIceConnectionState) {
     case PCImplIceConnectionState::New:
       STAMP_TIMECARD(mTimeCard, "Ice state: new");
       break;
     case PCImplIceConnectionState::Checking:
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
       // For telemetry
       mIceStartTime = TimeStamp::Now();
-#endif
       STAMP_TIMECARD(mTimeCard, "Ice state: checking");
       break;
     case PCImplIceConnectionState::Connected:
       STAMP_TIMECARD(mTimeCard, "Ice state: connected");
       break;
     case PCImplIceConnectionState::Completed:
       STAMP_TIMECARD(mTimeCard, "Ice state: completed");
       break;
@@ -3586,17 +3424,16 @@ PeerConnectionImpl::UpdateDefaultCandida
 }
 
 void
 PeerConnectionImpl::EndOfLocalCandidates(uint16_t level) {
   CSFLogDebug(logTag, "%s", __FUNCTION__);
   mJsepSession->EndOfLocalCandidates(level);
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 nsresult
 PeerConnectionImpl::BuildStatsQuery_m(
     mozilla::dom::MediaStreamTrack *aSelector,
     RTCStatsQuery *query) {
 
   if (!HasMedia()) {
     return NS_ERROR_UNEXPECTED;
   }
@@ -4017,23 +3854,19 @@ void PeerConnectionImpl::DeliverStatsRep
 
       if (rv.Failed()) {
         CSFLogError(logTag, "Error firing stats observer callback");
       }
     }
   }
 }
 
-#endif
-
 void
 PeerConnectionImpl::RecordLongtermICEStatistics() {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   WebrtcGlobalInformation::StoreLongTermICEStatistics(*this);
-#endif
 }
 
 void
 PeerConnectionImpl::OnNegotiationNeeded()
 {
   if (mSignalingState != PCImplSignalingState::SignalingStable) {
     // We will check whether we need to renegotiate when we reach stable again
     return;
@@ -4083,63 +3916,53 @@ void
 PeerConnectionImpl::IceStreamReady(NrIceMediaStream *aStream)
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
   MOZ_ASSERT(aStream);
 
   CSFLogDebug(logTag, "%s: %s", __FUNCTION__, aStream->name().c_str());
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 //Telemetry for when calls start
 void
 PeerConnectionImpl::startCallTelem() {
   if (!mStartTime.IsNull()) {
     return;
   }
 
   // Start time for calls
   mStartTime = TimeStamp::Now();
 
   // Increment session call counter
   // If we want to track Loop calls independently here, we need two histograms.
   Telemetry::Accumulate(Telemetry::WEBRTC_CALL_COUNT_2, 1);
 }
-#endif
 
 NS_IMETHODIMP
 PeerConnectionImpl::GetLocalStreams(nsTArray<RefPtr<DOMMediaStream > >& result)
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   for(uint32_t i=0; i < media()->LocalStreamsLength(); i++) {
     LocalSourceStreamInfo *info = media()->GetLocalStreamByIndex(i);
     NS_ENSURE_TRUE(info, NS_ERROR_UNEXPECTED);
     result.AppendElement(info->GetMediaStream());
   }
   return NS_OK;
-#else
-  return NS_ERROR_FAILURE;
-#endif
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::GetRemoteStreams(nsTArray<RefPtr<DOMMediaStream > >& result)
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   for(uint32_t i=0; i < media()->RemoteStreamsLength(); i++) {
     RemoteSourceStreamInfo *info = media()->GetRemoteStreamByIndex(i);
     NS_ENSURE_TRUE(info, NS_ERROR_UNEXPECTED);
     result.AppendElement(info->GetMediaStream());
   }
   return NS_OK;
-#else
-  return NS_ERROR_FAILURE;
-#endif
 }
 
 void
 PeerConnectionImpl::DTMFSendTimerCallback_m(nsITimer* timer, void* closure)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   auto state = static_cast<DTMFState*>(closure);
@@ -4174,26 +3997,24 @@ PeerConnectionImpl::DTMFSendTimerCallbac
           }), NS_DISPATCH_NORMAL);
       }
 
     }
   } else {
     state->mSendTimer->Cancel();
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   RefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(state->mPeerConnectionImpl->mPCObserver);
   if (!pco) {
     NS_WARNING("Failed to dispatch the RTCDTMFToneChange event!");
     return;
   }
 
   JSErrorResult jrv;
   pco->OnDTMFToneChange(state->mTrackId, eventTone, jrv);
 
   if (jrv.Failed()) {
     NS_WARNING("Failed to dispatch the RTCDTMFToneChange event!");
     return;
   }
-#endif
 }
 
 }  // end mozilla namespace
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
@@ -29,25 +29,23 @@
 #include "signaling/src/jsep/JsepSessionImpl.h"
 #include "signaling/src/sdp/SdpMediaSection.h"
 
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/PeerConnectionImplEnumsBinding.h"
 #include "PrincipalChangeObserver.h"
 #include "StreamTracks.h"
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "mozilla/TimeStamp.h"
 #include "mozilla/net/DataChannel.h"
 #include "VideoUtils.h"
 #include "VideoSegment.h"
 #include "mozilla/dom/RTCStatsReportBinding.h"
 #include "nsIPrincipal.h"
 #include "mozilla/PeerIdentity.h"
-#endif
 
 namespace test {
 #ifdef USE_FAKE_PCOBSERVER
 class AFakePCObserver;
 #endif
 }
 
 class nsGlobalWindow;
@@ -111,19 +109,17 @@ using mozilla::dom::RTCIceServer;
 using mozilla::dom::RTCOfferOptions;
 using mozilla::DOMMediaStream;
 using mozilla::NrIceCtx;
 using mozilla::NrIceMediaStream;
 using mozilla::DtlsIdentity;
 using mozilla::ErrorResult;
 using mozilla::NrIceStunServer;
 using mozilla::NrIceTurnServer;
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 using mozilla::PeerIdentity;
-#endif
 
 class PeerConnectionWrapper;
 class PeerConnectionMedia;
 class RemoteSourceStreamInfo;
 
 // Uuid Generator
 class PCUuidGenerator : public mozilla::JsepUuidGenerator {
  public:
@@ -171,29 +167,26 @@ public:
   void addTurnServer(const NrIceTurnServer& server) { mTurnServers.push_back (server); }
   const std::vector<NrIceStunServer>& getStunServers() const { return mStunServers; }
   const std::vector<NrIceTurnServer>& getTurnServers() const { return mTurnServers; }
   void setBundlePolicy(JsepBundlePolicy policy) { mBundlePolicy = policy;}
   JsepBundlePolicy getBundlePolicy() const { return mBundlePolicy; }
   void setIceTransportPolicy(NrIceCtx::Policy policy) { mIceTransportPolicy = policy;}
   NrIceCtx::Policy getIceTransportPolicy() const { return mIceTransportPolicy; }
 
-#ifndef MOZILLA_EXTERNAL_LINKAGE
   nsresult Init(const RTCConfiguration& aSrc);
   nsresult AddIceServer(const RTCIceServer& aServer);
-#endif
 
 private:
   std::vector<NrIceStunServer> mStunServers;
   std::vector<NrIceTurnServer> mTurnServers;
   JsepBundlePolicy mBundlePolicy;
   NrIceCtx::Policy mIceTransportPolicy;
 };
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 // Not an inner class so we can forward declare.
 class RTCStatsQuery {
   public:
     explicit RTCStatsQuery(bool internalStats);
     ~RTCStatsQuery();
 
     nsAutoPtr<mozilla::dom::RTCStatsReportInternal> report;
     std::string error;
@@ -206,17 +199,16 @@ class RTCStatsQuery {
     friend class PeerConnectionImpl;
     std::string pcName;
     bool internalStats;
     nsTArray<RefPtr<mozilla::MediaPipeline>> pipelines;
     RefPtr<NrIceCtx> iceCtx;
     bool grabAllLevels;
     DOMHighResTimeStamp now;
 };
-#endif // MOZILLA_INTERNAL_API
 
 // Enter an API call and check that the state is OK,
 // the PC isn't closed, etc.
 #define PC_AUTO_ENTER_API_CALL(assert_ice_ready) \
     do { \
       /* do/while prevents res from conflicting with locals */    \
       nsresult res = CheckApiState(assert_ice_ready);             \
       if (NS_FAILED(res)) return res; \
@@ -225,20 +217,18 @@ class RTCStatsQuery {
     do { \
       /* do/while prevents res from conflicting with locals */    \
       nsresult res = CheckApiState(assert_ice_ready);             \
       if (NS_FAILED(res)) return; \
     } while(0)
 #define PC_AUTO_ENTER_API_CALL_NO_CHECK() CheckThread()
 
 class PeerConnectionImpl final : public nsISupports,
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
                                  public mozilla::DataChannelConnection::DataConnectionListener,
                                  public dom::PrincipalChangeObserver<dom::MediaStreamTrack>,
-#endif
                                  public sigslot::has_slots<>
 {
   struct Internal; // Avoid exposing c includes to bindings
 
 public:
   explicit PeerConnectionImpl(const mozilla::dom::GlobalObject* aGlobal = nullptr);
 
   enum Error {
@@ -249,35 +239,31 @@ public:
     kInvalidSessionDescription        = 5,
     kIncompatibleSessionDescription   = 6,
     kIncompatibleMediaStreamTrack     = 8,
     kInternalError                    = 9
   };
 
   NS_DECL_THREADSAFE_ISUPPORTS
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
-#endif
 
   static already_AddRefed<PeerConnectionImpl>
       Constructor(const mozilla::dom::GlobalObject& aGlobal, ErrorResult& rv);
   static PeerConnectionImpl* CreatePeerConnection();
   already_AddRefed<DOMMediaStream> MakeMediaStream();
 
   nsresult CreateRemoteSourceStreamInfo(RefPtr<RemoteSourceStreamInfo>* aInfo,
                                         const std::string& aId);
 
   // DataConnection observers
   void NotifyDataChannel(already_AddRefed<mozilla::DataChannel> aChannel)
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     // PeerConnectionImpl only inherits from mozilla::DataChannelConnection
     // inside libxul.
     override
-#endif
     ;
 
   // Get the media object
   const RefPtr<PeerConnectionMedia>& media() const {
     PC_AUTO_ENTER_API_CALL_NO_CHECK();
     return mMedia;
   }
 
@@ -331,29 +317,25 @@ public:
   // Initialize PeerConnection from a PeerConnectionConfiguration object
   // (used directly by unit-tests, and indirectly by the JS entry point)
   // This is necessary because RTCConfiguration can't be used by unit-tests
   nsresult Initialize(PeerConnectionObserver& aObserver,
                       nsGlobalWindow* aWindow,
                       const PeerConnectionConfiguration& aConfiguration,
                       nsISupports* aThread);
 
-#ifndef MOZILLA_EXTERNAL_LINKAGE
   // Initialize PeerConnection from an RTCConfiguration object (JS entrypoint)
   void Initialize(PeerConnectionObserver& aObserver,
                   nsGlobalWindow& aWindow,
                   const RTCConfiguration& aConfiguration,
                   nsISupports* aThread,
                   ErrorResult &rv);
-#endif
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   void SetCertificate(mozilla::dom::RTCCertificate& aCertificate);
   const RefPtr<mozilla::dom::RTCCertificate>& Certificate() const;
-#endif
   // This is a hack to support external linkage.
   RefPtr<DtlsIdentity> Identity() const;
 
   NS_IMETHODIMP_TO_ERRORRESULT(CreateOffer, ErrorResult &rv,
                                const RTCOfferOptions& aOptions)
   {
     rv = CreateOffer(aOptions);
   }
@@ -441,31 +423,29 @@ public:
 
   NS_IMETHODIMP_TO_ERRORRESULT(ReplaceTrack, ErrorResult &rv,
                                mozilla::dom::MediaStreamTrack& aThisTrack,
                                mozilla::dom::MediaStreamTrack& aWithTrack)
   {
     rv = ReplaceTrack(aThisTrack, aWithTrack);
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   NS_IMETHODIMP_TO_ERRORRESULT(SetParameters, ErrorResult &rv,
                                dom::MediaStreamTrack& aTrack,
                                const dom::RTCRtpParameters& aParameters)
   {
     rv = SetParameters(aTrack, aParameters);
   }
 
   NS_IMETHODIMP_TO_ERRORRESULT(GetParameters, ErrorResult &rv,
                                dom::MediaStreamTrack& aTrack,
                                dom::RTCRtpParameters& aOutParameters)
   {
     rv = GetParameters(aTrack, aOutParameters);
   }
-#endif
 
   nsresult
   SetParameters(dom::MediaStreamTrack& aTrack,
                 const std::vector<JsepTrack::JsConstraints>& aConstraints);
 
   nsresult
   GetParameters(dom::MediaStreamTrack& aTrack,
                 std::vector<JsepTrack::JsConstraints>* aOutConstraints);
@@ -474,28 +454,25 @@ public:
                                dom::MediaStreamTrack& aRecvTrack,
                                unsigned short aSsrcIndex)
   {
     rv = SelectSsrc(aRecvTrack, aSsrcIndex);
   }
 
   nsresult GetPeerIdentity(nsAString& peerIdentity)
   {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
     if (mPeerIdentity) {
       peerIdentity = mPeerIdentity->ToString();
       return NS_OK;
     }
-#endif
 
     peerIdentity.SetIsVoid(true);
     return NS_OK;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   const PeerIdentity* GetPeerIdentity() const { return mPeerIdentity; }
   nsresult SetPeerIdentity(const nsAString& peerIdentity);
 
   const std::string& GetIdAsAscii() const
   {
     return mName;
   }
 
@@ -505,17 +482,16 @@ public:
     return NS_OK;
   }
 
   nsresult SetId(const nsAString& id)
   {
     mName = NS_ConvertUTF16toUTF8(id).get();
     return NS_OK;
   }
-#endif
 
   // this method checks to see if we've made a promise to protect media.
   bool PrivacyRequested() const { return mPrivacyRequested; }
 
   NS_IMETHODIMP GetFingerprint(char** fingerprint);
   void GetFingerprint(nsAString& fingerprint)
   {
     char *tmp;
@@ -630,32 +606,29 @@ public:
   void UpdateSignalingState(bool rollback = false);
 
   bool IsClosed() const;
   // called when DTLS connects; we only need this once
   nsresult SetDtlsConnected(bool aPrivacyRequested);
 
   bool HasMedia() const;
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // initialize telemetry for when calls start
   void startCallTelem();
 
   nsresult BuildStatsQuery_m(
       mozilla::dom::MediaStreamTrack *aSelector,
       RTCStatsQuery *query);
 
   static nsresult ExecuteStatsQuery_s(RTCStatsQuery *query);
 
   // for monitoring changes in track ownership
   // PeerConnectionMedia can't do it because it doesn't know about principals
   virtual void PrincipalChanged(dom::MediaStreamTrack* aTrack) override;
 
-#endif
-
   static std::string GetStreamId(const DOMMediaStream& aStream);
   static std::string GetTrackId(const dom::MediaStreamTrack& track);
 
   void OnMediaError(const std::string& aError);
 
 private:
   virtual ~PeerConnectionImpl();
   PeerConnectionImpl(const PeerConnectionImpl&rhs);
@@ -667,32 +640,23 @@ private:
   NS_IMETHODIMP EnsureDataConnection(uint16_t aNumstreams);
 
   nsresult CloseInt();
   nsresult CheckApiState(bool assert_ice_ready) const;
   void CheckThread() const {
     MOZ_ASSERT(CheckThreadInt(), "Wrong thread");
   }
   bool CheckThreadInt() const {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
-    // Thread assertions are disabled in the C++ unit tests because those
-    // make API calls off the main thread.
-    // This affects the standalone version of WebRTC since it is also used
-    // for an alternate build of the unit tests.
-    // TODO(ekr@rtfm.com): Fix the unit tests so they don't do that.
     bool on;
     NS_ENSURE_SUCCESS(mThread->IsOnCurrentThread(&on), false);
     NS_ENSURE_TRUE(on, false);
-#endif
     return true;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   nsresult GetTimeSinceEpoch(DOMHighResTimeStamp *result);
-#endif
 
   // Shut down media - called on main thread only
   void ShutdownMedia();
 
   void CandidateReady(const std::string& candidate, uint16_t level);
   void SendLocalIceCandidateToContent(uint16_t level,
                                       const std::string& mid,
                                       const std::string& candidate);
@@ -711,27 +675,25 @@ private:
   nsresult AddTrackToJsepSession(SdpMediaSection::MediaType type,
                                  const std::string& streamId,
                                  const std::string& trackId);
 
   nsresult SetupIceRestart();
   nsresult RollbackIceRestart();
   void FinalizeIceRestart();
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   static void GetStatsForPCObserver_s(
       const std::string& pcHandle,
       nsAutoPtr<RTCStatsQuery> query);
 
   // Sends an RTCStatsReport to JS. Must run on main thread.
   static void DeliverStatsReportToPCObserver_m(
       const std::string& pcHandle,
       nsresult result,
       nsAutoPtr<RTCStatsQuery> query);
-#endif
 
   // When ICE completes, we record a bunch of statistics that outlive the
   // PeerConnection. This is just telemetry right now, but this can also
   // include things like dumping the RLogConnector somewhere, saving away
   // an RTCStatsReport somewhere so it can be inspected after the call is over,
   // or other things.
   void RecordLongtermICEStatistics();
 
@@ -764,25 +726,21 @@ private:
   std::string mLocalRequestedSDP;
   std::string mRemoteRequestedSDP;
 
   // DTLS fingerprint
   std::string mFingerprint;
   std::string mRemoteFingerprint;
 
   // identity-related fields
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // The entity on the other end of the peer-to-peer connection;
   // void if they are not yet identified, and no identity setting has been set
   RefPtr<PeerIdentity> mPeerIdentity;
   // The certificate we are using.
   RefPtr<mozilla::dom::RTCCertificate> mCertificate;
-#else
-  RefPtr<DtlsIdentity> mIdentity;
-#endif
   // Whether an app should be prevented from accessing media produced by the PC
   // If this is true, then media will not be sent until mPeerIdentity matches
   // local streams PeerIdentity; and remote streams are protected from content
   //
   // This can be false if mPeerIdentity is set, in the case where identity is
   // provided, but the media is not protected from the app on either side
   bool mPrivacyRequested;
 
@@ -790,38 +748,34 @@ private:
   std::string mHandle;
 
   // A name for this PC that we are willing to expose to content.
   std::string mName;
 
   // The target to run stuff on
   nsCOMPtr<nsIEventTarget> mSTSThread;
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // DataConnection that's used to get all the DataChannels
   RefPtr<mozilla::DataChannelConnection> mDataConnection;
-#endif
 
   bool mAllowIceLoopback;
   bool mAllowIceLinkLocal;
   bool mForceIceTcp;
   RefPtr<PeerConnectionMedia> mMedia;
 
   // The JSEP negotiation session.
   mozilla::UniquePtr<PCUuidGenerator> mUuidGen;
   mozilla::UniquePtr<mozilla::JsepSession> mJsepSession;
   std::string mPreviousIceUfrag; // used during rollback of ice restart
   std::string mPreviousIcePwd; // used during rollback of ice restart
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // Start time of ICE, used for telemetry
   mozilla::TimeStamp mIceStartTime;
   // Start time of call used for Telemetry
   mozilla::TimeStamp mStartTime;
-#endif
 
   // Temporary: used to prevent multiple audio streams or multiple video streams
   // in a single PC. This is tied up in the IETF discussion around proper
   // representation of multiple streams in SDP, and strongly related to
   // Bug 840728.
   int mNumAudioStreams;
   int mNumVideoStreams;
   bool mHaveConfiguredCodecs;
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
@@ -37,27 +37,25 @@
 #include "nsICancelable.h"
 #include "nsILoadInfo.h"
 #include "nsIContentPolicy.h"
 #include "nsIProxyInfo.h"
 #include "nsIProtocolProxyService.h"
 
 #include "nsProxyRelease.h"
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "MediaStreamList.h"
 #include "nsIScriptGlobalObject.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/RTCStatsReportBinding.h"
 #include "MediaStreamTrack.h"
 #include "VideoStreamTrack.h"
 #include "MediaStreamError.h"
 #include "MediaManager.h"
-#endif
 
 
 
 namespace mozilla {
 using namespace dom;
 
 static const char* logTag = "PeerConnectionMedia";
 
@@ -119,34 +117,31 @@ PipelineDetachTransport_s(RefPtr<MediaPi
 
 void
 SourceStreamInfo::EndTrack(MediaStream* stream, dom::MediaStreamTrack* track)
 {
   if (!stream || !stream->AsSourceStream()) {
     return;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   class Message : public ControlMessage {
    public:
     Message(MediaStream* stream, TrackID track)
       : ControlMessage(stream),
         track_id_(track) {}
 
     virtual void Run() override {
       mStream->AsSourceStream()->EndTrack(track_id_);
     }
    private:
     TrackID track_id_;
   };
 
   stream->GraphImpl()->AppendMessage(
       MakeUnique<Message>(stream, track->mTrackID));
-#endif
-
 }
 
 void
 SourceStreamInfo::RemoveTrack(const std::string& trackId)
 {
   mTracks.erase(trackId);
 
   RefPtr<MediaPipeline> pipeline = GetPipelineByTrackId_m(trackId);
@@ -277,26 +272,24 @@ PeerConnectionMedia::PeerConnectionMedia
       mSTSThread(mParent->GetSTSThread()),
       mProxyResolveCompleted(false),
       mIceRestartState(ICE_RESTART_NONE) {
 }
 
 nsresult
 PeerConnectionMedia::InitProxy()
 {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // Allow mochitests to disable this, since mochitest configures a fake proxy
   // that serves up content.
   bool disable = Preferences::GetBool("media.peerconnection.disable_http_proxy",
                                       false);
   if (disable) {
     mProxyResolveCompleted = true;
     return NS_OK;
   }
-#endif
 
   nsresult rv;
   nsCOMPtr<nsIProtocolProxyService> pps =
     do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
   if (NS_FAILED(rv)) {
     CSFLogError(logTag, "%s: Failed to get proxy service: %d", __FUNCTION__, (int)rv);
     return NS_ERROR_FAILURE;
   }
@@ -355,21 +348,17 @@ PeerConnectionMedia::InitProxy()
 
 nsresult PeerConnectionMedia::Init(const std::vector<NrIceStunServer>& stun_servers,
                                    const std::vector<NrIceTurnServer>& turn_servers,
                                    NrIceCtx::Policy policy)
 {
   nsresult rv = InitProxy();
   NS_ENSURE_SUCCESS(rv, rv);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   bool ice_tcp = Preferences::GetBool("media.peerconnection.ice.tcp", false);
-#else
-  bool ice_tcp = false;
-#endif
 
   // TODO(ekr@rtfm.com): need some way to set not offerer later
   // Looks like a bug in the NrIceCtx API.
   mIceCtxHdlr = NrIceCtxHandler::Create("PC:" + mParentName,
                                         true, // Offerer
                                         mParent->GetAllowIceLoopback(),
                                         ice_tcp,
                                         mParent->GetAllowIceLinkLocal(),
@@ -379,21 +368,17 @@ nsresult PeerConnectionMedia::Init(const
     return NS_ERROR_FAILURE;
   }
 
   if (NS_FAILED(rv = mIceCtxHdlr->ctx()->SetStunServers(stun_servers))) {
     CSFLogError(logTag, "%s: Failed to set stun servers", __FUNCTION__);
     return rv;
   }
   // Give us a way to globally turn off TURN support
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   bool disabled = Preferences::GetBool("media.peerconnection.turn.disable", false);
-#else
-  bool disabled = false;
-#endif
   if (!disabled) {
     if (NS_FAILED(rv = mIceCtxHdlr->ctx()->SetTurnServers(turn_servers))) {
       CSFLogError(logTag, "%s: Failed to set turn servers", __FUNCTION__);
       return rv;
     }
   } else if (turn_servers.size() != 0) {
     CSFLogError(logTag, "%s: Setting turn servers disabled", __FUNCTION__);
   }
@@ -786,39 +771,31 @@ PeerConnectionMedia::RollbackIceRestart_
   mIceCtxHdlr->ctx()->AccumulateStats(stats);
 }
 
 bool
 PeerConnectionMedia::GetPrefDefaultAddressOnly() const
 {
   ASSERT_ON_THREAD(mMainThread); // will crash on STS thread
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   uint64_t winId = mParent->GetWindow()->WindowID();
 
   bool default_address_only = Preferences::GetBool(
     "media.peerconnection.ice.default_address_only", false);
   default_address_only |=
     !MediaManager::Get()->IsActivelyCapturingOrHasAPermission(winId);
-#else
-  bool default_address_only = true;
-#endif
   return default_address_only;
 }
 
 bool
 PeerConnectionMedia::GetPrefProxyOnly() const
 {
   ASSERT_ON_THREAD(mMainThread); // will crash on STS thread
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   return Preferences::GetBool("media.peerconnection.ice.proxy_only", false);
-#else
-  return false;
-#endif
 }
 
 void
 PeerConnectionMedia::ConnectSignals(NrIceCtx *aCtx, NrIceCtx *aOldCtx)
 {
   aCtx->SignalGatheringStateChange.connect(
       this,
       &PeerConnectionMedia::IceGatheringStateChange_s);
@@ -1466,17 +1443,16 @@ LocalSourceStreamInfo::TakePipelineFrom(
     static_cast<MediaPipelineTransmit*>(pipeline.get())->ReplaceTrack(aNewTrack);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mPipelines[newTrackId] = pipeline;
 
   return NS_OK;
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 /**
  * Tells you if any local track is isolated to a specific peer identity.
  * Obviously, we want all the tracks to be isolated equally so that they can
  * all be sent or not.  We check once when we are setting a local description
  * and that determines if we flip the "privacy requested" bit on.  Once the bit
  * is on, all media originating from this peer connection is isolated.
  *
  * @returns true if any track has a peerIdentity set on it
@@ -1545,17 +1521,16 @@ void RemoteSourceStreamInfo::UpdatePrinc
     RefPtr<MediaPipeline> pipeline = GetPipelineByTrackId_m(trackPair.first);
     if (pipeline) {
       MOZ_ASSERT(pipeline->direction() == MediaPipeline::RECEIVE);
       static_cast<MediaPipelineReceive*>(pipeline.get())
         ->SetPrincipalHandle_m(MakePrincipalHandle(aPrincipal));
     }
   }
 }
-#endif // MOZILLA_INTERNAL_API
 
 bool
 PeerConnectionMedia::AnyCodecHasPluginID(uint64_t aPluginID)
 {
   for (uint32_t i=0; i < mLocalSourceStreams.Length(); ++i) {
     if (mLocalSourceStreams[i]->AnyCodecHasPluginID(aPluginID)) {
       return true;
     }
@@ -1697,24 +1672,22 @@ LocalSourceStreamInfo::ForgetPipelineByT
       mPipelines.erase(trackId);
       return pipeline.forget();
     }
   }
 
   return nullptr;
 }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 auto
 RemoteTrackSource::ApplyConstraints(
     nsPIDOMWindowInner* aWindow,
     const dom::MediaTrackConstraints& aConstraints,
     dom::CallerType aCallerType) -> already_AddRefed<PledgeVoid>
 {
   RefPtr<PledgeVoid> p = new PledgeVoid();
   p->Reject(new dom::MediaStreamError(aWindow,
                                       NS_LITERAL_STRING("OverconstrainedError"),
                                       NS_LITERAL_STRING("")));
   return p.forget();
 }
-#endif
 
 } // namespace mozilla
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
@@ -15,23 +15,21 @@
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIProtocolProxyCallback.h"
 
 #include "signaling/src/jsep/JsepSession.h"
 #include "AudioSegment.h"
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "Layers.h"
 #include "VideoUtils.h"
 #include "ImageLayers.h"
 #include "VideoSegment.h"
 #include "MediaStreamTrack.h"
-#endif
 
 class nsIPrincipal;
 
 namespace mozilla {
 class DataChannel;
 class PeerIdentity;
 class MediaPipelineFactory;
 namespace dom {
@@ -138,30 +136,27 @@ public:
                         const std::string& aId)
      : SourceStreamInfo(aMediaStream, aParent, aId) {}
 
   nsresult TakePipelineFrom(RefPtr<LocalSourceStreamInfo>& info,
                             const std::string& oldTrackId,
                             dom::MediaStreamTrack& aNewTrack,
                             const std::string& newTrackId);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   void UpdateSinkIdentity_m(dom::MediaStreamTrack* aTrack,
                             nsIPrincipal* aPrincipal,
                             const PeerIdentity* aSinkIdentity);
-#endif
 
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(LocalSourceStreamInfo)
 
 private:
   already_AddRefed<MediaPipeline> ForgetPipelineByTrackId_m(
       const std::string& trackId);
 };
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
 class RemoteTrackSource : public dom::MediaStreamTrackSource
 {
 public:
   explicit RemoteTrackSource(nsIPrincipal* aPrincipal, const nsString& aLabel)
     : dom::MediaStreamTrackSource(aPrincipal, aLabel) {}
 
   dom::MediaSourceEnum GetMediaSource() const override
   {
@@ -183,36 +178,33 @@ public:
   {
     mPrincipal = aPrincipal;
     PrincipalChanged();
   }
 
 protected:
   virtual ~RemoteTrackSource() {}
 };
-#endif
 
 class RemoteSourceStreamInfo : public SourceStreamInfo {
   ~RemoteSourceStreamInfo() {}
  public:
   RemoteSourceStreamInfo(already_AddRefed<DOMMediaStream> aMediaStream,
                          PeerConnectionMedia *aParent,
                          const std::string& aId)
     : SourceStreamInfo(aMediaStream, aParent, aId),
       mReceiving(false)
   {
   }
 
   void DetachMedia_m() override;
   void RemoveTrack(const std::string& trackId) override;
   void SyncPipeline(RefPtr<MediaPipelineReceive> aPipeline);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   void UpdatePrincipal_m(nsIPrincipal* aPrincipal);
-#endif
 
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteSourceStreamInfo)
 
   void AddTrack(const std::string& trackId,
                 const RefPtr<dom::MediaStreamTrack>& aTrack) override
   {
     SourceStreamInfo::AddTrack(trackId, aTrack);
   }
@@ -334,30 +326,28 @@ class PeerConnectionMedia : public sigsl
   nsresult AddRemoteStream(RefPtr<RemoteSourceStreamInfo> aInfo);
 
   nsresult ReplaceTrack(const std::string& aOldStreamId,
                         const std::string& aOldTrackId,
                         dom::MediaStreamTrack& aNewTrack,
                         const std::string& aNewStreamId,
                         const std::string& aNewTrackId);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
   // In cases where the peer isn't yet identified, we disable the pipeline (not
   // the stream, that would potentially affect others), so that it sends
   // black/silence.  Once the peer is identified, re-enable those streams.
   // aTrack will be set if this update came from a principal change on aTrack.
   void UpdateSinkIdentity_m(dom::MediaStreamTrack* aTrack,
                             nsIPrincipal* aPrincipal,
                             const PeerIdentity* aSinkIdentity);
   // this determines if any track is peerIdentity constrained
   bool AnyLocalTrackHasPeerIdentity() const;
   // When we finally learn who is on the other end, we need to change the ownership
   // on streams
   void UpdateRemoteStreamPrincipals_m(nsIPrincipal* aPrincipal);
-#endif
 
   bool AnyCodecHasPluginID(uint64_t aPluginID);
 
   const nsCOMPtr<nsIThread>& GetMainThread() const { return mMainThread; }
   const nsCOMPtr<nsIEventTarget>& GetSTSThread() const { return mSTSThread; }
 
   static size_t GetTransportFlowIndex(int aStreamIndex, bool aRtcp)
   {