Add the URL attribute to cricket::Candiate. (Objc wrapper)

The url of the ICE server is added to the IceCandiate class.
This can be used to tell which server this candidate was gathered from.

BUG=webrtc:7128

Review-Url: https://codereview.webrtc.org/2688943003
Cr-Commit-Position: refs/heads/master@{#16652}
This commit is contained in:
zhihuang 2017-02-16 11:29:39 -08:00 committed by Commit bot
parent dbeeb701a2
commit d7e771da7b
4 changed files with 19 additions and 5 deletions

View File

@ -59,6 +59,10 @@ class IceCandidateInterface {
virtual int sdp_mline_index() const = 0;
// Only for use internally.
virtual const cricket::Candidate& candidate() const = 0;
// The URL of the ICE server which this candidate was gathered from.
// TODO(zhihuang): Remove the default implementation once the subclasses
// implement this method.
virtual std::string server_url() const { return ""; }
// Creates a SDP-ized form of this candidate.
virtual bool ToString(std::string* out) const = 0;
};

View File

@ -43,6 +43,8 @@ class JsepIceCandidate : public IceCandidateInterface {
return candidate_;
}
virtual std::string server_url() const { return candidate_.url(); }
virtual bool ToString(std::string* out) const;
private:

View File

@ -20,6 +20,7 @@
@synthesize sdpMid = _sdpMid;
@synthesize sdpMLineIndex = _sdpMLineIndex;
@synthesize sdp = _sdp;
@synthesize serverUrl = _serverUrl;
- (instancetype)initWithSdp:(NSString *)sdp
sdpMLineIndex:(int)sdpMLineIndex
@ -34,10 +35,11 @@
}
- (NSString *)description {
return [NSString stringWithFormat:@"RTCIceCandidate:\n%@\n%d\n%@",
return [NSString stringWithFormat:@"RTCIceCandidate:\n%@\n%d\n%@\n%@",
_sdpMid,
_sdpMLineIndex,
_sdp];
_sdp,
_serverUrl];
}
#pragma mark - Private
@ -48,9 +50,12 @@
std::string sdp;
candidate->ToString(&sdp);
return [self initWithSdp:[NSString stringForStdString:sdp]
sdpMLineIndex:candidate->sdp_mline_index()
sdpMid:[NSString stringForStdString:candidate->sdp_mid()]];
RTCIceCandidate *rtcCandidate =
[self initWithSdp:[NSString stringForStdString:sdp]
sdpMLineIndex:candidate->sdp_mline_index()
sdpMid:[NSString stringForStdString:candidate->sdp_mid()]];
rtcCandidate->_serverUrl = [NSString stringForStdString:candidate->server_url()];
return rtcCandidate;
}
- (std::unique_ptr<webrtc::IceCandidateInterface>)nativeCandidate {

View File

@ -32,6 +32,9 @@ RTC_EXPORT
/** The SDP string for this candidate. */
@property(nonatomic, readonly) NSString *sdp;
/** The URL of the ICE server which this candidate is gathered from. */
@property(nonatomic, readonly, nullable) NSString *serverUrl;
- (instancetype)init NS_UNAVAILABLE;
/**