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

Side by Side Diff: webrtc/api/jsepicecandidate.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/jsep.h ('k') | webrtc/api/jsepsessiondescription.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 // Implements the IceCandidateInterface. 11 // TODO(deadbeef): Move this out of api/; it's an implementation detail and
12 // shouldn't be used externally.
12 13
13 #ifndef WEBRTC_API_JSEPICECANDIDATE_H_ 14 #ifndef WEBRTC_API_JSEPICECANDIDATE_H_
14 #define WEBRTC_API_JSEPICECANDIDATE_H_ 15 #define WEBRTC_API_JSEPICECANDIDATE_H_
15 16
16 #include <string> 17 #include <string>
17 #include <utility> 18 #include <utility>
18 #include <vector> 19 #include <vector>
19 20
20 #include "webrtc/api/jsep.h" 21 #include "webrtc/api/jsep.h"
21 #include "webrtc/base/constructormagic.h" 22 #include "webrtc/base/constructormagic.h"
22 #include "webrtc/p2p/base/candidate.h" 23 #include "webrtc/p2p/base/candidate.h"
23 24
24 namespace webrtc { 25 namespace webrtc {
25 26
27 // Implementation of IceCandidateInterface.
26 class JsepIceCandidate : public IceCandidateInterface { 28 class JsepIceCandidate : public IceCandidateInterface {
27 public: 29 public:
28 JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index); 30 JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index);
29 JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index, 31 JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index,
30 const cricket::Candidate& candidate); 32 const cricket::Candidate& candidate);
31 ~JsepIceCandidate(); 33 ~JsepIceCandidate();
32 // |error| can be NULL if don't care about the failure reason. 34 // |err| may be NULL.
33 bool Initialize(const std::string& sdp, SdpParseError* err); 35 bool Initialize(const std::string& sdp, SdpParseError* err);
34 void SetCandidate(const cricket::Candidate& candidate) { 36 void SetCandidate(const cricket::Candidate& candidate) {
35 candidate_ = candidate; 37 candidate_ = candidate;
36 } 38 }
37 39
38 virtual std::string sdp_mid() const { return sdp_mid_; } 40 virtual std::string sdp_mid() const { return sdp_mid_; }
39 virtual int sdp_mline_index() const { return sdp_mline_index_; } 41 virtual int sdp_mline_index() const { return sdp_mline_index_; }
40 virtual const cricket::Candidate& candidate() const { 42 virtual const cricket::Candidate& candidate() const {
41 return candidate_; 43 return candidate_;
42 } 44 }
43 45
44 virtual bool ToString(std::string* out) const; 46 virtual bool ToString(std::string* out) const;
45 47
46 private: 48 private:
47 std::string sdp_mid_; 49 std::string sdp_mid_;
48 int sdp_mline_index_; 50 int sdp_mline_index_;
49 cricket::Candidate candidate_; 51 cricket::Candidate candidate_;
50 52
51 RTC_DISALLOW_COPY_AND_ASSIGN(JsepIceCandidate); 53 RTC_DISALLOW_COPY_AND_ASSIGN(JsepIceCandidate);
52 }; 54 };
53 55
54 // Implementation of IceCandidateCollection. 56 // Implementation of IceCandidateCollection which stores JsepIceCandidates.
55 // This implementation stores JsepIceCandidates.
56 class JsepCandidateCollection : public IceCandidateCollection { 57 class JsepCandidateCollection : public IceCandidateCollection {
57 public: 58 public:
58 JsepCandidateCollection() {} 59 JsepCandidateCollection() {}
59 // Move constructor is defined so that a vector of JsepCandidateCollections 60 // Move constructor is defined so that a vector of JsepCandidateCollections
60 // can be resized. 61 // can be resized.
61 JsepCandidateCollection(JsepCandidateCollection&& o) 62 JsepCandidateCollection(JsepCandidateCollection&& o)
62 : candidates_(std::move(o.candidates_)) {} 63 : candidates_(std::move(o.candidates_)) {}
63 ~JsepCandidateCollection(); 64 ~JsepCandidateCollection();
64 virtual size_t count() const { 65 virtual size_t count() const {
65 return candidates_.size(); 66 return candidates_.size();
66 } 67 }
67 virtual bool HasCandidate(const IceCandidateInterface* candidate) const; 68 virtual bool HasCandidate(const IceCandidateInterface* candidate) const;
68 // Adds and takes ownership of the JsepIceCandidate. 69 // Adds and takes ownership of the JsepIceCandidate.
70 // TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is
71 // more clear.
69 virtual void add(JsepIceCandidate* candidate) { 72 virtual void add(JsepIceCandidate* candidate) {
70 candidates_.push_back(candidate); 73 candidates_.push_back(candidate);
71 } 74 }
72 virtual const IceCandidateInterface* at(size_t index) const { 75 virtual const IceCandidateInterface* at(size_t index) const {
73 return candidates_[index]; 76 return candidates_[index];
74 } 77 }
75 // Removes the candidate that has a matching address and protocol. 78 // Removes the candidate that has a matching address and protocol.
79 //
76 // Returns the number of candidates that were removed. 80 // Returns the number of candidates that were removed.
77 size_t remove(const cricket::Candidate& candidate); 81 size_t remove(const cricket::Candidate& candidate);
78 82
79 private: 83 private:
80 std::vector<JsepIceCandidate*> candidates_; 84 std::vector<JsepIceCandidate*> candidates_;
81 85
82 RTC_DISALLOW_COPY_AND_ASSIGN(JsepCandidateCollection); 86 RTC_DISALLOW_COPY_AND_ASSIGN(JsepCandidateCollection);
83 }; 87 };
84 88
85 } // namespace webrtc 89 } // namespace webrtc
86 90
87 #endif // WEBRTC_API_JSEPICECANDIDATE_H_ 91 #endif // WEBRTC_API_JSEPICECANDIDATE_H_
OLDNEW
« no previous file with comments | « webrtc/api/jsep.h ('k') | webrtc/api/jsepsessiondescription.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698