tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SdpHelper.h (4504B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef _SDPHELPER_H_
      8 #define _SDPHELPER_H_
      9 
     10 #include <map>
     11 #include <string>
     12 #include <vector>
     13 
     14 #include "nsError.h"
     15 #include "sdp/SdpAttribute.h"
     16 #include "sdp/SdpMediaSection.h"
     17 #include "transport/m_cpp_utils.h"
     18 
     19 namespace mozilla {
     20 class SdpMediaSection;
     21 class Sdp;
     22 
     23 class SdpHelper {
     24 public:
     25  // Takes a std::string* into which error strings will be written for the
     26  // lifetime of the SdpHelper.
     27  explicit SdpHelper(std::string* errorDest) : mLastError(*errorDest) {}
     28  ~SdpHelper() {}
     29 
     30  nsresult GetComponent(const std::string& candidate, size_t* component);
     31  nsresult CopyTransportParams(size_t numComponents,
     32                               const SdpMediaSection& source,
     33                               SdpMediaSection* dest);
     34  bool AreOldTransportParamsValid(const Sdp& oldAnswer,
     35                                  const Sdp& offerersPreviousSdp,
     36                                  const Sdp& newOffer, size_t level);
     37  bool IceCredentialsDiffer(const SdpMediaSection& msection1,
     38                            const SdpMediaSection& msection2);
     39 
     40  bool MsectionIsDisabled(const SdpMediaSection& msection) const;
     41  static void DisableMsection(Sdp* sdp, SdpMediaSection* msection);
     42 
     43  // Maps each mid to the m-section that owns its bundle transport.
     44  // Mids that do not appear in an a=group:BUNDLE do not appear here.
     45  typedef std::map<std::string, const SdpMediaSection*> BundledMids;
     46 
     47  nsresult GetBundledMids(const Sdp& sdp, BundledMids* bundledMids);
     48 
     49  bool OwnsTransport(const Sdp& localSdp, uint16_t level, sdp::SdpType type);
     50  bool OwnsTransport(const SdpMediaSection& msection,
     51                     const BundledMids& bundledMids, sdp::SdpType type);
     52  void GetBundleGroups(const Sdp& sdp,
     53                       std::vector<SdpGroupAttributeList::Group>* groups) const;
     54 
     55  nsresult GetMidFromLevel(const Sdp& sdp, uint16_t level, std::string* mid);
     56  nsresult GetIdsFromMsid(const Sdp& sdp, const SdpMediaSection& msection,
     57                          std::vector<std::string>* streamId);
     58  nsresult GetMsids(const SdpMediaSection& msection,
     59                    std::vector<SdpMsidAttributeList::Msid>* msids);
     60  nsresult ParseMsid(const std::string& msidAttribute, std::string* streamId,
     61                     std::string* trackId);
     62  nsresult AddCandidateToSdp(Sdp* sdp, const std::string& candidate,
     63                             uint16_t level, const std::string& ufrag);
     64  nsresult SetIceGatheringComplete(Sdp* sdp, const std::string& ufrag);
     65  nsresult SetIceGatheringComplete(Sdp* sdp, uint16_t level,
     66                                   const std::string& ufrag);
     67  void SetDefaultAddresses(const std::string& defaultCandidateAddr,
     68                           uint16_t defaultCandidatePort,
     69                           const std::string& defaultRtcpCandidateAddr,
     70                           uint16_t defaultRtcpCandidatePort,
     71                           SdpMediaSection* msection);
     72  void SetupMsidSemantic(const std::vector<std::string>& msids, Sdp* sdp) const;
     73 
     74  std::string GetCNAME(const SdpMediaSection& msection) const;
     75 
     76  SdpMediaSection* FindMsectionByMid(Sdp& sdp, const std::string& mid) const;
     77 
     78  const SdpMediaSection* FindMsectionByMid(const Sdp& sdp,
     79                                           const std::string& mid) const;
     80 
     81  nsresult CopyStickyParams(const SdpMediaSection& source,
     82                            SdpMediaSection* dest);
     83  bool HasRtcp(SdpMediaSection::Protocol proto) const;
     84  static SdpMediaSection::Protocol GetProtocolForMediaType(
     85      SdpMediaSection::MediaType type);
     86  void AppendSdpParseErrors(
     87      const std::vector<std::pair<size_t, std::string> >& aErrors,
     88      std::string* aErrorString);
     89 
     90  static bool GetPtAsInt(const std::string& ptString, uint16_t* ptOutparam);
     91 
     92  void NegotiateAndAddExtmaps(
     93      const SdpMediaSection& remoteMsection,
     94      std::vector<SdpExtmapAttributeList::Extmap>& localExtensions,
     95      SdpMediaSection* localMsection);
     96 
     97  bool SdpMatch(const Sdp& sdp1, const Sdp& sdp2);
     98  nsresult ValidateTransportAttributes(const Sdp& aSdp, sdp::SdpType aType);
     99 
    100 private:
    101  std::string& mLastError;
    102 
    103  DISALLOW_COPY_ASSIGN(SdpHelper);
    104 };
    105 }  // namespace mozilla
    106 
    107 #endif  // _SDPHELPER_H_