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

Commit efc085c

Browse files
author
Codeusa
committed
Add in utility classes, create new threads for the peer factory, create scripts for basic automation of building, add configs for building outside of release x64.
1 parent f468c43 commit efc085c

25 files changed

+539
-62
lines changed

Spitfire.sln

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,40 @@ VisualStudioVersion = 15.0.26730.3
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Spitfire", "Spitfire\Spitfire.vcxproj", "{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpitfireUtils", "SpitfireUtils\SpitfireUtils.csproj", "{129233EA-CFEE-432B-9CEA-9CC7773C9A02}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
1013
Debug|x64 = Debug|x64
1114
Debug|x86 = Debug|x86
15+
Release|Any CPU = Release|Any CPU
1216
Release|x64 = Release|x64
1317
Release|x86 = Release|x86
1418
EndGlobalSection
1519
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|Any CPU.ActiveCfg = Debug|Win32
1621
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|x64.ActiveCfg = Debug|x64
1722
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|x64.Build.0 = Debug|x64
1823
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|x86.ActiveCfg = Debug|Win32
1924
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Debug|x86.Build.0 = Debug|Win32
25+
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|Any CPU.ActiveCfg = Release|Win32
2026
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|x64.ActiveCfg = Release|x64
2127
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|x64.Build.0 = Release|x64
2228
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|x86.ActiveCfg = Release|Win32
2329
{5950B9B8-D486-4B8B-A3A1-53F1738F45ED}.Release|x86.Build.0 = Release|Win32
30+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|x64.ActiveCfg = Debug|Any CPU
33+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|x64.Build.0 = Debug|Any CPU
34+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|x86.ActiveCfg = Debug|Any CPU
35+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Debug|x86.Build.0 = Debug|Any CPU
36+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|x64.ActiveCfg = Release|Any CPU
39+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|x64.Build.0 = Release|Any CPU
40+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|x86.ActiveCfg = Release|Any CPU
41+
{129233EA-CFEE-432B-9CEA-9CC7773C9A02}.Release|x86.Build.0 = Release|Any CPU
2442
EndGlobalSection
2543
GlobalSection(SolutionProperties) = preSolution
2644
HideSolutionNode = FALSE

Spitfire/CreateSessionDescriptionObserver.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ namespace Spitfire {
1717
public:
1818

1919

20-
virtual void OnSuccess(webrtc::SessionDescriptionInterface * desc);
21-
virtual void OnFailure(const std::string & error);
22-
CreateSessionDescriptionObserver(RtcConductor* manager);
20+
void OnSuccess(webrtc::SessionDescriptionInterface * desc) override;
21+
void OnFailure(const std::string & error) override;
22+
explicit CreateSessionDescriptionObserver(RtcConductor* manager);
2323
~CreateSessionDescriptionObserver();
2424

25-
int AddRef() const
25+
int AddRef() const override
2626
{
2727
return 0;
2828
};
29-
int Release() const
29+
int Release() const override
3030
{
3131
return 0;
3232
};

Spitfire/DataChannelObserver.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ void Spitfire::Observers::DataChannelObserver::OnStateChange()
1010
}
1111
}
1212

