From 93e692df9e4df4f5597ac6b2186ac3f578f5264f Mon Sep 17 00:00:00 2001 From: ziomus5555 Date: Sat, 2 Nov 2019 21:06:44 +0100 Subject: [PATCH] Camera settings --- Squirrowse.Client/Service/CameraService.cs | 11 +++++++++-- Squirrowse.Client/Service/ICameraService.cs | 2 +- Squirrowse.Client/Service/IStreamService.cs | 2 +- Squirrowse.Client/Service/StreamService.cs | 22 ++++++++++++++++----- Squirrowse.Client/Squirrowse.Client.csproj | 4 ++++ 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Squirrowse.Client/Service/CameraService.cs b/Squirrowse.Client/Service/CameraService.cs index 669f63b..5cdbe0c 100644 --- a/Squirrowse.Client/Service/CameraService.cs +++ b/Squirrowse.Client/Service/CameraService.cs @@ -8,9 +8,16 @@ namespace Squirrowse.Client.Service { public class CameraService : ICameraService { - public VideoCapture GetCamera() + public VideoCapture GetCamera(int height=480,int widght=640,double fps=15f,bool disposable = false) { - throw new NotImplementedException(); + + var cam = new VideoCapture(CaptureDevice.Any); + cam.Fps = fps; + cam.FrameHeight = height; + cam.FrameWidth = widght; + cam.IsEnabledDispose = disposable; + + return cam; } public Task GetFrame(VideoCapture video) diff --git a/Squirrowse.Client/Service/ICameraService.cs b/Squirrowse.Client/Service/ICameraService.cs index ae3ad18..3849785 100644 --- a/Squirrowse.Client/Service/ICameraService.cs +++ b/Squirrowse.Client/Service/ICameraService.cs @@ -8,7 +8,7 @@ namespace Squirrowse.Client.Service { public interface ICameraService { - public VideoCapture GetCamera(); + public VideoCapture GetCamera(int height = 480, int widght = 640, double fps = 15f, bool disposable = false); public Task GetFrame(VideoCapture video); } } diff --git a/Squirrowse.Client/Service/IStreamService.cs b/Squirrowse.Client/Service/IStreamService.cs index 2e26fc0..a56662e 100644 --- a/Squirrowse.Client/Service/IStreamService.cs +++ b/Squirrowse.Client/Service/IStreamService.cs @@ -8,7 +8,7 @@ namespace Squirrowse.Client.Service public interface IStreamService { Task SendStreamAsync(IAsyncEnumerable asb); - + Task SayHello(); } } diff --git a/Squirrowse.Client/Service/StreamService.cs b/Squirrowse.Client/Service/StreamService.cs index 0a3875a..c9292f6 100644 --- a/Squirrowse.Client/Service/StreamService.cs +++ b/Squirrowse.Client/Service/StreamService.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.SignalR.Client; using Microsoft.Extensions.Logging; +using Squirrowse.Core.Models; using System; using System.Collections.Generic; using System.Text; @@ -11,27 +12,38 @@ namespace Squirrowse.Client.Service { private readonly IConnectionManager connectionManager; private readonly ILogger logger; - + private readonly HubConnection session; public StreamService(ILogger logger, IConnectionManager connectionManager) { this.connectionManager = connectionManager; this.logger = logger; + session = connectionManager.Connect(); + session.StartAsync().ConfigureAwait(false); + } + + public async Task SayHello() + { + try + { + await session.SendAsync("AddToGroup",Groups.debug); + } + finally + { + + } } public async Task SendStreamAsync(IAsyncEnumerable asb) { - var con = connectionManager.Connect(); try { logger.LogInformation($"{nameof(SendStreamAsync)} Start stream"); - await con.StartAsync(); - await con.SendAsync("UploadByteStream", asb, default); + await session.SendAsync("UploadByteStream", asb, default); } finally { logger.LogInformation($"{nameof(SendStreamAsync)} End stream"); - await con.StopAsync(); } } } diff --git a/Squirrowse.Client/Squirrowse.Client.csproj b/Squirrowse.Client/Squirrowse.Client.csproj index 81c0779..a134225 100644 --- a/Squirrowse.Client/Squirrowse.Client.csproj +++ b/Squirrowse.Client/Squirrowse.Client.csproj @@ -11,4 +11,8 @@ + + + +