#import "RTCPeerConnection+Internal.h"
+#import "RTCDataChannel+Internal.h"
#import "RTCEnumConverter.h"
#import "RTCICECandidate+Internal.h"
#import "RTCICEServer+Internal.h"
#import "RTCMediaConstraints+Internal.h"
#import "RTCMediaStream+Internal.h"
+#import "RTCMediaStreamTrack+Internal.h"
#import "RTCSessionDescription+Internal.h"
-#import "RTCSessionDescriptonDelegate.h"
+#import "RTCSessionDescriptionDelegate.h"
#import "RTCSessionDescription.h"
+#import "RTCStatsDelegate.h"
+#import "RTCStatsReport+Internal.h"
#include "talk/app/webrtc/jsep.h"
class RTCCreateSessionDescriptionObserver
: public CreateSessionDescriptionObserver {
public:
- RTCCreateSessionDescriptionObserver(id<RTCSessionDescriptonDelegate> delegate,
- RTCPeerConnection* peerConnection) {
+ RTCCreateSessionDescriptionObserver(
+ id<RTCSessionDescriptionDelegate> delegate,
+ RTCPeerConnection* peerConnection) {
_delegate = delegate;
_peerConnection = peerConnection;
}
}
private:
- id<RTCSessionDescriptonDelegate> _delegate;
+ id<RTCSessionDescriptionDelegate> _delegate;
RTCPeerConnection* _peerConnection;
};
class RTCSetSessionDescriptionObserver : public SetSessionDescriptionObserver {
public:
- RTCSetSessionDescriptionObserver(id<RTCSessionDescriptonDelegate> delegate,
+ RTCSetSessionDescriptionObserver(id<RTCSessionDescriptionDelegate> delegate,
RTCPeerConnection* peerConnection) {
_delegate = delegate;
_peerConnection = peerConnection;
}
private:
- id<RTCSessionDescriptonDelegate> _delegate;
+ id<RTCSessionDescriptionDelegate> _delegate;
+ RTCPeerConnection* _peerConnection;
+};
+
+class RTCStatsObserver : public StatsObserver {
+ public:
+ RTCStatsObserver(id<RTCStatsDelegate> delegate,
+ RTCPeerConnection* peerConnection) {
+ _delegate = delegate;
+ _peerConnection = peerConnection;
+ }
+
+ virtual void OnComplete(const std::vector<StatsReport>& reports) OVERRIDE {
+ NSMutableArray* stats = [NSMutableArray arrayWithCapacity:reports.size()];
+ std::vector<StatsReport>::const_iterator it = reports.begin();
+ for (; it != reports.end(); ++it) {
+ RTCStatsReport* statsReport =
+ [[RTCStatsReport alloc] initWithStatsReport:*it];
+ [stats addObject:statsReport];
+ }
+ [_delegate peerConnection:_peerConnection didGetStats:stats];
+ }
+
+ private:
+ id<RTCStatsDelegate> _delegate;
RTCPeerConnection* _peerConnection;
};
}
return YES;
}
-- (void)createAnswerWithDelegate:(id<RTCSessionDescriptonDelegate>)delegate
+- (RTCDataChannel*)createDataChannelWithLabel:(NSString*)label
+ config:(RTCDataChannelInit*)config {
+ std::string labelString([label UTF8String]);
+ talk_base::scoped_refptr<webrtc::DataChannelInterface> dataChannel =
+ self.peerConnection->CreateDataChannel(labelString,
+ config.dataChannelInit);
+ return [[RTCDataChannel alloc] initWithDataChannel:dataChannel];
+}
+
+- (void)createAnswerWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
constraints:(RTCMediaConstraints*)constraints {
talk_base::scoped_refptr<webrtc::RTCCreateSessionDescriptionObserver>
observer(new talk_base::RefCountedObject<
self.peerConnection->CreateAnswer(observer, constraints.constraints);
}
-- (void)createOfferWithDelegate:(id<RTCSessionDescriptonDelegate>)delegate
+- (void)createOfferWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
constraints:(RTCMediaConstraints*)constraints {
talk_base::scoped_refptr<webrtc::RTCCreateSessionDescriptionObserver>
observer(new talk_base::RefCountedObject<
}
- (void)setLocalDescriptionWithDelegate:
- (id<RTCSessionDescriptonDelegate>)delegate
+ (id<RTCSessionDescriptionDelegate>)delegate
sessionDescription:(RTCSessionDescription*)sdp {
talk_base::scoped_refptr<webrtc::RTCSetSessionDescriptionObserver> observer(
new talk_base::RefCountedObject<webrtc::RTCSetSessionDescriptionObserver>(
}
- (void)setRemoteDescriptionWithDelegate:
- (id<RTCSessionDescriptonDelegate>)delegate
+ (id<RTCSessionDescriptionDelegate>)delegate
sessionDescription:(RTCSessionDescription*)sdp {
talk_base::scoped_refptr<webrtc::RTCSetSessionDescriptionObserver> observer(
new talk_base::RefCountedObject<webrtc::RTCSetSessionDescriptionObserver>(
self.peerConnection->Close();
}
+- (BOOL)getStatsWithDelegate:(id<RTCStatsDelegate>)delegate
+ mediaStreamTrack:(RTCMediaStreamTrack*)mediaStreamTrack
+ statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel {
+ talk_base::scoped_refptr<webrtc::RTCStatsObserver> observer(
+ new talk_base::RefCountedObject<webrtc::RTCStatsObserver>(delegate,
+ self));
+ webrtc::PeerConnectionInterface::StatsOutputLevel nativeOutputLevel =
+ [RTCEnumConverter convertStatsOutputLevelToNative:statsOutputLevel];
+ return self.peerConnection->GetStats(
+ observer, mediaStreamTrack.mediaTrack, nativeOutputLevel);
+}
+
@end
@implementation RTCPeerConnection (Internal)