#ifndef CONTENT_RENDERER_MEDIA_RTC_PEER_CONNECTION_HANDLER_H_
#define CONTENT_RENDERER_MEDIA_RTC_PEER_CONNECTION_HANDLER_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "content/common/content_export.h"
#include "content/renderer/media/peer_connection_handler_base.h"
#include "content/renderer/media/webrtc/media_stream_track_metrics.h"
#include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h"
#include "third_party/WebKit/public/platform/WebRTCStatsRequest.h"
#include "third_party/WebKit/public/platform/WebRTCStatsResponse.h"
namespace blink {
class WebFrame;
class WebRTCDataChannelHandler;
}
namespace content {
class PeerConnectionTracker;
class CONTENT_EXPORT LocalRTCStatsResponse
: public NON_EXPORTED_BASE(talk_base::RefCountInterface) {
public:
explicit LocalRTCStatsResponse(const blink::WebRTCStatsResponse& impl)
: impl_(impl) {
}
virtual blink::WebRTCStatsResponse webKitStatsResponse() const;
virtual size_t addReport(blink::WebString type, blink::WebString id,
double timestamp);
virtual void addStatistic(size_t report,
blink::WebString name, blink::WebString value);
protected:
virtual ~LocalRTCStatsResponse() {}
LocalRTCStatsResponse() {}
private:
blink::WebRTCStatsResponse impl_;
};
class CONTENT_EXPORT LocalRTCStatsRequest
: public NON_EXPORTED_BASE(talk_base::RefCountInterface) {
public:
explicit LocalRTCStatsRequest(blink::WebRTCStatsRequest impl);
LocalRTCStatsRequest();
virtual bool hasSelector() const;
virtual blink::WebMediaStreamTrack component() const;
virtual void requestSucceeded(const LocalRTCStatsResponse* response);
virtual scoped_refptr<LocalRTCStatsResponse> createResponse();
protected:
virtual ~LocalRTCStatsRequest();
private:
blink::WebRTCStatsRequest impl_;
talk_base::scoped_refptr<LocalRTCStatsResponse> response_;
};
class CONTENT_EXPORT RTCPeerConnectionHandler
: public PeerConnectionHandlerBase,
NON_EXPORTED_BASE(public blink::WebRTCPeerConnectionHandler) {
public:
RTCPeerConnectionHandler(
blink::WebRTCPeerConnectionHandlerClient* client,
MediaStreamDependencyFactory* dependency_factory);
virtual ~RTCPeerConnectionHandler();
void associateWithFrame(blink::WebFrame* frame);
bool InitializeForTest(
const blink::WebRTCConfiguration& server_configuration,
const blink::WebMediaConstraints& options,
PeerConnectionTracker* peer_connection_tracker);
virtual bool initialize(
const blink::WebRTCConfiguration& server_configuration,
const blink::WebMediaConstraints& options) OVERRIDE;
virtual void createOffer(
const blink::WebRTCSessionDescriptionRequest& request,
const blink::WebMediaConstraints& options) OVERRIDE;
virtual void createAnswer(
const blink::WebRTCSessionDescriptionRequest& request,
const blink::WebMediaConstraints& options) OVERRIDE;
virtual void setLocalDescription(
const blink::WebRTCVoidRequest& request,
const blink::WebRTCSessionDescription& description) OVERRIDE;
virtual void setRemoteDescription(
const blink::WebRTCVoidRequest& request,
const blink::WebRTCSessionDescription& description) OVERRIDE;
virtual blink::WebRTCSessionDescription localDescription()
OVERRIDE;
virtual blink::WebRTCSessionDescription remoteDescription()
OVERRIDE;
virtual bool updateICE(
const blink::WebRTCConfiguration& server_configuration,
const blink::WebMediaConstraints& options) OVERRIDE;
virtual bool addICECandidate(
const blink::WebRTCICECandidate& candidate) OVERRIDE;
virtual bool addICECandidate(
const blink::WebRTCVoidRequest& request,
const blink::WebRTCICECandidate& candidate) OVERRIDE;
virtual void OnaddICECandidateResult(const blink::WebRTCVoidRequest& request,
bool result);
virtual bool addStream(
const blink::WebMediaStream& stream,
const blink::WebMediaConstraints& options) OVERRIDE;
virtual void removeStream(
const blink::WebMediaStream& stream) OVERRIDE;
virtual void getStats(
const blink::WebRTCStatsRequest& request) OVERRIDE;
virtual blink::WebRTCDataChannelHandler* createDataChannel(
const blink::WebString& label,
const blink::WebRTCDataChannelInit& init) OVERRIDE;
virtual blink::WebRTCDTMFSenderHandler* createDTMFSender(
const blink::WebMediaStreamTrack& track) OVERRIDE;
virtual void stop() OVERRIDE;
virtual void OnError() OVERRIDE;
virtual void OnSignalingChange(
webrtc::PeerConnectionInterface::SignalingState new_state) OVERRIDE;
virtual void OnAddStream(webrtc::MediaStreamInterface* stream) OVERRIDE;
virtual void OnRemoveStream(webrtc::MediaStreamInterface* stream) OVERRIDE;
virtual void OnIceCandidate(
const webrtc::IceCandidateInterface* candidate) OVERRIDE;
virtual void OnIceConnectionChange(
webrtc::PeerConnectionInterface::IceConnectionState new_state) OVERRIDE;
virtual void OnIceGatheringChange(
webrtc::PeerConnectionInterface::IceGatheringState new_state) OVERRIDE;
virtual void OnDataChannel(
webrtc::DataChannelInterface* data_channel) OVERRIDE;
virtual void OnRenegotiationNeeded() OVERRIDE;
virtual void getStats(LocalRTCStatsRequest* request);
void GetStats(webrtc::StatsObserver* observer,
webrtc::MediaStreamTrackInterface* track,
webrtc::PeerConnectionInterface::StatsOutputLevel level);
PeerConnectionTracker* peer_connection_tracker();
private:
webrtc::SessionDescriptionInterface* CreateNativeSessionDescription(
const blink::WebRTCSessionDescription& description,
webrtc::SdpParseError* error);
blink::WebRTCPeerConnectionHandlerClient* client_;
blink::WebFrame* frame_;
PeerConnectionTracker* peer_connection_tracker_;
MediaStreamTrackMetrics track_metrics_;
int num_data_channels_created_;
DISALLOW_COPY_AND_ASSIGN(RTCPeerConnectionHandler);
};
}
#endif