summaryrefslogtreecommitdiffstats
path: root/media/webrtc/signaling/src/sdp/SipccSdp.h
blob: 04ef202abb7ab177b691d01f72d15f56b7ac17dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */

#ifndef _SIPCCSDP_H_
#define _SIPCCSDP_H_

#include <map>
#include <vector>
#include "mozilla/Attributes.h"

#include "signaling/src/sdp/Sdp.h"
#include "signaling/src/sdp/SipccSdpMediaSection.h"
#include "signaling/src/sdp/SipccSdpAttributeList.h"
extern "C" {
#include "signaling/src/sdp/sipcc/sdp.h"
}

#include "signaling/src/common/PtrVector.h"

namespace mozilla
{

class SipccSdpParser;
class SdpErrorHolder;

class SipccSdp final : public Sdp
{
  friend class SipccSdpParser;

public:
  explicit SipccSdp(const SdpOrigin& origin)
      : mOrigin(origin), mAttributeList(nullptr)
  {
  }

  virtual const SdpOrigin& GetOrigin() const override;

  // Note: connection information is always retrieved from media sections
  virtual uint32_t GetBandwidth(const std::string& type) const override;

  virtual size_t
  GetMediaSectionCount() const override
  {
    return mMediaSections.values.size();
  }

  virtual const SdpAttributeList&
  GetAttributeList() const override
  {
    return mAttributeList;
  }

  virtual SdpAttributeList&
  GetAttributeList() override
  {
    return mAttributeList;
  }

  virtual const SdpMediaSection& GetMediaSection(size_t level) const
      override;

  virtual SdpMediaSection& GetMediaSection(size_t level) override;

  virtual SdpMediaSection& AddMediaSection(
      SdpMediaSection::MediaType media, SdpDirectionAttribute::Direction dir,
      uint16_t port, SdpMediaSection::Protocol proto, sdp::AddrType addrType,
      const std::string& addr) override;

  virtual void Serialize(std::ostream&) const override;

private:
  SipccSdp() : mOrigin("", 0, 0, sdp::kIPv4, ""), mAttributeList(nullptr) {}

  bool Load(sdp_t* sdp, SdpErrorHolder& errorHolder);
  bool LoadOrigin(sdp_t* sdp, SdpErrorHolder& errorHolder);

  SdpOrigin mOrigin;
  SipccSdpBandwidths mBandwidths;
  SipccSdpAttributeList mAttributeList;
  PtrVector<SipccSdpMediaSection> mMediaSections;
};

} // namespace mozilla

#endif // _sdp_h_