Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: webrtc/api/jsep.h

Issue 2680273002: Adding more comments to every header file in api/ subdirectory. (Closed)
Patch Set: Merge with master Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/dtmfsenderinterface.h ('k') | webrtc/api/jsepicecandidate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 // Interfaces matching the draft-ietf-rtcweb-jsep-01. 11 // This file contains declarations of interfaces that wrap SDP-related
12 // constructs; session descriptions and ICE candidates. The inner "cricket::"
13 // objects shouldn't be accessed directly; the intention is that an application
14 // using the PeerConnection API only creates these objects from strings, and
15 // them passes them into the PeerConnection.
16 //
17 // Though in the future, we're planning to provide an SDP parsing API, with a
18 // structure more friendly than cricket::SessionDescription.
12 19
13 #ifndef WEBRTC_API_JSEP_H_ 20 #ifndef WEBRTC_API_JSEP_H_
14 #define WEBRTC_API_JSEP_H_ 21 #define WEBRTC_API_JSEP_H_
15 22
16 #include <stddef.h> 23 #include <stddef.h>
17 24
18 #include <string> 25 #include <string>
19 #include <vector> 26 #include <vector>
20 27
21 #include "webrtc/base/refcount.h" 28 #include "webrtc/base/refcount.h"
22 29
23 namespace cricket { 30 namespace cricket {
24 class Candidate; 31 class Candidate;
25 class SessionDescription; 32 class SessionDescription;
26 } // namespace cricket 33 } // namespace cricket
27 34
28 namespace webrtc { 35 namespace webrtc {
29 36
30 struct SdpParseError { 37 struct SdpParseError {
31 public: 38 public:
32 // The sdp line that causes the error. 39 // The sdp line that causes the error.
33 std::string line; 40 std::string line;
34 // Explains the error. 41 // Explains the error.
35 std::string description; 42 std::string description;
36 }; 43 };
37 44
38 // Class representation of an ICE candidate. 45 // Class representation of an ICE candidate.
46 //
39 // An instance of this interface is supposed to be owned by one class at 47 // An instance of this interface is supposed to be owned by one class at
40 // a time and is therefore not expected to be thread safe. 48 // a time and is therefore not expected to be thread safe.
49 //
50 // An instance can be created by CreateIceCandidate.
41 class IceCandidateInterface { 51 class IceCandidateInterface {
42 public: 52 public:
43 virtual ~IceCandidateInterface() {} 53 virtual ~IceCandidateInterface() {}
44 /// If present, this contains the identierfier of the "media stream 54 // If present, this is the value of the "a=mid" attribute of the candidate's
45 // identification" as defined in [RFC 3388] for m-line this candidate is 55 // m= section in SDP, which identifies the m= section.
46 // assocated with.
47 virtual std::string sdp_mid() const = 0; 56 virtual std::string sdp_mid() const = 0;
48 // This indeicates the index (starting at zero) of m-line in the SDP this 57 // This indicates the index (starting at zero) of m= section this candidate
49 // candidate is assocated with. 58 // is assocated with. Needed when an endpoint doesn't support MIDs.
50 virtual int sdp_mline_index() const = 0; 59 virtual int sdp_mline_index() const = 0;
60 // Only for use internally.
51 virtual const cricket::Candidate& candidate() const = 0; 61 virtual const cricket::Candidate& candidate() const = 0;
52 // Creates a SDP-ized form of this candidate. 62 // Creates a SDP-ized form of this candidate.
53 virtual bool ToString(std::string* out) const = 0; 63 virtual bool ToString(std::string* out) const = 0;
54 }; 64 };
55 65
56 // Creates a IceCandidateInterface based on SDP string. 66 // Creates a IceCandidateInterface based on SDP string.
57 // Returns NULL if the sdp string can't be parsed. 67 // Returns NULL if the sdp string can't be parsed.
58 // |error| can be NULL if doesn't care about the failure reason. 68 // |error| may be NULL.
59 IceCandidateInterface* CreateIceCandidate(const std::string& sdp_mid, 69 IceCandidateInterface* CreateIceCandidate(const std::string& sdp_mid,
60 int sdp_mline_index, 70 int sdp_mline_index,
61 const std::string& sdp, 71 const std::string& sdp,
62 SdpParseError* error); 72 SdpParseError* error);
63 73
64 // This class represents a collection of candidates for a specific m-line. 74 // This class represents a collection of candidates for a specific m= section.
65 // This class is used in SessionDescriptionInterface to represent all known 75 // Used in SessionDescriptionInterface.
66 // candidates for a certain m-line.
67 class IceCandidateCollection { 76 class IceCandidateCollection {
68 public: 77 public:
69 virtual ~IceCandidateCollection() {} 78 virtual ~IceCandidateCollection() {}
70 virtual size_t count() const = 0; 79 virtual size_t count() const = 0;
71 // Returns true if an equivalent |candidate| exist in the collection. 80 // Returns true if an equivalent |candidate| exist in the collection.
72 virtual bool HasCandidate(const IceCandidateInterface* candidate) const = 0; 81 virtual bool HasCandidate(const IceCandidateInterface* candidate) const = 0;
73 virtual const IceCandidateInterface* at(size_t index) const = 0; 82 virtual const IceCandidateInterface* at(size_t index) const = 0;
74 }; 83 };
75 84
76 // Class representation of a Session description. 85 // Class representation of an SDP session description.
77 // An instance of this interface is supposed to be owned by one class at 86 //
78 // a time and is therefore not expected to be thread safe. 87 // An instance of this interface is supposed to be owned by one class at a time
88 // and is therefore not expected to be thread safe.
89 //
90 // An instance can be created by CreateSessionDescription.
79 class SessionDescriptionInterface { 91 class SessionDescriptionInterface {
80 public: 92 public:
81 // Supported types: 93 // Supported types:
82 static const char kOffer[]; 94 static const char kOffer[];
83 static const char kPrAnswer[]; 95 static const char kPrAnswer[];
84 static const char kAnswer[]; 96 static const char kAnswer[];
85 97
86 virtual ~SessionDescriptionInterface() {} 98 virtual ~SessionDescriptionInterface() {}
99
100 // Only for use internally.
87 virtual cricket::SessionDescription* description() = 0; 101 virtual cricket::SessionDescription* description() = 0;
88 virtual const cricket::SessionDescription* description() const = 0; 102 virtual const cricket::SessionDescription* description() const = 0;
103
89 // Get the session id and session version, which are defined based on 104 // Get the session id and session version, which are defined based on
90 // RFC 4566 for the SDP o= line. 105 // RFC 4566 for the SDP o= line.
91 virtual std::string session_id() const = 0; 106 virtual std::string session_id() const = 0;
92 virtual std::string session_version() const = 0; 107 virtual std::string session_version() const = 0;
108
109 // kOffer/kPrAnswer/kAnswer
93 virtual std::string type() const = 0; 110 virtual std::string type() const = 0;
111
94 // Adds the specified candidate to the description. 112 // Adds the specified candidate to the description.
113 //
95 // Ownership is not transferred. 114 // Ownership is not transferred.
96 // Returns false if the session description does not have a media section that 115 //
97 // corresponds to the |candidate| label. 116 // Returns false if the session description does not have a media section
117 // that corresponds to |candidate.sdp_mid()| or
118 // |candidate.sdp_mline_index()|.
98 virtual bool AddCandidate(const IceCandidateInterface* candidate) = 0; 119 virtual bool AddCandidate(const IceCandidateInterface* candidate) = 0;
99 // Removes the candidates from the description. 120
121 // Removes the candidates from the description, if found.
122 //
100 // Returns the number of candidates removed. 123 // Returns the number of candidates removed.
101 virtual size_t RemoveCandidates( 124 virtual size_t RemoveCandidates(
102 const std::vector<cricket::Candidate>& candidates) { return 0; } 125 const std::vector<cricket::Candidate>& candidates) { return 0; }
103 126
104 // Returns the number of m- lines in the session description. 127 // Returns the number of m= sections in the session description.
105 virtual size_t number_of_mediasections() const = 0; 128 virtual size_t number_of_mediasections() const = 0;
106 // Returns a collection of all candidates that belong to a certain m-line 129
130 // Returns a collection of all candidates that belong to a certain m=
131 // section.
107 virtual const IceCandidateCollection* candidates( 132 virtual const IceCandidateCollection* candidates(
108 size_t mediasection_index) const = 0; 133 size_t mediasection_index) const = 0;
134
109 // Serializes the description to SDP. 135 // Serializes the description to SDP.
110 virtual bool ToString(std::string* out) const = 0; 136 virtual bool ToString(std::string* out) const = 0;
111 }; 137 };
112 138
113 // Creates a SessionDescriptionInterface based on SDP string and the type. 139 // Creates a SessionDescriptionInterface based on the SDP string and the type.
114 // Returns NULL if the sdp string can't be parsed or the type is unsupported. 140 // Returns NULL if the sdp string can't be parsed or the type is unsupported.
115 // |error| can be NULL if doesn't care about the failure reason. 141 // |error| may be NULL.
116 SessionDescriptionInterface* CreateSessionDescription(const std::string& type, 142 SessionDescriptionInterface* CreateSessionDescription(const std::string& type,
117 const std::string& sdp, 143 const std::string& sdp,
118 SdpParseError* error); 144 SdpParseError* error);
119 145
120 // Jsep CreateOffer and CreateAnswer callback interface. 146 // CreateOffer and CreateAnswer callback interface.
121 class CreateSessionDescriptionObserver : public rtc::RefCountInterface { 147 class CreateSessionDescriptionObserver : public rtc::RefCountInterface {
122 public: 148 public:
123 // The implementation of the CreateSessionDescriptionObserver takes 149 // This callback transfers the ownership of the |desc|.
124 // the ownership of the |desc|. 150 // TODO(deadbeef): Make this take an std::unique_ptr<> to avoid confusion
151 // around ownership.
125 virtual void OnSuccess(SessionDescriptionInterface* desc) = 0; 152 virtual void OnSuccess(SessionDescriptionInterface* desc) = 0;
126 virtual void OnFailure(const std::string& error) = 0; 153 virtual void OnFailure(const std::string& error) = 0;
127 154
128 protected: 155 protected:
129 ~CreateSessionDescriptionObserver() {} 156 ~CreateSessionDescriptionObserver() {}
130 }; 157 };
131 158
132 // Jsep SetLocalDescription and SetRemoteDescription callback interface. 159 // SetLocalDescription and SetRemoteDescription callback interface.
133 class SetSessionDescriptionObserver : public rtc::RefCountInterface { 160 class SetSessionDescriptionObserver : public rtc::RefCountInterface {
134 public: 161 public:
135 virtual void OnSuccess() = 0; 162 virtual void OnSuccess() = 0;
136 virtual void OnFailure(const std::string& error) = 0; 163 virtual void OnFailure(const std::string& error) = 0;
137 164
138 protected: 165 protected:
139 ~SetSessionDescriptionObserver() {} 166 ~SetSessionDescriptionObserver() {}
140 }; 167 };
141 168
142 } // namespace webrtc 169 } // namespace webrtc
143 170
144 #endif // WEBRTC_API_JSEP_H_ 171 #endif // WEBRTC_API_JSEP_H_
OLDNEW
« no previous file with comments | « webrtc/api/dtmfsenderinterface.h ('k') | webrtc/api/jsepicecandidate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698