mirror of
https://github.com/UltraCoderRU/libwebrtc.git
synced 2026-01-28 03:15:11 +00:00
Write an IPeer interface and replace the include directives
This commit is contained in:
parent
735024c66a
commit
7b70c378ac
7 changed files with 39 additions and 11 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@
|
|||
#define LIBWEBRTC_CREATEOFFEROBSERVER_H
|
||||
|
||||
#include <webrtc/api/jsep.h>
|
||||
#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() {}
|
||||
|
|
|
|||
27
Samples/PeerConnection/IPeer.h
Normal file
27
Samples/PeerConnection/IPeer.h
Normal file
|
|
@ -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
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
SetRemoteSessionDescriptionObserver::SetRemoteSessionDescriptionObserver(
|
||||
Peer *peer, webrtc::SessionDescriptionInterface* desc):
|
||||
IPeer *peer, webrtc::SessionDescriptionInterface* desc):
|
||||
_peer(peer), _desc(desc) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@
|
|||
#define LIBWEBRTC_SETREMOTESESSIONDESCRIPTIONOBSERVER_H
|
||||
|
||||
#include <webrtc/api/jsep.h>
|
||||
#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:
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue