104 lines
3.3 KiB
C#
104 lines
3.3 KiB
C#
|
|
using Godot;
|
||
|
|
using System;
|
||
|
|
|
||
|
|
namespace VideoOrchestra.Platform
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// Cross-platform interface for VP9 video decoding implementations
|
||
|
|
/// </summary>
|
||
|
|
public interface IVP9PlatformDecoder : IDisposable
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// Platform identifier
|
||
|
|
/// </summary>
|
||
|
|
string PlatformName { get; }
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Check if VP9 hardware decoding is supported on this platform
|
||
|
|
/// </summary>
|
||
|
|
bool IsHardwareDecodingSupported { get; }
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Initialize the decoder with specified dimensions
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="width">Video width</param>
|
||
|
|
/// <param name="height">Video height</param>
|
||
|
|
/// <param name="enableHardware">Enable hardware acceleration if available</param>
|
||
|
|
/// <returns>True if initialization succeeded</returns>
|
||
|
|
bool Initialize(int width, int height, bool enableHardware = true);
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Decode a VP9 frame for the specified stream
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="frameData">VP9 encoded frame data</param>
|
||
|
|
/// <param name="streamId">Stream identifier (0-2)</param>
|
||
|
|
/// <returns>True if decoding succeeded</returns>
|
||
|
|
bool DecodeFrame(byte[] frameData, int streamId);
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Get the decoded frame as ImageTexture for the specified stream
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="streamId">Stream identifier (0-2)</param>
|
||
|
|
/// <returns>Decoded frame texture, or null if not available</returns>
|
||
|
|
ImageTexture GetDecodedTexture(int streamId);
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Get platform-specific texture ID (OpenGL/DirectX/Metal)
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="streamId">Stream identifier (0-2)</param>
|
||
|
|
/// <returns>Native texture ID, or 0 if not available</returns>
|
||
|
|
uint GetNativeTextureId(int streamId);
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Get current decoder status
|
||
|
|
/// </summary>
|
||
|
|
VP9DecoderStatus GetStatus();
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Release all resources
|
||
|
|
/// </summary>
|
||
|
|
void Release();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// VP9 decoder status enumeration
|
||
|
|
/// </summary>
|
||
|
|
public enum VP9DecoderStatus
|
||
|
|
{
|
||
|
|
Uninitialized,
|
||
|
|
Initialized,
|
||
|
|
Decoding,
|
||
|
|
Error,
|
||
|
|
Released
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Exception thrown by VP9 platform decoders
|
||
|
|
/// </summary>
|
||
|
|
public class VP9DecoderException : Exception
|
||
|
|
{
|
||
|
|
public string PlatformName { get; }
|
||
|
|
public int StreamId { get; }
|
||
|
|
|
||
|
|
public VP9DecoderException(string platformName, string message)
|
||
|
|
: base($"[{platformName}] {message}")
|
||
|
|
{
|
||
|
|
PlatformName = platformName;
|
||
|
|
StreamId = -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
public VP9DecoderException(string platformName, int streamId, string message)
|
||
|
|
: base($"[{platformName}] Stream {streamId}: {message}")
|
||
|
|
{
|
||
|
|
PlatformName = platformName;
|
||
|
|
StreamId = streamId;
|
||
|
|
}
|
||
|
|
|
||
|
|
public VP9DecoderException(string platformName, string message, Exception innerException)
|
||
|
|
: base($"[{platformName}] {message}", innerException)
|
||
|
|
{
|
||
|
|
PlatformName = platformName;
|
||
|
|
StreamId = -1;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|