Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
Add in utility classes, create new threads for the peer factory, crea…
Browse files Browse the repository at this point in the history
…te scripts for basic automation of building, add configs for building outside of release x64.
  • Loading branch information
Codeusa committed Sep 6, 2017
1 parent f468c43 commit efc085c
Show file tree
Hide file tree
Showing 25 changed files with 539 additions and 62 deletions.
18 changes: 18 additions & 0 deletions Spitfire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,40 @@ VisualStudioVersion = 15.0.26730.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Spitfire", "Spitfire\Spitfire.vcxproj", "{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpitfireUtils", "SpitfireUtils\SpitfireUtils.csproj", "{129233EA-CFEE-432B-9CEA-9CC7773C9A02}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|Any CPU.ActiveCfg = Debug|Win32
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|x64.ActiveCfg = Debug|x64
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|x64.Build.0 = Debug|x64
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|x86.ActiveCfg = Debug|Win32
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|x86.Build.0 = Debug|Win32
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|Any CPU.ActiveCfg = Release|Win32
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|x64.ActiveCfg = Release|x64
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|x64.Build.0 = Release|x64
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|x86.ActiveCfg = Release|Win32
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|x86.Build.0 = Release|Win32
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|x64.ActiveCfg = Debug|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|x64.Build.0 = Debug|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|x86.ActiveCfg = Debug|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|x86.Build.0 = Debug|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|Any CPU.Build.0 = Release|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|x64.ActiveCfg = Release|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|x64.Build.0 = Release|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|x86.ActiveCfg = Release|Any CPU
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 5 additions & 5 deletions Spitfire/CreateSessionDescriptionObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ namespace Spitfire {
public:


virtual void OnSuccess(webrtc::SessionDescriptionInterface * desc);
virtual void OnFailure(const std::string & error);
CreateSessionDescriptionObserver(RtcConductor* manager);
void OnSuccess(webrtc::SessionDescriptionInterface * desc) override;
void OnFailure(const std::string & error) override;
explicit CreateSessionDescriptionObserver(RtcConductor* manager);
~CreateSessionDescriptionObserver();

int AddRef() const
int AddRef() const override
{
return 0;
};
int Release() const
int Release() const override
{
return 0;
};
Expand Down
8 changes: 8 additions & 0 deletions Spitfire/DataChannelObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ void Spitfire::Observers::DataChannelObserver::OnStateChange()
}
}

void Spitfire::Observers::DataChannelObserver::OnBufferedAmountChange(uint64_t previous_amount)
{
if (_manager->onBufferAmountChange != nullptr)
{
_manager->onBufferAmountChange(previous_amount, dataChannel->buffered_amount(), dataChannel->bytes_sent(), dataChannel->bytes_received());
}
}

void Spitfire::Observers::DataChannelObserver::OnMessage(const webrtc::DataBuffer & buffer)
{
if (buffer.binary)
Expand Down
9 changes: 3 additions & 6 deletions Spitfire/DataChannelObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ namespace Spitfire {
{
public:
// The data channel state have changed.
virtual void OnStateChange();
void OnStateChange() override;

// A data buffer was successfully received.
virtual void OnMessage(const webrtc::DataBuffer & buffer);
void OnMessage(const webrtc::DataBuffer & buffer) override;

// The data channel's buffered_amount has changed.
virtual void OnBufferedAmountChange(uint64_t previous_amount)
{

}
void OnBufferedAmountChange(uint64_t previous_amount) override;

explicit DataChannelObserver(RtcConductor* manager);
~DataChannelObserver();
Expand Down
18 changes: 9 additions & 9 deletions Spitfire/PeerConnectionObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,41 @@ namespace Spitfire {
public:

// Triggered when the SignalingState changed.
virtual void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state);
void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) override;

virtual void OnStateChange(StateType state_changed) { /* Obsolete. Ignore. */ }

// Triggered when media is received on a new stream from remote peer.
virtual void OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream)
void OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override
{
LOG(INFO) << __FUNCTION__ << " ";
}

virtual void OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream)
void OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override
{
LOG(INFO) << __FUNCTION__ << " ";
}


// Triggered when a remote peer open a data channel.
virtual void OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> channel);
void OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> channel) override;

// Triggered when renegotiation is needed, for example the ICE has restarted.
virtual void OnRenegotiationNeeded();
void OnRenegotiationNeeded() override;

// Called any time the IceConnectionState changes
virtual void OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state);
void OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) override;

// Called any time the IceGatheringState changes
virtual void OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state);
void OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) override;

// New Ice candidate have been found.
virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate);
void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;

virtual void OnIceComplete() { /* Obsolete. Ignore. */ }

// Called when the ICE connection receiving status changes.
virtual void OnIceConnectionReceivingChange(bool receiving) { /* Not Implemented */ };
void OnIceConnectionReceivingChange(bool receiving) override { /* Not Implemented */ };

explicit PeerConnectionObserver(RtcConductor* manager);
~PeerConnectionObserver();
Expand Down
26 changes: 12 additions & 14 deletions Spitfire/RtcConductor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ namespace Spitfire
}
serverConfigs.clear();

// network_thread_->Stop();
// worker_thread_->Stop();
// signaling_thread_->Stop();
network_thread_->Stop();
worker_thread_->Stop();
signaling_thread_->Stop();
rtc::Thread::Current()->Stop();


