Coverage Report

Created: 2018-09-25 14:53

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