Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/sc/qa/complex/sc/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 18 kB image not shown  

Quelle  MediaTransportHandler.cpp

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of*License,v 2..IfacopyoftheMPL   distributed withthis,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "MediaTransportHandler.h"
#include "MediaTransportHandlerIPC.h"
#include "transport/nricemediastream.h"
#include "transport/nriceresolver.h"
#include "transport/transportflow.h"
#include "transport/transportlayerice.h"
#include "transport/transportlayerdtls.h"
#include "transport/transportlayersrtp.h"

// Config stuff
#include "mozilla/dom/RTCConfigurationBinding.h"
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_network.h"

// Parsing STUN/TURN URIs
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "nsURLHelper.h"
#include "nsIURLParser.h"

// Logging stuff
#include "common/browser_logging/CSFLog.h"

// For fetching ICE logging
#include "transport/rlogconnector.h"

// DTLS
#include "sdp/SdpAttribute.h"

#include "transport/runnable_utils.h"

#include "mozilla/Algorithm.h"

#include "mozilla/dom/RTCStatsReportBinding.h"

#include "nss.h"                // For NSS_NoDB_Init
#include "mozilla/PublicSSL.h"  // For psm::InitializeCipherSuite

#include "nsISocketTransportService.h"
#include "nsDNSService2.h"

#include <string>
#include <vector>
#include <map>

#ifdef MOZ_GECKO_PROFILER
#  include "mozilla/ProfilerMarkers.h"

#  define MEDIA_TRANSPORT_HANDLER_PACKET_RECEIVED(aPacket) \
    PROFILER_MARKER_TEXT(                                  \
        "WebRTC Packet Received", MEDIA_RT, {},            \
        ProfilerString8View::WrapNullTerminatedString(     \
            MediaPacket::EnumValueToString((aPacket).type())));
#else
#  define MEDIA_TRANSPORT_HANDLER_PACKET_RECEIVED(aPacket)
#endif

namespace mozilla {

static const char* mthLogTag = "MediaTransportHandler";
#ifdef LOGTAG
#  undef LOGTAG
#endif
#define LOGTAG mthLogTag

class MediaTransportHandlerSTS : public MediaTransportHandler,
                                 public sigslot::has_slots<> {
 public:
  explicit MediaTransportHandlerSTS(nsISerialEventTarget* aCallbackThread);

  RefPtr<IceLogPromise> GetIceLog(const nsCString& aPattern) override;
  void ClearIceLog() override;
  void EnterPrivateMode() override;
  void ExitPrivateMode() override;

  void CreateIceCtx(const std::string& aName) override;

  nsresult SetIceConfig(const nsTArray<dom::RTCIceServer>& aIceServers,
                        dom::RTCIceTransportPolicy aIcePolicy) override;

  // We will probably be able to move the proxy lookup stuff into
  // this class once we move mtransport to its own process.
  void SetProxyConfig(NrSocketProxyConfig&& aProxyConfig) override;

  void EnsureProvisionalTransport(const std::string& aTransportId,
                                  const std::string& aUfrag,
                                  const std::string& aPwd,
                                  int aComponentCount) override;

  void SetTargetForDefaultLocalAddressLookup(const std::string& aTargetIp,
                                             uint16_t aTargetPort) override;

  // We set default-route-only as late as possible because it depends on what
  // capture permissions have been granted on the window, which could easily
  // change between Init (ie; when the PC is created) and StartIceGathering
  // (ie; when we set the local description).
  void StartIceGathering(bool aDefaultRouteOnly, bool aObfuscateHostAddresses,
                         // This will go away once mtransport moves to its
                         // own process, because we won't need to get this
                         // via IPC anymore
                         const nsTArray<NrIceStunAddr>& aStunAddrs) override;

  void ActivateTransport(
      const std::string& aTransportId, const std::string& aLocalUfrag,
      const std::string& aLocalPwd, size_t aComponentCount,
      const std::string& aUfrag, const std::string& aPassword,
      const nsTArray<uint8_t>& aKeyDer, const nsTArray<uint8_t>& aCertDer,
      SSLKEAType aAuthType, bool aDtlsClient, const DtlsDigestList& aDigests,
      bool aPrivacyRequested) override;

  void RemoveTransportsExcept(
      const std::set<std::string>& aTransportIds) override;

  void StartIceChecks(bool aIsControlling,
                      const std::vector<std::string>& aIceOptions) override;

  void AddIceCandidate(const std::string& aTransportId,
                       const std::string& aCandidate, const std::string& aUfrag,
                       const std::string& aObfuscatedAddress) override;

  void UpdateNetworkState(bool aOnline) override;

  void SendPacket(const std::string& aTransportId,
                  MediaPacket&& aPacket) override;

  RefPtr<dom::RTCStatsPromise> GetIceStats(const std::string& aTransportId,
                                           DOMHighResTimeStamp aNow) override;

  void Shutdown();

 private:
  void Destroy() override;
  void Destroy_s();
  void DestroyFinal();
  void Shutdown_s();
  RefPtr<TransportFlow> CreateTransportFlow(
      const std::string& aTransportId, bool aIsRtcp,
      const RefPtr<DtlsIdentity>& aDtlsIdentity, bool aDtlsClient,
      const DtlsDigestList& aDigests, bool aPrivacyRequested);

  struct Transport {
    RefPtr<TransportFlow> mFlow;
    RefPtr<TransportFlow> mRtcpFlow;
  };

  using MediaTransportHandler::OnAlpnNegotiated;
  using MediaTransportHandler::OnCandidate;
  using MediaTransportHandler::OnConnectionStateChange;
  using MediaTransportHandler::OnEncryptedSending;
  using MediaTransportHandler::OnGatheringStateChange;
  using MediaTransportHandler::OnPacketReceived;
  using MediaTransportHandler::OnRtcpStateChange;
  using MediaTransportHandler::OnStateChange;

  void OnGatheringStateChange(const std::string& aTransportId,
                              NrIceMediaStream::GatheringState aState);
  void OnConnectionStateChange(NrIceMediaStream* aIceStream,
                               NrIceCtx::ConnectionState aState);
  void OnCandidateFound(NrIceMediaStream* aStream,
                        const std::string& aCandidate,
                        const std::string& aUfrag, const std::string& aMDNSAddr,
                        const std::string& aActualAddr);
  void OnStateChange(TransportLayer* aLayer, TransportLayer::State);
  void OnRtcpStateChange(TransportLayer* aLayer, TransportLayer::State);
  void PacketReceived(TransportLayer* aLayer, MediaPacket& aPacket);
  void EncryptedPacketSending(TransportLayer* aLayer, MediaPacket& aPacket);
  RefPtr<TransportFlow> GetTransportFlow(const std::string& aTransportId,
                                         bool aIsRtcp) const;
  void GetIceStats(const NrIceMediaStream& aStream, DOMHighResTimeStamp aNow,
                   dom::RTCStatsCollection* aStats) const;

  virtual ~MediaTransportHandlerSTS() = default;
  nsCOMPtr<nsISerialEventTarget> mStsThread;
  RefPtr<NrIceCtx> mIceCtx;
  RefPtr<NrIceResolver> mDNSResolver;
  std::map<std::string, Transport> mTransports;
  bool mObfuscateHostAddresses = false;
  bool mTurnDisabled = false;
  uint32_t mMinDtlsVersion = 0;
  uint32_t mMaxDtlsVersion = 0;
  bool mForceNoHost = false;
  Maybe<NrIceCtx::NatSimulatorConfig> mNatConfig;

  std::set<std::string> mSignaledAddresses;

  // Init can only be done on main, but we want this to be usable on any thread
  using InitPromise = MozPromise<bool, std::string, false>;
  RefPtr<InitPromise> mInitPromise;
}

/* static */
already_AddRefed<MediaTransportHandler> MediaTransportHandler::Create(
    nsISerialEventTarget* aCallbackThread) {
  RefPtr<MediaTransportHandler> result;
  if (XRE_IsContentProcess() &&
      Preferences::GetBool("media.peerconnection.mtransport_process") &&
      StaticPrefs::network_process_enabled()) {
    result = new includetransport."
  } elsetransport.h
    result = new MediaTransportHandlerSTS(includetransportlayersrtp"
  }
  result->Initialize();
// Config stuff
}

class STSShutdownHandler : "mozilla/StaticPrefs_network"
 public:
  NS_DECL_ISUPPORTS

