Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // Interfaces matching the draft-ietf-rtcweb-jsep-01. |
| 12 | 12 |
| 13 #ifndef WEBRTC_API_JSEP_H_ | 13 #ifndef WEBRTC_API_JSEP_H_ |
| 14 #define WEBRTC_API_JSEP_H_ | 14 #define WEBRTC_API_JSEP_H_ |
| 15 | 15 |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "webrtc/base/basictypes.h" | 19 #include "webrtc/base/basictypes.h" |
| 20 #include "webrtc/base/refcount.h" | 20 #include "webrtc/base/refcount.h" |
| 21 #include "webrtc/base/scoped_ref_ptr.h" | |
| 21 | 22 |
| 22 namespace cricket { | 23 namespace cricket { |
| 23 class SessionDescription; | 24 class SessionDescription; |
| 24 class Candidate; | 25 class Candidate; |
| 25 } // namespace cricket | 26 } // namespace cricket |
| 26 | 27 |
| 27 namespace webrtc { | 28 namespace webrtc { |
| 28 | 29 |
| 29 struct SdpParseError { | 30 struct SdpParseError { |
| 30 public: | 31 public: |
| 31 // The sdp line that causes the error. | 32 // The sdp line that causes the error. |
| 32 std::string line; | 33 std::string line; |
| 33 // Explains the error. | 34 // Explains the error. |
| 34 std::string description; | 35 std::string description; |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 // Class representation of an ICE candidate. | 38 // Class representation of an ICE candidate. |
| 38 // An instance of this interface is supposed to be owned by one class at | 39 // An instance of this interface is supposed to be owned by one class at |
| 39 // a time and is therefore not expected to be thread safe. | 40 // a time and is therefore not expected to be thread safe. |
| 40 class IceCandidateInterface { | 41 class IceCandidateInterface : public rtc::RefCountInterface { |
| 41 public: | 42 public: |
| 42 virtual ~IceCandidateInterface() {} | 43 virtual ~IceCandidateInterface() {} |
| 43 /// If present, this contains the identierfier of the "media stream | 44 /// If present, this contains the identierfier of the "media stream |
| 44 // identification" as defined in [RFC 3388] for m-line this candidate is | 45 // identification" as defined in [RFC 3388] for m-line this candidate is |
| 45 // assocated with. | 46 // assocated with. |
| 46 virtual std::string sdp_mid() const = 0; | 47 virtual std::string sdp_mid() const = 0; |
| 47 // This indeicates the index (starting at zero) of m-line in the SDP this | 48 // This indeicates the index (starting at zero) of m-line in the SDP this |
| 48 // candidate is assocated with. | 49 // candidate is assocated with. |
| 49 virtual int sdp_mline_index() const = 0; | 50 virtual int sdp_mline_index() const = 0; |
| 50 virtual const cricket::Candidate& candidate() const = 0; | 51 virtual const cricket::Candidate& candidate() const = 0; |
| 51 // Creates a SDP-ized form of this candidate. | 52 // Creates a SDP-ized form of this candidate. |
| 52 virtual bool ToString(std::string* out) const = 0; | 53 virtual bool ToString(std::string* out) const = 0; |
| 53 }; | 54 }; |
| 54 | 55 |
| 56 typedef rtc::scoped_refptr<IceCandidateInterface> IceCandidateInterfaceRefPtr; | |
| 57 | |
| 55 // Creates a IceCandidateInterface based on SDP string. | 58 // Creates a IceCandidateInterface based on SDP string. |
| 56 // Returns NULL if the sdp string can't be parsed. | 59 // Returns NULL if the sdp string can't be parsed. |
| 57 // |error| can be NULL if doesn't care about the failure reason. | 60 // |error| can be NULL if doesn't care about the failure reason. |
| 58 IceCandidateInterface* CreateIceCandidate(const std::string& sdp_mid, | 61 IceCandidateInterface* CreateIceCandidate(const std::string& sdp_mid, |
| 59 int sdp_mline_index, | 62 int sdp_mline_index, |
| 60 const std::string& sdp, | 63 const std::string& sdp, |
| 61 SdpParseError* error); | 64 SdpParseError* error); |
| 62 | 65 |
| 63 // This class represents a collection of candidates for a specific m-line. | 66 // This class represents a collection of candidates for a specific m-line. |
| 64 // This class is used in SessionDescriptionInterface to represent all known | 67 // This class is used in SessionDescriptionInterface to represent all known |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 88 // Get the session id and session version, which are defined based on | 91 // Get the session id and session version, which are defined based on |
| 89 // RFC 4566 for the SDP o= line. | 92 // RFC 4566 for the SDP o= line. |
| 90 virtual std::string session_id() const = 0; | 93 virtual std::string session_id() const = 0; |
| 91 virtual std::string session_version() const = 0; | 94 virtual std::string session_version() const = 0; |
| 92 virtual std::string type() const = 0; | 95 virtual std::string type() const = 0; |
| 93 // Adds the specified candidate to the description. | 96 // Adds the specified candidate to the description. |
| 94 // Ownership is not transferred. | 97 // Ownership is not transferred. |
| 95 // Returns false if the session description does not have a media section that | 98 // Returns false if the session description does not have a media section that |
| 96 // corresponds to the |candidate| label. | 99 // corresponds to the |candidate| label. |
| 97 virtual bool AddCandidate(const IceCandidateInterface* candidate) = 0; | 100 virtual bool AddCandidate(const IceCandidateInterface* candidate) = 0; |
| 101 // Removes the candidates that have a matching address and protocol. | |
| 102 // Returns the number of candidates removed. | |
| 103 virtual int RemoveCandidates( | |
| 104 const std::vector<IceCandidateInterfaceRefPtr>& candidates) = 0; | |
|
pthatcher1
2016/03/01 23:51:53
Why do we have to use a scoped_refptr here? Why c
honghaiz3
2016/03/02 19:06:40
We cannot do vector<IceCandidateInterface>. If so,
pthatcher1
2016/03/02 20:37:58
If this is just because we want an IceCandidateInt
honghaiz3
2016/03/03 01:17:40
It is going to be a lot more complicated to try to
| |
| 105 | |
| 98 // Returns the number of m- lines in the session description. | 106 // Returns the number of m- lines in the session description. |
| 99 virtual size_t number_of_mediasections() const = 0; | 107 virtual size_t number_of_mediasections() const = 0; |
| 100 // Returns a collection of all candidates that belong to a certain m-line | 108 // Returns a collection of all candidates that belong to a certain m-line |
| 101 virtual const IceCandidateCollection* candidates( | 109 virtual const IceCandidateCollection* candidates( |
| 102 size_t mediasection_index) const = 0; | 110 size_t mediasection_index) const = 0; |
| 103 // Serializes the description to SDP. | 111 // Serializes the description to SDP. |
| 104 virtual bool ToString(std::string* out) const = 0; | 112 virtual bool ToString(std::string* out) const = 0; |
| 105 }; | 113 }; |
| 106 | 114 |
| 107 // Creates a SessionDescriptionInterface based on SDP string and the type. | 115 // Creates a SessionDescriptionInterface based on SDP string and the type. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 129 virtual void OnSuccess() = 0; | 137 virtual void OnSuccess() = 0; |
| 130 virtual void OnFailure(const std::string& error) = 0; | 138 virtual void OnFailure(const std::string& error) = 0; |
| 131 | 139 |
| 132 protected: | 140 protected: |
| 133 ~SetSessionDescriptionObserver() {} | 141 ~SetSessionDescriptionObserver() {} |
| 134 }; | 142 }; |
| 135 | 143 |
| 136 } // namespace webrtc | 144 } // namespace webrtc |
| 137 | 145 |
| 138 #endif // WEBRTC_API_JSEP_H_ | 146 #endif // WEBRTC_API_JSEP_H_ |
| OLD | NEW |