Skip to content

Commit

Permalink
Update to SDK version 15.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-miniailov committed Jan 22, 2024
1 parent 0e58bbd commit 5d22235
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MainWindow()
private async void Window_Loaded(object sender, RoutedEventArgs e)

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 35 in Media Blocks SDK/WPF/CSharp/Simple Player Core Demo/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
// We have to initialize the engine on start
MediaBlocksPipeline.InitSDK();
VisioForgeX.InitSDK();

_timer = new System.Timers.Timer(500);
_timer.Elapsed += _timer_Elapsed;
Expand Down Expand Up @@ -187,6 +187,8 @@ private async void Window_Closing(object sender, System.ComponentModel.CancelEve
_timer.Stop();

await DestroyEngineAsync();

VisioForgeX.DestroySDK();
}

private void tbVolume_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
Expand Down
61 changes: 5 additions & 56 deletions Media Blocks SDK/iOS/SimpleVideoCapture/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
using AVFoundation;
using Photos;
using Photos;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using UIKit;

using VisioForge.Core;
using VisioForge.Core.GStreamer.Base;
using VisioForge.Core.GStreamer.Helpers;
using VisioForge.Core.MediaBlocks;
using VisioForge.Core.MediaBlocks.AudioEncoders;
using VisioForge.Core.MediaBlocks.AudioRendering;
using VisioForge.Core.MediaBlocks.Sinks;
using VisioForge.Core.MediaBlocks.Sources;
using VisioForge.Core.MediaBlocks.Special;
using VisioForge.Core.MediaBlocks.VideoEncoders;
using VisioForge.Core.MediaBlocks.VideoProcessing;
using VisioForge.Core.MediaBlocks.VideoRendering;
using VisioForge.Core.Types;
using VisioForge.Core.Types.Events;
using VisioForge.Core.Types.X;
using VisioForge.Core.Types.X.AudioEncoders;
using VisioForge.Core.Types.X.Sinks;
using VisioForge.Core.Types.X.Sources;
Expand All @@ -30,8 +23,6 @@ namespace SimpleVideoCapture;
[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate {

private DeviceEnumerator _deviceEnumerator;

private MediaBlocksPipeline _pipeline;

private string _filename;
Expand Down Expand Up @@ -64,16 +55,8 @@ public class AppDelegate : UIApplicationDelegate {

private VideoCaptureDeviceInfo[] _cameras;

private bool _isPreview;

private VideoView _videoView;

// private SoundRecorder _recorder;

//private CustomImageView _videoView;

private BufferSinkBlock _audioSampleGrabber;

public override UIWindow? Window {
get;
set;
Expand Down Expand Up @@ -104,20 +87,15 @@ private void ShowToast(UIView view, string message)

private async Task CreateEngineAsync(bool capture)
{
MediaBlocksPipeline.InitSDK();

if (_deviceEnumerator == null)
{
_deviceEnumerator = new DeviceEnumerator();
}

VisioForgeX.InitSDK();

_pipeline = new MediaBlocksPipeline();
_pipeline.OnError += _pipeline_OnError;

// video source
if (_cameras == null)
{
_cameras = await _deviceEnumerator.VideoSourcesAsync();
_cameras = await DeviceEnumerator.Shared.VideoSourcesAsync();
}

if (_cameras.Length == 0)
Expand Down Expand Up @@ -312,35 +290,6 @@ private void AddButtons(UIView parent)
parent!.AddSubview(btTest);
}

private async Task TestAsync()
{
await _pipeline.StopAsync();

//_player = new StreamAudioPlayer();
//_player.Start();

//var data = new byte[1024 * 1024];
//Random.Shared.NextBytes(data);

//_player.PushData(data);

//_testPlayer = new AppSrcTest();
//_testPlayer.Start();

// _testSource = new AudioSourceTest();
// await _testSource.StartAsync();

// _recorder = new SoundRecorder(48000, 2);
// _recorder.StartRecording();

Thread.Sleep(1000);

InvokeOnMainThread(() =>
{
SaveVideoToPhotoLibrary(_filename);
});
}

public void SaveVideoToPhotoLibrary(string filePath)
{
PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public override void DidFinishLaunching (NSNotification notification)
public override void WillTerminate (NSNotification notification)
{
// Insert code here to tear down your application
VisioForge.Core.VisioForgeX.DestroySDK();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public partial class ViewController : NSViewController {

private AudioRendererBlock _audioRenderer;

private DeviceEnumerator _deviceEnumerator;

private Timer _timer;

private bool _timerFlag = false;
Expand All @@ -42,9 +40,7 @@ public override void ViewDidLoad ()
_videoView = new VideoViewGL(new CGRect(0, 0, videoViewHost.Bounds.Width, videoViewHost.Bounds.Height));
this.videoViewHost.AddSubview(_videoView);

MediaBlocksPipeline.InitSDK();

_deviceEnumerator = new DeviceEnumerator();
VisioForgeX.InitSDK();

edFilename.StringValue = "/Users/roman/Documents/video.mp4";

Expand Down Expand Up @@ -125,7 +121,7 @@ private async Task StartAsync()

if (sourceSettings.RenderAudio)
{
_audioRenderer = new AudioRendererBlock(_deviceEnumerator);
_audioRenderer = new AudioRendererBlock();
_pipeline.Connect(_source.AudioOutput, _audioRenderer.Input);
}

Expand Down
5 changes: 3 additions & 2 deletions Media Blocks SDK/macOS/SimpleVideoCaptureMBMac/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public override void DidFinishLaunching (NSNotification notification)

public override void WillTerminate (NSNotification notification)
{
// Insert code here to tear down your application
}
// Insert code here to tear down your application
VisioForge.Core.VisioForgeX.DestroySDK();
}
}

23 changes: 10 additions & 13 deletions Media Blocks SDK/macOS/SimpleVideoCaptureMBMac/ViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace SimpleVideoCaptureMBMac;

public partial class ViewController : NSViewController {

private MediaBlocksPipeline _pipeline;

private VideoViewGL _videoView;
Expand All @@ -25,8 +26,6 @@ public partial class ViewController : NSViewController {

private SystemAudioSourceBlock _audioSource;

private DeviceEnumerator _deviceEnumerator;

private Timer _timer;

private bool _timerFlag = false;
Expand All @@ -50,8 +49,6 @@ public override void ViewDidLoad ()
Debug.WriteLine($"Camera access: {granted}");
});

//MediaBlocksPipeline.InitSDK();

//_deviceEnumerator = new DeviceEnumerator();

//InvokeOnMainThread((Action)(async () =>
Expand All @@ -65,7 +62,7 @@ public override void ViewDidLoad ()
private async Task LoadDevicesAsync()
{
// video sources
var videoSources = await _deviceEnumerator.VideoSourcesAsync();
var videoSources = await DeviceEnumerator.Shared.VideoSourcesAsync();
cbVideoSource.RemoveAll();

foreach (var item in videoSources)
Expand All @@ -84,7 +81,7 @@ private async Task LoadDevicesAsync()
cbVideoSource_SelectionChanged(cbVideoSource, EventArgs.Empty);

// audio sources
var audioSources = await _deviceEnumerator.AudioSourcesAsync();
var audioSources = await DeviceEnumerator.Shared.AudioSourcesAsync();
cbAudioSource.RemoveAll();

foreach (var item in audioSources)
Expand All @@ -102,7 +99,7 @@ private async Task LoadDevicesAsync()
cbAudioSource_SelectionChanged(cbAudioSource, EventArgs.Empty);

// audio outputs
var audioOutputs = await _deviceEnumerator.AudioOutputsAsync();
var audioOutputs = await DeviceEnumerator.Shared.AudioOutputsAsync();
cbAudioOutput.RemoveAll();

foreach (var item in audioOutputs)
Expand All @@ -126,7 +123,7 @@ private async void cbVideoFormat_SelectionChanged(object sender, EventArgs e)
var format = cbVideoFormat.SelectedValue.ToString();
if (!string.IsNullOrEmpty(deviceName) && !string.IsNullOrEmpty(format))
{
var device = (await _deviceEnumerator.VideoSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
var device = (await DeviceEnumerator.Shared.VideoSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
if (device != null)
{
var formatItem = device.VideoFormats.FirstOrDefault(x => x.Name == format);
Expand Down Expand Up @@ -158,7 +155,7 @@ private async void cbAudioSource_SelectionChanged(object sender, EventArgs e)
{
cbAudioFormat.RemoveAll();

var device = (await _deviceEnumerator.AudioSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
var device = (await DeviceEnumerator.Shared.AudioSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
if (device != null)
{
foreach (var format in device.Formats)
Expand All @@ -185,7 +182,7 @@ private async void cbVideoSource_SelectionChanged(object sender, EventArgs e)
{
cbVideoFormat.RemoveAll();

var device = (await _deviceEnumerator.VideoSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
var device = (await DeviceEnumerator.Shared.VideoSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
if (device != null)
{
foreach (var item in device.VideoFormats)
Expand Down Expand Up @@ -262,7 +259,7 @@ private async Task StartAsync()
var format = cbVideoFormat.StringValue;
if (!string.IsNullOrEmpty(deviceName) && !string.IsNullOrEmpty(format))
{
var device = (await _deviceEnumerator.VideoSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
var device = (await DeviceEnumerator.Shared.VideoSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
if (device != null)
{
var formatItem = device.VideoFormats.FirstOrDefault(x => x.Name == format);
Expand All @@ -287,7 +284,7 @@ private async Task StartAsync()
format = cbAudioFormat.StringValue;
if (!string.IsNullOrEmpty(deviceName))
{
var device = (await _deviceEnumerator.AudioSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
var device = (await DeviceEnumerator.Shared.AudioSourcesAsync()).FirstOrDefault(x => x.DisplayName == deviceName);
if (device != null)
{
var formatItem = device.Formats.FirstOrDefault(x => x.Name == format);
Expand All @@ -304,7 +301,7 @@ private async Task StartAsync()
_videoRenderer = new VideoRendererBlock(_pipeline, _videoView);

// audio renderer
_audioRenderer = new AudioRendererBlock((await _deviceEnumerator.AudioOutputsAsync()).Where(device => device.DisplayName == cbAudioOutput.StringValue).First());
_audioRenderer = new AudioRendererBlock((await DeviceEnumerator.Shared.AudioOutputsAsync()).Where(device => device.DisplayName == cbAudioOutput.StringValue).First());

// capture
if (capture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public MainWindow()
#endif

// We have to initialize the engine on start
// MediaBlocksPipeline.InitSDK();

Activated += MainWindow_Activated;
Closing += MainWindow_Closing;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ private void Window_Destroying(object sender, EventArgs e)

private void MainPage_Loaded(object sender, EventArgs e)
{
#if __ANDROID__
_player = new MediaPlayerCoreX(videoView, Microsoft.Maui.ApplicationModel.Platform.CurrentActivity);
#else
var handler = videoView.Handler as VisioForge.Core.UI.MAUI.VideoViewXHandler;
_player = new MediaPlayerCoreX(handler.VideoView);
#endif
_player = new MediaPlayerCoreX(videoView);

_player.OnError += _player_OnError;
var audioOutputs = _player.Audio_OutputDevicesAsync(AudioOutputDeviceAPI.Default).Result;
Expand Down
1 change: 0 additions & 1 deletion Media Player SDK/WPF/CSharp/madVR Demo/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public MainWindow()
InitializeComponent();
}


private void timer1_Tick()
{
_timer.Tag = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public partial class MainWindow : Window, IDisposable

private VideoCaptureCoreX VideoCapture1;

private DeviceEnumerator _deviceEnumerator;

private bool disposedValue;

#region Controls
Expand Down Expand Up @@ -66,12 +64,11 @@ public MainWindow()
#endif

// We have to initialize the engine on start
MediaBlocksPipeline.InitSDK();
VisioForgeX.InitSDK();

_deviceEnumerator = DeviceEnumerator.GetShared();
_deviceEnumerator.OnVideoSourceAdded += DeviceEnumerator_OnVideoSourceAdded;
_deviceEnumerator.OnAudioSourceAdded += DeviceEnumerator_OnAudioSourceAdded;
_deviceEnumerator.OnAudioSinkAdded += DeviceEnumerator_OnAudioSinkAdded;
DeviceEnumerator.Shared.OnVideoSourceAdded += DeviceEnumerator_OnVideoSourceAdded;
DeviceEnumerator.Shared.OnAudioSourceAdded += DeviceEnumerator_OnAudioSourceAdded;
DeviceEnumerator.Shared.OnAudioSinkAdded += DeviceEnumerator_OnAudioSinkAdded;

InitControls();

Expand Down Expand Up @@ -365,12 +362,6 @@ private void DestroyEngine()
VideoCapture1.Dispose();
VideoCapture1 = null;
}

if (_deviceEnumerator != null)
{
_deviceEnumerator.Dispose();
_deviceEnumerator = null;
}
}

private async Task<string> SaveVideoFileDialogAsync()
Expand Down Expand Up @@ -918,6 +909,8 @@ private void cbFlipY_Checked(object sender, RoutedEventArgs e)
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
DestroyEngine();

VisioForgeX.ShutdownSDK();
}

protected virtual void Dispose(bool disposing)
Expand Down
Loading

0 comments on commit 5d22235

Please sign in to comment.