164 lines
5.9 KiB
C#
164 lines
5.9 KiB
C#
using System;
|
|
using VavCore.Wrapper;
|
|
|
|
namespace VavCoreTest;
|
|
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
Console.WriteLine("=== VavCore.Wrapper P/Invoke Test ===");
|
|
Console.WriteLine();
|
|
|
|
// Test 1: Library Initialization
|
|
Console.WriteLine("Test 1: Library Initialization");
|
|
try
|
|
{
|
|
bool initialized = VavCoreWrapper.Initialize();
|
|
Console.WriteLine($" VavCore.Initialize(): {(initialized ? "SUCCESS" : "FAILED")}");
|
|
|
|
if (initialized)
|
|
{
|
|
Console.WriteLine($" Library is initialized: {VavCoreWrapper.IsInitialized}");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($" ERROR: {ex.Message}");
|
|
Console.WriteLine($" Exception Type: {ex.GetType().Name}");
|
|
if (ex.InnerException != null)
|
|
{
|
|
Console.WriteLine($" Inner Exception: {ex.InnerException.Message}");
|
|
}
|
|
}
|
|
Console.WriteLine();
|
|
|
|
// Test 2: Version Information
|
|
Console.WriteLine("Test 2: Version Information");
|
|
try
|
|
{
|
|
string version = VavCoreWrapper.GetVersion();
|
|
Console.WriteLine($" VavCore Version: {version}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($" ERROR getting version: {ex.Message}");
|
|
}
|
|
Console.WriteLine();
|
|
|
|
// Test 3: Platform Information
|
|
Console.WriteLine("Test 3: Platform Information");
|
|
try
|
|
{
|
|
string libraryName = VavCoreTypes.GetLibraryName();
|
|
Console.WriteLine($" Library Name: {libraryName}");
|
|
|
|
var optimalDecoder = VavCoreTypes.GetOptimalDecoderType();
|
|
Console.WriteLine($" Optimal Decoder: {optimalDecoder}");
|
|
|
|
var optimalSurface = VavCoreTypes.GetOptimalSurfaceType();
|
|
Console.WriteLine($" Optimal Surface: {optimalSurface}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($" ERROR getting platform info: {ex.Message}");
|
|
}
|
|
Console.WriteLine();
|
|
|
|
// Test 4: Player Creation and Basic Operations
|
|
Console.WriteLine("Test 4: Player Creation and Basic Operations");
|
|
VavCoreWrapper? player = null;
|
|
try
|
|
{
|
|
player = new VavCoreWrapper();
|
|
Console.WriteLine(" Player created successfully");
|
|
|
|
// Test basic properties
|
|
Console.WriteLine($" Player handle: 0x{player.NativeHandle:X}");
|
|
|
|
// Test decoder capabilities
|
|
bool supportsAuto = player.SupportsSurfaceType(VavCoreTypes.SurfaceType.Auto);
|
|
bool supportsCPU = player.SupportsSurfaceType(VavCoreTypes.SurfaceType.CPU);
|
|
bool supportsD3D11 = player.SupportsSurfaceType(VavCoreTypes.SurfaceType.D3D11Texture);
|
|
|
|
Console.WriteLine($" Supports Auto Surface: {supportsAuto}");
|
|
Console.WriteLine($" Supports CPU Surface: {supportsCPU}");
|
|
Console.WriteLine($" Supports D3D11 Surface: {supportsD3D11}");
|
|
|
|
// Get optimal surface type for this player
|
|
var playerOptimalSurface = player.GetOptimalSurfaceType();
|
|
Console.WriteLine($" Player Optimal Surface: {playerOptimalSurface}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($" ERROR creating player: {ex.Message}");
|
|
if (ex.InnerException != null)
|
|
{
|
|
Console.WriteLine($" Inner Exception: {ex.InnerException.Message}");
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
player?.Dispose();
|
|
Console.WriteLine(" Player disposed");
|
|
}
|
|
Console.WriteLine();
|
|
|
|
// Test 5: Static Utility Methods
|
|
Console.WriteLine("Test 5: Static Utility Methods");
|
|
try
|
|
{
|
|
string availableDecoders = VavCoreWrapper.GetAvailableDecoders();
|
|
Console.WriteLine($" Available Decoders: {availableDecoders}");
|
|
|
|
var optimalDecoderType = VavCoreWrapper.GetOptimalDecoderType();
|
|
Console.WriteLine($" Static Optimal Decoder: {optimalDecoderType}");
|
|
|
|
var optimalSurfaceType = VavCoreWrapper.GetOptimalSurfaceType("vulkan");
|
|
Console.WriteLine($" Static Optimal Surface (Vulkan): {optimalSurfaceType}");
|
|
|
|
bool av1Supported = VavCoreWrapper.IsCodecSupported(VavCoreTypes.VideoCodecType.AV1);
|
|
bool vp9Supported = VavCoreWrapper.IsCodecSupported(VavCoreTypes.VideoCodecType.VP9);
|
|
|
|
Console.WriteLine($" AV1 Codec Supported: {av1Supported}");
|
|
Console.WriteLine($" VP9 Codec Supported: {vp9Supported}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($" ERROR in utility methods: {ex.Message}");
|
|
}
|
|
Console.WriteLine();
|
|
|
|
// Test 6: Error Handling
|
|
Console.WriteLine("Test 6: Error Handling");
|
|
try
|
|
{
|
|
string successMsg = VavCoreWrapper.GetErrorMessage(VavCoreTypes.VavCoreResult.Success);
|
|
string errorMsg = VavCoreWrapper.GetErrorMessage(VavCoreTypes.VavCoreResult.ErrorFileNotFound);
|
|
|
|
Console.WriteLine($" Success Message: {successMsg}");
|
|
Console.WriteLine($" Error Message: {errorMsg}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($" ERROR in error handling: {ex.Message}");
|
|
}
|
|
Console.WriteLine();
|
|
|
|
// Test 7: Library Cleanup
|
|
Console.WriteLine("Test 7: Library Cleanup");
|
|
try
|
|
{
|
|
VavCoreWrapper.Cleanup();
|
|
Console.WriteLine(" VavCore.Cleanup(): SUCCESS");
|
|
Console.WriteLine($" Library is initialized: {VavCoreWrapper.IsInitialized}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($" ERROR during cleanup: {ex.Message}");
|
|
}
|
|
Console.WriteLine();
|
|
|
|
Console.WriteLine("=== VavCore.Wrapper Test Completed ===");
|
|
}
|
|
} |