* limitations under the License.
*/
-namespace Tizen.Multimedia.MediaCodec
+internal static partial class Interop
{
- internal static partial class Interop
+ internal static partial class Libraries
{
- internal static partial class Libraries
- {
- public const string MediaCodec = "libcapi-media-codec.so.0";
- public const string MediaTool = "libcapi-media-tool.so.0";
- }
+ public const string MediaCodec = "libcapi-media-codec.so.0";
+ public const string MediaTool = "libcapi-media-tool.so.0";
}
}
using System;
using System.Runtime.InteropServices;
+using Tizen.Multimedia.MediaCodec;
-namespace Tizen.Multimedia.MediaCodec
+internal static partial class Interop
{
- internal static partial class Interop
+ internal static class MediaCodec
{
- internal static class MediaCodec
- {
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void InputBufferUsedCallback(IntPtr mediaPacket, IntPtr arg);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void InputBufferUsedCallback(IntPtr mediaPacket, IntPtr arg);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void OutputBufferAvailableCallback(IntPtr mediaPacket, IntPtr arg);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void OutputBufferAvailableCallback(IntPtr mediaPacket, IntPtr arg);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void ErrorCallback(int errorCode, IntPtr arg);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ErrorCallback(int errorCode, IntPtr arg);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void EosCallback(IntPtr arg);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void EosCallback(IntPtr arg);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void BufferStatusCallback(int statusCode, IntPtr arg);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void BufferStatusCallback(int statusCode, IntPtr arg);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate bool SupportedCodecCallback(int codecType, IntPtr arg);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool SupportedCodecCallback(int codecType, IntPtr arg);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_create")]
- internal static extern int Create(out IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_create")]
+ internal static extern MediaCodecErrorCode Create(out IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_destroy")]
- internal static extern int Destroy(IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_destroy")]
+ internal static extern MediaCodecErrorCode Destroy(IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_codec")]
- internal static extern int Configure(IntPtr handle, int codecType, int flags);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_codec")]
+ internal static extern MediaCodecErrorCode Configure(IntPtr handle, int codecType, int flags);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_vdec_info")]
- internal static extern int SetVideoDecoderInfo(IntPtr handle, int width, int height);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_vdec_info")]
+ internal static extern MediaCodecErrorCode SetVideoDecoderInfo(IntPtr handle, int width, int height);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_venc_info")]
- internal static extern int SetVideoEncoderInfo(IntPtr handle, int width, int height,
- int fps, int targetBits);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_venc_info")]
+ internal static extern MediaCodecErrorCode SetVideoEncoderInfo(IntPtr handle, int width, int height,
+ int fps, int targetBits);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_adec_info")]
- internal static extern int SetAudioDecoderInfo(IntPtr handle, int sampleRate, int channel,
- int bit);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_adec_info")]
+ internal static extern MediaCodecErrorCode SetAudioDecoderInfo(IntPtr handle, int sampleRate, int channel,
+ int bit);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_aenc_info")]
- internal static extern int SetAudioEncoderInfo(IntPtr handle, int sampleRate, int channel,
- int bit, int bitRate);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_aenc_info")]
+ internal static extern MediaCodecErrorCode SetAudioEncoderInfo(IntPtr handle, int sampleRate, int channel,
+ int bit, int bitRate);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_prepare")]
- internal static extern int Prepare(IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_prepare")]
+ internal static extern MediaCodecErrorCode Prepare(IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unprepare")]
- internal static extern int Unprepare(IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unprepare")]
+ internal static extern MediaCodecErrorCode Unprepare(IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_process_input")]
- internal static extern int Process(IntPtr handle, IntPtr mediaPacket, ulong timeoutInUs);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_process_input")]
+ internal static extern MediaCodecErrorCode Process(IntPtr handle, IntPtr mediaPacket, ulong timeoutInUs);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_get_output")]
- internal static extern int GetOutput(IntPtr handle, out IntPtr packet, ulong timeoutInUs);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_get_output")]
+ internal static extern MediaCodecErrorCode GetOutput(IntPtr handle, out IntPtr packet, ulong timeoutInUs);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_flush_buffers")]
- internal static extern int FlushBuffers(IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_flush_buffers")]
+ internal static extern MediaCodecErrorCode FlushBuffers(IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_input_buffer_used_cb")]
- internal static extern int SetInputBufferUsedCb(IntPtr handle,
- InputBufferUsedCallback cb, IntPtr arg = default(IntPtr));
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_input_buffer_used_cb")]
+ internal static extern MediaCodecErrorCode SetInputBufferUsedCb(IntPtr handle,
+ InputBufferUsedCallback cb, IntPtr arg = default(IntPtr));
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_input_buffer_used_cb")]
- internal static extern int UnsetInputBufferUsedCb(IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_input_buffer_used_cb")]
+ internal static extern MediaCodecErrorCode UnsetInputBufferUsedCb(IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_output_buffer_available_cb")]
- internal static extern int SetOutputBufferAvailableCb(IntPtr handle,
- OutputBufferAvailableCallback cb, IntPtr arg = default(IntPtr));
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_output_buffer_available_cb")]
+ internal static extern MediaCodecErrorCode SetOutputBufferAvailableCb(IntPtr handle,
+ OutputBufferAvailableCallback cb, IntPtr arg = default(IntPtr));
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_output_buffer_available_cb")]
- internal static extern int UnsetOutputBufferAvailableCb(IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_output_buffer_available_cb")]
+ internal static extern MediaCodecErrorCode UnsetOutputBufferAvailableCb(IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_error_cb")]
- internal static extern int SetErrorCb(IntPtr handle, ErrorCallback cb, IntPtr arg = default(IntPtr));
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_error_cb")]
+ internal static extern MediaCodecErrorCode SetErrorCb(IntPtr handle, ErrorCallback cb, IntPtr arg = default(IntPtr));
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_error_cb")]
- internal static extern int UnsetErrorCb(IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_error_cb")]
+ internal static extern MediaCodecErrorCode UnsetErrorCb(IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_eos_cb")]
- internal static extern int SetEosCb(IntPtr handle, EosCallback cb, IntPtr arg = default(IntPtr));
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_eos_cb")]
+ internal static extern MediaCodecErrorCode SetEosCb(IntPtr handle, EosCallback cb, IntPtr arg = default(IntPtr));
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_eos_cb")]
- internal static extern int UnsetEosCb(IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_eos_cb")]
+ internal static extern MediaCodecErrorCode UnsetEosCb(IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_buffer_status_cb")]
- internal static extern int SetBufferStatusCb(IntPtr handle, BufferStatusCallback cb,
- IntPtr arg = default(IntPtr));
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_buffer_status_cb")]
+ internal static extern MediaCodecErrorCode SetBufferStatusCb(IntPtr handle, BufferStatusCallback cb,
+ IntPtr arg = default(IntPtr));
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_buffer_status_cb")]
- internal static extern int UnsetBufferStatusCb(IntPtr handle);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_buffer_status_cb")]
+ internal static extern MediaCodecErrorCode UnsetBufferStatusCb(IntPtr handle);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_get_supported_type")]
- internal static extern int GetSupportedType(IntPtr handle, int codecType, bool isEncoder,
- out int value);
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_get_supported_type")]
+ internal static extern MediaCodecErrorCode GetSupportedType(IntPtr handle, int codecType, bool isEncoder,
+ out int value);
- [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_foreach_supported_codec_static")]
- internal static extern int ForeachSupportedCodec(SupportedCodecCallback cb, IntPtr arg);
- }
+ [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_foreach_supported_codec_static")]
+ internal static extern MediaCodecErrorCode ForeachSupportedCodec(SupportedCodecCallback cb, IntPtr arg);
}
}
+
using System;
using System.Runtime.InteropServices;
-namespace Tizen.Multimedia.MediaCodec
+internal static partial class Interop
{
- internal static partial class Interop
+ internal static class MediaPacket
{
- internal static class MediaPacket
- {
- [DllImport(Libraries.MediaTool, EntryPoint = "media_packet_destroy")]
- internal static extern int Destroy(IntPtr handle);
- }
+ [DllImport(Libraries.MediaTool, EntryPoint = "media_packet_destroy")]
+ internal static extern int Destroy(IntPtr handle);
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using Native = Interop.MediaCodec;
namespace Tizen.Multimedia.MediaCodec
{
/// <since_tizen> 3 </since_tizen>
public MediaCodec()
{
- int ret = Interop.MediaCodec.Create(out _handle);
-
- if (ret == (int)MediaCodecErrorCode.InvalidOperation)
- {
- throw new InvalidOperationException("Not able to initialize a new media codec.");
- }
-
- MultimediaDebug.AssertNoError(ret);
+ Native.Create(out _handle).ThrowIfFailed("Failed to create media codec.");
RegisterInputProcessed();
RegisterErrorOccurred();
{
if (_handle != IntPtr.Zero)
{
- Interop.MediaCodec.Destroy(_handle);
+ Native.Destroy(_handle).ThrowIfFailed("Failed to destry media codec.");
_handle = IntPtr.Zero;
}
var videoCodecList = new List<MediaFormatVideoMimeType>();
var audioCodecList = new List<MediaFormatAudioMimeType>();
- Interop.MediaCodec.SupportedCodecCallback cb = (codecType, _) =>
+ Native.SupportedCodecCallback cb = (codecType, _) =>
{
if ((codecType & CodecKindMask) == CodecKindVideo)
{
return true;
};
- int ret = Interop.MediaCodec.ForeachSupportedCodec(cb, IntPtr.Zero);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.ForeachSupportedCodec(cb, IntPtr.Zero).ThrowIfFailed("Failed to get supported codec.");
_supportedVideoCodecs = videoCodecList.AsReadOnly();
_supportedAudioCodecs = audioCodecList.AsReadOnly();
{
ValidateNotDisposed();
- int ret = Interop.MediaCodec.Prepare(_handle);
-
- if (ret == (int)MediaCodecErrorCode.NotInitialized)
- {
- throw new InvalidOperationException("The codec is not configured.");
- }
- if (ret != (int)MediaCodecErrorCode.None)
- {
- throw new InvalidOperationException("Operation failed.");
- }
-
- MultimediaDebug.AssertNoError(ret);
+ Native.Prepare(_handle).ThrowIfFailed("Failed to prepare media codec.");
}
/// <summary>
{
ValidateNotDisposed();
- int ret = Interop.MediaCodec.Unprepare(_handle);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.Unprepare(_handle).ThrowIfFailed("Failed to unprepare media codec.");
}
/// <summary>
if (encoder)
{
- int ret = Interop.MediaCodec.SetAudioEncoderInfo(_handle, format.SampleRate,
- format.Channel, format.Bit, format.BitRate);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.SetAudioEncoderInfo(_handle, format.SampleRate, format.Channel, format.Bit, format.BitRate).
+ ThrowIfFailed("Failed to set audio encoder information.");
}
else
{
- int ret = Interop.MediaCodec.SetAudioDecoderInfo(_handle, format.SampleRate,
- format.Channel, format.Bit);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.SetAudioDecoderInfo(_handle, format.SampleRate, format.Channel, format.Bit).
+ ThrowIfFailed("Failed to set audio decoder information.");
}
}
if (encoder)
{
- int ret = Interop.MediaCodec.SetVideoEncoderInfo(_handle, format.Size.Width,
- format.Size.Height, format.FrameRate, format.BitRate / 1000);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.SetVideoEncoderInfo(_handle, format.Size.Width, format.Size.Height, format.FrameRate, format.BitRate / 1000).
+ ThrowIfFailed("Failed to set video encoder information.");
}
else
{
- int ret = Interop.MediaCodec.SetVideoDecoderInfo(_handle, format.Size.Width, format.Size.Height);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.SetVideoDecoderInfo(_handle, format.Size.Width, format.Size.Height).
+ ThrowIfFailed("Failed to set video decoder information.");
}
}
flags |= (int)supportType;
- int ret = Interop.MediaCodec.Configure(_handle, codecType, flags);
-
- if (ret == (int)MediaCodecErrorCode.NotSupportedOnDevice)
- {
- throw new NotSupportedException("The format is not supported.");
- }
- MultimediaDebug.AssertNoError(ret);
+ Native.Configure(_handle, codecType, flags).ThrowIfFailed("Failed to configure media codec.");
}
/// <summary>
MediaPacket.Lock packetLock = MediaPacket.Lock.Get(packet);
- int ret = Interop.MediaCodec.Process(_handle, packetLock.GetHandle(), 0);
-
- if (ret == (int)MediaCodecErrorCode.InvalidState)
- {
- throw new InvalidOperationException("The codec is in invalid state.");
- }
-
- MultimediaDebug.AssertNoError(ret);
+ Native.Process(_handle, packetLock.GetHandle(), 0).ThrowIfFailed("Failed to process input."); ;
}
/// <summary>
{
ValidateNotDisposed();
- int ret = Interop.MediaCodec.FlushBuffers(_handle);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.FlushBuffers(_handle).ThrowIfFailed("Failed to flush buffers.");
}
/// <summary>
private MediaCodecTypes GetCodecType(int mimeType, bool isEncoder)
{
int codecType = mimeType & CodecTypeMask;
- int value = 0;
- int ret = Interop.MediaCodec.GetSupportedType(_handle, codecType, isEncoder, out value);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.GetSupportedType(_handle, codecType, isEncoder, out int value).
+ ThrowIfFailed("Failed to get supported media codec type.");
return (MediaCodecTypes)value;
}
#region OutputAvailable event
private EventHandler<OutputAvailableEventArgs> _outputAvailable;
- private Interop.MediaCodec.OutputBufferAvailableCallback _outputBufferAvailableCb;
+ private Native.OutputBufferAvailableCallback _outputBufferAvailableCb;
private object _outputAvailableLock = new object();
/// <summary>
{
if (_outputAvailable == null)
{
- Interop.MediaPacket.Destroy(packetHandle);
+ try
+ {
+ Native.Destroy(packetHandle).ThrowIfFailed("Failed to destroy packet.");
+ }
+ catch (Exception)
+ {
+ // Do not throw exception in pinvoke callback.
+ }
+
return;
}
}
catch (Exception e)
{
- Interop.MediaPacket.Destroy(packetHandle);
+ try
+ {
+ Native.Destroy(packetHandle).ThrowIfFailed("Failed to destroy packet.");
+ }
+ catch
+ {
+ // Do not throw exception in pinvoke callback.
+ }
MultimediaLog.Error(typeof(MediaCodec).FullName, "Failed to raise OutputAvailable event", e);
}
}
};
- int ret = Interop.MediaCodec.SetOutputBufferAvailableCb(_handle, _outputBufferAvailableCb);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.SetOutputBufferAvailableCb(_handle, _outputBufferAvailableCb).
+ ThrowIfFailed("Failed to set output buffer available callback.");
}
private void UnregisterOutputAvailableCallback()
{
- int ret = Interop.MediaCodec.UnsetOutputBufferAvailableCb(_handle);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.UnsetOutputBufferAvailableCb(_handle).ThrowIfFailed("Failed to unregister output available callback.");
}
#endregion
#region InputProcessed event
- private Interop.MediaCodec.InputBufferUsedCallback _inputBufferUsedCb;
+ private Native.InputBufferUsedCallback _inputBufferUsedCb;
/// <summary>
/// Occurs when an input packet is processed.
InputProcessed?.Invoke(this, new InputProcessedEventArgs(packet));
};
- int ret = Interop.MediaCodec.SetInputBufferUsedCb(_handle, _inputBufferUsedCb);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.SetInputBufferUsedCb(_handle, _inputBufferUsedCb).
+ ThrowIfFailed("Failed to set input buffer used callback.");
}
#endregion
#region ErrorOccurred event
- private Interop.MediaCodec.ErrorCallback _errorCb;
+ private Native.ErrorCallback _errorCb;
/// <summary>
/// Occurs whenever an error is produced in the codec.
ErrorOccurred?.Invoke(this, new MediaCodecErrorOccurredEventArgs(error));
};
- int ret = Interop.MediaCodec.SetErrorCb(_handle, _errorCb);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.SetErrorCb(_handle, _errorCb).ThrowIfFailed("Failed to set error callback.");
}
#endregion
#region EosReached event
- private Interop.MediaCodec.EosCallback _eosCb;
+ private Native.EosCallback _eosCb;
/// <summary>
/// Occurs when the codec processes all input data.
{
_eosCb = _ => EosReached?.Invoke(this, EventArgs.Empty);
- int ret = Interop.MediaCodec.SetEosCb(_handle, _eosCb);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.SetEosCb(_handle, _eosCb).ThrowIfFailed("Failed to set eos callback.");
}
-
#endregion
#region BufferStatusChanged event
- private Interop.MediaCodec.BufferStatusCallback _bufferStatusCb;
+ private Native.BufferStatusCallback _bufferStatusCb;
/// <summary>
/// Occurs when the codec needs more data or has enough data.
new BufferStatusChangedEventArgs((MediaCodecStatus)statusCode));
};
- int ret = Interop.MediaCodec.SetBufferStatusCb(_handle, _bufferStatusCb);
-
- MultimediaDebug.AssertNoError(ret);
+ Native.SetBufferStatusCb(_handle, _bufferStatusCb).
+ ThrowIfFailed("Failed to set buffer status callback.");
}
#endregion
}
* limitations under the License.
*/
+using System;
+using System.IO;
using Tizen.Internals.Errors;
namespace Tizen.Multimedia.MediaCodec
/// </summary>
InvalidStream = MediaCodecErrorCode.InvalidStream,
}
+
+ internal static class MediaCodecErrorExtensions
+ {
+ internal static void ThrowIfFailed(this MediaCodecErrorCode errorCode, string message)
+ {
+ if (errorCode == MediaCodecErrorCode.None)
+ {
+ return;
+ }
+
+ string msg = $"{ (message ?? "Operation failed") } : { errorCode.ToString() }.";
+
+ switch (errorCode)
+ {
+ case MediaCodecErrorCode.OutOfMemory:
+ throw new OutOfMemoryException(msg);
+
+ case MediaCodecErrorCode.InvalidParameter:
+ throw new ArgumentException(msg);
+
+ case MediaCodecErrorCode.CodecNotFound:
+ case MediaCodecErrorCode.DecodingError:
+ case MediaCodecErrorCode.InvalidOperation:
+ case MediaCodecErrorCode.InvalidState:
+ case MediaCodecErrorCode.InvalidInBuffer:
+ case MediaCodecErrorCode.InvalidOutBuffer:
+ case MediaCodecErrorCode.Internal:
+ case MediaCodecErrorCode.NotInitialized:
+ case MediaCodecErrorCode.InvalidStream:
+ case MediaCodecErrorCode.StreamNotFound:
+ throw new InvalidOperationException(msg);
+
+ case MediaCodecErrorCode.NotSupportedOnDevice:
+ case MediaCodecErrorCode.NotSupportedFormat:
+ throw new NotSupportedException(msg);
+
+ case MediaCodecErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException(msg);
+
+ case MediaCodecErrorCode.OutOfStorage:
+ throw new IOException($"{msg}; Not enough disk space or specified path is not available to .");
+
+ case MediaCodecErrorCode.NoAvailableBuffer:
+ case MediaCodecErrorCode.OverflowInBuffer:
+ throw new InternalBufferOverflowException(msg);
+
+ default:
+ throw new Exception($"Unknown error : {errorCode.ToString()}.");
+ }
+ }
+ }
}
internal static partial class Interop
{
-
internal static partial class Recorder
{
[DllImport(Libraries.Recorder, EntryPoint = "recorder_create_audiorecorder")]