13+
void Spitfire::Observers::DataChannelObserver::OnBufferedAmountChange(uint64_t previous_amount)
14+
{
15+
if (_manager->onBufferAmountChange != nullptr)
16+
{
17+
_manager->onBufferAmountChange(previous_amount, dataChannel->buffered_amount(), dataChannel->bytes_sent(), dataChannel->bytes_received());
18+
}
19+
}
20+
1321
void Spitfire::Observers::DataChannelObserver::OnMessage(const webrtc::DataBuffer & buffer)
1422
{
1523
if (buffer.binary)

Spitfire/DataChannelObserver.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ namespace Spitfire {
1818
{
1919
public:
2020
// The data channel state have changed.
21-
virtual void OnStateChange();
21+
void OnStateChange() override;
2222

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

2626
// The data channel's buffered_amount has changed.
27-
virtual void OnBufferedAmountChange(uint64_t previous_amount)
28-
{
29-
30-
}
27+
void OnBufferedAmountChange(uint64_t previous_amount) override;
3128

3229
explicit DataChannelObserver(RtcConductor* manager);
3330
~DataChannelObserver();

Spitfire/PeerConnectionObserver.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,41 @@ namespace Spitfire {
1414
public:
1515

1616
// Triggered when the SignalingState changed.
17-
virtual void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state);
17+
void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) override;
1818

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

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

27-
virtual void OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream)
27+
void OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override
2828
{
2929
LOG(INFO) << __FUNCTION__ << " ";
3030
}
3131

3232

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

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

3939
// Called any time the IceConnectionState changes
40-
virtual void OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state);
40+
void OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
4141

4242
// Called any time the IceGatheringState changes
43-
virtual void OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state);
43+
void OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
4444

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

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

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

5353
explicit PeerConnectionObserver(RtcConductor* manager);
5454
~PeerConnectionObserver();

Spitfire/RtcConductor.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ namespace Spitfire
5656
}
5757
serverConfigs.clear();
5858

59-
// network_thread_->Stop();
60-
// worker_thread_->Stop();
61-
// signaling_thread_->Stop();
59+
network_thread_->Stop();
60+
worker_thread_->Stop();
61+
signaling_thread_->Stop();
6262
rtc::Thread::Current()->Stop();
6363

6464

@@ -67,22 +67,20 @@ namespace Spitfire
6767
bool RtcConductor::InitializePeerConnection()
6868
{
6969

70-
rtc::LogMessage::LogTimestamps();
71-
rtc::LogMessage::LogThreads();
72-
rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE);
73-
rtc::LogMessage::SetLogToStderr(true);
7470
rtc::ThreadManager::Instance()->WrapCurrentThread();
7571
RTC_DCHECK(pc_factory_ == nullptr);
7672
RTC_DCHECK(peerObserver->peerConnection == nullptr);
7773

78-
//network_thread_.reset(rtc::Thread::CreateWithSocketServer().release());
79-
//worker_thread_.reset(rtc::Thread::Create().release());
80-
//signaling_thread_.reset(rtc::Thread::Create().release());
81-
//network_thread_->Start();
82-
// worker_thread_->Start();
83-
// signaling_thread_->Start();
74+
network_thread_ = rtc::Thread::CreateWithSocketServer().release();
75+
worker_thread_ = rtc::Thread::Create().release();
76+
signaling_thread_ = rtc::Thread::Create().release();
8477

