From 5f0b6f3a08884ea52e79a839d134342aeec81d67 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Wed, 2 Aug 2023 15:45:41 +0900 Subject: [PATCH] [Multimedia] Fix VD SVACE issues --- .../WavPlayer/WavPlayerError.cs | 4 ++- .../Player/PlayerError.cs | 22 ++++++++------ .../MetadataEditor/MetadataEditorError.cs | 4 +++ .../MetadataExtractorError.cs | 13 ++++++-- .../Recorder/RecorderExtensions.cs | 6 ++++ .../MediaController/MediaControlEnums.cs | 12 ++++++++ .../MediaController/MediaControllerError.cs | 3 ++ .../WebRTC/WebRTCDataChannel.cs | 4 +-- .../WebRTC/WebRTCError.cs | 2 ++ .../WebRTC/WebRTCSignalingServer.cs | 4 +-- .../StreamRecorder/StreamRecorderEnums.cs | 18 +++++++++++ .../StreamRecorder/StreamRecorderError.cs | 10 +++++-- .../ImageUtil/ImageUtilEnums.cs | 30 ++----------------- .../MediaVision/VisionColorSpace.cs | 8 +++++ 14 files changed, 93 insertions(+), 47 deletions(-) diff --git a/src/Tizen.Multimedia.AudioIO/WavPlayer/WavPlayerError.cs b/src/Tizen.Multimedia.AudioIO/WavPlayer/WavPlayerError.cs index 4570b22fe1c..037bcef211d 100644 --- a/src/Tizen.Multimedia.AudioIO/WavPlayer/WavPlayerError.cs +++ b/src/Tizen.Multimedia.AudioIO/WavPlayer/WavPlayerError.cs @@ -51,8 +51,10 @@ internal static void Validate(this WavPlayerError error, string message) case WavPlayerError.InvalidOperation: throw new InvalidOperationException(message); + + default: + break; } } } - } diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerError.cs b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerError.cs index 7bc6eee8ff7..3a21db007a0 100644 --- a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerError.cs +++ b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerError.cs @@ -54,36 +54,36 @@ internal enum PlayerErrorCode internal static class PlayerErrorCodeExtensions { - internal static void ThrowIfFailed(this PlayerErrorCode err, Player player, string message) + internal static void ThrowIfFailed(this PlayerErrorCode errorCode, Player player, string message) { - if (err == PlayerErrorCode.None) + if (errorCode == PlayerErrorCode.None) { return; } - var ex = err.GetException(message); + var ex = errorCode.GetException(message); if (ex == null) { // Notify only when it can't be handled. - player?.NotifyError((int)err, message); + player?.NotifyError((int)errorCode, message); - throw new InvalidOperationException($"{message} : Unknown error({err.ToString()})."); + throw new InvalidOperationException($"{message} : Unknown error({errorCode.ToString()})."); } throw ex; } - internal static Exception GetException(this PlayerErrorCode err, string message) + internal static Exception GetException(this PlayerErrorCode errorCode, string message) { - if (err == PlayerErrorCode.None) + if (errorCode == PlayerErrorCode.None) { return null; } - string msg = $"{ (message ?? "Operation failed") } : { err.ToString() }."; + string msg = $"{ (message ?? "Operation failed") } : { errorCode.ToString() }."; - switch (err) + switch (errorCode) { case PlayerErrorCode.InvalidArgument: case PlayerErrorCode.InvalidUri: @@ -133,6 +133,10 @@ internal static Exception GetException(this PlayerErrorCode err, string message) case PlayerErrorCode.NotAvailable: throw new NotAvailableException(msg); + + default: + Log.Info(PlayerLog.Tag, "Unknow error: " + errorCode); + break; } return null; diff --git a/src/Tizen.Multimedia.Metadata/MetadataEditor/MetadataEditorError.cs b/src/Tizen.Multimedia.Metadata/MetadataEditor/MetadataEditorError.cs index 9256900363c..c3c53777123 100644 --- a/src/Tizen.Multimedia.Metadata/MetadataEditor/MetadataEditorError.cs +++ b/src/Tizen.Multimedia.Metadata/MetadataEditor/MetadataEditorError.cs @@ -67,6 +67,10 @@ internal static void ThrowIfError(this MetadataEditorError errorCode, string err case MetadataEditorError.OperationFailed: case MetadataEditorError.UpdateNotPossible: throw new InvalidOperationException(errorMessages); + + default: + Log.Error(typeof(MetadataEditor).FullName, $"Unknown error : {errorCode.ToString()}"); + break; } } } diff --git a/src/Tizen.Multimedia.Metadata/MetadataExtractor/MetadataExtractorError.cs b/src/Tizen.Multimedia.Metadata/MetadataExtractor/MetadataExtractorError.cs index 73fd6b47226..953f0dddb08 100644 --- a/src/Tizen.Multimedia.Metadata/MetadataExtractor/MetadataExtractorError.cs +++ b/src/Tizen.Multimedia.Metadata/MetadataExtractor/MetadataExtractorError.cs @@ -36,9 +36,14 @@ internal enum MetadataExtractorError internal static class MetadataExtractorRetValidator { - internal static void ThrowIfError(MetadataExtractorError error, string errorMessage) + internal static void ThrowIfError(MetadataExtractorError errorCode, string errorMessage) { - switch (error) + if (errorCode == MetadataExtractorError.None) + { + return; + } + + switch (errorCode) { case MetadataExtractorError.InvalidParameter: throw new ArgumentException(errorMessage); @@ -54,6 +59,10 @@ internal static void ThrowIfError(MetadataExtractorError error, string errorMess case MetadataExtractorError.OperationFailed: throw new InvalidOperationException(errorMessage); + + default: + Log.Error(typeof(MetadataExtractor).FullName, $"Unknown error : {errorCode.ToString()}"); + break; } } } diff --git a/src/Tizen.Multimedia.Recorder/Recorder/RecorderExtensions.cs b/src/Tizen.Multimedia.Recorder/Recorder/RecorderExtensions.cs index 19924b104dc..9364d838534 100644 --- a/src/Tizen.Multimedia.Recorder/Recorder/RecorderExtensions.cs +++ b/src/Tizen.Multimedia.Recorder/Recorder/RecorderExtensions.cs @@ -53,6 +53,9 @@ public static IEnumerable GetSupportedFileFormats(this Recor case RecorderVideoCodec.Theora: yield return RecorderFileFormat.Ogg; break; + + default: + break; } } @@ -93,6 +96,9 @@ public static IEnumerable GetSupportedFileFormats(this Recor case RecorderAudioCodec.Pcm: yield return RecorderFileFormat.Wav; break; + + default: + break; } } diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControlEnums.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControlEnums.cs index 2797d6dce98..ef908a20b3e 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/MediaControlEnums.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControlEnums.cs @@ -397,6 +397,7 @@ internal static MediaControlPlaybackState ToPublic(this MediaControllerNativePla case MediaControllerNativePlaybackState.Connecting: return MediaControlPlaybackState.Connecting; case MediaControllerNativePlaybackState.Buffering: return MediaControlPlaybackState.Buffering; case MediaControllerNativePlaybackState.Error: return MediaControlPlaybackState.Error; + default: break; } Debug.Fail($"Not supported code for playback state{nativeState}."); @@ -417,6 +418,7 @@ internal static MediaControllerNativePlaybackState ToNative(this MediaControlPla case MediaControlPlaybackState.Connecting: return MediaControllerNativePlaybackState.Connecting; case MediaControlPlaybackState.Buffering: return MediaControllerNativePlaybackState.Buffering; case MediaControlPlaybackState.Error: return MediaControllerNativePlaybackState.Error; + default: break; } return MediaControllerNativePlaybackState.None; } @@ -433,6 +435,7 @@ internal static MediaControlPlaybackCommand ToPublic(this MediaControllerNativeP case MediaControllerNativePlaybackAction.FastForward: return MediaControlPlaybackCommand.FastForward; case MediaControllerNativePlaybackAction.Rewind: return MediaControlPlaybackCommand.Rewind; case MediaControllerNativePlaybackAction.Toggle: return MediaControlPlaybackCommand.Toggle; + default: break; } Debug.Fail($"Not supported code for playback command{nativeAction}."); @@ -451,6 +454,7 @@ internal static MediaControllerNativePlaybackAction ToNative(this MediaControlPl case MediaControlPlaybackCommand.FastForward: return MediaControllerNativePlaybackAction.FastForward; case MediaControlPlaybackCommand.Rewind: return MediaControllerNativePlaybackAction.Rewind; case MediaControlPlaybackCommand.Toggle: return MediaControllerNativePlaybackAction.Toggle; + default: break; } return MediaControllerNativePlaybackAction.Play; } @@ -490,6 +494,8 @@ internal static MediaControlNativeDisplayMode ToNative(this MediaControlDisplayM case MediaControlDisplayMode.CroppedFull: nativeMode = MediaControlNativeDisplayMode.CroppedFull; break; + default: + break; } return nativeMode; } @@ -512,6 +518,8 @@ internal static MediaControlDisplayMode ToPublic(this MediaControlNativeDisplayM case MediaControlNativeDisplayMode.CroppedFull: nativeMode = MediaControlDisplayMode.CroppedFull; break; + default: + break; } return nativeMode; } @@ -550,6 +558,8 @@ internal static MediaControlNativeDisplayRotation ToNative(this Rotation mode) case Rotation.Rotate270: nativeMode = MediaControlNativeDisplayRotation.Rotate270; break; + default: + break; } return nativeMode; } @@ -572,6 +582,8 @@ internal static Rotation ToPublic(this MediaControlNativeDisplayRotation mode) case MediaControlNativeDisplayRotation.Rotate270: nativeMode = Rotation.Rotate270; break; + default: + break; } return nativeMode; } diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerError.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerError.cs index d1b03441991..60bceaec757 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerError.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerError.cs @@ -56,6 +56,9 @@ internal static void ThrowIfError(this MediaControllerError error, string messag case MediaControllerError.PermissionDenied: throw new UnauthorizedAccessException(msg); + + default: + break; } throw new InvalidOperationException($"Unknown error({error}) : {message}"); diff --git a/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCDataChannel.cs b/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCDataChannel.cs index 9a2ded38362..fcb1dc7de8e 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCDataChannel.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCDataChannel.cs @@ -76,7 +76,7 @@ public WebRTCDataChannel(WebRTC webRtc, string label, Bundle bundle) NativeDataChannel.Create(webRtc.Handle, label, bundle_, out _handle). ThrowIfFailed("Failed to create webrtc data channel"); - Debug.Assert(_handle != null); + Debug.Assert(_handle != IntPtr.Zero); Label = label; } @@ -227,7 +227,7 @@ protected virtual void Dispose(bool disposing) return; } - if (_handle != null) + if (_handle != IntPtr.Zero) { NativeDataChannel.Destroy(_handle); _disposed = true; diff --git a/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCError.cs b/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCError.cs index a0c4c5dd82d..b072b6e0ef9 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCError.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCError.cs @@ -59,6 +59,8 @@ internal static void ThrowIfFailed(this WebRTCErrorCode errorCode, string messag throw new ArgumentException(errMessage); case WebRTCErrorCode.PermissionDenied: throw new UnauthorizedAccessException(errMessage); + default: + break; } } } diff --git a/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCSignalingServer.cs b/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCSignalingServer.cs index 7852c44936c..5928867fcee 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCSignalingServer.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/WebRTCSignalingServer.cs @@ -95,7 +95,7 @@ protected virtual void Dispose(bool disposing) return; } - if (_handle != null) + if (_handle != IntPtr.Zero) { SignalingServer.Destroy(_handle); _disposed = true; @@ -243,7 +243,7 @@ protected virtual void Dispose(bool disposing) return; } - if (_handle != null) + if (_handle != IntPtr.Zero) { SignalingClient.Disconnect(_handle); diff --git a/src/Tizen.Multimedia.StreamRecorder/StreamRecorder/StreamRecorderEnums.cs b/src/Tizen.Multimedia.StreamRecorder/StreamRecorder/StreamRecorderEnums.cs index 5b62ee0c1e1..a035cc89057 100644 --- a/src/Tizen.Multimedia.StreamRecorder/StreamRecorder/StreamRecorderEnums.cs +++ b/src/Tizen.Multimedia.StreamRecorder/StreamRecorder/StreamRecorderEnums.cs @@ -166,6 +166,9 @@ internal static RecorderVideoCodec ToRecorderEnum(this StreamRecorderVideoCodec case StreamRecorderVideoCodec.Mpeg4: return RecorderVideoCodec.Mpeg4; + + default: + break; } Debug.Fail("Unknown video codec value."); @@ -181,6 +184,9 @@ internal static StreamRecorderVideoCodec ToStreamRecorderEnum(this RecorderVideo case RecorderVideoCodec.Mpeg4: return StreamRecorderVideoCodec.Mpeg4; + + default: + break; } throw new NotSupportedException($"{value.ToString()} is not supported."); @@ -199,6 +205,9 @@ internal static RecorderAudioCodec ToRecorderEnum(this StreamRecorderAudioCodec case StreamRecorderAudioCodec.Pcm: return RecorderAudioCodec.Pcm; + + default: + break; } Debug.Fail("Unknown audio codec value."); @@ -218,6 +227,9 @@ internal static StreamRecorderAudioCodec ToStreamRecorderEnum(this RecorderAudio case RecorderAudioCodec.Pcm: return StreamRecorderAudioCodec.Pcm; + + default: + break; } throw new NotSupportedException($"{value.ToString()} is not supported."); @@ -242,6 +254,9 @@ internal static RecorderFileFormat ToRecorderEnum(this StreamRecorderFileFormat case StreamRecorderFileFormat.Wav: return RecorderFileFormat.Wav; + + default: + break; } Debug.Fail("Unknown file format value."); @@ -267,6 +282,9 @@ internal static StreamRecorderFileFormat ToStreamRecorderEnum(this RecorderFileF case RecorderFileFormat.Wav: return StreamRecorderFileFormat.Wav; + + default: + break; } throw new NotSupportedException($"{value.ToString()} is not supported."); diff --git a/src/Tizen.Multimedia.StreamRecorder/StreamRecorder/StreamRecorderError.cs b/src/Tizen.Multimedia.StreamRecorder/StreamRecorder/StreamRecorderError.cs index 3c971de9f7d..736537880e4 100644 --- a/src/Tizen.Multimedia.StreamRecorder/StreamRecorder/StreamRecorderError.cs +++ b/src/Tizen.Multimedia.StreamRecorder/StreamRecorder/StreamRecorderError.cs @@ -40,14 +40,14 @@ internal static StreamRecorderErrorCode Ignore(this StreamRecorderErrorCode erro return (ignore == errorCode) ? StreamRecorderErrorCode.None : errorCode; } - internal static void ThrowIfError(this StreamRecorderErrorCode err, string errorMessage) + internal static void ThrowIfError(this StreamRecorderErrorCode errorCode, string errorMessage) { - if (err == StreamRecorderErrorCode.None) + if (errorCode == StreamRecorderErrorCode.None) { return; } - switch (err) + switch (errorCode) { case StreamRecorderErrorCode.InvalidParameter: throw new ArgumentException(errorMessage); @@ -67,6 +67,10 @@ internal static void ThrowIfError(this StreamRecorderErrorCode err, string error case StreamRecorderErrorCode.OutOfStorage: throw new IOException(errorMessage); + + default: + Log.Error("Tizen.Multimedia.StreamRecorder", $"Unknown error : {errorCode.ToString()}"); + break; } } } diff --git a/src/Tizen.Multimedia.Util/ImageUtil/ImageUtilEnums.cs b/src/Tizen.Multimedia.Util/ImageUtil/ImageUtilEnums.cs index c850ea10d5c..37d60822770 100644 --- a/src/Tizen.Multimedia.Util/ImageUtil/ImageUtilEnums.cs +++ b/src/Tizen.Multimedia.Util/ImageUtil/ImageUtilEnums.cs @@ -196,34 +196,21 @@ internal static ColorSpace ToCommonColorSpace(this ImageColorSpace value) switch (value) { case ImageColorSpace.YV12: return ColorSpace.YV12; - case ImageColorSpace.Uyvy: return ColorSpace.Uyvy; - case ImageColorSpace.Yuyv: return ColorSpace.Yuyv; - case ImageColorSpace.Yuv422: return ColorSpace.Yuv422P; - case ImageColorSpace.I420: return ColorSpace.I420; - case ImageColorSpace.Rgb565: return ColorSpace.Rgb565; - case ImageColorSpace.Rgb888: return ColorSpace.Rgb888; - case ImageColorSpace.Argb8888: return ColorSpace.Argb8888; - case ImageColorSpace.Bgra8888: return ColorSpace.Bgra8888; - case ImageColorSpace.Rgba8888: return ColorSpace.Rgba8888; - case ImageColorSpace.Bgrx8888: return ColorSpace.Bgrx8888; - case ImageColorSpace.NV12: return ColorSpace.NV12; - case ImageColorSpace.NV16: return ColorSpace.NV16; - case ImageColorSpace.NV21: return ColorSpace.NV21; - case ImageColorSpace.NV61: return ColorSpace.NV61; + default: break; } Debug.Fail($"Not supported color space : {value.ToString()}!"); @@ -240,34 +227,21 @@ internal static ImageColorSpace ToImageColorSpace(this ColorSpace colorSpace) switch (colorSpace) { case ColorSpace.YV12: return ImageColorSpace.YV12; - case ColorSpace.Uyvy: return ImageColorSpace.Uyvy; - case ColorSpace.Yuyv: return ImageColorSpace.Yuyv; - case ColorSpace.Yuv422: return ImageColorSpace.Yuv422; - case ColorSpace.I420: return ImageColorSpace.I420; - case ColorSpace.Rgb565: return ImageColorSpace.Rgb565; - case ColorSpace.Rgb888: return ImageColorSpace.Rgb888; - case ColorSpace.Argb8888: return ImageColorSpace.Argb8888; - case ColorSpace.Bgra8888: return ImageColorSpace.Bgra8888; - case ColorSpace.Rgba8888: return ImageColorSpace.Rgba8888; - case ColorSpace.Bgrx8888: return ImageColorSpace.Bgrx8888; - case ColorSpace.NV12: return ImageColorSpace.NV12; - case ColorSpace.NV16: return ImageColorSpace.NV16; - case ColorSpace.NV21: return ImageColorSpace.NV21; - case ColorSpace.NV61: return ImageColorSpace.NV61; + default: break; } throw new NotSupportedException($"The ColorSpace.{colorSpace.ToString()} is not supported."); diff --git a/src/Tizen.Multimedia.Vision/MediaVision/VisionColorSpace.cs b/src/Tizen.Multimedia.Vision/MediaVision/VisionColorSpace.cs index 71454287b8e..3211904b635 100755 --- a/src/Tizen.Multimedia.Vision/MediaVision/VisionColorSpace.cs +++ b/src/Tizen.Multimedia.Vision/MediaVision/VisionColorSpace.cs @@ -99,6 +99,10 @@ internal static ColorSpace ToCommonColorSpace(this VisionColorSpace value) case VisionColorSpace.Rgb888: return ColorSpace.Rgb888; case VisionColorSpace.Rgba: return ColorSpace.Rgba8888; + + default: + Log.Error(MediaVisionLog.Tag, "Not supported color format"); + break; } throw new NotSupportedException("Implementation does not support the specified value." + value.ToString()); @@ -134,6 +138,10 @@ internal static VisionColorSpace ToVisionColorSpace(this ColorSpace colorSpace) case ColorSpace.Rgb888: return VisionColorSpace.Rgb888; case ColorSpace.Rgba8888: return VisionColorSpace.Rgba; + + default: + Log.Error(MediaVisionLog.Tag, "Not supported color format"); + break; } throw new NotSupportedException("Implementation does not support the specified value." + colorSpace.ToString());