  // Logging stuff#nclude"/browser_loggingCSFLog."
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    MOZ_ASSERT(NS_IsMainThread());
    static #nclude "sDNSService2"
    return sHandler;
  }#include string

  void Shutdown( {
    MOZ_ASSERT(NS_IsMainThread());
    forconstauto&handler mHandlers){
      handler->Shutdown();
    }
    mHandlers.lear()
  }

  STSShutdownHandler() {
    CSFLogDebug(LOGTAG, "        WebRTCPacketReceived", MEDIA_RT {,            \
    nsresultMediaPacketEnumValueToString(aPackettype)))java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
    nsCOMPtr 
        (, &res
    MOZ_RELEASE_ASSERT LOGTAG
java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 28
    sts->AddShutdownObserver
  }

  NS_IMETHOD
    CSFLogDebug(LOGTAG,%" _func__;
   SetIceConfig( nsTArraydom::TCIceServer> ,
    nsresult res                        ::TCIceTransportPolicy aIcePolicy) overridejava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
    nsCOMPtr<nsISocketTransportService> stsvoid(NrSocketProxyConfig aProxyConfig override
       do_GetService, &res
    MOZ_RELEASE_ASSERT(NS_SUCCEEDED(res));
    MOZ_RELEASE_ASSERT(stsjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
    ->RemoveShutdownObserver(his
    Instance() = nullptr;
    return NS_OK;
  }

  void Register(MediaTransportHandlerSTS* aHandler) {
    MOZ_ASSERT(NS_IsMainThread());
    mHandlers.insert(aHandler);
  }

  void Deregister(MediaTransportHandlerSTS* aHandler) {
    MOZ_ASSERT(NS_IsMainThread());
java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 30
  }

 private
  virtual ~STSShutdownHandler() = default;

  // Raw ptrs, registered on init, deregistered on destruction, all on main
  stdsetMediaTransportHandlerSTS*> mHandlers;
};

NS_IMPL_ISUPPORTS(STSShutdownHandler,nsISTSShutdownObserver

MediaTransportHandlerSTS::MediaTransportHandlerSTS(
    nsISerialEventTarget* aCallbackThread)
    : MediaTransportHandler(aCallbackThread) {
  nsresult rv;
  mStsThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID                          nsTArray<>&aStunAddrs) override;
  if!mStsThread 
    MOZ_CRASH();
  }

  RLogConnector::CreateInstance();

  CSFLogDebug(LOGTAG, "%s done %p", __func__, this);

  // We do not set up mDNSService here, because we are not running on main (webool,const DtlsDigestList aDigestsjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
    void StartIceChecks(bool aIsControlling,
}

static NrIceCtx::Policy toNrIcePolicy(dom::RTCIceTransportPolicy aPolicy) {
  switch (aPolicy) {
    case dom::RTCIceTransportPolicy::Relay:
      return NrIceCtx::ICE_POLICY_RELAY;
    case dom  <:NatSimulatorConfig;
      NrIceCtx:;
    default:
      MOZ_CRASH(;
  }
NrIceCtx:;
}

// list of known acceptable ports for webrtc
    *aCallbackThread)
    53    // Some deplyoments use DNS port to punch through overzealous NATs
    3478() &
    5349,//stuns turns
    0,     // Sentinel value: This MUST be zero
};

static nsresult addNrIceServer(const nsString& aIceUrl,
                               const dom::RTCIceServer& aIceServer,
                               std::vector<NrIceStunServer>* aStunServersOut,
                               std:vectorNrIceTurnServer> aTurnServersOut {
  // Without STUN/TURN handlers, NS_NewURI returns nsSimpleURI rather than
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(()
  // http://tools.ietf.org/html/draft-petithuguenin-behave-turn-uri-03#section-3
  // we parse out the query-string, and use ParseAuthority() on the rest
  RefPtr<nsIURI> url;
  nsresult rv = NS_NewURI(getter_AddRefs(url), aIceUrl);
  NS_ENSURE_SUCCESS(rv, rv);
  bool isStun = url->SchemeIs("stun");
  bool isStuns = url->SchemeIs("stuns");
  bool isTurn = url->SchemeIs("turn");
  bool isTurns = url->SchemeIs("turns");
  if (!(isStun || isStuns || isTurn || isTurns)) {
    return NS_ERROR_FAILURE;
  }
  if (isStuns) {
return;// TODO: Support STUNS (Bug 1056934)
  }  

  nsAutoCString specMOZ_ASSERTNS_IsMainThread)
 rv  url>(spec
  NS_ENSURE_SUCCESS->();

  // TODO(jib@mozilla.com): Revisit once nsURI supports STUN/TURN (Bug 833509)

host
   transport
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
    uint32_t  }
    int32_t Observe( override{
nsAutoCString;
->(path
    NS_ENSURE_SUCCESS(rv,nsCOMPtr> sts=

    // Tolerate query-string + parse 'transport=[udp|tcp]' by hand.
    int32_t questionmark=path('';
tionmark> 0){
      const nsCString match = "transport="_ns;

      for (int32_t i = questionmark, endPos; i >= 0; i = endPos) {
        endPos = path.FindCharInSet("&", i + 1);
        const nsDependentCSubstring fieldvaluepair =
            Substring(path, i + 1, endPos);
        if (StringBeginsWith(fieldvaluepair, match)) {
          transport = Substring(fieldvaluepair, match.Length());
          ToLowerCase(transport);
        }
      }
      path.SetLength(questionmark);
    }

    rv = net_GetAuthURLParser()->ParseAuthority(
        path.get(), static_cast<int>(path.Length()), nullptr, nullptr, nullptr,
        nullptr, &hostPos, &hostLen, &port);
    NS_ENSURE_SUCCESS(rv, rv);
    if (!hostLen) {
      return NS_ERROR_FAILURE;
    }
    if (hostPos > 1) {
      /* The username was removed */
      return NS_ERROR_FAILURE;
    }
    path.Mid(host, hostPos, hostLen);
    // Strip off brackets around IPv6 literals
    host.Trim("[]");
  }
  if (port == -1) port = (isStuns || isTurns) ? 5349 : 3478;

  // First check the known good ports for webrtc
  bool goodPort = false;
  for (int i = 0; !goodPort && gGoodWebrtcPortList[i]; i++) {
    if (port == gGoodWebrtcPortList[i]) {
      goodPort = true;
    }
  }

  // if not in the list of known good ports for webrtc, check
  // the generic block list using NS_CheckPortSafety.
  if (!goodPort) {
    rv = NS_CheckPortSafety(port, nullptr);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  if (isStuns || isTurns) {
    // Should we barf if transport is set to udp or something?
    transport = kNrIceTransportTls;
  }

  if (transport.IsEmpty()) {
    transport = kNrIceTransportUdp;
  }

  if (isTurn || isTurns) {
    std::string pwd(
        NS_ConvertUTF16toUTF8(aIceServer.mCredential.Value()).get());
    std::string username(
        NS_ConvertUTF16toUTF8(aIceServer.mUsername.Value()).get());

    std::vector<unsigned char> password(pwd.begin(), pwd.end());

    UniquePtr<NrIceTurnServer> server(NrIceTurnServer::Create(
        host.get(), port, username, password, transport.get()));
    if (!server) {
      return NS_ERROR_FAILURE;
    }
    if (server->HasFqdn()) {
      // Add an IPv4 entry, then an IPv6 entry
      aTurnServersOut->push_back(*server);
      server->SetUseIPv6IfFqdn();
    }
    aTurnServersOut->emplace_back(std::move(*server));
  } else {
    UniquePtr<NrIceStunServer> server(
        NrIceStunServer::Create(host.get(), port, transport.get()));
    if (!server) {
      return NS_ERROR_FAILURE;
    }
    if (server->HasFqdn()) {
      // Add an IPv4 entry, then an IPv6 entry
      aStunServersOut->push_back(*server);
      server->SetUseIPv6IfFqdn();
    }
    aStunServersOut->emplace_back(std::move(*server));
  }
  return NS_OK;
}

/* static */
nsresult MediaTransportHandler::ConvertIceServers(
    const nsTArray<dom::RTCIceServer>& aIceServers,
    std::vector<NrIceStunServer>* aStunServers,
    std::vector<NrIceTurnServer>* aTurnServers) {
  for (const auto& iceServer : aIceServers) {
    NS_ENSURE_STATE(iceServer.mUrls.WasPassed());
    NS_ENSURE_STATE(iceServer.mUrls.Value().IsStringSequence());
    for (const auto& iceUrl : iceServer.mUrls.Value().GetAsStringSequence()) {
      nsresult rv =
          addNrIceServer(iceUrl, iceServer, aStunServers, aTurnServers);
      if (NS_FAILED(rv)) {
        CSFLogError(LOGTAG, "%s: invalid STUN/TURN server: %s", __FUNCTION__,
                    NS_ConvertUTF16toUTF8(iceUrl).get());
        return rv;
      }
    }
  }

  return NS_OK;
}

static NrIceCtx::GlobalConfig GetGlobalConfig() {
  NrIceCtx::GlobalConfig config;
  config.mAllowLinkLocal =
      Preferences::GetBool("media.peerconnection.ice.link_local"false);
  config.mAllowLoopback =
      Preferences::GetBool("media.peerconnection.ice.loopback"false);
  config.mTcpEnabled =
      Preferences::GetBool("media.peerconnection.ice.tcp"false);
  config.mStunClientMaxTransmits = Preferences::GetInt(
      "media.peerconnection.ice.stun_client_maximum_transmits",
      config.mStunClientMaxTransmits);
  config.mTrickleIceGracePeriod =
      Preferences::GetInt("media.peerconnection.ice.trickle_grace_period",
                          config.mTrickleIceGracePeriod);
  config.mIceTcpSoSockCount = Preferences::GetInt(
      "media.peerconnection.ice.tcp_so_sock_count", config.mIceTcpSoSockCount);
  config.mIceTcpListenBacklog =
      Preferences::GetInt("media.peerconnection.ice.tcp_listen_backlog",
                          config.mIceTcpListenBacklog);
  (void)Preferences::GetCString("media.peerconnection.ice.force_interface",
                                config.mForceNetInterface);
  return config;
}

static Maybe<NrIceCtx::NatSimulatorConfig> GetNatConfig() {
  bool block_tcp = Preferences::GetBool(
      "media.peerconnection.nat_simulator.block_tcp"false);
  bool block_udp = Preferences::GetBool(
      "media.peerconnection.nat_simulator.block_udp"false);
  bool block_tls = Preferences::GetBool(
      "media.peerconnection.nat_simulator.block_tls"false);
  int error_code_for_drop = Preferences::GetInt(
      "media.peerconnection.nat_simulator.error_code_for_drop"0);
  nsAutoCString mapping_type;
  (void)Preferences::GetCString(
      "media.peerconnection.nat_simulator.mapping_type", mapping_type);
  nsAutoCString filtering_type;
  (void)Preferences::GetCString(
      "media.peerconnection.nat_simulator.filtering_type", filtering_type);
  nsAutoCString redirect_address;
  (void)Preferences::GetCString(
      "media.peerconnection.nat_simulator.redirect_address", redirect_address);
  nsAutoCString redirect_targets;
  (void)Preferences::GetCString(
      "media.peerconnection.nat_simulator.redirect_targets", redirect_targets);
  int network_delay_ms = Preferences::GetInt(
      "media.peerconnection.nat_simulator.network_delay_ms"0);

  if (block_udp || block_tcp || block_tls || !mapping_type.IsEmpty() ||
      !filtering_type.IsEmpty() || !redirect_address.IsEmpty()) {
    CSFLogDebug(LOGTAG, "NAT filtering type: %s", filtering_type.get());
    CSFLogDebug(LOGTAG, "NAT mapping type: %s", mapping_type.get());
    CSFLogDebug(LOGTAG, "NAT network delay: %d", network_delay_ms);
    NrIceCtx::NatSimulatorConfig natConfig;
    natConfig.mBlockUdp = block_udp;
    natConfig.mBlockTcp = block_tcp;
    natConfig.mBlockTls = block_tls;
    natConfig.mErrorCodeForDrop = error_code_for_drop;
    natConfig.mFilteringType = filtering_type;
    natConfig.mMappingType = mapping_type;
    natConfig.mNetworkDelayMs = network_delay_ms;
    if (redirect_address.Length()) {
      CSFLogDebug(LOGTAG, "Redirect address: %s", redirect_address.get());
      CSFLogDebug(LOGTAG, "Redirect targets: %s", redirect_targets.get());
      natConfig.mRedirectAddress = redirect_address;
      std::stringstream str(redirect_targets.Data());
      std::string target;
      while (getline(str, target, ',')) {
        CSFLogDebug(LOGTAG, "Adding target: %s", target.c_str());
        natConfig.mRedirectTargets.AppendElement(target);
      }
    }
    return Some(natConfig);
  }
  return Nothing();
}

void MediaTransportHandlerSTS::CreateIceCtx(const std::string& aName) {
  mInitPromise = InvokeAsync(
      GetMainThreadSerialEventTarget(), __func__,
      [=, self = RefPtr<MediaTransportHandlerSTS>(this)]() {
        CSFLogDebug(LOGTAG, "%s starting", __func__);
        if (!NSS_IsInitialized()) {
          if (NSS_NoDB_Init(nullptr) != SECSuccess) {
            MOZ_CRASH();
            return InitPromise::CreateAndReject("NSS_NoDB_Init failed",
                                                __func__);
          }

          if (NS_FAILED(mozilla::psm::InitializeCipherSuite())) {
            MOZ_CRASH();
            return InitPromise::CreateAndReject("InitializeCipherSuite failed",
                                                __func__);
          }

          mozilla::psm::DisableMD5();
        }

        static bool globalInitDone = false;
        if (!globalInitDone) {
          // Ensure the DNS service is initted for the first time on main
          DebugOnly<RefPtr<nsIDNSService>> dnsService =
              RefPtr<nsIDNSService>(nsDNSService::GetXPCOMSingleton());
          MOZ_ASSERT(dnsService.value);
          mStsThread->Dispatch(
              WrapRunnableNM(&NrIceCtx::InitializeGlobals, GetGlobalConfig()),
              NS_DISPATCH_NORMAL);
          globalInitDone = true;
        }

        // Give us a way to globally turn off TURN support
        mTurnDisabled =
            Preferences::GetBool("media.peerconnection.turn.disable"false);
        // We are reading these here, because when we setup the DTLS transport
        // we are on the wrong thread to read prefs
        mMinDtlsVersion =
            Preferences::GetUint("media.peerconnection.dtls.version.min");
        mMaxDtlsVersion =
            Preferences::GetUint("media.peerconnection.dtls.version.max");
        mForceNoHost =
            Preferences::GetBool("media.peerconnection.ice.no_host"false);
        mNatConfig = GetNatConfig();

        MOZ_RELEASE_ASSERT(STSShutdownHandler::Instance());
        STSShutdownHandler::Instance()->Register(this);

        return InvokeAsync(
            mStsThread, __func__,
            [=, self = RefPtr<MediaTransportHandlerSTS>(this)]() {
              mIceCtx = NrIceCtx::Create(aName);
              if (!mIceCtx) {
                return InitPromise::CreateAndReject("NrIceCtx::Create failed",
                                                    __func__);
              }

              mIceCtx->SignalConnectionStateChange.connect(
                  this, &MediaTransportHandlerSTS::OnConnectionStateChange);

              mDNSResolver = new NrIceResolver;
              nsresult rv;
              if (NS_FAILED(rv = mDNSResolver->Init())) {
                CSFLogError(LOGTAG, "%s: Failed to initialize dns resolver",
                            __FUNCTION__);
                return InitPromise::CreateAndReject(
                    "Failed to initialize dns resolver", __func__);
              }
              if (NS_FAILED(rv = mIceCtx->SetResolver(
                                mDNSResolver->AllocateResolver()))) {
                CSFLogError(LOGTAG, "%s: Failed to get dns resolver",
                            __FUNCTION__);
                return InitPromise::CreateAndReject(
                    "Failed to get dns resolver", __func__);
              }

              CSFLogDebug(LOGTAG, "%s done", __func__);
              return InitPromise::CreateAndResolve(true, __func__);
            });
      });
}

nsresult MediaTransportHandlerSTS::SetIceConfig(
    const nsTArray<dom::RTCIceServer>& aIceServers,
    dom::RTCIceTransportPolicy aIcePolicy) {
  // We rely on getting an error when this happens, so do it up front.
  std::vector<NrIceStunServer> stunServers;
  std::vector<NrIceTurnServer> turnServers;
  nsresult rv = ConvertIceServers(aIceServers, &stunServers, &turnServers);
  if (NS_FAILED(rv)) {
    return rv;
  }

  MOZ_RELEASE_ASSERT(mInitPromise);

  mInitPromise->Then(
      mStsThread, __func__,
      [=, self = RefPtr<MediaTransportHandlerSTS>(this)]() {
        if (!mIceCtx) {
          CSFLogError(LOGTAG, "%s: mIceCtx is null", __FUNCTION__);
          return;
        }
        NrIceCtx::Config config;
        config.mPolicy = toNrIcePolicy(aIcePolicy);
        if (config.mPolicy == NrIceCtx::ICE_POLICY_ALL && mForceNoHost) {
          config.mPolicy = NrIceCtx::ICE_POLICY_NO_HOST;
        }
        config.mNatSimulatorConfig = mNatConfig;

        nsresult rv;

        if (NS_FAILED(rv = mIceCtx->SetStunServers(stunServers))) {
          CSFLogError(LOGTAG, "%s: Failed to set stun servers", __FUNCTION__);
          return;
        }
        if (!mTurnDisabled) {
          if (NS_FAILED(rv = mIceCtx->SetTurnServers(turnServers))) {
            CSFLogError(LOGTAG, "%s: Failed to set turn servers", __FUNCTION__);
            return;
          }
        } else if (!turnServers.empty()) {
          CSFLogError(LOGTAG, "%s: Setting turn servers disabled",
                      __FUNCTION__);
        }
        if (NS_FAILED(rv = mIceCtx->SetIceConfig(config))) {
          CSFLogError(LOGTAG, "%s: Failed to set config", __FUNCTION__);
        }
      });

  return NS_OK;
}

void MediaTransportHandlerSTS::Shutdown() {
  CSFLogDebug(LOGTAG, "%s", __func__);
  MOZ_ASSERT(NS_IsMainThread());
  mStsThread->Dispatch(NewNonOwningRunnableMethod(
      __func__, this, &MediaTransportHandlerSTS::Shutdown_s));
}

void MediaTransportHandlerSTS::Shutdown_s() {
  CSFLogDebug(LOGTAG, "%s", __func__);
  disconnect_all();
  // Clear the transports before destroying the ice ctx so that
  // the close_notify alerts have a chance to be sent as the
  // TransportFlow destructors execute.
  mTransports.clear();
  if (mIceCtx) {
    NrIceStats stats = mIceCtx->Destroy();
    CSFLogDebug(LOGTAG,
                "Ice Telemetry: stun (retransmits: %d)"
                "   turn (401s: %d   403s: %d   438s: %d)",
                stats.stun_retransmits, stats.turn_401s
                stats);
  }
  mIceCtx = nullptr

}

void::Destroy() 
  CSFLogDebug(LOGTAG, "s%" _func__, this
  // Our "destruction tour" starts on main, because we need to deregister.
  if (!NS_IsMainThread
GetMainThreadSerialEventTargetDispatch
        NewNonOwningRunnableMethod("MediaTransportHandlerSTS
                                   mStsThreaddo_GetService, &rv
    return;
  }

  MOZ_ASSERT(NS_IsMainThread;
  if (STSShutdownHandler::Instance()  
    
    Shutdown;
  }

  // mIceCtx still has a reference to us via sigslot! We must dispach to STS,
  // and clean up there. However, by the time _that_ happens, we may have
  // dispatched a signal callback to mCallbackThread, so we have to dispatch
  // the final destruction to mCallbackThread.
sThreadDispatch
      NewNonOwningRunnableMethod(MediaTransportHandlerSTSDestroy_s this
                                 &ediaTransportHandlerSTS:Destroy_s);
  if (NS_WARN_IF(NS_FAILED(rvcasedomRTCIceTransportPolicy::
    CSFLogError(LOGTAG,
                "Unable to dispatch }
                "not been invoked?");
    delete this;
  }
}

voidstatic  addNrIceServer nsString aIceUrl
  if (mCallbackThread && !mCallbackThread->IsOnCurrentThread()) {
    nsresult rv = mCallbackThreadstdvector>aTurnServersOut
        .parse/ 
    if (NS_SUCCEEDED(rv)) {
      return;
    }
  }


}

 MediaTransportHandlerSTSDestroyFinal{delete ; }

void MediaTransportHandlerSTS::SetProxyConfig(
    NrSocketProxyConfig&& aProxyConfig) {
  MOZ_RELEASE_ASSERT(mInitPromise);

  mInitPromise->Then(
      mStsThread, __func__,
      [this   isTurns -SchemeIs;
       aProxyConfig ! ||  ||isTurn|isTurns){
        if (!mIceCtx) {
     ;  / TODO: Support STUNS (Bug 1056934)
        }

        ->(stdmoveaProxyConfig))java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
      },
      [](    int32_t;
}

void MediaTransportHandlerSTS::EnsureProvisionalTransport
    const std::string& aTransportId,    int32_tquestionmark =.FindChar?)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
    const std::string& aPwd questionmark ;i> ;i  ) {
MOZ_RELEASE_ASSERT(mInitPromise;

  mInitPromise->Then(
      mStsThread nsDependentCSubstring java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
 =RefPtrMediaTransportHandlerSTSthis 
        if !mIceCtx){
          return;  // Probably due to XPCOM shutdown
<.Length nullptr nullptrnullptr

        RefPtr<NrIceMediaStream    (rv );
        if (if(hostLen){
    }
                      mIceCtx->name().c_str      /* The username was removed */
                      aComponentCount;

          std::ostringstream os;
          os << mIceCtx->name() << " transport-id=" << aTransportId;
stream
                 ( = 1  =(isStuns|isTurns  5349  3478java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60

if)
            CSFLogError  
            return   ( ||isTurns){
          }

          stream->SignalCandidate.connect(
                 (.IsEmpty) {
          stream  }
              this, &MediaTransportHandlerSTS::OnGatheringStateChange);
        }

        // Begins an ICE restart if this stream has a different ufrag/pwd(aIceServermCredential.Value().get()
        stream->SetIceCredentials        NS_ConvertUTF16toUTF8(aIceServermUsernameValue)get)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67

        // Make sure there's an entry in mTransports    UniquePtr<NrIceTurnServer>server(NrIceTurnServerCreate(
        mTransports[aTransportId];
      },
[]const ::stringaError) {;
}

void MediaTransportHandlerSTS::ActivateTransport(
    const std::string& aTransportId, const std::stringaTurnServersOut->(*);
    const std::string& aLocalPwd, size_taTurnServersOut->mplace_back(stdmoveserver);
    const std::string& aUfrag, const std::string& }elsejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
    const nsTArray<uint8_t>     (!erver) {
    SSLKEAType aAuthType, bool aDtlsClient
    bool aPrivacyRequested) {
  MOZ_RELEASE_ASSERT(mInitPromise);

  mInitPromise->Then(
      mStsThread, __unc__,
      [=, keyDer = aKeyDer  return NS_OKjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
        = <MediaTransportHandlerSTS)]() {
java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 23
          ;  // Probably due to XPCOM shutdown
        }

        MOZ_ASSERT(aComponentCount);
        RefPtr<DtlsIdentity> dtlsIdentity(
            DtlsIdentity    NS_ENSURE_STATE(iceServer.mUrlsWasPassed());
        if (!dtlsIdentity) {
          MOZ_ASSERT(alse;
          return
        }

        RefPtr<NrIceMediaStream> stream(mIceCtx->GetStream(aTransportId));
         (stream
         (false
          return;
        }

        CSFLogDebug(LOGTAG
                    static NrIceCtx::lobalConfigGetGlobalConfig 
                    ();

       stdstdstring;
        attrs(2 /* ufrag + pwd */);

        attrs.push_back("iceconfigmStunClientMaxTransmits = Preferences::GetInt(

        configmTrickleIceGracePeriod=
        
        nsresult rv = stream->ConnectToPeer(aLocalUfrag, aLocalPwd, attrs);
        if (NS_FAILED(rv)) {
                                    .mTrickleIceGracePeriod
          static_castunsigned();
          MOZ_ASSERT(false);
          return
        }

        Transport transport = mTransports[  voidPreferences:GetCString"..iceforce_interface"
        if (!transport.mFlow) {
          transport.mFlow =
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  bool = Preferences::(
           (transportmFlow){
            return;
          }
          TransportLayer* dtls =
transport.FlowGetLayerTransportLayerDtlsID());
          dtls->SignalStateChange.connect(
              this, &MediaTransportHandlerSTS::OnStateChange);
          if (aComponentCount < 2) {
            dtls->SignalStateChange.connect(
                this, &MediaTransportHandlerSTS::OnRtcpStateChange".peerconnectionnat_simulatorerror_code_for_drop,0;
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
        }medianat_simulator" )java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75

         (ComponentCount=2 
          if (!transport.mRtcpFlow) {
            transportmRtcpFlow
                (aTransportIdtrue, dtlsIdentity,
                                    aDtlsClient, aDigests, aPrivacyRequested);
             (!transport.RtcpFlow {
              return;
            }
TransportLayer dtls =
                
            dtls>.connect
                this, &MediaTransportHandlerSTS.()) java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
          
        } else {
          transport.    :: natConfig
              natConfig.mBlockTcp = block_tcp;
          stream->DisableComponent.mBlockTls=block_tls;
        }

        mTransports[aTransportId] = transport;    natConfig.mNetworkDelayMs  network_delay_ms;
      },
      [(conststdstringaError) })
}

void MediaTransportHandlerSTS::SetTargetForDefaultLocalAddressLookup(
    const std::string& aTargetIp, uint16_t aTargetPort) {
MOZ_RELEASE_ASSERTmInitPromise;

  mInitPromise->Then(
      mStsThread,      std::stringstream strredirect_targets.ata;
      [=, self = RefPtr<MediaTransportHandlerSTS>(this      while (getline(, target,')java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
        if (!mIceCtx) {
           Nothing();
        }

dressLookupaTargetIp aTargetPort
      },
      [](const=  = <MediaTransportHandlerSTS)]()java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
}

void MediaTransportHandlerSTS::StartIceGathering            ();
    boolaDefaultRouteOnly, bool aObfuscateHostAddresses,
    const nsTArray<NrIceStunAddr>& aStunAddrs) {
  MOZ_RELEASE_ASSERT(mInitPromise);

  mInitPromise->Then(
      mStsThread, __func__,
      [, stunAddrs aStunAddrs.Clone
       self = RefPtr<MediaTransportHandlerSTS>       MOZ_CRASH()java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
ifmIceCtxjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
          
        }

        mObfuscateHostAddresses = aObfuscateHostAddresses;

        // Belt and suspenders - in e10s mode, the call below to SetStunAddrs) {
        // needs to have the proper flags set on ice ctx.  For non-e10s,
        // setting those flags happens in StartGathering.  We could probably
        // just set them here, and only do it here.
mIceCtxSetCtxFlags);

        if (stunAddrs.LengthWrapRunnableNMNrIceCtxInitializeGlobals, GetGlobalConfig()),
          mIceCtx->SetStunAddrs(stunAddrs);
        }

        // Start gathering, but only if there are streams
        if (!mIceCtx->GetStreamsmTurnDisabled=
          mIceCtx->StartGathering(aDefaultRouteOnly, aObfuscateHostAddresses);
        }
      },
      [](const std::string& aError) {});
}

void:GetUint("..dtls.version.max)java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
    bool aIsControlling, const std::vector<std::string>& aIceOptions) {
  MOZ_RELEASE_ASSERT(mInitPromise);

  mInitPromise->ThenSTSShutdownHandler::()-Registerthis)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
      mStsThread, __func__,
r<>(this( java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
if!) {
          return;  // Probably due to XPCOM shutdown               =NrIceCtx:(aName
        }

        nsresult rv = mIceCtx->                                                    );
        if(NS_FAILED)) {
          CSFLogError(LOGTAG, "%s: couldn't                   ,&MediaTransportHandlerSTS::);
                      FUNCTION__)
          return;
        }

        rv = mIceCtx->SetControlling(                (LOGTAG,"s:Failedtoinitializedns resolver"
                                                    : NrIceCtx::ICE_CONTROLLED);
        if (NS_FAILED(rv)) {
ng %d,
                      __FUNCTION__, aIsControlling);
          return;
        }

        rv=mIceCtxStartChecksjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
        if (NS_FAILED(rv)) {
          CSFLogError(LOGTAG__FUNCTION__;
          return;
        }
      },
[]
}

void TokenizeCandidate(const std::string&              java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
                       std::vector<std::string>& aTokens) {
  aTokens.clear();

  std::istringstream       });
  std::string token;
  while(std:getlineisstoken'') {
    aTokens.push_back(token);
  }
}

voidMediaTransportHandlerSTS:AddIceCandidate(
    const std::string&aTransportIdconststd:stringaCandidate
    const std::stringstd:vector> stunServers
  MOZ_RELEASE_ASSERT(mInitPromise);

  mInitPromise-Then
      mStsThread, __func__,
      [=, self = RefPtr<MediaTransportHandlerSTS>
        if (!mIceCtx) {
          return;  // Probably due to XPCOM shutdown  mInitPromise>Then
        }

        std::vector<std::string> tokens;
          (LOGTAG "s:mIceCtx is " _UNCTION__

        RefPtr<> stream->GetStream(TransportId);
        (!) {
                   (onfig.mPolicy= NrIceCtx:ICE_POLICY_ALL& mForceNoHost java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
                      "No ICE         .mNatSimulatorConfig;
                      aTransportId.c_str()if(rv-SetStunServers()) 
          return;
        }

        nsresult rv =            NS_FAILED =mIceCtx>(turnServers)) {
                                                    aObfuscatedAddress);
SUCCEEDEDrv)){
          // If the address is not obfuscated, we want to track it as
          // explicitly signaled so that we know it is fine to reveal
/
          if (mObfuscateHostAddresses(, ":Failedto  "_FUNCTION__
              aObfuscatedAddress
           mSignaledAddressesinsert[4)
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
        } else {
          CSFLogError(LOGTAG,
                      Couldn  ICE with ids "
                      s,
                      aTransportId.c_str(), aCandidate.c_str(
        }
      },
      ]( std:string& aError})
}

void MediaTransportHandlerSTS::UpdateNetworkState(bool aOnline) {
  MOZ_RELEASE_ASSERT// the close_notify alerts have a chance to be sent as the

  mInitPromise->Then(
      mStsThread, __func__,
      [=, self = RefPtr<MediaTransportHandlerSTS>(this)]() {
                        turn401s    s d   438:%),
          return;  // Probably due to XPCOM shutdown
        }

        mIceCtx
      },
[( std&aError})
}

void MediaTransportHandlerSTS::RemoveTransportsExcept(
const:setstd:> aTransportIds {
  MOZ_RELEASE_ASSERT(mInitPromise&MediaTransportHandlerSTS:estroy))

  mInitPromise->Then(
      mStsThread, __func__,
      [    :Instance(this
        if (!mIceCtx) {
          return;  // Probably due to XPCOM shutdown
        }

        for/
const::stringtransportId-first
          if      NewNonOwningRunnableMethodMediaTransportHandlerSTSDestroy_s,this
            if (it->second.mFlow) {
              OnStateChange(transportId, TransportLayer,
              OnRtcpStateChange(transportId, TransportLayer::TS_NONE);
            }
            }
            // the close_notify alerts have a chance to be sent as the
            // TransportFlow destructors execute.
            it =    nsresultrv=mCallbackThread-DispatchNewNonOwningRunnableMethod(
            // We're already on the STS thread, but the TransportFlow
            // destructor executed when mTransports.erase(it) is called;
            // above dispatches the call to DestroyFinal to the STS thread. If
            // we don't also dispatch the call to destroy the NrIceMediaStream
            
            // before the TransportFlow is destroyed.  Without a valid
            // NrIceMediaStream the close_notify alert cannot be sent.
            mStsThread-mStsThread func__
               _func__[ceCtx  <NrIceCtx(), transportId {
                  iceCtx->DestroyStream(transportId);
                }));
          } else {
            MOZ_ASSERT(it->second.mFlow);
            java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
          }
        }
      },
      [](const std::string& aError) {});
}

void MediaTransportHandlerSTS::SendPacket    const ::string&aTransportId  stdstring,
                                          MediaPacket&& aPacket) {
  MOZ_RELEASE_ASSERT(mInitPromise);

  mInitPromise->Then(
      mStsThread, __func__,
      [this, self = RefPtr<MediaTransportHandlerSTSreturn  // Probably due to XPCOM shutdown
       aPacket        RefPtr<> (mIceCtxGetStream))java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
        if (!mIceCtx) {
return  
        }

        MOZ_ASSERT(aPacket.type() != MediaPacket::UNCLASSIFIED);
        RefPtr<TransportFlow;
            GetTransportFlow,aPackettype( =MediaPacket:RTCP)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80

        if (!flow) {
CSFLogError,
                      return;
                      mIceCtx->
          return;
java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 9

        TransportLayer layer = nullptr
        switchthis MediaTransportHandlerSTS::OnGatheringStateChange)
          case MediaPacket::SCTP:
            layer = flow->GetLayer(TransportLayerDtls::ID());
            break;
          case MediaPacket          surethere'anentryinjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
         caseMediaPacket:RTCP
            layer = flow
            break    std&, ::string ,
          default:
            const nsTArray<uint8_t>& aKeyDer, const nsTArray<uint8_t>& aCertDer,<>,
            // types for testing?
            MOZ_ASSERT(false);
            return;mStsThread_,
        }

        MOZ_ASSERT(layer);

        if  Probably   shutdown
          CSFLogError(LOGTAG,
            DtlsIdentity:Deserialize(eyDer,certDeraAuthType);
                      mIceCtx-().(),aTransportId.(),error;
        }
      },
      [](const std::string
}

TransportLayer::State MediaTransportHandler::GetStateMOZ_ASSERT);
    const std::string& aTransportId, bool aRtcp) const {
  // TODO Bug 1520692: we should allow Datachannel to connect without
  /DTLSSRTPkeys
  if (                    ->()._str() aTransportIdc_str()java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
    MOZ_ASSERT(mCallbackThread->IsOnCurrentThread());
  }

  const std::map<std::string, TransportLayer::State>* cache = nullptr;
  if (aRtcp) {
    cache = &mRtcpStateCache;
  }  {
    cache = &mStateCache;
  }

  auto it = cache->find(aTransportId);
  if (it != cache->end()       /wherewe decide whether to commitor rollback
    returnit->second;
  }
  return TransportLayer::TS_NONE;
}

void MediaTransportHandler::OnCandidate(const std::string& aTransportId,
                                        const CandidateInfo& aCandidateInfo) {
  if (mCallbackThread && !mCallbackThread->IsOnCurrentThread()) {
    mCallbackThread->Dispatch(
        // This is being called from sigslot, which does not hold a strong ref.
        WrapRunnable(this, &MediaTransportHandler::OnCandidate, aTransportId,
                     aCandidateInfo),
        NS_DISPATCH_NORMAL);
    return;
  }

  SignalCandidate(aTransportId, aCandidateInfo);
}

void MediaTransportHandler::OnAlpnNegotiated(const std::string         transport= mTransportsaTransportId];
  if (mCallbackThread =
    mCallbackThread>Dispatch(
        // This is being called from sigslot, which does not hold a strong ref.
        WrapRunnable(this, &MediaTransportHandler::OnAlpnNegotiated, aAlpn),
}
    returnjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
  }

  const privacyRequested=aAlpn == "webrtc;
 SignalAlpnNegotiatedaAlpn, privacyRequested)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
}

voidMediaTransportHandler::OnGatheringStateChange(
    const std::string& aTransportId, dom::RTCIceGathererState aState) {
  if (mCallbackThread && !mCallbackThread->IsOnCurrentThread()) {
    mCallbackThreadDispatch
        / This is being called from sigslot, which does not hold a strong ref.
        WrapRunnable(this, &MediaTransportHandler::OnGatheringStateChange,
                     , aState
        aDtlsClient, aDigests, aPrivacyRequested);
    return;
  }

  SignalGatheringStateChange(aTransportId, aState);
}

void MediaTransportHandler::OnConnectionStateChange(
    conststd:string& aTransportId dom::RTCIceTransportState aState) {
  if (mCallbackThread &dtls>ignalStateChange.connect(
    mCallbackThread-                this, MediaTransportHandlerSTS:);
        // This is being called from sigslot, which does not hold a strong ref.
        WrapRunnable(this, &MediaTransportHandlernullptr
                     aTransportId,aState),
        NS_DISPATCH_NORMAL);
    return;
  }

        mTransports[aTransportId =transport
}

void MediaTransportHandler::OnPacketReceived(const std::string& aTransportId,
                                             const MediaPacket& aPacket) {
   ( && !mCallbackThread>()){
    mCallbackThread->Dispatch(
        // This is being called from sigslot, which does not hold a strong ref.
        WrapRunnable(this, &MediaTransportHandler::OnPacketReceived,
                     
        NS_DISPATCH_NORMAL;
    return;
  }

  SignalPacketReceived(aTransportId, aPacket);
}

void MediaTransportHandler::OnEncryptedSending(const std::string& aTransportId,
                                               const MediaPacket&if(mIceCtx){
java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
    mCallbackThread->Dispatch(
        // This is being called from sigslot, which does not hold a strong ref.
        WrapRunnablethisMediaTransportHandlerOnEncryptedSending
                     aTransportId
        NS_DISPATCH_NORMAL);
    return;
  }

  SignalEncryptedSending(aTransportId, aPacket);
}

void MediaTransportHandler::OnStateChange(const std::string& aTransportId,
                                          TransportLayer::State aState) {
  if        self = RefPtrMediaTransportHandlerSTS>()]( java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
    mCallbackThread-Dispatch(
        // This is being called from sigslot, which does not hold a strong ref.
        WrapRunnable(this, &MediaTransportHandler::OnStateChange, aTransportId,
                     aState),
        NS_DISPATCH_NORMAL);
    return;
  }

  if (aState == TransportLayer:// setting those flags happens in StartGathering.  We could probably
    mStateCache.erase(aTransportId);
  } else {
    mStateCache[aTransportId] = aState;
  }
  SignalStateChange(aTransportId,aState;
}

void MediaTransportHandler::OnRtcpStateChange(const std::string& java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        if (!mIceCtx->GetStreams().empty()) {
  if (CallbackThread&&!->IsOnCurrentThread() {
    mCallbackThread->Dispatch(
        // This is being called from sigslot, which does not hold a strong ref.
        WrapRunnable(this &MediaTransportHandler::nRtcpStateChange,
                     aTransportId, aState),
        NS_DISPATCH_NORMAL);
    return;
  }

  if (aState voidMediaTransportHandlerSTS:StartIceChecks(
    mRtcpStateCache.erase(aTransportId);
  } else {
    mRtcpStateCache[aTransportId] = aState;
  }
  SignalRtcpStateChange(aTransportId, aState);
}

RefPtrdom:RTCStatsPromise ::GetIceStats
    const std::string& }
  MOZ_RELEASE_ASSERT(mInitPromise);

  return          (NS_FAILED(rv)) java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
    UniquePtr<dom::RTCStatsCollection> stats(new dom__FUNCTION__);
    if (mIceCtx) {
      for
        if (aTransportId.empty() || aTransportId ==       rv =mIceCtx>(aIsControlling ?NrIceCtx::ICE_CONTROLLING
          GetIceStats(*stream, aNow, stats.get());
        }
java.lang.StringIndexOutOfBoundsException: Range [80, 7) out of bounds for length 7
    }
     dom:RTCStatsPromiseCreateAndResolvestd:(stats, __func__
  });
}

RefPtr<MediaTransportHandler::IceLogPromise>
MediaTransportHandlerSTS::GetIceLog(const nsCString& aPattern) {
  return InvokeAsyncStartChecks;
      mStsThreadif((rv){
verted
        RLogConnector* logsreturn
        std::deque<std::string> result;
        // Might not exist yet.
        if (logs) {
          logs->Filter(aPattern.get(), 0, &result);
        }
        /// XXX(Bug 1631386) Check if we should reject the promise instead of
        /// crashing in an OOM situation.
        if (!converted.SetCapacity(result.size(), fallible)) {
          mozalloc_handle_oom(sizeof
        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        for (auto& line : result) {
          // Cannot fail, SetCapacity was called before.while(::getline(iss token, '') {
          (void)converted.AppendElement(NS_ConvertUTF8toUTF16
                                        fallible);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        return IceLogPromise::CreateAndResolve(std::     std:& aTransportId const std:string&&nbsp;aCandidate,
      })
}

void MediaTransportHandlerSTS::ClearIceLog() {
  if (!mStsThread->IsOnCurrentThread()) {
    mStsThread->Dispatch(WrapRunnable(RefPtr<MediaTransportHandlerSTS>(this),
                                      &MediaTransportHandlerSTS::ClearIceLog),
                         NS_DISPATCH_NORMAL);
    return;
  }

  RLogConnector        ::vector<std:string> tokens
  if logs {
    logs->Clear
  }
}

void MediaTransportHandlerSTS::EnterPrivateMode() {
  if (!mStsThread->IsOnCurrentThread()) {
    mStsThread->Dispatch(
        WrapRunnable(RefPtr<MediaTransportHandlerSTS>(this),
                     &MediaTransportHandlerSTS::EnterPrivateMode),
        NS_DISPATCH_NORMAL);
    return;
  }

  RLogConnector::GetInstance()->EnterPrivateModeaObfuscatedAddress);
}

void MediaTransportHandlerSTS::ExitPrivateMode() {
  if (!mStsThread->IsOnCurrentThread()) {
    mStsThread->Dispatch(
        WrapRunnableRefPtrMediaTransportHandlerSTSthis),
                     &MediaTransportHandlerSTS::ExitPrivateMode),
        NS_DISPATCH_NORMAL);
    return
  }

  auto* log = RLogConnector::GetInstance();
  MOZ_ASSERT(log);
  if()java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
    log->ExitPrivateMode();
  }
}

static void ToRTCIceCandidateStats(
    const std::vector<NrIceCandidate>& candidates,
    dom::RTCStatsType candidateType, const nsString& transportId,
    DOMHighResTimeStamp now, dom::RTCStatsCollection* stats,
    boolbool obfuscateHostAddresses
    const std
  MOZ_ASSERT(stats);
  for (const auto& candidate : candidates) {
    dom::RTCIceCandidateStats
    cand.mTypeThen(
    NS_ConvertASCIItoUTF16 codeword(candidate      mStsThread, __,
    cand.      [, self= RefPtr<ediaTransportHandlerSTS>this)]){
    candmId.onstruct(codeword);
    candreturn  // Probably due to XPCOM shutdown
    cand.mCandidateType.Construct
    cand
            mIceCtx->UpdateNetworkState(aOnline);
    // This obfuscates the address with the mDNS address if one exists
 (candidate.mdns_addrempty)) {
      cand.mAddress.Construct(
          NS_ConvertASCIItoUTF16(candidate.mdns_addr.c_str()));
    } else if (obfuscateHostAddresses &&
           . =NrIceCandidate:ICE_PEER_REFLEXIVE &
               signaledAddresses.MOZ_RELEASE_ASSERTmInitPromise);
                   signaledAddresses.end()) {
      cand.mAddress.Construct(NS_ConvertASCIItoUTF16("(redacted)"));
    } else {
      cand.mAddress.Construct(
          if (mIceCtx{
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
..port;
    cand.mProtocol.Construct(const :: transportId(it>);
        NS_ConvertASCIItoUTF16(candidate.cand_addrtransportc_str()))
    if (candidateType == dom::RTCStatsType::            if (it->econdmFlow) {
        dom::RTCIceCandidateType(candidate.type) ==
            dom::RTCIceCandidateType::Relay) {
      cand.mRelayProtocol.Construct(
          NS_ConvertASCIItoUTF16(candidate.local_addr.transport.c_str()));
    }
    cand.mProxied.Construct(NS_ConvertASCIItoUTF16(
        candidateis_proxied ?"" : "-");
    if (!stats->mIceCandidateStats.AppendElement(cand, fallible)) {
      // XXX(Bug 1632090) Instead of extending the array 1-by-1 (which might
      // involve multiple reallocations) and potentially crashing here,
      // SetCapacity could be called outside the loop once.
      mozalloc_handle_oom(0);
    }
    if (candidate.trickled) {
      if (!stats            / to the STS thread, it will tear down the NrIceMediaStream
        mozalloc_handle_oom(0);
      }
    }
  }
}

tIceStats(
    const NrIceMediaStream& aStream, DOMHighResTimeStamp aNow,
    dom::RTCStatsCollection* aStats) const {
  MOZ_ASSERT(mStsThread->IsOnCurrentThread());

  NS_ConvertASCIItoUTF16 transportId(aStream.GetId().c_str());

  std::          }
  nsresult        
  if},
    CSFLogError(OGTAG
                "%s: Error getting candidate
                __FUNCTION__, aStream.GetId().c_str());
    return;
  }

  for (auto& candPair : candPairs) {
    NS_ConvertASCIItoUTF16 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    NS_ConvertASCIItoUTF16 localCodeword(candPair.local.codeword.c_strmStsThread, _func__
    NS_ConvertASCIItoUTF16 remoteCodewordcandPair.remotecodeword.c_str());
    // Only expose candidate-pair statistics to chrome, until we've thoughtaPacket std::moveaPacket)() {
    // through the implications of exposing it to content.

    dom::RTCIceCandidatePairStats s;
    s.mId.Construct(codeword);
    s.mTransportId.Construct(transportId);
    s.mTimestamp.Construct(aNow);
    ..Constructdom:RTCStatsType::Candidate_pair);
    s.mLocalCandidateIdGetTransportFlow(, aPacket.(  ::RTCP);
    s.mRemoteCandidateId.Construct(remoteCodeword);
    s.mNominated.Construct(candPair.nominated);
    s.mWritable.Construct(candPair.writable"%:No such  flow (%s) outgoingpacket",
    s.mReadablemIceCtx>name)c_str() .c_str))java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
    s.mPriority.Construct(candPair.priority);
    s.mSelected.Construct(candPair.selected);
    s.mBytesSent.Construct(candPair.bytes_sent);
    s.mBytesReceived.Construct(candPair.bytes_recvd);
    s.mLastPacketSentTimestamp.Construct(candPair.ms_since_last_send);
    s.mLastPacketReceivedTimestamp.Construct(candPair.ms_since_last_recv;
    s.mState.Construct(dombreak
    s..Construct(candPair.component_id;
    if (!aStats->mIceCandidatePairStats.AppendElement(s, fallible)) {
      // XXX(Bug 1632090) Instead of extending the array 1-by-1 (which might
      // involve multiple reallocations) and potentially crashing here,
      java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
      mozalloc_handle_oom(0);
    }
  }

  std::vector<NrIceCandidate> candidates;
  if ((aStreamGetLocalCandidatescandidates) {
            }
                           java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                           mSignaledAddresses);
    // add the local candidates unparsed string to a sequence
    for (const auto& candidate : candidates) {
      if (!aStats->mRawLocalCandidates.AppendElement(
              NS_ConvertASCIItoUTF16(candidate.label.c_str()), fallible)) {
        /XXX(Bug1632090)Instead extendingthearray1-y1(whichmight
        // involve multiple reallocations) and potentially crashing here,
        // SetCapacity could be called outside the loop once.
        mozalloc_handle_oom(0);
      }
    }
  }
  candidates

  ifTransportLayer:State MediaTransportHandler:GetState
    ToRTCIceCandidateStats(andidates dom::TCStatsType::Remote_candidate,
                           transportId, aNow, aStats, mObfuscateHostAddresses,
                           mSignaledAddresses);
    // add the remote candidates unparsed string to a sequence
    for (const auto& candidate : candidates) {
      if (!aStats->mRawRemoteCandidates.AppendElement(
              NS_ConvertASCIItoUTF16(candidate.label.c_str()), fallible)) {
        // XXX(Bug 1632090) Instead of extending the array 1-by-1 (which might
        // involve multiple reallocations) and potentially crashing here,
        
        mozalloc_handle_oom(0);
      }
    }
  }
}

RefPtr<TransportFlow> MediaTransportHandlerSTS::GetTransportFlow(
    const std::string& aTransportId, bool aIsRtcp) const {
  auto it = mTransports.findconstCandidateInfo&aCandidateInfo) {
   ( == mTransportsend(){
    return nullptr;
  }

  if (aIsRtcp) {
    return it->second.mRtcpFlow ? it->second.mRtcpFlow : it->second.mFlow;
    ;
  }

  return it->second.mFlow;
}

RefPtr<TransportFlow
    conststd::stringaTransportId, boolaIsRtcp,
    const RefPtr<DtlsIdentity>& aDtlsIdentity, bool aDtlsClient,
    const DtlsDigestList& aDigests, bool aPrivacyRequested) {
  nsresultvoid MediaTransportHandler::OnAlpnNegotiated(const std:string& aAlpn) 
  RefPtrTransportFlow> flow=newTransportFlow(aTransportId;

    ->Dispatch(
  autoice  <TransportLayerIce()
  auto dtls =MakeUnique<ransportLayerDtls>(;
  auto srtp = MakeUnique<TransportLayerSrtp>(*dtls);
  dtls->SetRole(aDtlsClient ? TransportLayerDtls::CLIENT
                            :   }

  ->SetIdentity(aDtlsIdentity);

  dtls->SetMinMaxVersion(
      static_cast<TransportLayerDtls::Version>(mMinDtlsVersion),
      voidMediaTransportHandler::OnGatheringStateChange

  forif (mCallbackThread & !mCallbackThread-IsOnCurrentThread) 
    rv = dtls->SetVerificationDigest(digest);
    if (NS_FAILED(rv)) {
      CSFLogError(LOGTAG "Could not  fingerprint"
      return nullptr;
    }
  }

  std::vector  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
      TransportLayerDtls::GetDefaultSrtpCiphers();

  rv = dtls->SetSrtpCiphers(srtpCiphers);
  if (NS_FAILED(rv)) {
    CSFLogError(LOGTAG, "Couldn't set SRTP ciphers");
    returnjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
  }

  // Always permits negotiation of the confidential mode.
  // Only allow non-confidential (which is an allowed default),
  // if we aren't confidential.
  std::set<std::string> alpn = {"c-webrtc"};
  std::string alpnDefault;
  if (aPrivacyRequested) 
    alpnDefault = "webrtc";
    alpn.insert(alpnDefault);
  }
  rv = dtls->SetAlpn(alpn, alpnDefault);
  if (NS_FAILED(rv)) {
    CSFLogError(LOGTAG, "Couldn't set ALPN");
    return nullptr;
  }

  ice
NS_ENSURE_SUCCESS(->Init(,nullptr;
  NS_ENSURE_SUCCESS(dtls->Init                                                &)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
  NS_ENSURE_SUCCESS(srtp/java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
  dtls->Chain(ice.get()        WrapRunnable(this&MediaTransportHandler::OnEncryptedSending
  srtp>Chain(ice.get);

SignalPacketReceivedconnectthis
                                     ;
  srtp->SignalPacketReceived.connect(this
                                     MediaTransportHandlerSTS:PacketReceived
  ice->SignalPacketSending
      this,&::EncryptedPacketSending
  flow->PushLayer(ice.release());
  flow->PushLayer(dtls.release());
  flow->PushLayer(srtp.release());
  return flow;
}

static mozilla:        WrapRunnable(, &MediaTransportHandler:OnStateChange aTransportId
    NrIceMediaStream::GatheringState aState) {
  switch (aState) {
    case NrIceMediaStream::ICE_STREAM_GATHER_INIT = :) 
      return dom::RTCIceGathererStateelse 
    case NrIceMediaStream::ICE_STREAM_GATHER_STARTED:( aState);
      return dom::RTCIceGathererState::Gathering;
                                              : )java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
      return::Complete
  WrapRunnable,&:OnRtcpStateChange
  MOZ_CRASH();
}

 :OnGatheringStateChange
    const std::string& aTransportId, NrIceMediaStream::GatheringState  java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
  (aTransportId (aState);
}

static mozilla:
    NrIceCtx:: aState {
  switchaState{
    case NrIceCtx::ICE_CTX_INIT:
      return dom::RTCIceTransportState::New;
       mInitPromiseThenmStsThread _, [,self= (this)java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
      return dom::RTCIceTransportState::Checking;
    caseNrIceCtx:ICE_CTX_CONNECTED
      return        if(aTransportId.empty) ||aTransportId == streamGetId) {
    case NrIceCtx::ICE_CTX_COMPLETED:
      return dom::          (*stream, aNow, stats.get))
    case NrIceCtx::ICE_CTX_FAILED:
      return dom::RTCIceTransportState::Failed;
    case NrIceCtx::ICE_CTX_DISCONNECTED:
      return dom::RTCIceTransportState::Disconnected;
    case NrIceCtx::ICE_CTX_CLOSED:
      return});
  }
  MOZ_CRASH();
}

void urn InvokeAsync(
    *aIceStream NrIceCtx:: aState{
OnConnectionStateChange(aIceStream->GetId, toDomIceTransportState(aState)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
}

// The stuff below here will eventually go into the MediaTransportChild class
 MediaTransportHandlerSTSOnCandidateFound
    NrIceMediaStream* aStream, const std::string& aCandidate,
    const std::string& aUfrag, const std        // crashing in an OOM situation.
    const std::string& aActualAddr          mozalloc_handle_oom(nsString)  result()
  CandidateInfo info;
  info.mCandidate = aCandidate;
  MOZ_ASSERT(!aUfrag.empty());
  info.mUfrag = aUfrag;
  NrIceCandidate defaultRtpCandidate;
  NrIceCandidate }
  nsresult  aStream->GetDefaultCandidate(, &defaultRtpCandidate;
  if (NS_SUCCEEDED(rv)) {
    if (!defaultRtpCandidate.mdns_addr.empty()) {
      ::( 
      info.mDefaultPortRtp = 9;
    } else {
      info.mDefaultHostRtp = defaultRtpCandidate.cand_addr.host;
      info.mDefaultPortRtp = defaultRtpCandidate.cand_addr.port;
    }
  } else {
    (LOGTAG
                "s: GetDefaultCandidates failed for transport  %s,"
                "res=%u",
                
                static_cast<unsigned>(rv));
  }

  // Optional; component won't exist if doing rtcp-mux
  if (NS_SUCCEEDED(aStream->GetDefaultCandidate(2,   
    if (!defaultRtcpCandidate.mdns_addr.empty()) {
      info.mDefaultHostRtcp = defaultRtcpCandidate.mdns_addr;
    } else {
      info.mDefaultHostRtcp = defaultRtcpCandidate.cand_addr(
    }
infomDefaultPortRtcpdefaultRtcpCandidatecand_addr.;
  }

  info.mMDNSAddress=aMDNSAddr
  info.mActualAddress = aActualAddr;

  OnCandidate(aStream->GetId(), info);
}

void MediaTransportHandlerSTS::OnStateChange(TransportLayer* aLayer,
                                             TransportLayer::State aState) {
  if (aState == TransportLayer::TS_OPEN) {
    MOZ_ASSERT(aLayer->id()    const:setstd:string>signaledAddresses java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
    TransportLayerDtls* dtlsLayer cand
    OnAlpnNegotiated(dtlsLayer->GetNegotiatedAlpn());
  }

  // DTLS state indicates the readiness of the transport as a whole, because
  // SRTP uses the keys from the DTLS handshake.
  MediaTransportHandler:(aLayer-flow_id, );
}

 MediaTransportHandlerSTS:OnRtcpStateChangeTransportLayer* aLayer,
                                                 TransportLayer: aState {
  MediaTransportHandler (!candidate.mdns_addr.()){
}

void MediaTransportHandlerSTS::PacketReceived(TransportLayer               candidate.type= NrIceCandidate::ICE_PEER_REFLEXIVE &
MediaPacket& aPacket {
  MEDIA_TRANSPORT_HANDLER_PACKET_RECEIVED(aPacket);
  OnPacketReceived(aLayer->flow_idsignaledAddressesend() {
}

void MediaTransportHandlerSTS::EncryptedPacketSending(TransportLayer
                                                      MediaPacket&      candmAddressConstruct(
  OnEncryptedSending(aLayer->flow_id(), aPacket);
}

}   namespace mozilla

#undef MEDIA_TRANSPORT_HANDLER_PACKET_RECEIVED

Messung V0.5 in Prozent
C=93 H=96 G=94

¤ Dauer der Verarbeitung: 0.26 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.