Skip to content

Commit

Permalink
Update to SDK version 15.9.23
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-miniailov committed Apr 30, 2024
1 parent 3ea50b9 commit cb05854
Show file tree
Hide file tree
Showing 39 changed files with 1,344 additions and 8 deletions.
14 changes: 14 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:RTSPViewer"
x:Class="RTSPViewer.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
12 changes: 12 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace RTSPViewer
{
public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
}
15 changes: 15 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="RTSPViewer.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:RTSPViewer"
Shell.FlyoutBehavior="Disabled"
Shell.NavBarIsVisible="False">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
10 changes: 10 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace RTSPViewer
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
62 changes: 62 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="RTSPViewer.MainPage"
xmlns:my="clr-namespace:VisioForge.Core.UI.MAUI;assembly=VisioForge.Core.UI.MAUI">

<Grid>
<!--WidthRequest="1280" HeightRequest="720"-->
<Grid RowSpacing="0" RowDefinitions="*,Auto" >

<!--<my:VideoView Grid.Row="0"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
x:Name="videoView"
Background="Black"/>-->

<Grid x:Name="videoViewHost"
Grid.Row="0"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Background="Black">
<my:VideoView
x:Name="videoView"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand" />
</Grid>

<StackLayout Grid.Row="1" x:Name="pnMain" Orientation="Vertical" HorizontalOptions="Fill" Background="#1e1e1e">

<Entry
x:Name="edURL"
Placeholder="RTSP URL (not HTTP or ONVIF)"
HorizontalOptions="FillAndExpand" />

<Grid Margin="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>

<Entry
Grid.Column="0"
x:Name="edUsername"
Placeholder="User name" />

<Entry
Grid.Column="1"
x:Name="edPassword"
Placeholder="Password" />

<Button
Grid.Column="2"
x:Name="btPlay"
Text="PLAY"
VerticalOptions="Center"
Clicked="btPlay_Clicked" />
</Grid>
</StackLayout>
</Grid>
</Grid>
</ContentPage>
114 changes: 114 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using System.Diagnostics;
using VisioForge.Core;
using VisioForge.Core.MediaBlocks;
using VisioForge.Core.MediaBlocks.AudioRendering;
using VisioForge.Core.MediaBlocks.Sources;
using VisioForge.Core.MediaBlocks.VideoRendering;
using VisioForge.Core.Types;
using VisioForge.Core.Types.Events;
using VisioForge.Core.Types.X.Sources;

namespace RTSPViewer
{
public partial class MainPage : ContentPage
{
private MediaBlocksPipeline _pipeline;

private RTSPSourceBlock _rtspSource;

private MediaBlock _videoRenderer;

private AudioRendererBlock _audioRenderer;

public MainPage()
{
InitializeComponent();

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

private void CreateEngine()
{
_pipeline = new MediaBlocksPipeline(true);

_pipeline.OnError += VideoCapture1_OnError;
}

private async Task DestroyEngineAsync()
{
if (_pipeline != null)
{
_pipeline.OnError -= VideoCapture1_OnError;

await _pipeline.DisposeAsync();
_pipeline = null;
}
}

private async Task OpenAsync()
{
CreateEngine();

var rtsp = await RTSPSourceSettings.CreateAsync(new Uri(edURL.Text), edUsername.Text, edPassword.Text, true);
var info = rtsp.GetInfo();

if (info == null)
{
await DisplayAlert("Alert", "Unable to get RTSP source info. Please, use the direct RTSP URL, not HTTP ONVIF", "OK");
return;
}

_rtspSource = new RTSPSourceBlock(rtsp);

#if __IOS__ && !__MACCATALYST__ || __ANDROID__
var vv = videoView.Handler.PlatformView;
_videoRenderer = new VideoRendererBlock(_pipeline, (IVideoView)vv);
#else
_videoRenderer = new VideoRendererBlock(_pipeline, videoView);
#endif

_pipeline.Connect(_rtspSource.VideoOutput, _videoRenderer.Input);

if (info.AudioStreams.Count > 0)
{
_audioRenderer = new AudioRendererBlock();
_pipeline.Connect(_rtspSource.AudioOutput, _audioRenderer.Input);
}

await _pipeline.StartAsync();
}

private async Task StopAsync()
{
if (_pipeline != null)
{
await _pipeline.StopAsync();
}

await DestroyEngineAsync();
}

private async void btPlay_Clicked(object sender, EventArgs e)
{
if (btPlay.Text == "PLAY")
{
btPlay.Text = "STOP";

await OpenAsync();
}
else
{
btPlay.Text = "PLAY";

await StopAsync();
}
}

private void VideoCapture1_OnError(object sender, ErrorsEventArgs e)
{
Debug.WriteLine(e.Message);
}
}

}
29 changes: 29 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.Extensions.Logging;
using SkiaSharp.Views.Maui.Controls.Hosting;
using VisioForge.Core.UI.MAUI;

namespace RTSPViewer
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseSkiaSharp()
.ConfigureMauiHandlers(handlers => handlers.AddVisioForgeHandlers())
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

#if DEBUG
builder.Logging.AddDebug();
#endif

return builder.Build();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
11 changes: 11 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Android.App;
using Android.Content.PM;
using Android.OS;

namespace RTSPViewer
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Android.App;
using Android.Runtime;

namespace RTSPViewer
{
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Foundation;

namespace RTSPViewer
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
30 changes: 30 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/Platforms/MacCatalyst/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>
16 changes: 16 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/Platforms/MacCatalyst/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using ObjCRuntime;
using UIKit;

namespace RTSPViewer
{
public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}
17 changes: 17 additions & 0 deletions Media Blocks SDK/MAUI/RTSPViewer/Platforms/Tizen/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using System;

namespace RTSPViewer
{
internal class Program : MauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
}
Loading

0 comments on commit cb05854

Please sign in to comment.