85-
pc_factory_ = webrtc::CreatePeerConnectionFactory(rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(), FakeAudioCaptureModule::Create(),
78+
79+
network_thread_->Start();
80+
worker_thread_->Start();
81+
signaling_thread_->Start();
82+
83+
pc_factory_ = webrtc::CreatePeerConnectionFactory(network_thread_, worker_thread_, signaling_thread_, FakeAudioCaptureModule::Create(),
8684
new FakeWebRtcVideoEncoderFactory(),
8785
new FakeWebRtcVideoDecoderFactory());
8886

Spitfire/RtcConductor.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ namespace Spitfire
1919
typedef void(__stdcall *OnErrorCallbackNative)();
2020
typedef void(__stdcall *OnSuccessCallbackNative)(const char * type, const char * sdp);
2121
typedef void(__stdcall *OnFailureCallbackNative)(const char * error);
22-
typedef void(__stdcall *OnIceCandidateCallbackNative)(const char * sdp_mid, int sdp_mline_index, const char * sdp);
23-
typedef void(__stdcall *OnRenderCallbackNative)(uint8_t * frame_buffer, uint32_t w, uint32_t h);
22+
typedef void(__stdcall *OnIceCandidateCallbackNative)(const char * sdpMid, int sdpIndex, const char * sdp);
23+
typedef void(__stdcall *OnRenderCallbackNative)(uint8_t * frameBuffer, uint32_t w, uint32_t h);
2424
typedef void(__stdcall *OnDataMessageCallbackNative)(const char * msg);
2525
typedef void(__stdcall *OnDataBinaryMessageCallbackNative)(const uint8_t * msg, uint32_t size);
2626
typedef void(__stdcall *OnIceStateChangeCallbackNative)(webrtc::PeerConnectionInterface::IceConnectionState state);
2727
typedef void(__stdcall *OnDataChannelStateCallbackNative)(webrtc::DataChannelInterface::DataState state);
28-
28+
typedef void(__stdcall *OnBufferAmountCallbackNative)(uint64_t previousAmount, uint64_t currentAmount, uint64_t bytesSent, uint64_t bytesReceived);
2929

3030
class RtcConductor
3131
{
@@ -58,6 +58,7 @@ namespace Spitfire
5858
OnIceStateChangeCallbackNative onIceStateChange;
5959
OnIceCandidateCallbackNative onIceCandidate;
6060
OnDataChannelStateCallbackNative onDataChannelState;
61+
OnBufferAmountCallbackNative onBufferAmountChange;
6162
OnDataMessageCallbackNative onDataMessage;
6263
OnDataBinaryMessageCallbackNative onDataBinaryMessage;
6364

@@ -80,9 +81,9 @@ namespace Spitfire
8081

8182
private:
8283

83-
std::unique_ptr<rtc::Thread> worker_thread_;
84-
std::unique_ptr<rtc::Thread> signaling_thread_;
85-
std::unique_ptr<rtc::Thread> network_thread_;
84+
rtc::Thread* worker_thread_;
85+
rtc::Thread* signaling_thread_;
86+
rtc::Thread* network_thread_;
8687

8788
bool CreatePeerConnection(bool dtls);
8889

Spitfire/RtcUtils.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@
8383
#pragma comment(lib,"common_video.lib")
8484
#pragma comment(lib,"congestion_controller.lib")
8585
#pragma comment(lib,"create_pc_factory.lib")
86-
#pragma comment(lib,"desktop_capture.lib")
87-
#pragma comment(lib,"desktop_capture_differ_sse2.lib")
8886
#pragma comment(lib,"dl.lib")
8987
#pragma comment(lib,"event_log_visualizer_utils.lib")
9088
#pragma comment(lib,"field_trial_default.lib")
@@ -183,12 +181,15 @@ namespace Spitfire
183181
void InitializeSSL()
184182
{
185183
rtc::EnsureWinsockInit();
186-
rtc::InitializeSSL(NULL);
184+
rtc::InitializeSSL(nullptr);
187185
}
188186

189187
void EnableLogging()
190188
{
191-
189+
rtc::LogMessage::LogTimestamps();
190+
rtc::LogMessage::LogThreads();
191+
rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE);
192+
rtc::LogMessage::SetLogToStderr(true);
192193
}
193194

194195
void CleanupSSL()
@@ -199,7 +200,7 @@ namespace Spitfire
199200

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

202-
extern "C" FILE * __cdecl __iob_func(void)
203+
extern "C" FILE * __cdecl __iob_func()
203204
{
204205
return _iob;
205206
}

Spitfire/SetSessionDescriptionObserver.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ namespace Spitfire {
1212
public:
1313

1414
~SetSessionDescriptionObserver();
15-
SetSessionDescriptionObserver(RtcConductor* manager);
15+
explicit SetSessionDescriptionObserver(RtcConductor* manager);
1616

17-
virtual void OnSuccess();
18-
virtual void OnFailure(const std::string& error);
17+
void OnSuccess() override;
18+
void OnFailure(const std::string& error) override;
1919

20-
int AddRef() const
20+
int AddRef() const override
2121
{
2222
return 0;
2323
};
24-
int Release() const
24+
int Release() const override
2525
{
2626
return 0;
2727
};

0 commit comments

Comments
 (0)