Expand All @@ -67,22 +67,20 @@ namespace Spitfire
bool RtcConductor::InitializePeerConnection()
{

rtc::LogMessage::LogTimestamps();
rtc::LogMessage::LogThreads();
rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE);
rtc::LogMessage::SetLogToStderr(true);
rtc::ThreadManager::Instance()->WrapCurrentThread();
RTC_DCHECK(pc_factory_ == nullptr);
RTC_DCHECK(peerObserver->peerConnection == nullptr);

//network_thread_.reset(rtc::Thread::CreateWithSocketServer().release());
//worker_thread_.reset(rtc::Thread::Create().release());
//signaling_thread_.reset(rtc::Thread::Create().release());
//network_thread_->Start();
// worker_thread_->Start();
// signaling_thread_->Start();
network_thread_ = rtc::Thread::CreateWithSocketServer().release();
worker_thread_ = rtc::Thread::Create().release();
signaling_thread_ = rtc::Thread::Create().release();

pc_factory_ = webrtc::CreatePeerConnectionFactory(rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(), FakeAudioCaptureModule::Create(),

network_thread_->Start();
worker_thread_->Start();
signaling_thread_->Start();

pc_factory_ = webrtc::CreatePeerConnectionFactory(network_thread_, worker_thread_, signaling_thread_, FakeAudioCaptureModule::Create(),
new FakeWebRtcVideoEncoderFactory(),
new FakeWebRtcVideoDecoderFactory());

Expand Down
13 changes: 7 additions & 6 deletions Spitfire/RtcConductor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ namespace Spitfire
typedef void(__stdcall *OnErrorCallbackNative)();
typedef void(__stdcall *OnSuccessCallbackNative)(const char * type, const char * sdp);
typedef void(__stdcall *OnFailureCallbackNative)(const char * error);
typedef void(__stdcall *OnIceCandidateCallbackNative)(const char * sdp_mid, int sdp_mline_index, const char * sdp);
typedef void(__stdcall *OnRenderCallbackNative)(uint8_t * frame_buffer, uint32_t w, uint32_t h);
typedef void(__stdcall *OnIceCandidateCallbackNative)(const char * sdpMid, int sdpIndex, const char * sdp);
typedef void(__stdcall *OnRenderCallbackNative)(uint8_t * frameBuffer, uint32_t w, uint32_t h);
typedef void(__stdcall *OnDataMessageCallbackNative)(const char * msg);
typedef void(__stdcall *OnDataBinaryMessageCallbackNative)(const uint8_t * msg, uint32_t size);
typedef void(__stdcall *OnIceStateChangeCallbackNative)(webrtc::PeerConnectionInterface::IceConnectionState state);
typedef void(__stdcall *OnDataChannelStateCallbackNative)(webrtc::DataChannelInterface::DataState state);

typedef void(__stdcall *OnBufferAmountCallbackNative)(uint64_t previousAmount, uint64_t currentAmount, uint64_t bytesSent, uint64_t bytesReceived);

class RtcConductor
{
Expand Down Expand Up @@ -58,6 +58,7 @@ namespace Spitfire
OnIceStateChangeCallbackNative onIceStateChange;
OnIceCandidateCallbackNative onIceCandidate;
OnDataChannelStateCallbackNative onDataChannelState;
OnBufferAmountCallbackNative onBufferAmountChange;
OnDataMessageCallbackNative onDataMessage;
OnDataBinaryMessageCallbackNative onDataBinaryMessage;

Expand All @@ -80,9 +81,9 @@ namespace Spitfire

private:

std::unique_ptr<rtc::Thread> worker_thread_;
std::unique_ptr<rtc::Thread> signaling_thread_;
std::unique_ptr<rtc::Thread> network_thread_;
rtc::Thread* worker_thread_;
rtc::Thread* signaling_thread_;
rtc::Thread* network_thread_;

bool CreatePeerConnection(bool dtls);

Expand Down
11 changes: 6 additions & 5 deletions Spitfire/RtcUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
#pragma comment(lib,"common_video.lib")
#pragma comment(lib,"congestion_controller.lib")
#pragma comment(lib,"create_pc_factory.lib")
#pragma comment(lib,"desktop_capture.lib")
#pragma comment(lib,"desktop_capture_differ_sse2.lib")
#pragma comment(lib,"dl.lib")
#pragma comment(lib,"event_log_visualizer_utils.lib")
#pragma comment(lib,"field_trial_default.lib")
Expand Down Expand Up @@ -183,12 +181,15 @@ namespace Spitfire
void InitializeSSL()
{
rtc::EnsureWinsockInit();
rtc::InitializeSSL(NULL);
rtc::InitializeSSL(nullptr);
}

void EnableLogging()
{

rtc::LogMessage::LogTimestamps();
rtc::LogMessage::LogThreads();
rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE);
rtc::LogMessage::SetLogToStderr(true);
}

void CleanupSSL()
Expand All @@ -199,7 +200,7 @@ namespace Spitfire

FILE _iob[] = { *stdin, *stdout, *stderr };

extern "C" FILE * __cdecl __iob_func(void)
extern "C" FILE * __cdecl __iob_func()
{
return _iob;
}
10 changes: 5 additions & 5 deletions Spitfire/SetSessionDescriptionObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ namespace Spitfire {
public:

~SetSessionDescriptionObserver();
SetSessionDescriptionObserver(RtcConductor* manager);
explicit SetSessionDescriptionObserver(RtcConductor* manager);

virtual void OnSuccess();
virtual void OnFailure(const std::string& error);
void OnSuccess() override;
void OnFailure(const std::string& error) override;

int AddRef() const
int AddRef() const override
{
return 0;
};
int Release() const
int Release() const override
{
return 0;
};
Expand Down
Loading

0 comments on commit efc085c

Please sign in to comment.