mirror of
https://github.com/UltraCoderRU/libwebrtc.git
synced 2026-01-28 11:15:13 +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 "CreateSessionObserver.h"
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
#include "Peer.h"
|
|
||||||
#include "SetLocalSessionDescriptionObserver.h"
|
#include "SetLocalSessionDescriptionObserver.h"
|
||||||
|
|
||||||
using namespace webrtc;
|
using namespace webrtc;
|
||||||
|
|
||||||
CreateSessionObserver::CreateSessionObserver(Peer *peer): _peer(peer) {
|
CreateSessionObserver::CreateSessionObserver(IPeer *peer): _peer(peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateSessionObserver::OnSuccess(SessionDescriptionInterface* desc) {
|
void CreateSessionObserver::OnSuccess(SessionDescriptionInterface* desc) {
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,17 @@
|
||||||
#define LIBWEBRTC_CREATEOFFEROBSERVER_H
|
#define LIBWEBRTC_CREATEOFFEROBSERVER_H
|
||||||
|
|
||||||
#include <webrtc/api/jsep.h>
|
#include <webrtc/api/jsep.h>
|
||||||
#include "Peer.h"
|
#include "IPeer.h"
|
||||||
|
|
||||||
class CreateSessionObserver: public webrtc::CreateSessionDescriptionObserver {
|
class CreateSessionObserver: public webrtc::CreateSessionDescriptionObserver {
|
||||||
public:
|
public:
|
||||||
CreateSessionObserver(Peer *peer);
|
CreateSessionObserver(IPeer *peer);
|
||||||
|
|
||||||
void OnSuccess(webrtc::SessionDescriptionInterface* desc);
|
void OnSuccess(webrtc::SessionDescriptionInterface* desc);
|
||||||
void OnFailure(const std::string& error);
|
void OnFailure(const std::string& error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Peer *_peer;
|
IPeer *_peer;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~CreateSessionObserver() {}
|
~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/test/fakeconstraints.h"
|
||||||
#include "webrtc/api/peerconnectioninterface.h"
|
#include "webrtc/api/peerconnectioninterface.h"
|
||||||
|
|
||||||
class Peer : public webrtc::PeerConnectionObserver {
|
#include "IPeer.h"
|
||||||
|
|
||||||
|
class Peer: public IPeer {
|
||||||
public:
|
public:
|
||||||
Peer();
|
Peer();
|
||||||
~Peer();
|
~Peer();
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
|
|
||||||
SetRemoteSessionDescriptionObserver::SetRemoteSessionDescriptionObserver(
|
SetRemoteSessionDescriptionObserver::SetRemoteSessionDescriptionObserver(
|
||||||
Peer *peer, webrtc::SessionDescriptionInterface* desc):
|
IPeer *peer, webrtc::SessionDescriptionInterface* desc):
|
||||||
_peer(peer), _desc(desc) {
|
_peer(peer), _desc(desc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,18 @@
|
||||||
#define LIBWEBRTC_SETREMOTESESSIONDESCRIPTIONOBSERVER_H
|
#define LIBWEBRTC_SETREMOTESESSIONDESCRIPTIONOBSERVER_H
|
||||||
|
|
||||||
#include <webrtc/api/jsep.h>
|
#include <webrtc/api/jsep.h>
|
||||||
#include "Peer.h"
|
#include "IPeer.h"
|
||||||
|
|
||||||
class SetRemoteSessionDescriptionObserver:
|
class SetRemoteSessionDescriptionObserver:
|
||||||
public webrtc::SetSessionDescriptionObserver {
|
public webrtc::SetSessionDescriptionObserver {
|
||||||
public:
|
public:
|
||||||
SetRemoteSessionDescriptionObserver(Peer *peer, webrtc::SessionDescriptionInterface* desc);
|
SetRemoteSessionDescriptionObserver(IPeer *peer, webrtc::SessionDescriptionInterface* desc);
|
||||||
|
|
||||||
void OnSuccess();
|
void OnSuccess();
|
||||||
void OnFailure(const std::string& error);
|
void OnFailure(const std::string& error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Peer *_peer;
|
IPeer *_peer;
|
||||||
webrtc::SessionDescriptionInterface* _desc;
|
webrtc::SessionDescriptionInterface* _desc;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ enum {
|
||||||
STATE_CHAT
|
STATE_CHAT
|
||||||
};
|
};
|
||||||
|
|
||||||
static Peer *peer = NULL;
|
static IPeer *peer = NULL;
|
||||||
static int state = STATE_EXCHANGE;
|
static int state = STATE_EXCHANGE;
|
||||||
|
|
||||||
void HandleSDP(Json::Value object) {
|
void HandleSDP(Json::Value object) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue