diff --git a/Samples/PeerConnection/CreateSessionObserver.cpp b/Samples/PeerConnection/CreateSessionObserver.cpp index cc932dc..2c30693 100644 --- a/Samples/PeerConnection/CreateSessionObserver.cpp +++ b/Samples/PeerConnection/CreateSessionObserver.cpp @@ -4,12 +4,11 @@ #include "CreateSessionObserver.h" #include "Console.h" -#include "Peer.h" #include "SetLocalSessionDescriptionObserver.h" using namespace webrtc; -CreateSessionObserver::CreateSessionObserver(Peer *peer): _peer(peer) { +CreateSessionObserver::CreateSessionObserver(IPeer *peer): _peer(peer) { } void CreateSessionObserver::OnSuccess(SessionDescriptionInterface* desc) { diff --git a/Samples/PeerConnection/CreateSessionObserver.h b/Samples/PeerConnection/CreateSessionObserver.h index 51c9cae..f8a5321 100644 --- a/Samples/PeerConnection/CreateSessionObserver.h +++ b/Samples/PeerConnection/CreateSessionObserver.h @@ -6,17 +6,17 @@ #define LIBWEBRTC_CREATEOFFEROBSERVER_H #include -#include "Peer.h" +#include "IPeer.h" class CreateSessionObserver: public webrtc::CreateSessionDescriptionObserver { public: - CreateSessionObserver(Peer *peer); + CreateSessionObserver(IPeer *peer); void OnSuccess(webrtc::SessionDescriptionInterface* desc); void OnFailure(const std::string& error); private: - Peer *_peer; + IPeer *_peer; protected: ~CreateSessionObserver() {} diff --git a/Samples/PeerConnection/IPeer.h b/Samples/PeerConnection/IPeer.h new file mode 100644 index 0000000..89ad821 --- /dev/null +++ b/Samples/PeerConnection/IPeer.h @@ -0,0 +1,27 @@ +// +// Created by ax on 26/09/16. +// + +#ifndef LIBWEBRTC_IPEER_H +#define LIBWEBRTC_IPEER_H + +#include "webrtc/api/peerconnectioninterface.h" + +class IPeer { +public: + virtual void CreateOffer(webrtc::CreateSessionDescriptionObserver *createSDPObserver) = 0; + virtual void CreateAnswer(webrtc::CreateSessionDescriptionObserver *createSDPObserver) = 0; + + virtual bool AddIceCandidate(webrtc::IceCandidateInterface *candidate) = 0; + + virtual void SetLocalSessionDescription(webrtc::SessionDescriptionInterface* desc, + webrtc::SetSessionDescriptionObserver *setSDPObserver) = 0; + virtual void SetRemoteSessionDescription(webrtc::SessionDescriptionInterface* desc, + webrtc::SetSessionDescriptionObserver *setSDPObserver) = 0; + + virtual bool IsConnected() = 0; + virtual void SetDataChannel(webrtc::DataChannelInterface *dataChannel) = 0; + virtual void SendMessage(const std::string& message) = 0; +}; + +#endif //LIBWEBRTC_IPEER_H diff --git a/Samples/PeerConnection/Peer.h b/Samples/PeerConnection/Peer.h index 73d96dd..1225069 100644 --- a/Samples/PeerConnection/Peer.h +++ b/Samples/PeerConnection/Peer.h @@ -9,7 +9,9 @@ #include "webrtc/api/test/fakeconstraints.h" #include "webrtc/api/peerconnectioninterface.h" -class Peer : public webrtc::PeerConnectionObserver { +#include "IPeer.h" + +class Peer: public IPeer { public: Peer(); ~Peer(); diff --git a/Samples/PeerConnection/SetRemoteSessionDescriptionObserver.cpp b/Samples/PeerConnection/SetRemoteSessionDescriptionObserver.cpp index 2635b42..0324a29 100644 --- a/Samples/PeerConnection/SetRemoteSessionDescriptionObserver.cpp +++ b/Samples/PeerConnection/SetRemoteSessionDescriptionObserver.cpp @@ -8,7 +8,7 @@ SetRemoteSessionDescriptionObserver::SetRemoteSessionDescriptionObserver( - Peer *peer, webrtc::SessionDescriptionInterface* desc): + IPeer *peer, webrtc::SessionDescriptionInterface* desc): _peer(peer), _desc(desc) { } diff --git a/Samples/PeerConnection/SetRemoteSessionDescriptionObserver.h b/Samples/PeerConnection/SetRemoteSessionDescriptionObserver.h index 3530030..0102086 100644 --- a/Samples/PeerConnection/SetRemoteSessionDescriptionObserver.h +++ b/Samples/PeerConnection/SetRemoteSessionDescriptionObserver.h @@ -6,18 +6,18 @@ #define LIBWEBRTC_SETREMOTESESSIONDESCRIPTIONOBSERVER_H #include -#include "Peer.h" +#include "IPeer.h" class SetRemoteSessionDescriptionObserver: public webrtc::SetSessionDescriptionObserver { public: - SetRemoteSessionDescriptionObserver(Peer *peer, webrtc::SessionDescriptionInterface* desc); + SetRemoteSessionDescriptionObserver(IPeer *peer, webrtc::SessionDescriptionInterface* desc); void OnSuccess(); void OnFailure(const std::string& error); private: - Peer *_peer; + IPeer *_peer; webrtc::SessionDescriptionInterface* _desc; protected: diff --git a/Samples/PeerConnection/main.cpp b/Samples/PeerConnection/main.cpp index c99b3bb..648c493 100644 --- a/Samples/PeerConnection/main.cpp +++ b/Samples/PeerConnection/main.cpp @@ -12,7 +12,7 @@ enum { STATE_CHAT }; -static Peer *peer = NULL; +static IPeer *peer = NULL; static int state = STATE_EXCHANGE; void HandleSDP(Json::Value object) {