mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-31 23:53:21 +00:00
First commit of MeshAgent for MeshCentral
This commit is contained in:
6
webrtc/C# Sample/App.config
Normal file
6
webrtc/C# Sample/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
177
webrtc/C# Sample/DebugForm.Designer.cs
generated
Normal file
177
webrtc/C# Sample/DebugForm.Designer.cs
generated
Normal file
@@ -0,0 +1,177 @@
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
partial class DebugForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.sendRateLabel = new System.Windows.Forms.Label();
|
||||
this.retryLabel = new System.Windows.Forms.Label();
|
||||
this.normalRetryLabel = new System.Windows.Forms.Label();
|
||||
this.rCreditsLabel = new System.Windows.Forms.Label();
|
||||
this.windowSizeLabel = new System.Windows.Forms.Label();
|
||||
this.fastRecoveryLabel = new System.Windows.Forms.Label();
|
||||
this.t3Label = new System.Windows.Forms.Label();
|
||||
this.rttLabel = new System.Windows.Forms.Label();
|
||||
this.tsnLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// sendRateLabel
|
||||
//
|
||||
this.sendRateLabel.AutoSize = true;
|
||||
this.sendRateLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 19.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.sendRateLabel.Location = new System.Drawing.Point(27, 9);
|
||||
this.sendRateLabel.Name = "sendRateLabel";
|
||||
this.sendRateLabel.Size = new System.Drawing.Size(190, 38);
|
||||
this.sendRateLabel.TabIndex = 0;
|
||||
this.sendRateLabel.Text = "Send Rate:";
|
||||
this.sendRateLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// retryLabel
|
||||
//
|
||||
this.retryLabel.AutoSize = true;
|
||||
this.retryLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 19.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.retryLabel.ForeColor = System.Drawing.Color.DarkRed;
|
||||
this.retryLabel.Location = new System.Drawing.Point(27, 47);
|
||||
this.retryLabel.Name = "retryLabel";
|
||||
this.retryLabel.Size = new System.Drawing.Size(272, 38);
|
||||
this.retryLabel.TabIndex = 1;
|
||||
this.retryLabel.Text = "Fast Retry Rate:";
|
||||
this.retryLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// normalRetryLabel
|
||||
//
|
||||
this.normalRetryLabel.AutoSize = true;
|
||||
this.normalRetryLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 19.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.normalRetryLabel.Location = new System.Drawing.Point(27, 85);
|
||||
this.normalRetryLabel.Name = "normalRetryLabel";
|
||||
this.normalRetryLabel.Size = new System.Drawing.Size(315, 38);
|
||||
this.normalRetryLabel.TabIndex = 2;
|
||||
this.normalRetryLabel.Text = "Normal Retry Rate:";
|
||||
this.normalRetryLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// rCreditsLabel
|
||||
//
|
||||
this.rCreditsLabel.AutoSize = true;
|
||||
this.rCreditsLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.rCreditsLabel.Location = new System.Drawing.Point(29, 429);
|
||||
this.rCreditsLabel.Name = "rCreditsLabel";
|
||||
this.rCreditsLabel.Size = new System.Drawing.Size(215, 29);
|
||||
this.rCreditsLabel.TabIndex = 3;
|
||||
this.rCreditsLabel.Text = "Receiver Credits:";
|
||||
this.rCreditsLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// windowSizeLabel
|
||||
//
|
||||
this.windowSizeLabel.AutoSize = true;
|
||||
this.windowSizeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.windowSizeLabel.Location = new System.Drawing.Point(29, 400);
|
||||
this.windowSizeLabel.Name = "windowSizeLabel";
|
||||
this.windowSizeLabel.Size = new System.Drawing.Size(311, 29);
|
||||
this.windowSizeLabel.TabIndex = 4;
|
||||
this.windowSizeLabel.Text = "Congestion Window Size:";
|
||||
this.windowSizeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// fastRecoveryLabel
|
||||
//
|
||||
this.fastRecoveryLabel.AutoSize = true;
|
||||
this.fastRecoveryLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.fastRecoveryLabel.Location = new System.Drawing.Point(29, 371);
|
||||
this.fastRecoveryLabel.Name = "fastRecoveryLabel";
|
||||
this.fastRecoveryLabel.Size = new System.Drawing.Size(259, 29);
|
||||
this.fastRecoveryLabel.TabIndex = 5;
|
||||
this.fastRecoveryLabel.Text = "Fast Recovery Mode:";
|
||||
this.fastRecoveryLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// t3Label
|
||||
//
|
||||
this.t3Label.AutoSize = true;
|
||||
this.t3Label.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.t3Label.Location = new System.Drawing.Point(29, 342);
|
||||
this.t3Label.Name = "t3Label";
|
||||
this.t3Label.Size = new System.Drawing.Size(189, 29);
|
||||
this.t3Label.TabIndex = 6;
|
||||
this.t3Label.Text = "T3-RTX Timer:";
|
||||
this.t3Label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// rttLabel
|
||||
//
|
||||
this.rttLabel.AutoSize = true;
|
||||
this.rttLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.rttLabel.Location = new System.Drawing.Point(29, 313);
|
||||
this.rttLabel.Name = "rttLabel";
|
||||
this.rttLabel.Size = new System.Drawing.Size(218, 29);
|
||||
this.rttLabel.TabIndex = 7;
|
||||
this.rttLabel.Text = "Round Trip Time:";
|
||||
this.rttLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// tsnLabel
|
||||
//
|
||||
this.tsnLabel.AutoSize = true;
|
||||
this.tsnLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.tsnLabel.Location = new System.Drawing.Point(29, 284);
|
||||
this.tsnLabel.Name = "tsnLabel";
|
||||
this.tsnLabel.Size = new System.Drawing.Size(142, 29);
|
||||
this.tsnLabel.TabIndex = 8;
|
||||
this.tsnLabel.Text = "TSN Floor:";
|
||||
this.tsnLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// DebugForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(746, 467);
|
||||
this.Controls.Add(this.tsnLabel);
|
||||
this.Controls.Add(this.rttLabel);
|
||||
this.Controls.Add(this.t3Label);
|
||||
this.Controls.Add(this.fastRecoveryLabel);
|
||||
this.Controls.Add(this.windowSizeLabel);
|
||||
this.Controls.Add(this.rCreditsLabel);
|
||||
this.Controls.Add(this.normalRetryLabel);
|
||||
this.Controls.Add(this.retryLabel);
|
||||
this.Controls.Add(this.sendRateLabel);
|
||||
this.Name = "DebugForm";
|
||||
this.Text = "DebugForm";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DebugForm_FormClosing);
|
||||
this.Load += new System.EventHandler(this.DebugForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label sendRateLabel;
|
||||
private System.Windows.Forms.Label retryLabel;
|
||||
private System.Windows.Forms.Label normalRetryLabel;
|
||||
private System.Windows.Forms.Label rCreditsLabel;
|
||||
private System.Windows.Forms.Label windowSizeLabel;
|
||||
private System.Windows.Forms.Label fastRecoveryLabel;
|
||||
private System.Windows.Forms.Label t3Label;
|
||||
private System.Windows.Forms.Label rttLabel;
|
||||
private System.Windows.Forms.Label tsnLabel;
|
||||
}
|
||||
}
|
||||
193
webrtc/C# Sample/DebugForm.cs
Normal file
193
webrtc/C# Sample/DebugForm.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using OpenSource.WebRTC;
|
||||
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
public partial class DebugForm : Form
|
||||
{
|
||||
private DateTime startTime = DateTime.Now;
|
||||
|
||||
DateTime FastEnterTime;
|
||||
int FastResentPackets = 0;
|
||||
int NormalResentPackets = 0;
|
||||
int sackpackets = 0;
|
||||
int t3rtxcounter = 0;
|
||||
int tsncounter = 0;
|
||||
|
||||
int totalBytes = 0;
|
||||
bool closing = false;
|
||||
private Random r = new Random();
|
||||
private WebRTCConnection mConnection;
|
||||
private WebRTCDataChannel mDataChannel;
|
||||
public DebugForm(WebRTCConnection connection)
|
||||
{
|
||||
InitializeComponent();
|
||||
Text = "WebRTC Debug View - NOT Connected";
|
||||
mConnection = connection;
|
||||
}
|
||||
|
||||
private async void DebugForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
mDataChannel = await mConnection.CreateDataChannel("DebugChannel");
|
||||
//mConnection._Debug_SetLossPercentage(5);
|
||||
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
if (mDataChannel == null)
|
||||
{
|
||||
Text = "WebRTC Debug View - Error";
|
||||
return;
|
||||
}
|
||||
|
||||
Text = "WebRTC Debug View - Connected";
|
||||
//mConnection.DebugEvents_OnReceiverCredits += mConnection_DebugEvents_OnReceiverCredits;
|
||||
mConnection.DebugEvents_OnSendFastRetry += mConnection_DebugEvents_OnSendFastRetry;
|
||||
mConnection.DebugEvents_OnSendRetry += mConnection_DebugEvents_OnSendRetry;
|
||||
mConnection.DebugEvents_OnHold += mConnection_DebugEvents_OnHold;
|
||||
mConnection.OnConnectionSendOk += mConnection_OnConnectionSendOk;
|
||||
mConnection.DebugEvents_OnCongestionWindowSizeChanged += mConnection_DebugEvents_OnCongestionWindowSizeChanged;
|
||||
|
||||
mConnection.DebugEvents_OnFastRecovery += mConnection_DebugEvents_OnFastRecovery;
|
||||
//mConnection.DebugEvents_OnRTTCalculated += mConnection_DebugEvents_OnRTTCalculated;
|
||||
mConnection.DebugEvents_OnT3RTX += mConnection_DebugEvents_OnT3RTX;
|
||||
//mConnection.DebugEvents_OnTSNFloorNotRaised += mConnection_DebugEvents_OnTSNFloorNotRaised;
|
||||
|
||||
//mConnection.DebugEvents_OnSACKReceived += mConnection_DebugEvents_OnSACKReceived;
|
||||
|
||||
StartSendingJunk();
|
||||
}
|
||||
|
||||
async void mConnection_DebugEvents_OnTSNFloorNotRaised(WebRTCConnection sender, int resendCounter)
|
||||
{
|
||||
tsncounter++;
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
|
||||
tsnLabel.Text = "(" + tsncounter.ToString() + ") Resend Count: " + resendCounter.ToString();
|
||||
}
|
||||
|
||||
async void mConnection_DebugEvents_OnT3RTX(WebRTCConnection sender, bool IsExpired, bool IsEnabled, int RTOValue)
|
||||
{
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
if (IsExpired) { t3Label.ForeColor = Color.DarkRed; ++t3rtxcounter; }
|
||||
if (!IsExpired && !IsEnabled) t3Label.ForeColor = Color.Black;
|
||||
if (IsEnabled) t3Label.ForeColor = Color.DarkGreen;
|
||||
|
||||
t3Label.Text = "T3-RTX Timer [" + t3rtxcounter.ToString() + "]: " + (IsEnabled ? ("[ENABLED] " + RTOValue.ToString() + " ms") : "[DISABLED]");
|
||||
}
|
||||
|
||||
async void mConnection_DebugEvents_OnRTTCalculated(WebRTCConnection sender, int SRTT)
|
||||
{
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
rttLabel.Text = "Round Trip Time: " + SRTT.ToString() + "ms calculated @" + DateTime.Now.ToLongTimeString();
|
||||
}
|
||||
|
||||
async void mConnection_DebugEvents_OnFastRecovery(WebRTCConnection sender, bool EnterFastRecovery)
|
||||
{
|
||||
if (EnterFastRecovery) { FastEnterTime = DateTime.Now; FastResentPackets = 0; }
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
retryLabel.ForeColor = EnterFastRecovery ? Color.DarkGreen : Color.DarkRed;
|
||||
fastRecoveryLabel.Text = "Fast Recovery Mode: " + (EnterFastRecovery ? "[ENTERED]" : "[EXITED]");
|
||||
}
|
||||
|
||||
async void mConnection_DebugEvents_OnSACKReceived(WebRTCConnection sender, uint TSN)
|
||||
{
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
rCreditsLabel.Text = "SACKs received: " + (++sackpackets).ToString();
|
||||
}
|
||||
|
||||
async void mConnection_DebugEvents_OnCongestionWindowSizeChanged(WebRTCConnection sender, int windowSize)
|
||||
{
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
this.windowSizeLabel.Text = "Congestion Window Size: " + windowSize.ToString() + " bytes";
|
||||
}
|
||||
|
||||
void mConnection_DebugEvents_OnHold(WebRTCConnection sender, int holdCount)
|
||||
{
|
||||
}
|
||||
|
||||
async void mConnection_DebugEvents_OnSendRetry(WebRTCConnection sender, int retryCount)
|
||||
{
|
||||
NormalResentPackets += retryCount;
|
||||
int rate = (int)(((double)NormalResentPackets) / (DateTime.Now - startTime).TotalSeconds) / 1024;
|
||||
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
normalRetryLabel.Text = "Normal Retry Rate: " + rate.ToString() + " KB/second";
|
||||
|
||||
}
|
||||
|
||||
async void mConnection_DebugEvents_OnSendFastRetry(WebRTCConnection sender, int retryCount)
|
||||
{
|
||||
FastResentPackets += retryCount;
|
||||
int rate = (int)(((double)FastResentPackets) / (DateTime.Now - FastEnterTime).TotalSeconds) / 1024;
|
||||
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
retryLabel.Text = "Fast Retry Rate: " + rate.ToString() + " KB/second";
|
||||
}
|
||||
|
||||
void mConnection_OnConnectionSendOk(WebRTCConnection sender)
|
||||
{
|
||||
StartSendingJunk();
|
||||
}
|
||||
|
||||
async void mConnection_DebugEvents_OnReceiverCredits(WebRTCConnection sender, int receiverCredits)
|
||||
{
|
||||
if (receiverCredits < 0)
|
||||
{
|
||||
int x = 5;
|
||||
}
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
rCreditsLabel.Text = "Receiver Credits: " + receiverCredits.ToString();
|
||||
}
|
||||
|
||||
void StartSendingJunk()
|
||||
{
|
||||
Task.Run((Action)(async () =>
|
||||
{
|
||||
int count = 0;
|
||||
byte[] buffer = new byte[4096];
|
||||
WebRTCDataChannel.SendStatus status;
|
||||
|
||||
if (totalBytes == 0 || (DateTime.Now - startTime).TotalSeconds > 10)
|
||||
{
|
||||
startTime = DateTime.Now;
|
||||
totalBytes = 0;
|
||||
NormalResentPackets = 0;
|
||||
}
|
||||
|
||||
if (closing) { return; }
|
||||
|
||||
do
|
||||
{
|
||||
r.NextBytes(buffer);
|
||||
status = mDataChannel.Send(buffer);
|
||||
count += buffer.Length;
|
||||
} while (status == WebRTCDataChannel.SendStatus.ALL_DATA_SENT);
|
||||
|
||||
|
||||
|
||||
totalBytes += count;
|
||||
|
||||
count = (int)(((double)totalBytes) / (DateTime.Now - startTime).TotalSeconds)/1024;
|
||||
if (!closing)
|
||||
{
|
||||
await this.ContextSwitchToMessagePumpAsync();
|
||||
sendRateLabel.Text = "Send Rate: " + count.ToString() + " KBytes / second";
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void DebugForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
closing = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
120
webrtc/C# Sample/DebugForm.resx
Normal file
120
webrtc/C# Sample/DebugForm.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
13
webrtc/C# Sample/FormExtensions.cs
Normal file
13
webrtc/C# Sample/FormExtensions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenSource.WebRTC;
|
||||
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
public static class FormExtensions
|
||||
{
|
||||
}
|
||||
}
|
||||
320
webrtc/C# Sample/MainForm.Designer.cs
generated
Normal file
320
webrtc/C# Sample/MainForm.Designer.cs
generated
Normal file
@@ -0,0 +1,320 @@
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
this.launchBrowserButton = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.serverLinkLabel_passive = new System.Windows.Forms.LinkLabel();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.stunSettingsButton = new System.Windows.Forms.Button();
|
||||
this.stunLabel = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.serverStatusLabel = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.serverLinkLabel = new System.Windows.Forms.LinkLabel();
|
||||
this.closeButton = new System.Windows.Forms.Button();
|
||||
this.infoLinkLabel = new System.Windows.Forms.LinkLabel();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.sTUNServersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// launchBrowserButton
|
||||
//
|
||||
this.launchBrowserButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.launchBrowserButton.Location = new System.Drawing.Point(423, 170);
|
||||
this.launchBrowserButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.launchBrowserButton.Name = "launchBrowserButton";
|
||||
this.launchBrowserButton.Size = new System.Drawing.Size(131, 41);
|
||||
this.launchBrowserButton.TabIndex = 2;
|
||||
this.launchBrowserButton.Text = "New Instance";
|
||||
this.launchBrowserButton.UseVisualStyleBackColor = true;
|
||||
this.launchBrowserButton.Click += new System.EventHandler(this.browserButton_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(11, 49);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(145, 17);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Browser-Initiated URL";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox1.Controls.Add(this.serverLinkLabel_passive);
|
||||
this.groupBox1.Controls.Add(this.label4);
|
||||
this.groupBox1.Controls.Add(this.stunSettingsButton);
|
||||
this.groupBox1.Controls.Add(this.stunLabel);
|
||||
this.groupBox1.Controls.Add(this.label3);
|
||||
this.groupBox1.Controls.Add(this.serverStatusLabel);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.serverLinkLabel);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(109, 33);
|
||||
this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
|
||||
this.groupBox1.Size = new System.Drawing.Size(444, 121);
|
||||
this.groupBox1.TabIndex = 4;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "State";
|
||||
//
|
||||
// serverLinkLabel_passive
|
||||
//
|
||||
this.serverLinkLabel_passive.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.serverLinkLabel_passive.Location = new System.Drawing.Point(175, 70);
|
||||
this.serverLinkLabel_passive.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.serverLinkLabel_passive.Name = "serverLinkLabel_passive";
|
||||
this.serverLinkLabel_passive.Size = new System.Drawing.Size(258, 17);
|
||||
this.serverLinkLabel_passive.TabIndex = 16;
|
||||
this.serverLinkLabel_passive.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
this.serverLinkLabel_passive.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.serverLinkLabel_passive_LinkClicked);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(11, 70);
|
||||
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(163, 17);
|
||||
this.label4.TabIndex = 15;
|
||||
this.label4.Text = "Application-Initiated URL";
|
||||
//
|
||||
// stunSettingsButton
|
||||
//
|
||||
this.stunSettingsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stunSettingsButton.Location = new System.Drawing.Point(403, 92);
|
||||
this.stunSettingsButton.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.stunSettingsButton.Name = "stunSettingsButton";
|
||||
this.stunSettingsButton.Size = new System.Drawing.Size(31, 16);
|
||||
this.stunSettingsButton.TabIndex = 14;
|
||||
this.stunSettingsButton.Text = "*";
|
||||
this.stunSettingsButton.UseVisualStyleBackColor = true;
|
||||
this.stunSettingsButton.Click += new System.EventHandler(this.stunSettingsButton_Click);
|
||||
//
|
||||
// stunLabel
|
||||
//
|
||||
this.stunLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stunLabel.Location = new System.Drawing.Point(137, 92);
|
||||
this.stunLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.stunLabel.Name = "stunLabel";
|
||||
this.stunLabel.Size = new System.Drawing.Size(257, 16);
|
||||
this.stunLabel.TabIndex = 13;
|
||||
this.stunLabel.Text = "Disabled";
|
||||
this.stunLabel.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(11, 92);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(97, 17);
|
||||
this.label3.TabIndex = 8;
|
||||
this.label3.Text = "STUN servers";
|
||||
//
|
||||
// serverStatusLabel
|
||||
//
|
||||
this.serverStatusLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.serverStatusLabel.Location = new System.Drawing.Point(137, 25);
|
||||
this.serverStatusLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.serverStatusLabel.Name = "serverStatusLabel";
|
||||
this.serverStatusLabel.Size = new System.Drawing.Size(296, 16);
|
||||
this.serverStatusLabel.TabIndex = 7;
|
||||
this.serverStatusLabel.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(11, 25);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(94, 17);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Server Status";
|
||||
//
|
||||
// serverLinkLabel
|
||||
//
|
||||
this.serverLinkLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.serverLinkLabel.Location = new System.Drawing.Point(172, 49);
|
||||
this.serverLinkLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.serverLinkLabel.Name = "serverLinkLabel";
|
||||
this.serverLinkLabel.Size = new System.Drawing.Size(261, 17);
|
||||
this.serverLinkLabel.TabIndex = 4;
|
||||
this.serverLinkLabel.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
this.serverLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.serverLinkLabel_LinkClicked);
|
||||
//
|
||||
// closeButton
|
||||
//
|
||||
this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.closeButton.Location = new System.Drawing.Point(287, 170);
|
||||
this.closeButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.closeButton.Name = "closeButton";
|
||||
this.closeButton.Size = new System.Drawing.Size(131, 41);
|
||||
this.closeButton.TabIndex = 6;
|
||||
this.closeButton.Text = "Close";
|
||||
this.closeButton.UseVisualStyleBackColor = true;
|
||||
this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
|
||||
//
|
||||
// infoLinkLabel
|
||||
//
|
||||
this.infoLinkLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.infoLinkLabel.Location = new System.Drawing.Point(9, 188);
|
||||
this.infoLinkLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.infoLinkLabel.Name = "infoLinkLabel";
|
||||
this.infoLinkLabel.Size = new System.Drawing.Size(204, 16);
|
||||
this.infoLinkLabel.TabIndex = 9;
|
||||
this.infoLinkLabel.TabStop = true;
|
||||
this.infoLinkLabel.Text = "info.meshcentral.com";
|
||||
this.infoLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.infoLinkLabel_LinkClicked);
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.settingsToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Padding = new System.Windows.Forms.Padding(8, 2, 0, 2);
|
||||
this.menuStrip1.Size = new System.Drawing.Size(569, 36);
|
||||
this.menuStrip1.TabIndex = 12;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.closeToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 32);
|
||||
this.fileToolStripMenuItem.Text = "&File";
|
||||
//
|
||||
// closeToolStripMenuItem
|
||||
//
|
||||
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
|
||||
this.closeToolStripMenuItem.Size = new System.Drawing.Size(152, 32);
|
||||
this.closeToolStripMenuItem.Text = "&Close";
|
||||
//
|
||||
// settingsToolStripMenuItem
|
||||
//
|
||||
this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.sTUNServersToolStripMenuItem});
|
||||
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
||||
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(95, 32);
|
||||
this.settingsToolStripMenuItem.Text = "&Settings";
|
||||
//
|
||||
// sTUNServersToolStripMenuItem
|
||||
//
|
||||
this.sTUNServersToolStripMenuItem.Name = "sTUNServersToolStripMenuItem";
|
||||
this.sTUNServersToolStripMenuItem.Size = new System.Drawing.Size(211, 32);
|
||||
this.sTUNServersToolStripMenuItem.Text = "STUN servers...";
|
||||
this.sTUNServersToolStripMenuItem.Click += new System.EventHandler(this.stunSettingsButton_Click);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Image = global::WebRTC_Sample.Properties.Resources.WebRTCSample;
|
||||
this.pictureBox1.Location = new System.Drawing.Point(16, 33);
|
||||
this.pictureBox1.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(85, 79);
|
||||
this.pictureBox1.TabIndex = 5;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AcceptButton = this.launchBrowserButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.closeButton;
|
||||
this.ClientSize = new System.Drawing.Size(569, 215);
|
||||
this.Controls.Add(this.infoLinkLabel);
|
||||
this.Controls.Add(this.closeButton);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.launchBrowserButton);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "MainForm";
|
||||
this.Text = "Meshcentral - WebRTC Sample Server";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button launchBrowserButton;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label serverStatusLabel;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.LinkLabel serverLinkLabel;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Button closeButton;
|
||||
private System.Windows.Forms.LinkLabel infoLinkLabel;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem sTUNServersToolStripMenuItem;
|
||||
private System.Windows.Forms.Label stunLabel;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button stunSettingsButton;
|
||||
private System.Windows.Forms.LinkLabel serverLinkLabel_passive;
|
||||
private System.Windows.Forms.Label label4;
|
||||
}
|
||||
}
|
||||
|
||||
232
webrtc/C# Sample/MainForm.cs
Normal file
232
webrtc/C# Sample/MainForm.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
Copyright 2014 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using OpenSource.WebRTC;
|
||||
using System.Net;
|
||||
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private System.IO.Pipes.PipeStream mPipe;
|
||||
private byte[] pipeBuffer = null;
|
||||
|
||||
|
||||
private SimpleRendezvousServer mServer;
|
||||
private Dictionary<string, RendezvousData> eventTable = new Dictionary<string, RendezvousData>();
|
||||
private string htmlpage = null, passiveHtmlpage = null;
|
||||
private Dictionary<string, SessionForm> userForms = new Dictionary<string, SessionForm>();
|
||||
private bool StunServersInUse = false;
|
||||
private string[] StunServers = { "stun.ekiga.net", "stun.ideasip.com", "stun.schlund.de", "stunserver.org", "stun.softjoys.com", "stun.voiparound.com", "stun.voipbuster.com", "stun.voipstunt.com", "stun.voxgratia.org" };
|
||||
|
||||
public MainForm(string[] args)
|
||||
{
|
||||
InitializeComponent();
|
||||
try
|
||||
{
|
||||
htmlpage = File.ReadAllText("webrtcsample.html");
|
||||
passiveHtmlpage = File.ReadAllText("webrtcpassivesample.html");
|
||||
mServer = new SimpleRendezvousServer();
|
||||
mServer.OnGet = OnGet;
|
||||
mServer.OnPost = OnPost;
|
||||
serverStatusLabel.Text = "Running";
|
||||
serverLinkLabel.Text = "http://127.0.0.1:" + mServer.Port.ToString() + "/start";
|
||||
serverLinkLabel_passive.Text = "http://127.0.0.1:" + mServer.Port.ToString() + "/passive";
|
||||
}
|
||||
catch (Exception) { serverStatusLabel.Text = "Error"; }
|
||||
|
||||
WebRTCConnection.ChainAlwaysRunning = true;
|
||||
int dport = WebRTCConnection.StartDefaultLogger(0);
|
||||
this.Text += " [dPort: " + dport.ToString() + "]";
|
||||
|
||||
System.Diagnostics.Process.Start("http://127.0.0.1:" + dport.ToString());
|
||||
|
||||
if(args.Length == 1)
|
||||
{
|
||||
mPipe = new System.IO.Pipes.NamedPipeClientStream(".", args[0], System.IO.Pipes.PipeDirection.InOut);
|
||||
((System.IO.Pipes.NamedPipeClientStream)mPipe).Connect();
|
||||
pipeBuffer = new byte[4096];
|
||||
StartClient();
|
||||
}
|
||||
}
|
||||
|
||||
private async void StartClient()
|
||||
{
|
||||
SessionForm ss = new SessionForm();
|
||||
userForms.Add("/" + ss.Value.ToString(), ss);
|
||||
ss.Show(this);
|
||||
|
||||
string offer = await ss.Connection.GenerateOffer();
|
||||
byte[] b = UTF8Encoding.UTF8.GetBytes(offer);
|
||||
mPipe.Write(b, 0, b.Length);
|
||||
StartRead(ss);
|
||||
}
|
||||
private void GetNewPassivePOC(WebRTCCommons.CustomAwaiter<byte[]> awaiter)
|
||||
{
|
||||
BeginInvoke((Action<WebRTCCommons.CustomAwaiter<byte[]>>)(async (a) =>
|
||||
{
|
||||
SessionForm f = new SessionForm();
|
||||
if (StunServersInUse) { f.SetStunServers(false, StunServers); }
|
||||
f.FormClosing += SessionFormClosing;
|
||||
f.Show(this);
|
||||
|
||||
userForms.Add("/" + f.Value.ToString(), f);
|
||||
|
||||
string content = passiveHtmlpage.Replace("/*{{{ICESERVERS}}}*/", "").Replace("{{{OFFER_URL}}}", "127.0.0.1:" + mServer.Port.ToString() + "/" + f.Value.ToString());
|
||||
string sdp = await f.GetOffer();
|
||||
|
||||
content = content.Replace("/*{{{SDP}}}*/", System.Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(sdp)));
|
||||
|
||||
string header = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\nContent-Length: " + content.Length.ToString() + "\r\n\r\n";
|
||||
a.SetComplete(UTF8Encoding.UTF8.GetBytes(header + content));
|
||||
}), awaiter);
|
||||
}
|
||||
private void GetNewPOC(IPEndPoint from, WebRTCCommons.CustomAwaiter<byte[]> awaiter)
|
||||
{
|
||||
BeginInvoke((Action<IPEndPoint, WebRTCCommons.CustomAwaiter<byte[]>>)((origin, a) =>
|
||||
{
|
||||
SessionForm f = new SessionForm();
|
||||
if (StunServersInUse) { f.SetStunServers(false, StunServers); }
|
||||
f.FormClosing += SessionFormClosing;
|
||||
f.Show(this);
|
||||
|
||||
userForms.Add("/" + f.Value.ToString(), f);
|
||||
|
||||
string content = htmlpage.Replace("/*{{{ICESERVERS}}}*/", "").Replace("{{{OFFER_URL}}}", origin.Address.ToString() + ":" + mServer.Port.ToString() + "/" + f.Value.ToString());
|
||||
string header = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\nContent-Length: " + content.Length.ToString() + "\r\n\r\n";
|
||||
a.SetComplete(UTF8Encoding.UTF8.GetBytes(header + content));
|
||||
}), from, awaiter);
|
||||
|
||||
}
|
||||
|
||||
void SessionFormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
SessionForm f = sender as SessionForm;
|
||||
userForms.Remove("/" + f.Value.ToString());
|
||||
}
|
||||
|
||||
private WebRTCCommons.CustomAwaiter<byte[]> OnPost(SimpleRendezvousServer sender, string path, string body)
|
||||
{
|
||||
return (userForms[path].GetOfferResponse(body));
|
||||
}
|
||||
|
||||
private WebRTCCommons.CustomAwaiter<byte[]> OnGet(SimpleRendezvousServer sender, IPEndPoint from, string path)
|
||||
{
|
||||
WebRTCCommons.CustomAwaiter<byte[]> retVal = new WebRTCCommons.CustomAwaiter<byte[]>();
|
||||
|
||||
switch (path)
|
||||
{
|
||||
case "/start":
|
||||
GetNewPOC(from, retVal);
|
||||
break;
|
||||
case "/passive":
|
||||
GetNewPassivePOC(retVal);
|
||||
break;
|
||||
default:
|
||||
retVal.SetComplete(UTF8Encoding.UTF8.GetBytes("HTTP/1.1 404 Not Found\r\nConnection: close\r\n\r\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
return (retVal);
|
||||
}
|
||||
|
||||
public class RendezvousData
|
||||
{
|
||||
public ManualResetEvent waitHandle = new ManualResetEvent(false);
|
||||
public byte[] inData = null;
|
||||
public byte[] outData = null;
|
||||
}
|
||||
|
||||
private void browserButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
mPipe = new System.IO.Pipes.NamedPipeServerStream("bbtest", System.IO.Pipes.PipeDirection.InOut, 1, System.IO.Pipes.PipeTransmissionMode.Message, System.IO.Pipes.PipeOptions.Asynchronous);
|
||||
System.Diagnostics.Process.Start(Application.ExecutablePath, "bbtest");
|
||||
pipeBuffer = new byte[4096];
|
||||
SessionForm ss = new SessionForm();
|
||||
userForms.Add("/" + ss.Value.ToString(), ss);
|
||||
ss.Show(this);
|
||||
((System.IO.Pipes.NamedPipeServerStream)mPipe).BeginWaitForConnection(WaitForConnectionSink, ss);
|
||||
}
|
||||
|
||||
private void WaitForConnectionSink(IAsyncResult result)
|
||||
{
|
||||
SessionForm ss = (SessionForm)result.AsyncState;
|
||||
((System.IO.Pipes.NamedPipeServerStream)mPipe).EndWaitForConnection(result);
|
||||
StartRead(ss);
|
||||
}
|
||||
private async void StartRead(SessionForm ss)
|
||||
{
|
||||
int bytesRead = await mPipe.ReadAsync(pipeBuffer, 0, pipeBuffer.Length);
|
||||
string offer = UTF8Encoding.UTF8.GetString(pipeBuffer, 0, bytesRead);
|
||||
string resp = await ss.Connection.SetOffer(offer);
|
||||
byte[] respB = UTF8Encoding.UTF8.GetBytes(resp);
|
||||
if (mPipe as System.IO.Pipes.NamedPipeClientStream == null)
|
||||
{
|
||||
await mPipe.WriteAsync(respB, 0, respB.Length);
|
||||
}
|
||||
|
||||
}
|
||||
private void serverLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start(serverLinkLabel.Text);
|
||||
}
|
||||
|
||||
private void closeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void infoLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start("http://" + infoLinkLabel.Text);
|
||||
}
|
||||
|
||||
private void stunSettingsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (StunSettingsForm f = new StunSettingsForm())
|
||||
{
|
||||
f.StunServers = StunServers;
|
||||
f.StunServersInUse = StunServersInUse;
|
||||
if (f.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
StunServersInUse = f.StunServersInUse;
|
||||
if (StunServersInUse) { StunServers = f.StunServers; stunLabel.Text = StunServers.Length.ToString() + " server(s) in use"; } else { stunLabel.Text = "Disabled"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
WebRTCConnection.ChainAlwaysRunning = false;
|
||||
}
|
||||
|
||||
private void serverLinkLabel_passive_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start(serverLinkLabel_passive.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
146
webrtc/C# Sample/MainForm.resx
Normal file
146
webrtc/C# Sample/MainForm.resx
Normal file
@@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAIAEBAQAAAABAAoAQAAJgAAACAgEAAAAAQA6AIAAE4BAAAoAAAAEAAAACAAAAABAAQAAAAAAIAA
|
||||
AAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/
|
||||
AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAC/MAAAAIiIiDMwiIiIAAAACAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAeP//////hwB4d3d3d3eHcHiIiIiIiIdweIiIiIiCp3B////////3cAeI
|
||||
iIiIiIhwAHd3d3d3d3AAAAAAAAAAAAAAAAAAAAAA//8AAPw/AAAAAAAAAAAAAP5/AAD+fwAAgAMAAAAB
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAgAAAAMABAAD//wAA//8AACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAA
|
||||
AAAAAAAAEAAAABAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD/
|
||||
/wD/AAAA/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
O/szAAAAAAAAAPD//////zv7Mw///////w9wd3d3d3czMzMHd3d3d3cHAAAAAAAAAH8AAAAAAAAAAAAA
|
||||
AAAAAAB/AAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAd3d3d3d3d3d3d3d3d3
|
||||
AAAH+IiIiIiIiIiIiIiIh3AAB/j/////////////+Id3AAf4d3d3d3d3d3d3d3iHdwAH+P//////////
|
||||
///4h3cAB/h3d3d3d3d3d3d3eId3AAf4iIiIiIiIiIiIiIiHdwAH+IiIiIiIiIiIiCIoh3cAB/iIiIiI
|
||||
iIiIiIiqqId3AAf////////////////3dwAAeIiIiIiIiIiIiIiIiHcAAAeIiIiIiIiIiIiIiIiHAAAA
|
||||
d3d3d3d3d3d3d3d3dwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////
|
||||
///////////////wH/9AAAACQAAAAkAAAAL//H////x////8f//AAAAPgAAAB4AAAAOAAAABgAAAAYAA
|
||||
AAGAAAABgAAAAYAAAAGAAAABgAAAAcAAAAHgAAAB8AAAA////////////////////////////////w==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
38
webrtc/C# Sample/Program.cs
Normal file
38
webrtc/C# Sample/Program.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright 2014 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm(args));
|
||||
}
|
||||
}
|
||||
}
|
||||
36
webrtc/C# Sample/Properties/AssemblyInfo.cs
Normal file
36
webrtc/C# Sample/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("WebRTC Sample")]
|
||||
[assembly: AssemblyDescription("Basic sample code for using WebRTC data channel within a C# application.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Open Source under Apache 2.0 license")]
|
||||
[assembly: AssemblyProduct("WebRTC Sample")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Intel Corporation")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("51a2007e-634e-4f21-8c0a-042af1269539")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.1.0.0")]
|
||||
73
webrtc/C# Sample/Properties/Resources.Designer.cs
generated
Normal file
73
webrtc/C# Sample/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34014
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WebRTC_Sample.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WebRTC_Sample.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap WebRTCSample {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("WebRTCSample", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
124
webrtc/C# Sample/Properties/Resources.resx
Normal file
124
webrtc/C# Sample/Properties/Resources.resx
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="WebRTCSample" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\WebRTC Sample.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
30
webrtc/C# Sample/Properties/Settings.Designer.cs
generated
Normal file
30
webrtc/C# Sample/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18444
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WebRTC_Sample.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
webrtc/C# Sample/Properties/Settings.settings
Normal file
7
webrtc/C# Sample/Properties/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
40
webrtc/C# Sample/ReadMe.txt
Normal file
40
webrtc/C# Sample/ReadMe.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
========================================================================
|
||||
DYNAMIC LINK LIBRARY : MicrostackWrapper Project Overview
|
||||
========================================================================
|
||||
|
||||
AppWizard has created this MicrostackWrapper DLL for you.
|
||||
|
||||
This file contains a summary of what you will find in each of the files that
|
||||
make up your MicrostackWrapper application.
|
||||
|
||||
|
||||
MicrostackWrapper.vcxproj
|
||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
||||
It contains information about the version of Visual C++ that generated the file, and
|
||||
information about the platforms, configurations, and project features selected with the
|
||||
Application Wizard.
|
||||
|
||||
MicrostackWrapper.vcxproj.filters
|
||||
This is the filters file for VC++ projects generated using an Application Wizard.
|
||||
It contains information about the association between the files in your project
|
||||
and the filters. This association is used in the IDE to show grouping of files with
|
||||
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
|
||||
"Source Files" filter).
|
||||
|
||||
MicrostackWrapper.cpp
|
||||
This is the main DLL source file.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other standard files:
|
||||
|
||||
StdAfx.h, StdAfx.cpp
|
||||
These files are used to build a precompiled header (PCH) file
|
||||
named MicrostackWrapper.pch and a precompiled types file named StdAfx.obj.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other notes:
|
||||
|
||||
AppWizard uses "TODO:" comments to indicate parts of the source code you
|
||||
should add to or customize.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
116
webrtc/C# Sample/SessionForm.Designer.cs
generated
Normal file
116
webrtc/C# Sample/SessionForm.Designer.cs
generated
Normal file
@@ -0,0 +1,116 @@
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
partial class SessionForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SessionForm));
|
||||
this.messageTextBox = new System.Windows.Forms.TextBox();
|
||||
this.inputTextBox = new System.Windows.Forms.TextBox();
|
||||
this.sendButton = new System.Windows.Forms.Button();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// messageTextBox
|
||||
//
|
||||
this.messageTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.messageTextBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.messageTextBox.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.messageTextBox.Multiline = true;
|
||||
this.messageTextBox.Name = "messageTextBox";
|
||||
this.messageTextBox.ReadOnly = true;
|
||||
this.messageTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.messageTextBox.Size = new System.Drawing.Size(613, 315);
|
||||
this.messageTextBox.TabIndex = 0;
|
||||
//
|
||||
// inputTextBox
|
||||
//
|
||||
this.inputTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.inputTextBox.Enabled = false;
|
||||
this.inputTextBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.inputTextBox.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.inputTextBox.Name = "inputTextBox";
|
||||
this.inputTextBox.Size = new System.Drawing.Size(500, 22);
|
||||
this.inputTextBox.TabIndex = 1;
|
||||
this.inputTextBox.TextChanged += new System.EventHandler(this.inputText_TextChanged);
|
||||
this.inputTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.inputText_KeyUp);
|
||||
//
|
||||
// sendButton
|
||||
//
|
||||
this.sendButton.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.sendButton.Enabled = false;
|
||||
this.sendButton.Location = new System.Drawing.Point(500, 0);
|
||||
this.sendButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.sendButton.Name = "sendButton";
|
||||
this.sendButton.Size = new System.Drawing.Size(113, 26);
|
||||
this.sendButton.TabIndex = 2;
|
||||
this.sendButton.Text = "Send";
|
||||
this.sendButton.UseVisualStyleBackColor = true;
|
||||
this.sendButton.TextChanged += new System.EventHandler(this.inputText_TextChanged);
|
||||
this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
|
||||
this.sendButton.KeyUp += new System.Windows.Forms.KeyEventHandler(this.inputText_KeyUp);
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.inputTextBox);
|
||||
this.panel1.Controls.Add(this.sendButton);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 315);
|
||||
this.panel1.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(613, 26);
|
||||
this.panel1.TabIndex = 3;
|
||||
//
|
||||
// SessionForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(613, 341);
|
||||
this.Controls.Add(this.messageTextBox);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "SessionForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "WebRTC Session";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UserForm_FormClosing);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox messageTextBox;
|
||||
private System.Windows.Forms.TextBox inputTextBox;
|
||||
private System.Windows.Forms.Button sendButton;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
}
|
||||
}
|
||||
215
webrtc/C# Sample/SessionForm.cs
Normal file
215
webrtc/C# Sample/SessionForm.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
Copyright 2014 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using OpenSource.WebRTC;
|
||||
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
public partial class SessionForm : Form
|
||||
{
|
||||
public bool isConnected
|
||||
{
|
||||
get
|
||||
{
|
||||
return (mConnected);
|
||||
}
|
||||
}
|
||||
private WebRTCConnection mConnection;
|
||||
private WebRTCDataChannel mData;
|
||||
private bool closing = false;
|
||||
private bool mConnected = false;
|
||||
|
||||
private int mValue = new Random().Next(1, int.MaxValue);
|
||||
public int Value { get { return (mValue); } }
|
||||
public void SetStunServers(bool preserveOrder, params string[] servers)
|
||||
{
|
||||
if (!preserveOrder) { servers.Shuffle(); }
|
||||
mConnection.SetStunServers(servers);
|
||||
}
|
||||
|
||||
public WebRTCConnection Connection { get { return (mConnection); } }
|
||||
public SessionForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
mConnection = new WebRTCConnection();
|
||||
|
||||
mConnection.OnConnected += mConnection_OnConnected;
|
||||
mConnection.OnDisconnected += mConnection_OnDisconnected;
|
||||
mConnection.OnDataChannel += mConnection_OnDataChannel;
|
||||
messageTextBox.Text += ("Got offer at " + DateTime.Now.ToShortTimeString() + ", buiding answer...\r\n");
|
||||
this.Text += " dPort: " + WebRTCConnection.StartDefaultLogger(0).ToString();
|
||||
}
|
||||
|
||||
|
||||
private async void GetOfferAsync(WebRTCCommons.CustomAwaiter<string> awaiter)
|
||||
{
|
||||
string sdp = await mConnection.GenerateOffer();
|
||||
awaiter.SetComplete(sdp);
|
||||
}
|
||||
public WebRTCCommons.CustomAwaiter<string> GetOffer()
|
||||
{
|
||||
WebRTCCommons.CustomAwaiter<string> retVal = new WebRTCCommons.CustomAwaiter<string>();
|
||||
GetOfferAsync(retVal);
|
||||
return (retVal);
|
||||
}
|
||||
|
||||
void mConnection_OnDisconnected(WebRTCConnection sender)
|
||||
{
|
||||
mConnected = false;
|
||||
mConnection = null;
|
||||
if (!closing)
|
||||
{
|
||||
BeginInvoke((Action)(() =>
|
||||
{
|
||||
Close();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
async void mConnection_OnConnected(WebRTCConnection sender)
|
||||
{
|
||||
mConnected = true;
|
||||
BeginInvoke((Action)(() =>
|
||||
{
|
||||
messageTextBox.Text += ("Connected at " + DateTime.Now.ToShortTimeString() + "\r\n");
|
||||
messageTextBox.Select(messageTextBox.Text.Length, 0);
|
||||
}));
|
||||
|
||||
WebRTCDataChannel dc = await sender.CreateDataChannel("MyDataChannel"); // Wait to see if this is ACK'ed
|
||||
if (dc != null)
|
||||
{
|
||||
// YUP
|
||||
mData = dc;
|
||||
mData.OnStringReceiveData += mData_OnStringReceiveData;
|
||||
mData.OnClosing += mData_OnClosing;
|
||||
}
|
||||
|
||||
BeginInvoke(((Action<WebRTCDataChannel>)((d) =>
|
||||
{
|
||||
messageTextBox.Text += ("Local DataChannel Creation (MyDataChannel) was " + (d != null ? "ACKed" : "NOT ACKed") + "\r\n");
|
||||
messageTextBox.Select(messageTextBox.Text.Length, 0);
|
||||
if (d != null)
|
||||
{
|
||||
inputTextBox.Enabled = true; // Only setting if true, because there could already be a dataChannel that has already enabled the textbox
|
||||
}
|
||||
})), dc);
|
||||
}
|
||||
|
||||
void mData_OnClosing(WebRTCDataChannel sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
BeginInvoke(((Action<WebRTCDataChannel>)((d) =>
|
||||
{
|
||||
messageTextBox.Text += ("Data Channel (" + d.ChannelName + ") was closed\r\n");
|
||||
messageTextBox.Select(messageTextBox.Text.Length, 0);
|
||||
})), sender);
|
||||
}
|
||||
catch(InvalidOperationException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void mConnection_OnDataChannel(WebRTCConnection sender, WebRTCDataChannel DataChannel)
|
||||
{
|
||||
mData = DataChannel;
|
||||
mData.OnStringReceiveData += mData_OnStringReceiveData;
|
||||
|
||||
BeginInvoke(((Action<WebRTCDataChannel>)((dc) =>
|
||||
{
|
||||
messageTextBox.Text += ("DataChannel Created by Remote peer: (" + dc.ChannelName + "[" + dc.StreamId.ToString() + "]) was established\r\n");
|
||||
messageTextBox.Select(messageTextBox.Text.Length, 0);
|
||||
inputTextBox.Enabled = true;
|
||||
})), DataChannel);
|
||||
}
|
||||
|
||||
void mData_OnStringReceiveData(WebRTCDataChannel sender, string data)
|
||||
{
|
||||
BeginInvoke(((Action<WebRTCDataChannel, string>)((dc, msg) =>
|
||||
{
|
||||
messageTextBox.Text += ("Remote [" + dc.ChannelName + "]: " + msg + "\r\n");
|
||||
messageTextBox.Select(messageTextBox.Text.Length, 0);
|
||||
})), sender, data);
|
||||
|
||||
}
|
||||
|
||||
private async void GetOfferResponseAsync(WebRTCCommons.CustomAwaiter<byte[]> awaiter, string offer)
|
||||
{
|
||||
string offerResponse = await mConnection.SetOffer(offer);
|
||||
byte[] r = UTF8Encoding.UTF8.GetBytes("HTTP/1.1 200 OK\r\nContent-Type: text/sdp\r\nConnection: close\r\nContent-Length: " + offerResponse.Length.ToString() + "\r\n\r\n" + offerResponse);
|
||||
awaiter.SetComplete(r);
|
||||
}
|
||||
public WebRTCCommons.CustomAwaiter<byte[]> GetOfferResponse(string offer)
|
||||
{
|
||||
WebRTCCommons.CustomAwaiter<byte[]> retVal = new WebRTCCommons.CustomAwaiter<byte[]>();
|
||||
GetOfferResponseAsync(retVal, offer);
|
||||
return (retVal);
|
||||
}
|
||||
|
||||
private void sendButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (inputTextBox.Text == "*CLOSE*")
|
||||
{
|
||||
mData.Close();
|
||||
}
|
||||
else if (inputTextBox.Text == "*PAUSE*")
|
||||
{
|
||||
mData.ParentConnection.Pause();
|
||||
}
|
||||
else if (inputTextBox.Text == "*RESUME*")
|
||||
{
|
||||
mData.ParentConnection.Resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
mData.Send(inputTextBox.Text);
|
||||
}
|
||||
messageTextBox.Text += ("Local: " + inputTextBox.Text + "\r\n");
|
||||
inputTextBox.Text = "";
|
||||
}
|
||||
|
||||
private void inputText_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
sendButton.Enabled = inputTextBox.Text != "";
|
||||
}
|
||||
|
||||
private void inputText_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter && sendButton.Enabled) { sendButton_Click(sendButton, null); }
|
||||
}
|
||||
|
||||
private void UserForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
closing = true;
|
||||
if (mConnection != null)
|
||||
{
|
||||
mConnection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
143
webrtc/C# Sample/SessionForm.resx
Normal file
143
webrtc/C# Sample/SessionForm.resx
Normal file
@@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAIAEBAQAAAABAAoAQAAJgAAACAgEAAAAAQA6AIAAE4BAAAoAAAAEAAAACAAAAABAAQAAAAAAIAA
|
||||
AAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/
|
||||
AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAC/MAAAAIiIiDMwiIiIAAAACAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAeP//////hwB4d3d3d3eHcHiIiIiIiIdweIiIiIiCp3B////////3cAeI
|
||||
iIiIiIhwAHd3d3d3d3AAAAAAAAAAAAAAAAAAAAAA//8AAPw/AAAAAAAAAAAAAP5/AAD+fwAAgAMAAAAB
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAgAAAAMABAAD//wAA//8AACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAA
|
||||
AAAAAAAAEAAAABAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD/
|
||||
/wD/AAAA/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
O/szAAAAAAAAAPD//////zv7Mw///////w9wd3d3d3czMzMHd3d3d3cHAAAAAAAAAH8AAAAAAAAAAAAA
|
||||
AAAAAAB/AAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAd3d3d3d3d3d3d3d3d3
|
||||
AAAH+IiIiIiIiIiIiIiIh3AAB/j/////////////+Id3AAf4d3d3d3d3d3d3d3iHdwAH+P//////////
|
||||
///4h3cAB/h3d3d3d3d3d3d3eId3AAf4iIiIiIiIiIiIiIiHdwAH+IiIiIiIiIiIiCIoh3cAB/iIiIiI
|
||||
iIiIiIiqqId3AAf////////////////3dwAAeIiIiIiIiIiIiIiIiHcAAAeIiIiIiIiIiIiIiIiHAAAA
|
||||
d3d3d3d3d3d3d3d3dwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////
|
||||
///////////////wH/9AAAACQAAAAkAAAAL//H////x////8f//AAAAPgAAAB4AAAAOAAAABgAAAAYAA
|
||||
AAGAAAABgAAAAYAAAAGAAAABgAAAAcAAAAHgAAAB8AAAA////////////////////////////////w==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
196
webrtc/C# Sample/SimpleRendezvousServer.cs
Normal file
196
webrtc/C# Sample/SimpleRendezvousServer.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
Copyright 2014 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using OpenSource.WebRTC;
|
||||
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
/// <summary>
|
||||
/// Very simple HTTP/WebRTC rendez-vous server. It grabs a random local port and acts like a very basic HTTP server.
|
||||
/// It serves the WebRTC sample web page and handles offer/answer requests.
|
||||
/// </summary>
|
||||
public class SimpleRendezvousServer
|
||||
{
|
||||
private TcpListener mListener;
|
||||
private const int GET_HEADER = 542393671;
|
||||
private const int POST_HEADER = 1414745936;
|
||||
private const int END_HEADER = 168626701;
|
||||
|
||||
public delegate WebRTCCommons.CustomAwaiter<byte[]> GetHandler(SimpleRendezvousServer sender, IPEndPoint from, string path);
|
||||
public delegate WebRTCCommons.CustomAwaiter<byte[]> PostHandler(SimpleRendezvousServer sender, string path, string body);
|
||||
|
||||
public GetHandler OnGet;
|
||||
public PostHandler OnPost;
|
||||
|
||||
private class ReadWrapper
|
||||
{
|
||||
public TcpClient client;
|
||||
public Stream s;
|
||||
public byte[] buffer;
|
||||
public int offset;
|
||||
public int totalRead;
|
||||
|
||||
public ReadWrapper(TcpClient c, byte[] data)
|
||||
{
|
||||
buffer = data;
|
||||
offset = 0;
|
||||
totalRead = 0;
|
||||
client = c;
|
||||
s = client.GetStream();
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleRendezvousServer()
|
||||
{
|
||||
mListener = new TcpListener(new IPEndPoint(IPAddress.Any, 0));
|
||||
mListener.Start();
|
||||
//mListener.BeginAcceptSocket(OnAccept, null);
|
||||
mListener.BeginAcceptTcpClient(OnAccept, null);
|
||||
}
|
||||
|
||||
public int Port { get { return ((mListener.LocalEndpoint as IPEndPoint).Port); } }
|
||||
|
||||
private void OnAccept(IAsyncResult result)
|
||||
{
|
||||
try
|
||||
{
|
||||
TcpClient sock = mListener.EndAcceptTcpClient(result);
|
||||
ReadWrapper RW = new ReadWrapper(sock, new byte[32768]);
|
||||
RW.s.ReadAsync(RW.buffer, 0, RW.buffer.Length).ContinueWith((Action<Task<int>, object>)OnRead, RW);
|
||||
}
|
||||
catch { }
|
||||
mListener.BeginAcceptSocket(OnAccept, null);
|
||||
}
|
||||
|
||||
private int GetContentLength(byte[] buffer, int offset, int count)
|
||||
{
|
||||
string[] headers = UTF8Encoding.UTF8.GetString(buffer, offset, count).Split(new string[] { "\r\n" }, StringSplitOptions.None);
|
||||
foreach (string header in headers)
|
||||
{
|
||||
if (header.IndexOf(":") > 0)
|
||||
{
|
||||
string headerName = header.Substring(0, header.IndexOf(":")).Trim();
|
||||
string headerValue = header.Substring(header.IndexOf(":") + 1).Trim();
|
||||
if (headerName.ToUpper() == "CONTENT-LENGTH") { return (int.Parse(headerValue)); }
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private async Task<byte[]> ProcessGet(IPEndPoint from, string value)
|
||||
{
|
||||
if (OnGet == null) return null;
|
||||
string path = "";
|
||||
try { path = value.Split(new string[] { " " }, StringSplitOptions.None)[1]; } catch { return null; }
|
||||
return await OnGet(this, from, path);
|
||||
}
|
||||
|
||||
private async Task<byte[]> ProcessPost(string value, string body)
|
||||
{
|
||||
if (OnPost == null) return null;
|
||||
string path = "";
|
||||
try { path = value.Split(new string[] { " " }, StringSplitOptions.None)[1]; } catch { return null; }
|
||||
return await OnPost(this, path, body);
|
||||
}
|
||||
|
||||
|
||||
private async void OnRead(Task<int> t, object j)
|
||||
{
|
||||
ReadWrapper RW = j as ReadWrapper;
|
||||
RW.totalRead += t.Result;
|
||||
|
||||
if (RW.totalRead < 4)
|
||||
{
|
||||
RW.offset += t.Result;
|
||||
object jj = RW.s.ReadAsync(RW.buffer, RW.offset, RW.buffer.Length - RW.totalRead).ContinueWith((Action<Task<int>, object>)OnRead, RW);
|
||||
return;
|
||||
}
|
||||
|
||||
int h = BitConverter.ToInt32(RW.buffer, 0);
|
||||
int eoh = -1;
|
||||
string[] headers = new string[0];
|
||||
|
||||
switch (h)
|
||||
{
|
||||
case GET_HEADER:
|
||||
case POST_HEADER:
|
||||
for (int i = 4; i < RW.totalRead; ++i) { if (BitConverter.ToInt32(RW.buffer, i) == END_HEADER) { eoh = i; break; } }
|
||||
if (eoh > 0) { headers = UTF8Encoding.UTF8.GetString(RW.buffer, 0, RW.totalRead).Split(new string[] { "\r\n" }, StringSplitOptions.None); }
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (eoh > 0)
|
||||
{
|
||||
switch (h)
|
||||
{
|
||||
case GET_HEADER:
|
||||
byte[] resp = await ProcessGet(RW.client.Client.LocalEndPoint as IPEndPoint, headers[0]).ConfigureAwait(false);
|
||||
if (resp.Length > 0) { RW.s.Write(resp, 0, resp.Length); }
|
||||
RW.s.Close();
|
||||
break;
|
||||
case POST_HEADER:
|
||||
// Check for Content-Length
|
||||
int contentLength = -1;
|
||||
foreach (string header in headers)
|
||||
{
|
||||
if (header.IndexOf(":") > 0)
|
||||
{
|
||||
string headerName = header.Substring(0, header.IndexOf(":")).Trim();
|
||||
string headerValue = header.Substring(header.IndexOf(":") + 1).Trim();
|
||||
if (headerName.ToUpper() == "CONTENT-LENGTH") { contentLength = (int.Parse(headerValue)); break; }
|
||||
}
|
||||
}
|
||||
if (contentLength > 0)
|
||||
{
|
||||
if (contentLength + eoh + 4 <= RW.totalRead)
|
||||
{
|
||||
byte[] postResp = await ProcessPost(headers[0], UTF8Encoding.UTF8.GetString(RW.buffer, eoh + 4, contentLength)).ConfigureAwait(false);
|
||||
if (postResp.Length > 0) { RW.s.Write(postResp, 0, postResp.Length); }
|
||||
RW.s.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
RW.offset += t.Result;
|
||||
object jj = RW.s.ReadAsync(RW.buffer, RW.offset, RW.buffer.Length - RW.totalRead).ContinueWith((Action<Task<int>, object>)OnRead, RW);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] postResp = await ProcessPost(headers[0], null).ConfigureAwait(false);
|
||||
if (postResp.Length > 0) { RW.s.Write(postResp, 0, postResp.Length); }
|
||||
RW.s.Close();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RW.offset += t.Result;
|
||||
object jj = RW.s.ReadAsync(RW.buffer, RW.offset, RW.buffer.Length - RW.totalRead).ContinueWith((Action<Task<int>, object>)OnRead, RW);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
146
webrtc/C# Sample/StunSettingsForm.Designer.cs
generated
Normal file
146
webrtc/C# Sample/StunSettingsForm.Designer.cs
generated
Normal file
@@ -0,0 +1,146 @@
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
partial class StunSettingsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(StunSettingsForm));
|
||||
this.stunTextBox = new System.Windows.Forms.TextBox();
|
||||
this.stunCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// stunTextBox
|
||||
//
|
||||
this.stunTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stunTextBox.Location = new System.Drawing.Point(6, 42);
|
||||
this.stunTextBox.Multiline = true;
|
||||
this.stunTextBox.Name = "stunTextBox";
|
||||
this.stunTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.stunTextBox.Size = new System.Drawing.Size(321, 176);
|
||||
this.stunTextBox.TabIndex = 13;
|
||||
//
|
||||
// stunCheckBox
|
||||
//
|
||||
this.stunCheckBox.AutoSize = true;
|
||||
this.stunCheckBox.Checked = true;
|
||||
this.stunCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.stunCheckBox.Location = new System.Drawing.Point(6, 19);
|
||||
this.stunCheckBox.Name = "stunCheckBox";
|
||||
this.stunCheckBox.Size = new System.Drawing.Size(115, 17);
|
||||
this.stunCheckBox.TabIndex = 12;
|
||||
this.stunCheckBox.Text = "Use STUN servers";
|
||||
this.stunCheckBox.UseVisualStyleBackColor = true;
|
||||
this.stunCheckBox.CheckedChanged += new System.EventHandler(this.stunCheckBox_CheckedChanged);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(333, 44);
|
||||
this.label1.TabIndex = 14;
|
||||
this.label1.Text = "STUN servers are used with WebRTC to determin the public IP addresses and port of" +
|
||||
" endpoints. If not used, only the local interfaces will be used.";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox1.Controls.Add(this.stunCheckBox);
|
||||
this.groupBox1.Controls.Add(this.stunTextBox);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 56);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(333, 224);
|
||||
this.groupBox1.TabIndex = 15;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "STUN Servers";
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(270, 286);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 16;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.Location = new System.Drawing.Point(189, 286);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 17;
|
||||
this.okButton.Text = "OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// StunSettingsForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(357, 321);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "StunSettingsForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "STUN Servers";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox stunTextBox;
|
||||
private System.Windows.Forms.CheckBox stunCheckBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
}
|
||||
}
|
||||
47
webrtc/C# Sample/StunSettingsForm.cs
Normal file
47
webrtc/C# Sample/StunSettingsForm.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WebRTC_Sample
|
||||
{
|
||||
public partial class StunSettingsForm : Form
|
||||
{
|
||||
public StunSettingsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public Boolean StunServersInUse
|
||||
{
|
||||
get { return stunCheckBox.Checked; }
|
||||
set { stunTextBox.Enabled = stunCheckBox.Checked = value; }
|
||||
}
|
||||
|
||||
public String[] StunServers
|
||||
{
|
||||
get { return stunTextBox.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); }
|
||||
set { stunTextBox.Text = string.Join("\r\n", value); }
|
||||
}
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
}
|
||||
|
||||
private void stunCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
stunTextBox.Enabled = stunCheckBox.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
143
webrtc/C# Sample/StunSettingsForm.resx
Normal file
143
webrtc/C# Sample/StunSettingsForm.resx
Normal file
@@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAIAEBAQAAAABAAoAQAAJgAAACAgEAAAAAQA6AIAAE4BAAAoAAAAEAAAACAAAAABAAQAAAAAAIAA
|
||||
AAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/
|
||||
AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAC/MAAAAIiIiDMwiIiIAAAACAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAeP//////hwB4d3d3d3eHcHiIiIiIiIdweIiIiIiCp3B////////3cAeI
|
||||
iIiIiIhwAHd3d3d3d3AAAAAAAAAAAAAAAAAAAAAA//8AAPw/AAAAAAAAAAAAAP5/AAD+fwAAgAMAAAAB
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAgAAAAMABAAD//wAA//8AACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAA
|
||||
AAAAAAAAEAAAABAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD/
|
||||
/wD/AAAA/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
O/szAAAAAAAAAPD//////zv7Mw///////w9wd3d3d3czMzMHd3d3d3cHAAAAAAAAAH8AAAAAAAAAAAAA
|
||||
AAAAAAB/AAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAd3d3d3d3d3d3d3d3d3
|
||||
AAAH+IiIiIiIiIiIiIiIh3AAB/j/////////////+Id3AAf4d3d3d3d3d3d3d3iHdwAH+P//////////
|
||||
///4h3cAB/h3d3d3d3d3d3d3eId3AAf4iIiIiIiIiIiIiIiHdwAH+IiIiIiIiIiIiCIoh3cAB/iIiIiI
|
||||
iIiIiIiqqId3AAf////////////////3dwAAeIiIiIiIiIiIiIiIiHcAAAeIiIiIiIiIiIiIiIiHAAAA
|
||||
d3d3d3d3d3d3d3d3dwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////
|
||||
///////////////wH/9AAAACQAAAAkAAAAL//H////x////8f//AAAAPgAAAB4AAAAOAAAABgAAAAYAA
|
||||
AAGAAAABgAAAAYAAAAGAAAABgAAAAcAAAAHgAAAB8AAAA////////////////////////////////w==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
147
webrtc/C# Sample/WebRTC Sample.csproj
Normal file
147
webrtc/C# Sample/WebRTC Sample.csproj
Normal file
@@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{128C450F-C8B3-403A-9D0C-E5AD6B7F566F}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WebRTC_Sample</RootNamespace>
|
||||
<AssemblyName>WebRTC Sample</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>WebRTC Sample.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>WebRTC_Sample.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FormExtensions.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SimpleRendezvousServer.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SessionForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SessionForm.Designer.cs">
|
||||
<DependentUpon>SessionForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="StunSettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="StunSettingsForm.Designer.cs">
|
||||
<DependentUpon>StunSettingsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WebRTC.cs" />
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="SessionForm.resx">
|
||||
<DependentUpon>SessionForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="StunSettingsForm.resx">
|
||||
<DependentUpon>StunSettingsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="WebRTC Sample.ico" />
|
||||
<None Include="WebRTC Sample.png" />
|
||||
<Content Include="webrtcpassivesample.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="webrtcsample.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
BIN
webrtc/C# Sample/WebRTC Sample.ico
Normal file
BIN
webrtc/C# Sample/WebRTC Sample.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
webrtc/C# Sample/WebRTC Sample.png
Normal file
BIN
webrtc/C# Sample/WebRTC Sample.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
BIN
webrtc/C# Sample/WebRTC.aps
Normal file
BIN
webrtc/C# Sample/WebRTC.aps
Normal file
Binary file not shown.
472
webrtc/C# Sample/WebRTC.cpp
Normal file
472
webrtc/C# Sample/WebRTC.cpp
Normal file
@@ -0,0 +1,472 @@
|
||||
/*
|
||||
Copyright 2014 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
//
|
||||
// MicrostackWrapper.cpp : Defines the exported functions for the DLL application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "WebRTC.h"
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
|
||||
#if defined(WIN32)
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
extern "C"
|
||||
{
|
||||
#include "../../microstack/ILibAsyncSocket.h"
|
||||
#include "../../microstack/ILibParsers.h"
|
||||
#include "../../microstack/ILibWebRTC.h"
|
||||
#include "../../microstack/ILibCrypto.h"
|
||||
#include "../../microstack/ILibWrapperWebRTC.h"
|
||||
#include "../../microstack/ILibWebServer.h"
|
||||
#include "../../microstack/ILibRemoteLogging.h"
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
char g_SessionRandom[32];
|
||||
unsigned int g_SessionRandomId;
|
||||
char g_selfid[UTIL_HASHSIZE];
|
||||
|
||||
struct util_cert selfcert;
|
||||
struct util_cert selftlscert;
|
||||
struct util_cert selftlsclientcert;
|
||||
SSL_CTX* ctx = NULL;
|
||||
char tlsServerCertThumbprint[32];
|
||||
extern void* ILibWrapper_WebRTC_Connection_GetStunModule(ILibWrapper_WebRTC_Connection connection);
|
||||
|
||||
__declspec(dllexport) void ILibWrapper_Free(void* ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
//
|
||||
// Chain Management
|
||||
//
|
||||
__declspec(dllexport) void* ILibWrapper_CreateMicrostackChain()
|
||||
{
|
||||
return(ILibCreateChain());
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_StartChain(void *chain)
|
||||
{
|
||||
ILibStartChain(chain);
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_StopChain(void *chain)
|
||||
{
|
||||
ILibStopChain(chain);
|
||||
}
|
||||
__declspec(dllexport) int ILibWrapper_IsChainRunning(void* chain)
|
||||
{
|
||||
return(ILibIsChainRunning(chain));
|
||||
}
|
||||
__declspec(dllexport) void* ILibWrapper_DLL_GetBaseTimer(void* chain)
|
||||
{
|
||||
return(ILibGetBaseTimer(chain));
|
||||
}
|
||||
|
||||
__declspec(dllexport) int ILibWrapper_DLL_IsChainDisposing(void *chain)
|
||||
{
|
||||
return(ILibIsChainBeingDestroyed(chain));
|
||||
}
|
||||
|
||||
|
||||
__declspec(dllexport) unsigned short ILibWrapper_StartDefaultLogger(void *chain, unsigned short portNumber)
|
||||
{
|
||||
#if defined(_REMOTELOGGING) && defined(_REMOTELOGGINGSERVER)
|
||||
return(ILibStartDefaultLogger(chain, portNumber));
|
||||
#else
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
__declspec(dllexport) void ILibWrapper_RemoteLogging_Print(void *chain, ILibRemoteLogging_Modules module, ILibRemoteLogging_Flags flags, char *msg)
|
||||
{
|
||||
ILibRemoteLogging_printf(ILibChainGetLogger(chain), module, flags, "%s", msg);
|
||||
}
|
||||
|
||||
//
|
||||
// XML Parsing
|
||||
//
|
||||
__declspec(dllexport) void* ILibWrapper_ParseXML(char* buffer, int offset, int length)
|
||||
{
|
||||
struct ILibXMLNode *n = ILibParseXML(buffer, offset, length);
|
||||
if(n!=NULL)
|
||||
{
|
||||
ILibProcessXMLNodeList(n);
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
__declspec(dllexport) void* ILibWrapper_GetXMLAttributes(struct ILibXMLNode *node)
|
||||
{
|
||||
return(ILibGetXMLAttributes(node));
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_BuildXMLNamespaceLookupTable(struct ILibXMLNode *node)
|
||||
{
|
||||
ILibXML_BuildNamespaceLookupTable(node);
|
||||
}
|
||||
__declspec(dllexport) char* ILibWrapper_LookupXMLNamespace(struct ILibXMLNode* current, char* prefix, int prefixLength)
|
||||
{
|
||||
return(ILibXML_LookupNamespace(current, prefix, prefixLength));
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_DestructXMLNodeList(struct ILibXMLNode *node)
|
||||
{
|
||||
ILibDestructXMLNodeList(node);
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_DestructXMLAttributeList(struct ILibXMLAttribute *a)
|
||||
{
|
||||
ILibDestructXMLAttributeList(a);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// LifeTimeMonitor
|
||||
//
|
||||
__declspec(dllexport) void* ILibWrapper_CreateLifeTime(void *chain)
|
||||
{
|
||||
return(ILibCreateLifeTime(chain));
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_LifeTimeAddEx(void *LifetimeMonitorObject, void *data, int ms, ILibLifeTime_OnCallback Callback, ILibLifeTime_OnCallback Destroy)
|
||||
{
|
||||
ILibLifeTime_AddEx(LifetimeMonitorObject, data, ms, Callback, Destroy);
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_LifeTimeRemove(void *LifeTimeToken, void *data)
|
||||
{
|
||||
ILibLifeTime_Remove(LifeTimeToken, data);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// String Parsing
|
||||
//
|
||||
__declspec(dllexport) void* ILibWrapper_ParseString(char* buffer, int offset, int length, const char* Delimiter, int DelimiterLength)
|
||||
{
|
||||
return(ILibParseString(buffer, offset, length, Delimiter, DelimiterLength));
|
||||
}
|
||||
__declspec(dllexport) void* ILibWrapper_ParseStringAdv(char* buffer, int offset, int length, const char* Delimiter, int DelimiterLength)
|
||||
{
|
||||
return(ILibParseStringAdv(buffer, offset, length, Delimiter, DelimiterLength));
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_DestructParserResults(struct parser_result *result)
|
||||
{
|
||||
ILibDestructParserResults(result);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Crypto
|
||||
//
|
||||
__declspec(dllexport) void ILibWrapper_OpenSSL_Init()
|
||||
{
|
||||
util_openssl_init();
|
||||
}
|
||||
|
||||
__declspec(dllexport) void ILibWrapper_OpenSSL_UnInit()
|
||||
{
|
||||
util_openssl_uninit();
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_InitializeCerts()
|
||||
{
|
||||
memset(&selfcert,0,sizeof(struct util_cert));
|
||||
memset(&selftlscert,0,sizeof(struct util_cert));
|
||||
memset(&selftlsclientcert,0,sizeof(struct util_cert));
|
||||
|
||||
util_mkCert(NULL, &selfcert, 2048, 10000, "localhost", CERTIFICATE_ROOT, NULL);
|
||||
util_keyhash(selfcert,g_selfid);
|
||||
|
||||
util_mkCert(&selfcert, &selftlscert, 2048, 10000, "localhost", CERTIFICATE_TLS_SERVER, NULL);
|
||||
util_mkCert(&selfcert, &selftlsclientcert, 2048, 10000, "localhost", CERTIFICATE_TLS_CLIENT, NULL);
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_InitializeDTLS()
|
||||
{
|
||||
ctx = SSL_CTX_new(DTLSv1_method());
|
||||
SSL_CTX_use_certificate(ctx, selftlscert.x509);
|
||||
SSL_CTX_use_PrivateKey(ctx,selftlscert.pkey);
|
||||
|
||||
int l = 32;
|
||||
X509_digest(selftlscert.x509, EVP_get_digestbyname("sha256"), (unsigned char*)tlsServerCertThumbprint, (unsigned int*)&l);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void ILibWrapper_UnInitializeDTLS()
|
||||
{
|
||||
SSL_CTX_free(ctx);
|
||||
ctx = NULL;
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_UnInitializeCerts()
|
||||
{
|
||||
util_freecert(&selftlsclientcert);
|
||||
util_freecert(&selftlscert);
|
||||
util_freecert(&selfcert);
|
||||
|
||||
memset(&selfcert,0,sizeof(struct util_cert));
|
||||
memset(&selftlscert,0,sizeof(struct util_cert));
|
||||
memset(&selftlsclientcert,0,sizeof(struct util_cert));
|
||||
}
|
||||
|
||||
__declspec(dllexport) void* ILibWrapper_GetCTX()
|
||||
{
|
||||
return(ctx);
|
||||
}
|
||||
__declspec(dllexport) char* ILibWrapper_GetTLSServerThumbprint()
|
||||
{
|
||||
return(tlsServerCertThumbprint);
|
||||
}
|
||||
|
||||
//
|
||||
// IPAddress Helper
|
||||
//
|
||||
__declspec(dllexport) char* ILibWrapper_SockAddr_GetAddressString(struct sockaddr* addr, char* buffer, int bufferLength)
|
||||
{
|
||||
return(ILibInet_ntop2(addr, buffer, bufferLength));
|
||||
}
|
||||
__declspec(dllexport) unsigned short ILibWrapper_SockAddr_GetPort(struct sockaddr* addr)
|
||||
{
|
||||
unsigned short retVal = 0;
|
||||
switch(addr->sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
retVal = ntohs(((struct sockaddr_in*)addr)->sin_port);
|
||||
break;
|
||||
case AF_INET6:
|
||||
retVal = ntohs(((struct sockaddr_in6*)addr)->sin6_port);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
__declspec(dllexport) int ILibWrapper_SockAddrIn6_Size()
|
||||
{
|
||||
return(sizeof(struct sockaddr_in6));
|
||||
}
|
||||
__declspec(dllexport) void* ILibWrapper_SockAddr_FromString(char* buffer, unsigned short port)
|
||||
{
|
||||
struct sockaddr_in* retVal = (struct sockaddr_in*)malloc(sizeof(struct sockaddr_in6));
|
||||
if(retVal==NULL){ILIBCRITICALEXIT(254);}
|
||||
memset(retVal,0,sizeof(struct sockaddr_in6));
|
||||
|
||||
retVal->sin_family = AF_INET;
|
||||
retVal->sin_port = htons(port);
|
||||
ILibInet_pton(AF_INET, buffer, &(retVal->sin_addr));
|
||||
return(retVal);
|
||||
}
|
||||
__declspec(dllexport) void* ILibWrapper_SockAddr_FromString6(char* buffer, unsigned short port)
|
||||
{
|
||||
struct sockaddr_in6* retVal = (struct sockaddr_in6*)malloc(sizeof(struct sockaddr_in6));
|
||||
if(retVal==NULL){ILIBCRITICALEXIT(254);}
|
||||
memset(retVal,0,sizeof(struct sockaddr_in6));
|
||||
|
||||
retVal->sin6_family = AF_INET6;
|
||||
retVal->sin6_port = htons(port);
|
||||
ILibInet_pton(AF_INET6, buffer, &(retVal->sin6_addr));
|
||||
return(retVal);
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_FreeSockAddr(void *addr)
|
||||
{
|
||||
free(addr);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void* ILibWrapper_SockAddr_FromBytes(char* buffer, int offset, int length)
|
||||
{
|
||||
struct sockaddr_in6* retVal = (struct sockaddr_in6*)malloc(sizeof(struct sockaddr_in6));
|
||||
if(retVal==NULL){ILIBCRITICALEXIT(254);}
|
||||
memset(retVal, 0, sizeof(struct sockaddr_in6));
|
||||
|
||||
memcpy(retVal, buffer+offset, length);
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// WebRTC
|
||||
//
|
||||
|
||||
__declspec(dllexport) unsigned short ILibWrapper_DLL_WebRTC_StartDefaultLogger(ILibWrapper_WebRTC_ConnectionFactory factory, unsigned short port)
|
||||
{
|
||||
#if defined(_REMOTELOGGING) && defined(_REMOTELOGGINGSERVER)
|
||||
void *chain = ((ILibChain_Link*)factory)->ParentChain;
|
||||
if (ILibChainGetLogger(chain) == NULL)
|
||||
{
|
||||
return(ILibStartDefaultLogger(chain, port));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chain != NULL)
|
||||
{
|
||||
return(ILibWebServer_GetPortNumber((ILibWebServer_ServerToken)(((void**)&((int*)chain)[2])[1])));
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// ConnectionFactory Methods
|
||||
//
|
||||
|
||||
// Creates a Factory object that can create WebRTC Connection objects.
|
||||
__declspec(dllexport) ILibWrapper_WebRTC_ConnectionFactory ILibWrapper_DLL_WebRTC_ConnectionFactory_CreateConnectionFactory(void* chain, unsigned short localPort)
|
||||
{
|
||||
return(ILibWrapper_WebRTC_ConnectionFactory_CreateConnectionFactory(chain, localPort));
|
||||
}
|
||||
|
||||
// Sets the TURN server to use for all WebRTC connections
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_ConnectionFactory_SetTurnServer(ILibWrapper_WebRTC_ConnectionFactory factory, struct sockaddr_in6* turnServer, char* username, char* password, ILibWebRTC_TURN_ConnectFlags turnSetting)
|
||||
{
|
||||
ILibWrapper_WebRTC_ConnectionFactory_SetTurnServer(factory, turnServer, username, (int)strlen(username), password, (int)strlen(password), turnSetting);
|
||||
}
|
||||
|
||||
// Creates an unconnected WebRTC Connection
|
||||
__declspec(dllexport) ILibWrapper_WebRTC_Connection ILibWrapper_DLL_WebRTC_ConnectionFactory_CreateConnection(ILibWrapper_WebRTC_ConnectionFactory factory, ILibWrapper_WebRTC_Connection_OnConnect OnConnectHandler, ILibWrapper_WebRTC_Connection_OnDataChannel OnDataChannelHandler, ILibWrapper_WebRTC_Connection_OnSendOK OnConnectionSendOK)
|
||||
{
|
||||
return(ILibWrapper_WebRTC_ConnectionFactory_CreateConnection(factory, OnConnectHandler, OnDataChannelHandler, OnConnectionSendOK));
|
||||
}
|
||||
|
||||
//
|
||||
// Connection Methods
|
||||
//
|
||||
|
||||
// Set the STUN Servers to use with the WebRTC Connection when gathering candidates
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_Connection_SetStunServers(ILibWrapper_WebRTC_Connection connection, char** serverList, int serverLength)
|
||||
{
|
||||
ILibWrapper_WebRTC_Connection_SetStunServers(connection, serverList, serverLength);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_Connection_AddRemoteCandidate(ILibWrapper_WebRTC_Connection connection, struct sockaddr_in6* candidate)
|
||||
{
|
||||
ILibORTC_AddRemoteCandidate(ILibWrapper_WebRTC_Connection_GetStunModule(connection), ILibWrapper_WebRTC_Connection_GetLocalUsername(connection), candidate);
|
||||
}
|
||||
|
||||
// Non zero value if the underlying SCTP session is established
|
||||
__declspec(dllexport) int ILibWrapper_DLL_WebRTC_Connection_IsConnected(ILibWrapper_WebRTC_Connection connection)
|
||||
{
|
||||
return(ILibWrapper_WebRTC_Connection_IsConnected(connection));
|
||||
}
|
||||
|
||||
// Disconnects the unerlying SCTP session, if it is connected
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_Connection_Disconnect(ILibWrapper_WebRTC_Connection connection)
|
||||
{
|
||||
ILibWrapper_WebRTC_Connection_Disconnect(connection);
|
||||
}
|
||||
|
||||
// Creates a WebRTC Data Channel, using the next available Stream ID
|
||||
__declspec(dllexport) ILibWrapper_WebRTC_DataChannel* ILibWrapper_DLL_WebRTC_DataChannel_Create(ILibWrapper_WebRTC_Connection connection, char* channelName, int channelNameLen, ILibWrapper_WebRTC_DataChannel_OnDataChannelAck OnAckHandler, void *userData)
|
||||
{
|
||||
ILibWrapper_WebRTC_DataChannel* retVal = ILibWrapper_WebRTC_DataChannel_Create(connection, channelName, channelNameLen, OnAckHandler);
|
||||
retVal->userData = userData;
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_DataChannel_Close(ILibWrapper_WebRTC_DataChannel* dataChannel)
|
||||
{
|
||||
ILibWrapper_WebRTC_DataChannel_Close(dataChannel);
|
||||
}
|
||||
|
||||
// Creates a WebRTC Data Channel, using the specified Stream ID
|
||||
__declspec(dllexport) ILibWrapper_WebRTC_DataChannel* ILibWrapper_DLL_WebRTC_DataChannel_CreateEx(ILibWrapper_WebRTC_Connection connection, char* channelName, int channelNameLen, unsigned short streamId, ILibWrapper_WebRTC_DataChannel_OnDataChannelAck OnAckHandler, void* userData)
|
||||
{
|
||||
ILibWrapper_WebRTC_DataChannel* retVal = ILibWrapper_WebRTC_DataChannel_CreateEx(connection, channelName, channelNameLen, streamId, OnAckHandler);
|
||||
retVal->userData = userData;
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_Connection_SetUserData(ILibWrapper_WebRTC_Connection connection, void *user1, void *user2, void *user3)
|
||||
{
|
||||
ILibWrapper_WebRTC_Connection_SetUserData(connection, user1, user2, user3);
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_Connection_GetUserData(ILibWrapper_WebRTC_Connection connection, void **user1, void **user2, void **user3)
|
||||
{
|
||||
ILibWrapper_WebRTC_Connection_GetUserData(connection, user1, user2, user3);
|
||||
}
|
||||
|
||||
//
|
||||
// WebRTC Connection Management
|
||||
//
|
||||
|
||||
// Generate an SDP Offer (WebRTC Initiator)
|
||||
__declspec(dllexport) char* ILibWrapper_DLL_WebRTC_Connection_GenerateOffer(ILibWrapper_WebRTC_Connection connection, ILibWrapper_WebRTC_OnConnectionCandidate onCandidates)
|
||||
{
|
||||
return(ILibWrapper_WebRTC_Connection_GenerateOffer(connection, onCandidates));
|
||||
}
|
||||
|
||||
// Set an SDP Answer/Offer (WebRTC Receiver)
|
||||
__declspec(dllexport) char* ILibWrapper_DLL_WebRTC_Connection_SetOffer(ILibWrapper_WebRTC_Connection connection, char* offer, int offerLen, ILibWrapper_WebRTC_OnConnectionCandidate onCandidates)
|
||||
{
|
||||
return(ILibWrapper_WebRTC_Connection_SetOffer(connection, offer, offerLen, onCandidates));
|
||||
}
|
||||
|
||||
// Generate an udpated SDP offer containing the candidate specified
|
||||
__declspec(dllexport) char* ILibWrapper_DLL_WebRTC_Connection_AddServerReflexiveCandidateToLocalSDP(ILibWrapper_WebRTC_Connection connection, struct sockaddr_in6* candidate)
|
||||
{
|
||||
return(ILibWrapper_WebRTC_Connection_AddServerReflexiveCandidateToLocalSDP(connection, candidate));
|
||||
}
|
||||
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_Connection_Pause(ILibWrapper_WebRTC_Connection connection)
|
||||
{
|
||||
ILibWrapper_WebRTC_Connection_Pause(connection);
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_Connection_Resume(ILibWrapper_WebRTC_Connection connection)
|
||||
{
|
||||
ILibWrapper_WebRTC_Connection_Resume(connection);
|
||||
}
|
||||
|
||||
//
|
||||
// WebRTC Data Channel
|
||||
//
|
||||
|
||||
// Send Binary Data over the specified Data Channel
|
||||
__declspec(dllexport) ILibTransport_DoneState ILibWrapper_DLL_WebRTC_DataChannel_Send(ILibWrapper_WebRTC_DataChannel* dataChannel, char* data, int dataLen)
|
||||
{
|
||||
return(ILibWrapper_WebRTC_DataChannel_Send(dataChannel, data, dataLen));
|
||||
}
|
||||
|
||||
// Send Arbitrary Data over the specified Data Channel. (Must specify the data type)
|
||||
__declspec(dllexport) ILibTransport_DoneState ILibWrapper_DLL_WebRTC_DataChannel_SendEx(ILibWrapper_WebRTC_DataChannel* dataChannel, char* data, int dataLen, int dataType)
|
||||
{
|
||||
return(ILibWrapper_WebRTC_DataChannel_SendEx(dataChannel, data, dataLen, dataType));
|
||||
}
|
||||
|
||||
// Send String Data over the specified Data Channel
|
||||
__declspec(dllexport) ILibTransport_DoneState ILibWrapper_DLL_WebRTC_DataChannel_SendString(ILibWrapper_WebRTC_DataChannel* dataChannel, char* data, int dataLen)
|
||||
{
|
||||
return(ILibWrapper_WebRTC_DataChannel_SendString(dataChannel, data, dataLen));
|
||||
}
|
||||
|
||||
#ifdef _WEBRTCDEBUG
|
||||
// SCTP Instrumentation
|
||||
__declspec(dllexport) void ILibWrapper_DLL_WebRTC_ConnectionFactory_SetSimulatedLossPercentage(void* connectionFactory, int lossPercentage)
|
||||
{
|
||||
ILibWrapper_WebRTC_ConnectionFactory_SetSimulatedLossPercentage(connectionFactory, lossPercentage);
|
||||
}
|
||||
__declspec(dllexport) void ILibWrapper_SCTP_SetTSNCallback(void *dtlsSession, ILibSCTP_OnTSNChanged tsnHandler)
|
||||
{
|
||||
ILibSCTP_SetTSNCallback(dtlsSession, tsnHandler);
|
||||
}
|
||||
|
||||
__declspec(dllexport) int ILibWrapper_DLL_SCTP_Debug_SetDebug(void *connection, char* debugField, ILibSCTP_OnSCTPDebug handler)
|
||||
{
|
||||
return(ILibSCTP_Debug_SetDebugCallback(((void**)connection)[0], debugField, handler));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
1460
webrtc/C# Sample/WebRTC.cs
Normal file
1460
webrtc/C# Sample/WebRTC.cs
Normal file
File diff suppressed because it is too large
Load Diff
78
webrtc/C# Sample/WebRTC.filters
Normal file
78
webrtc/C# Sample/WebRTC.filters
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Microstack">
|
||||
<UniqueIdentifier>{3f87ffbb-0dd7-47e0-b7cc-d27495c5e526}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="core">
|
||||
<UniqueIdentifier>{29d8d56d-879a-4e7e-bb14-1f56896a8a74}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="MicrostackWrapper.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Microstack\ILibAsyncSocket.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Microstack\ILibAsyncUDPSocket.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Microstack\ILibParsers.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Microstack\ILibWebClient.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="core\utils.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Microstack\ILibWebRTC.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MicrostackWrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Microstack\ILibAsyncSocket.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Microstack\ILibAsyncUDPSocket.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Microstack\ILibParsers.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Microstack\ILibWebServer.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\utils.c">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Microstack\ILibWebRTC.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
38
webrtc/C# Sample/WebRTC.h
Normal file
38
webrtc/C# Sample/WebRTC.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright 2014 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// The following ifdef block is the standard way of creating macros which make exporting
|
||||
// from a DLL simpler. All files within this DLL are compiled with the MICROSTACKWRAPPER_EXPORTS
|
||||
// symbol defined on the command line. This symbol should not be defined on any project
|
||||
// that uses this DLL. This way any other project whose source files include this file see
|
||||
// MICROSTACKWRAPPER_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
#ifdef MICROSTACKWRAPPER_EXPORTS
|
||||
#define MICROSTACKWRAPPER_API __declspec(dllexport)
|
||||
#else
|
||||
#define MICROSTACKWRAPPER_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
// This class is exported from the MicrostackWrapper.dll
|
||||
class MICROSTACKWRAPPER_API CMicrostackWrapper {
|
||||
public:
|
||||
CMicrostackWrapper(void);
|
||||
// TODO: add your methods here.
|
||||
};
|
||||
|
||||
extern MICROSTACKWRAPPER_API int nMicrostackWrapper;
|
||||
|
||||
MICROSTACKWRAPPER_API int fnMicrostackWrapper(void);
|
||||
BIN
webrtc/C# Sample/WebRTC.rc
Normal file
BIN
webrtc/C# Sample/WebRTC.rc
Normal file
Binary file not shown.
215
webrtc/C# Sample/WebRTC.vcxproj
Normal file
215
webrtc/C# Sample/WebRTC.vcxproj
Normal file
@@ -0,0 +1,215 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{7777E837-E7A3-481B-8BD2-4C76F639ECFC}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>MicrostackWrapper</RootNamespace>
|
||||
<ProjectName>WebRTC</ProjectName>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\C# Sample\bin\x86\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\C# Sample\obj\x86\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\C# Sample\bin\x64\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\C# Sample\obj\x64\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\C# Sample\bin\x86\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\C# Sample\obj\x86\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\C# Sample\bin\x64\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\C# Sample\obj\x64\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MICROSTACKWRAPPER_EXPORTS;MICROSTACK_NO_STDAFX;WINSOCK2;_MSC_PLATFORM_TOOLSET_$(PlatformToolset);_CONSOLE;_REMOTELOGGING;_REMOTELOGGINGSERVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\openssl\include;..\..\openssl\include\openssl;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>Crypt32.lib;..\..\openssl\libstatic\libssl32MTd.lib;..\..\openssl\libstatic\libcrypto32MTd.lib;DbgHelp.lib;ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_WINDOWS;_USRDLL;MICROSTACKWRAPPER_EXPORTS;MICROSTACK_NO_STDAFX;WINSOCK2;_MSC_PLATFORM_TOOLSET_$(PlatformToolset);_CONSOLE;_REMOTELOGGING;_REMOTELOGGINGSERVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\openssl\include;..\..\openssl\include\openssl;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>Crypt32.lib;..\..\openssl\libstatic\libcrypto64MTd.lib;..\..\openssl\libstatic\libssl64MTd.lib;DbgHelp.lib;ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MICROSTACKWRAPPER_EXPORTS;MICROSTACK_NO_STDAFX;WINSOCK2;_MSC_PLATFORM_TOOLSET_$(PlatformToolset);_CONSOLE;_REMOTELOGGING;_REMOTELOGGINGSERVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\openssl\include;..\..\openssl\include\openssl;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>Crypt32.lib;..\..\openssl\libstatic\libcrypto32MT.lib;..\..\openssl\libstatic\libssl32MT.lib;DbgHelp.lib;ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_WINDOWS;_USRDLL;MICROSTACKWRAPPER_EXPORTS;MICROSTACK_NO_STDAFX;WINSOCK2;_MSC_PLATFORM_TOOLSET_$(PlatformToolset);_CONSOLE;_REMOTELOGGING;_REMOTELOGGINGSERVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\openssl\include;..\..\openssl\include\openssl;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>Crypt32.lib;..\..\openssl\libstatic\libcrypto64MT.lib;..\..\openssl\libstatic\libssl64MT.lib;DbgHelp.lib;ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\microstack\ILibCrypto.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibAsyncServerSocket.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibAsyncSocket.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibAsyncUDPSocket.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibParsers.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibRemoteLogging.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibWebClient.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibWebRTC.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibWebServer.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibWrapperWebRTC.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="WebRTC.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\microstack\ILibCrypto.c" />
|
||||
<ClCompile Include="..\..\microstack\ILibAsyncServerSocket.c" />
|
||||
<ClCompile Include="..\..\microstack\ILibAsyncSocket.c" />
|
||||
<ClCompile Include="..\..\microstack\ILibAsyncUDPSocket.c" />
|
||||
<ClCompile Include="..\..\microstack\ILibParsers.c" />
|
||||
<ClCompile Include="..\..\microstack\ILibRemoteLogging.c" />
|
||||
<ClCompile Include="..\..\microstack\ILibWebClient.c" />
|
||||
<ClCompile Include="..\..\microstack\ILibWebRTC.c" />
|
||||
<ClCompile Include="..\..\microstack\ILibWebServer.c" />
|
||||
<ClCompile Include="..\..\microstack\ILibWrapperWebRTC.c" />
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
</PrecompiledHeader>
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="WebRTC.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="WebRTC.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
86
webrtc/C# Sample/WebRTC.vcxproj.filters
Normal file
86
webrtc/C# Sample/WebRTC.vcxproj.filters
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="stdafx.cpp" />
|
||||
<ClCompile Include="WebRTC.cpp" />
|
||||
<ClCompile Include="..\..\microstack\ILibAsyncServerSocket.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\microstack\ILibAsyncSocket.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\microstack\ILibAsyncUDPSocket.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\microstack\ILibCrypto.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\microstack\ILibParsers.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\microstack\ILibRemoteLogging.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\microstack\ILibWebClient.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\microstack\ILibWebRTC.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\microstack\ILibWebServer.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\microstack\ILibWrapperWebRTC.c">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="WebRTC.h" />
|
||||
<ClInclude Include="..\..\microstack\ILibAsyncServerSocket.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\microstack\ILibAsyncSocket.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\microstack\ILibAsyncUDPSocket.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\microstack\ILibCrypto.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\microstack\ILibParsers.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\microstack\ILibRemoteLogging.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\microstack\ILibWebClient.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\microstack\ILibWebRTC.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\microstack\ILibWebServer.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\microstack\ILibWrapperWebRTC.h">
|
||||
<Filter>Microstack</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Microstack">
|
||||
<UniqueIdentifier>{6a592a1b-34c3-4c4c-8bd1-72082faa84d2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Core">
|
||||
<UniqueIdentifier>{481014fb-4e91-4ae7-8f41-0a1f05dad9df}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="WebRTC.rc" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
19
webrtc/C# Sample/dllmain.cpp
Normal file
19
webrtc/C# Sample/dllmain.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
// dllmain.cpp : Defines the entry point for the DLL application.
|
||||
#include "stdafx.h"
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
14
webrtc/C# Sample/resource.h
Normal file
14
webrtc/C# Sample/resource.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by WebRTC.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
8
webrtc/C# Sample/stdafx.cpp
Normal file
8
webrtc/C# Sample/stdafx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// MicrostackWrapper.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
16
webrtc/C# Sample/stdafx.h
Normal file
16
webrtc/C# Sample/stdafx.h
Normal file
@@ -0,0 +1,16 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
8
webrtc/C# Sample/targetver.h
Normal file
8
webrtc/C# Sample/targetver.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// Including SDKDDKVer.h defines the highest available Windows platform.
|
||||
|
||||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
||||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
||||
|
||||
#include <SDKDDKVer.h>
|
||||
142
webrtc/C# Sample/webrtcpassivesample.html
Normal file
142
webrtc/C# Sample/webrtcpassivesample.html
Normal file
@@ -0,0 +1,142 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<!--
|
||||
Copyright 2014 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>WebRTC Sample</title>
|
||||
</head>
|
||||
<body onload="start()" onunload="stop()">
|
||||
<span id="outputtext"></span>
|
||||
<hr />
|
||||
<textarea id="inputtext" style="width:100%" onkeypress="onUserKeyPressEvent(event)"></textarea>
|
||||
<script type="text/javascript">
|
||||
var connection = null;
|
||||
var datachannel = null;
|
||||
var configuration = { "iceServers": [/*{{{ICESERVERS}}}*/] };
|
||||
var currentoffer = null;
|
||||
var requester;
|
||||
var sdp = "";
|
||||
var outputtextbox = document.getElementById("outputtext");
|
||||
var inputtextbox = document.getElementById("inputtext");
|
||||
var remoteSDP = "/*{{{SDP}}}*/";
|
||||
|
||||
function stop() { connection.close(); }
|
||||
|
||||
function start() {
|
||||
msg("Starting...");
|
||||
|
||||
if (typeof mozRTCPeerConnection !== 'undefined') { connection = new mozRTCPeerConnection(configuration); }
|
||||
else if (typeof RTCPeerConnection !== 'undefined') { connection = new RTCPeerConnection(configuration); }
|
||||
else if (typeof webkitRTCPeerConnection !== 'undefined') { connection = new webkitRTCPeerConnection(configuration); }
|
||||
else return false;
|
||||
|
||||
connection.ondatachannel = onNewDataChannel;
|
||||
connection.onicecandidate = onIceCandidate;
|
||||
connection.oniceconnectionstatechange = function ()
|
||||
{
|
||||
if (connection.iceConnectionState == 'disconnected') {
|
||||
msg('DISCONNECTED');
|
||||
alert('This session has closed!');
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var ax;
|
||||
var rSDP = window.atob(remoteSDP);
|
||||
|
||||
//setTimeout(function () {
|
||||
if (typeof mozRTCSessionDescription !== 'undefined') { ax = new mozRTCSessionDescription({ type: "offer", sdp: rSDP }) } else { ax = new RTCSessionDescription({ type: "offer", sdp: rSDP }) }
|
||||
connection.setRemoteDescription(ax, onSetRemoteDescriptionDone, onError);
|
||||
//}, 2000);
|
||||
//alert(rSDP);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function onNewDataChannel(e)
|
||||
{
|
||||
msg("Connected.");
|
||||
msg("Channel [" + e.channel.label + "] created");
|
||||
datachannel = e.channel;
|
||||
datachannel.onmessage = function (event) { msg("Remote [" + event.currentTarget.label + "]: " + event.data); }
|
||||
datachannel.onclose = function (event) { msg("Channel [" + event.currentTarget.label + "] was closed by remote"); }
|
||||
}
|
||||
|
||||
function onUserKeyPressEvent(event) {
|
||||
if (event.keyCode == 13) {
|
||||
datachannel.send(inputtextbox.value);
|
||||
msg("Local: " + inputtextbox.value);
|
||||
inputtextbox.value = "";
|
||||
if (e.preventDefault) e.preventDefault();
|
||||
if (e.stopPropagation) e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onIceCandidate(e) {
|
||||
if (e.candidate == null) {
|
||||
if (sdp == "") {
|
||||
msg("SDP ERROR!");
|
||||
return;
|
||||
}
|
||||
msg('Posting WebRTC offer...');
|
||||
requester = new XMLHttpRequest();
|
||||
requester.onload = initiatorResponse;
|
||||
requester.onerror = initiatorErrorResponse;
|
||||
requester.open("POST", "http://{{{OFFER_URL}}}", true);
|
||||
requester.send(sdp);
|
||||
|
||||
return;
|
||||
}
|
||||
currentoffer.sdp += ("a=" + e.candidate.candidate + "\r\n");
|
||||
sdp = currentoffer.sdp;
|
||||
}
|
||||
|
||||
function onCandidateAdded(e) { debug('onCandidateAdded: ' + e); }
|
||||
|
||||
function onSetLocalDescriptionDone() { }
|
||||
|
||||
function initiatorResponse() {
|
||||
if (requester.status != 200) {
|
||||
msg('ERROR: ' + requester.status);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function initiatorErrorResponse() { msg('Could not contact server.'); }
|
||||
|
||||
function onSetRemoteDescriptionDone()
|
||||
{
|
||||
connection.createAnswer(onAnswerDone, onError);
|
||||
}
|
||||
function onAnswerDone(answer) {
|
||||
currentoffer = answer;
|
||||
sdp = currentoffer.sdp;
|
||||
|
||||
connection.setLocalDescription(answer, onSetLocalDescriptionDone, onError);
|
||||
currentanswer = answer;
|
||||
}
|
||||
|
||||
function stop() { connection.close(); }
|
||||
function onError(e) { if (e.message) alert("onError: " + e.message); else alert(e); }
|
||||
function debug(m) { /* console.log(m); */ }
|
||||
function msg(m) { outputtextbox.innerHTML += (m + "<br />"); }
|
||||
|
||||
</script>
|
||||
</body>
|
||||
155
webrtc/C# Sample/webrtcsample.html
Normal file
155
webrtc/C# Sample/webrtcsample.html
Normal file
@@ -0,0 +1,155 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<!--
|
||||
Copyright 2014 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>WebRTC Sample</title>
|
||||
</head>
|
||||
<body onload="start()" onunload="stop()">
|
||||
<span id="outputtext"></span>
|
||||
<span id="debugText"></span>
|
||||
<hr />
|
||||
<textarea id="inputtext" style="width:100%" onkeypress="onUserKeyPressEvent(event)"></textarea>
|
||||
<script type="text/javascript">
|
||||
var connection = null;
|
||||
var datachannel = null;
|
||||
var configuration = { "iceServers": [/*{{{ICESERVERS}}}*/] };
|
||||
var currentoffer = null;
|
||||
var requester;
|
||||
var sdp = "";
|
||||
var outputtextbox = document.getElementById("outputtext");
|
||||
var inputtextbox = document.getElementById("inputtext");
|
||||
var debugtextbox = document.getElementById("debugText");
|
||||
var startTime = null;
|
||||
var bytesReceived = 0;
|
||||
var totalReceived = 0;
|
||||
function stop() { connection.close(); }
|
||||
|
||||
function start() {
|
||||
msg("Starting...");
|
||||
|
||||
if (typeof mozRTCPeerConnection !== 'undefined') { connection = new mozRTCPeerConnection(configuration); }
|
||||
else if (typeof RTCPeerConnection !== 'undefined') { connection = new RTCPeerConnection(configuration); }
|
||||
else if (typeof webkitRTCPeerConnection !== 'undefined') { connection = new webkitRTCPeerConnection(configuration); }
|
||||
else return false;
|
||||
|
||||
datachannel = connection.createDataChannel("sampleDataChannel", { reliable: true });
|
||||
datachannel.onmessage = function (event) { msg("Remote [" + event.currentTarget.label + "]: " + event.data); }
|
||||
datachannel.onopen = function () { msg("Local Data channel creation [sampleDataChannel] was successful"); };
|
||||
datachannel.onclose = function (event) { msg("Channel [" + event.currentTarget.label + "] was closed by remote"); }
|
||||
|
||||
connection.ondatachannel = onNewDataChannel;
|
||||
connection.onicecandidate = onIceCandidate;
|
||||
connection.createOffer(onOfferDone, onError, { mandatory: { OfferToReceiveAudio: false, OfferToReceiveVideo: false } });
|
||||
connection.oniceconnectionstatechange = function ()
|
||||
{
|
||||
if (connection.iceConnectionState == 'disconnected') {
|
||||
msg('DISCONNECTED');
|
||||
//alert('This session has closed!');
|
||||
//window.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onNewDataChannel(e) {
|
||||
msg("Channel [" + e.channel.label + "] created by remote peer");
|
||||
datachannel = e.channel;
|
||||
datachannel.onmessage = onMessage;
|
||||
datachannel.onclose = function (event) { msg("Channel [" + event.currentTarget.label + "] was closed by remote"); }
|
||||
}
|
||||
|
||||
function onMessage(event)
|
||||
{
|
||||
if (event.currentTarget.label != "DebugChannel") {
|
||||
msg("Remote [" + event.currentTarget.label + "]: " + event.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startTime == null)
|
||||
{
|
||||
startTime = Date.now();
|
||||
}
|
||||
else if (Date.now() > (startTime + 10000))
|
||||
{
|
||||
startTime = Date.now();
|
||||
bytesReceived = 0;
|
||||
}
|
||||
|
||||
bytesReceived += event.data.byteLength;
|
||||
totalReceived += event.data.byteLength;
|
||||
|
||||
var rate = 1000 * (bytesReceived / (Date.now() - startTime));
|
||||
rate = rate / 1024;
|
||||
dbgMsg("Received " + totalReceived/1024 + " Kb @ " + rate.toFixed(2) + " Kbytes per second");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function onUserKeyPressEvent(event) {
|
||||
if (event.keyCode == 13) {
|
||||
datachannel.send(inputtextbox.value);
|
||||
msg("Local: " + inputtextbox.value);
|
||||
inputtextbox.value = "";
|
||||
if (e.preventDefault) e.preventDefault();
|
||||
if (e.stopPropagation) e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onIceCandidate(e) {
|
||||
if (e.candidate == null) {
|
||||
msg('Posting WebRTC offer...');
|
||||
requester = new XMLHttpRequest();
|
||||
requester.onload = initiatorResponse;
|
||||
requester.onerror = initiatorErrorResponse;
|
||||
requester.open("POST", "http://{{{OFFER_URL}}}", true);
|
||||
requester.send(sdp);
|
||||
return;
|
||||
}
|
||||
currentoffer.sdp += ("a=" + e.candidate.candidate + "\r\n");
|
||||
sdp = currentoffer.sdp;
|
||||
}
|
||||
|
||||
function onCandidateAdded(e) { debug('onCandidateAdded: ' + e); }
|
||||
|
||||
function onOfferDone(offer) {
|
||||
// debug(offer.sdp);
|
||||
currentoffer = offer;
|
||||
connection.setLocalDescription(offer, onSetLocalDescriptionDone, onError);
|
||||
}
|
||||
|
||||
function onSetLocalDescriptionDone() { }
|
||||
|
||||
function initiatorResponse() {
|
||||
msg('Got answer, connecting...');
|
||||
var ax;
|
||||
if (typeof mozRTCSessionDescription !== 'undefined') { ax = new mozRTCSessionDescription({ type: "answer", sdp: requester.responseText }) } else { ax = new RTCSessionDescription({ type: "answer", sdp: requester.responseText }) }
|
||||
connection.setRemoteDescription(ax, onSetRemoteDescriptionDone, onError);
|
||||
}
|
||||
|
||||
function initiatorErrorResponse() { msg('Could not contact server.'); }
|
||||
|
||||
function onSetRemoteDescriptionDone() { debug('setRemoteDescription() completed'); }
|
||||
function stop() { connection.close(); }
|
||||
function onError(e) { if (e.message) alert("onError: " + e.message); else alert(e); }
|
||||
function debug(m) { /* console.log(m); */ }
|
||||
function msg(m) { outputtextbox.innerHTML += (m + "<br />"); }
|
||||
function dbgMsg(m) { debugtextbox.innerHTML = m; }
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user