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