Skip to content

Commit 37e1e30

Browse files
committed
Added some extra options to webrtc webcam server demo.
1 parent 80c7963 commit 37e1e30

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

examples/WebRTCExamples/WebRTCWebcamServer/Program.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@
2626
using Serilog.Extensions.Logging;
2727
using SIPSorcery.Media;
2828
using SIPSorcery.Net;
29+
using SIPSorceryMedia.Abstractions;
2930
using SIPSorceryMedia.Encoders;
3031
using SIPSorceryMedia.FFmpeg;
3132
using SIPSorceryMedia.Windows;
33+
using Vpx.Net;
3234
using WebSocketSharp.Server;
3335

3436
namespace demo
3537
{
3638
class Program
3739
{
40+
private const string LINUX_FFMPEG_LIB_PATH = "/usr/local/lib/";
41+
3842
private const int WEBSOCKET_PORT = 8081;
3943
private const string STUN_URL = "stun:stun.sipsorcery.com";
4044
//private const string WEBCAM_NAME = "Logitech QuickCam Pro 9000";
@@ -45,7 +49,6 @@ class Program
4549
static void Main()
4650
{
4751
Console.WriteLine("WebRTC Webcam Send Demo");
48-
Console.WriteLine("Press ctrl-c to exit.");
4952

5053
logger = AddConsoleLogger();
5154

@@ -65,6 +68,16 @@ static void Main()
6568
//}
6669
//await winVideoEP.StartVideo();
6770

71+
if (Environment.OSVersion.Platform == PlatformID.Unix)
72+
{
73+
FFmpegInit.Initialise(FfmpegLogLevelEnum.AV_LOG_VERBOSE, LINUX_FFMPEG_LIB_PATH, logger);
74+
}
75+
else
76+
{
77+
FFmpegInit.Initialise(FfmpegLogLevelEnum.AV_LOG_VERBOSE, null, logger);
78+
}
79+
80+
6881
// Start web socket.
6982
Console.WriteLine("Starting web socket server...");
7083
var webSocketServer = new WebSocketServer(IPAddress.Any, WEBSOCKET_PORT);
@@ -94,12 +107,14 @@ private static async Task<RTCPeerConnection> CreatePeerConnection()
94107
};
95108
var pc = new RTCPeerConnection(config);
96109

97-
WindowsVideoEndPoint winVideoEP = new WindowsVideoEndPoint(new VpxVideoEncoder(), WEBCAM_NAME);
110+
//WindowsVideoEndPoint winVideoEP = new WindowsVideoEndPoint(new VP8Codec(), WEBCAM_NAME);
111+
//WindowsVideoEndPoint winVideoEP = new WindowsVideoEndPoint(new VP8Codec(), WEBCAM_NAME, 960, 720, 30);
112+
//WindowsVideoEndPoint winVideoEP = new WindowsVideoEndPoint(new VpxVideoEncoder(), WEBCAM_NAME);
113+
//WindowsVideoEndPoint winVideoEP = new WindowsVideoEndPoint(new VpxVideoEncoder(), WEBCAM_NAME, 1920, 1080, 30);
98114
//WindowsVideoEndPoint winVideoEP = new WindowsVideoEndPoint(new FFmpegVideoEncoder(), WEBCAM_NAME);
115+
WindowsVideoEndPoint winVideoEP = new WindowsVideoEndPoint(new FFmpegVideoEncoder(), WEBCAM_NAME, 1920, 1080, 30);
99116
//WindowsVideoEndPoint winVideoEP = new WindowsVideoEndPoint(WEBCAM_NAME, 1920, 1080, 30);
100-
//winVideoEP.RestrictFormats(x => x.Codec == SIPSorceryMedia.Abstractions.V1.VideoCodecsEnum.H264);
101-
102-
117+
winVideoEP.RestrictFormats(x => x.Codec == VideoCodecsEnum.H264);
103118

104119
bool initResult = await winVideoEP.InitialiseVideoSourceDevice();
105120
if (!initResult)

examples/WebRTCExamples/WebRTCWebcamServer/WebRTCWebcamServer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19+
<ProjectReference Include="..\..\..\src\SIPSOrcery.VP8\SIPSorcery.VP8.csproj" />
1920
<ProjectReference Include="..\..\..\src\SIPSorcery\SIPSorcery.csproj" />
2021
<ProjectReference Include="..\..\..\src\SIPSorceryMedia.FFmpeg\SIPSorceryMedia.FFmpeg.csproj" />
2122
<ProjectReference Include="..\..\..\src\SIPSorceryMedia.Windows\SIPSorceryMedia.Windows.csproj" />

0 commit comments

Comments
 (0)