tor-browser

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

SipccSdp.h (2434B)


      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 _SIPCCSDP_H_
      8 #define _SIPCCSDP_H_
      9 
     10 #include <vector>
     11 
     12 #include "sdp/Sdp.h"
     13 #include "sdp/SdpParser.h"
     14 #include "sdp/SipccSdpAttributeList.h"
     15 #include "sdp/SipccSdpMediaSection.h"
     16 extern "C" {
     17 #include "sipcc_sdp.h"
     18 }
     19 
     20 namespace mozilla {
     21 
     22 class SipccSdpParser;
     23 
     24 class SipccSdp final : public Sdp {
     25  friend class SipccSdpParser;
     26 
     27 public:
     28  explicit SipccSdp(const SdpOrigin& origin)
     29      : mOrigin(origin), mAttributeList(nullptr) {}
     30  SipccSdp(const SipccSdp& aOrig);
     31 
     32  virtual Sdp* Clone() const override;
     33 
     34  virtual const SdpOrigin& GetOrigin() const override;
     35 
     36  // Note: connection information is always retrieved from media sections
     37  virtual uint32_t GetBandwidth(const std::string& type) const override;
     38 
     39  virtual size_t GetMediaSectionCount() const override {
     40    return mMediaSections.size();
     41  }
     42 
     43  virtual const SdpAttributeList& GetAttributeList() const override {
     44    return mAttributeList;
     45  }
     46 
     47  virtual SdpAttributeList& GetAttributeList() override {
     48    return mAttributeList;
     49  }
     50 
     51  virtual const SdpMediaSection& GetMediaSection(size_t level) const override;
     52 
     53  virtual SdpMediaSection& GetMediaSection(size_t level) override;
     54 
     55  virtual SdpMediaSection& AddMediaSection(SdpMediaSection::MediaType media,
     56                                           SdpDirectionAttribute::Direction dir,
     57                                           uint16_t port,
     58                                           SdpMediaSection::Protocol proto,
     59                                           sdp::AddrType addrType,
     60                                           const std::string& addr) override;
     61 
     62  virtual void Serialize(std::ostream&) const override;
     63 
     64 private:
     65  using InternalResults = SdpParser::InternalResults;
     66 
     67  SipccSdp() : mOrigin("", 0, 0, sdp::kIPv4, ""), mAttributeList(nullptr) {}
     68 
     69  bool Load(sdp_t* sdp, InternalResults& results);
     70  bool LoadOrigin(sdp_t* sdp, InternalResults& results);
     71 
     72  SdpOrigin mOrigin;
     73  SipccSdpBandwidths mBandwidths;
     74  SipccSdpAttributeList mAttributeList;
     75  std::vector<UniquePtr<SipccSdpMediaSection>> mMediaSections;
     76 };
     77 
     78 }  // namespace mozilla
     79 
     80 #endif  // _sdp_h_