Added CodecNotSupportedException.
authorcoderhyme <jhyo.kim@samsung.com>
Fri, 19 May 2017 02:21:16 +0000 (11:21 +0900)
committercoderhyme <jhyo.kim@samsung.com>
Fri, 19 May 2017 02:38:30 +0000 (11:38 +0900)
This is an exception thrown if a codec is not supported.

Change-Id: Iede40a7a55ef9d45caffd2e5eb34ccf7a12978ae
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
src/Tizen.Multimedia.MediaPlayer/Player/PlayerEnums.cs
src/Tizen.Multimedia.MediaPlayer/Player/PlayerError.cs
src/Tizen.Multimedia/Common/CodecNotSupportedException.cs [new file with mode: 0644]

index 7d1e9d2..e6a1071 100644 (file)
@@ -43,7 +43,8 @@ namespace Tizen.Multimedia
         DrmFutureUse = PlayerErrorCode.DrmFutureUse,
         DrmNotPermitted = PlayerErrorCode.DrmNotPermitted,
         ResourceLimit = PlayerErrorCode.ResourceLimit,
-        ServiceDisconnected = PlayerErrorCode.ServiceDisconnected
+        ServiceDisconnected = PlayerErrorCode.ServiceDisconnected,
+        SubtitleNotSupported = PlayerErrorCode.NotSupportedSubtitle,
     }
 
     /// <summary>
index 187c8bf..4beb26d 100644 (file)
@@ -44,7 +44,10 @@ namespace Tizen.Multimedia
         DrmFutureUse = PlayerErrorClass | 0x0a,
         DrmNotPermitted = PlayerErrorClass | 0x0b,
         ResourceLimit = PlayerErrorClass | 0x0c,
-        ServiceDisconnected = PlayerErrorClass | 0x0d
+        ServiceDisconnected = PlayerErrorClass | 0x0d,
+        NotSupportedAudioCodec = PlayerErrorClass | 0x0e,
+        NotSupportedVideoCodec = PlayerErrorClass | 0x0f,
+        NotSupportedSubtitle = PlayerErrorClass | 0x10
     }
 
     internal static class PlayerErrorCodeExtensions
@@ -99,6 +102,13 @@ namespace Tizen.Multimedia
 
                 case PlayerErrorCode.ResourceLimit:
                     throw new ResouceLimitException(msg);
+
+                case PlayerErrorCode.NotSupportedAudioCodec:
+                    throw new CodecNotSupportedException(CodecKind.Audio);
+
+                case PlayerErrorCode.NotSupportedVideoCodec:
+                    throw new CodecNotSupportedException(CodecKind.Video);
+
             }
 
             throw new Exception(msg);
diff --git a/src/Tizen.Multimedia/Common/CodecNotSupportedException.cs b/src/Tizen.Multimedia/Common/CodecNotSupportedException.cs
new file mode 100644 (file)
index 0000000..ed8dec6
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Multimedia
+{
+    /// <summary>
+    /// Specifies whether a codec is audio codec or video codec.
+    /// </summary>
+    public enum CodecKind
+    {
+        /// <summary>
+        /// Audio codec
+        /// </summary>
+        Audio,
+
+        /// <summary>
+        /// Video codec
+        /// </summary>
+        Video
+    }
+
+    /// <summary>
+    /// The exception that is thrown when the codec for an input file or a data stream is not supported
+    /// or the input is malformed.
+    /// </summary>
+    public class CodecNotSupportedException : InvalidOperationException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CodecNotSupportedException"/> class
+        /// with <see cref="CodecKind"/> indicating which codec is not supported.
+        /// </summary>
+        public CodecNotSupportedException(CodecKind kind)
+        {
+            CodecKind = kind;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CodecNotSupportedException"/> class with
+        /// <see cref="CodecKind"/> indicating which codec is not supported and a specified error message.
+        /// </summary>
+        public CodecNotSupportedException(CodecKind kind, string message) : base(message)
+        {
+            CodecKind = kind;
+        }
+
+        /// <summary>
+        /// Gets the <see cref="CodecKind"/> of the exception.
+        /// </summary>
+        public CodecKind CodecKind { get; }
+    }
+}