Add separated MediaCodec project and the solution for Mulitmedia.
authorcoderhyme <jhyo.kim@samsung.com>
Tue, 16 May 2017 00:41:08 +0000 (09:41 +0900)
committercoderhyme <jhyo.kim@samsung.com>
Tue, 16 May 2017 01:17:06 +0000 (10:17 +0900)
Change-Id: Ib1e6c58a39414e4229a7fd1fa2c395cbb6dabe85
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
20 files changed:
Tizen.Multimedia.sln [new file with mode: 0644]
packaging/csapi-multimedia.spec
src/Tizen.Multimedia.MediaCodec/Interop/Interop.Libraries.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/Interop/Interop.MediaCodec.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/MediaCodec/BufferStatusChangedEventArgs.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/MediaCodec/InputProcessedEventArgs.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodec.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecError.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecErrorOccurredEventArgs.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecStatus.cs [moved from src/Tizen.Multimedia/Common/InternalsVisibleDefinitions.cs with 57% similarity]
src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecType.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/MediaCodec/OutputAvailableEventArgs.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/MediaCodec/SupportedCodecType.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/Properties/AssemblyInfo.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.csproj [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.nuspec [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.project.json [new file with mode: 0644]
src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.snk [new file with mode: 0644]
src/Tizen.Multimedia/Properties/AssemblyInfo.cs
src/Tizen.Multimedia/Tizen.Multimedia.csproj

diff --git a/Tizen.Multimedia.sln b/Tizen.Multimedia.sln
new file mode 100644 (file)
index 0000000..4907a30
--- /dev/null
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Multimedia", "Tizen.Multimedia\Tizen.Multimedia.csproj", "{0CE698B0-4849-4096-9D7F-30E611F50DAD}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Multimedia.MediaCodec", "Tizen.Multimedia.MediaCodec\Tizen.Multimedia.MediaCodec.csproj", "{C74F30BE-BC8D-4D1A-84D6-F7255A6687BE}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Any CPU = Debug|Any CPU
+               Release|Any CPU = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {0CE698B0-4849-4096-9D7F-30E611F50DAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {0CE698B0-4849-4096-9D7F-30E611F50DAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {0CE698B0-4849-4096-9D7F-30E611F50DAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {0CE698B0-4849-4096-9D7F-30E611F50DAD}.Release|Any CPU.Build.0 = Release|Any CPU
+               {C74F30BE-BC8D-4D1A-84D6-F7255A6687BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {C74F30BE-BC8D-4D1A-84D6-F7255A6687BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {C74F30BE-BC8D-4D1A-84D6-F7255A6687BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {C74F30BE-BC8D-4D1A-84D6-F7255A6687BE}.Release|Any CPU.Build.0 = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
index 34e7ea6..349d4bf 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       csapi-multimedia
 Summary:    Tizen Multimedia API for C#
-Version:    1.1.0
+Version:    1.0.0
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
@@ -19,7 +19,9 @@ BuildRequires: csapi-application-common-nuget
 BuildRequires: elm-sharp-nuget
 BuildRequires: csapi-information-nuget
 
-%define Assemblies Tizen.Multimedia
+%define Assemblies \
+       Tizen.Multimedia 1.1.1 \
+       Tizen.Multimedia.MediaCodec 1.0.0
 
 %description
 %{summary}
@@ -31,14 +33,23 @@ BuildRequires: csapi-information-nuget
 cp %{SOURCE1} .
 
 %build
-for ASM in %{Assemblies}; do
-%dotnet_build $ASM
-%dotnet_pack $ASM/$ASM.nuspec %{version}
+AssemArray=(%Assemblies)
+
+for((i=0; i<${#AssemArray[*]};i+=2))
+do
+       AsmName=${AssemArray[$i]}
+       AsmVer=${AssemArray[$i+1]}
+       %dotnet_build $AsmName
+       %dotnet_pack $AsmName/$AsmName.nuspec $AsmVer
 done
 
 %install
-for ASM in %{Assemblies}; do
-%dotnet_install $ASM
+AssemArray=(%Assemblies)
+
+for((i=0; i<${#AssemArray[*]};i+=2))
+do
+       AsmName=${AssemArray[$i]}
+       %dotnet_install $AsmName
 done
 
 %files
diff --git a/src/Tizen.Multimedia.MediaCodec/Interop/Interop.Libraries.cs b/src/Tizen.Multimedia.MediaCodec/Interop/Interop.Libraries.cs
new file mode 100644 (file)
index 0000000..c3added
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+namespace Tizen.Multimedia.MediaCodec
+{
+    internal static partial class Interop
+    {
+        internal static partial class Libraries
+        {
+            public const string MediaCodec = "libcapi-media-codec.so.0";
+        }
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/Interop/Interop.MediaCodec.cs b/src/Tizen.Multimedia.MediaCodec/Interop/Interop.MediaCodec.cs
new file mode 100644 (file)
index 0000000..4d32948
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * 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;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Multimedia.MediaCodec
+{
+    internal static partial class Interop
+    {
+        internal static class MediaCodec
+        {
+            [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 ErrorCallback(int errorCode, 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 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_destroy")]
+            internal static extern int 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_vdec_info")]
+            internal static extern int 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_adec_info")]
+            internal static extern int 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_prepare")]
+            internal static extern int Prepare(IntPtr handle);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unprepare")]
+            internal static extern int 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_get_output")]
+            internal static extern int 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_set_input_buffer_used_cb")]
+            internal static extern int SetInputBufferUsedCb(IntPtr handle,
+                InputBufferUsedCallback cb, IntPtr arg);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_input_buffer_used_cb")]
+            internal static extern int UnsetInputBufferUsedCb(IntPtr handle);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_output_buffer_available_cb")]
+            internal static extern int SetOutputBufferAvaiableCb(IntPtr handle,
+                OutputBufferAvailableCallback cb, IntPtr arg);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_output_buffer_available_cb")]
+            internal static extern int UnsetOutputBufferAvaiableCb(IntPtr handle);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_error_cb")]
+            internal static extern int SetErrorCb(IntPtr handle, ErrorCallback cb, IntPtr arg);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_error_cb")]
+            internal static extern int UnsetErrorCb(IntPtr handle);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_eos_cb")]
+            internal static extern int SetEosCb(IntPtr handle, EosCallback cb, IntPtr arg);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_eos_cb")]
+            internal static extern int UnsetEosCb(IntPtr handle);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_set_buffer_status_cb")]
+            internal static extern int SetBufferStatusCb(IntPtr handle, BufferStatusCallback cb,
+                IntPtr arg);
+
+            [DllImport(Libraries.MediaCodec, EntryPoint = "mediacodec_unset_buffer_status_cb")]
+            internal static extern int 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_foreach_supported_codec_static")]
+            internal static extern int ForeachSupportedCodec(SupportedCodecCallback cb, IntPtr arg);
+        }
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/MediaCodec/BufferStatusChangedEventArgs.cs b/src/Tizen.Multimedia.MediaCodec/MediaCodec/BufferStatusChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..6beac7c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.MediaCodec
+{
+    /// <summary>
+    /// Provides data for the <see cref="MediaCodec.BufferStatusChanged"/> event.
+    /// </summary>
+    public class BufferStatusChangedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Initializes a new instance of the BufferStatusChangedEventArgs class.
+        /// </summary>
+        /// <param name="status">The value representing new status of the codec.</param>
+        public BufferStatusChangedEventArgs(MediaCodecStatus status)
+        {
+            Status = status;
+        }
+
+        /// <summary>
+        /// Gets the value indicating new status of the codec.
+        /// </summary>
+        public MediaCodecStatus Status { get; }
+
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/MediaCodec/InputProcessedEventArgs.cs b/src/Tizen.Multimedia.MediaCodec/MediaCodec/InputProcessedEventArgs.cs
new file mode 100644 (file)
index 0000000..1883d95
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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;
+using System.Diagnostics;
+
+namespace Tizen.Multimedia.MediaCodec
+{
+    /// <summary>
+    /// Provides data for the <see cref="MediaCodec.InputProcessed"/> event.
+    /// </summary>
+    public class InputProcessedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Initializes a new instance of the InputProcessedEventArgs class.
+        /// </summary>
+        /// <param name="packet">The packet that the codec has processed.</param>
+        internal InputProcessedEventArgs(MediaPacket packet)
+        {
+            Debug.Assert(packet != null);
+
+            Packet = packet;
+        }
+
+        /// <summary>
+        /// Gets the packet that the codec has processed.
+        /// </summary>
+        public MediaPacket Packet { get; }
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodec.cs b/src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodec.cs
new file mode 100644 (file)
index 0000000..2ab943c
--- /dev/null
@@ -0,0 +1,691 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using System.Diagnostics;
+
+namespace Tizen.Multimedia.MediaCodec
+{
+    /// <summary>
+    /// Provides the means to encode and decode video and audio data.
+    /// </summary>
+    public class MediaCodec : IDisposable
+    {
+        private static readonly int CodecTypeMask = 0xFFFF;
+        private static readonly int CodecKindMask = 0x3000;
+        private static readonly int CodecKindAudio = 0x1000;
+        private static readonly int CodecKindVideo = 0x2000;
+
+        private IntPtr _handle;
+
+        /// <summary>
+        /// Initialize a new instance of the MediaCodec class.
+        /// </summary>
+        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);
+
+            RegisterInputProcessed();
+            RegisterErrorOccurred();
+        }
+
+        #region IDisposable-support
+        private bool _isDisposed = false;
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!_isDisposed)
+            {
+                if (_handle != IntPtr.Zero)
+                {
+                    Interop.MediaCodec.Destroy(_handle);
+                    _handle = IntPtr.Zero;
+                }
+
+                _isDisposed = true;
+            }
+        }
+
+        ~MediaCodec()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+
+            GC.SuppressFinalize(this);
+        }
+        #endregion
+
+        /// <summary>
+        /// Validates if the object already has been disposed of.
+        /// </summary>
+        /// <exception cref="ObjectDisposedException">The current object has been disposed of.</exception>
+        private void ValidateNotDisposed()
+        {
+            if (_isDisposed)
+            {
+                throw new ObjectDisposedException(nameof(MediaCodec));
+            }
+        }
+
+        private static IEnumerable<MediaFormatVideoMimeType> _supportedVideoCodecs;
+
+        /// <summary>
+        /// Gets the audio codec list that the current device supports.
+        /// </summary>
+        public static IEnumerable<MediaFormatVideoMimeType> SupportedVideoCodecs
+        {
+            get
+            {
+                if (_supportedVideoCodecs == null)
+                {
+                    LoadSupportedCodec();
+                }
+
+                return _supportedVideoCodecs;
+            }
+        }
+
+        private static IEnumerable<MediaFormatAudioMimeType> _supportedAudioCodecs;
+
+
+        /// <summary>
+        /// Gets the audio codec list that the current device supports.
+        /// </summary>
+        public static IEnumerable<MediaFormatAudioMimeType> SupportedAudioCodecs
+        {
+            get
+            {
+                if (_supportedAudioCodecs == null)
+                {
+                    LoadSupportedCodec();
+                }
+
+                return _supportedAudioCodecs;
+            }
+        }
+
+        private static bool TryGetMimeTypeFromCodecType<T>(int codecType, ref T result)
+        {
+            if (codecType == -1)
+            {
+                return false;
+            }
+
+            foreach (T value in Enum.GetValues(typeof(T)))
+            {
+                if ((Convert.ToInt32(value) & CodecTypeMask) == codecType)
+                {
+                    result = value;
+                    return true;
+                }
+            }
+
+            Debug.Fail($"Unknown codec : { codecType }.");
+            return false;
+        }
+
+        private static void LoadSupportedCodec()
+        {
+            var videoCodecList = new List<MediaFormatVideoMimeType>();
+            var audioCodecList = new List<MediaFormatAudioMimeType>();
+
+            Interop.MediaCodec.SupportedCodecCallback cb = (codecType, _) =>
+            {
+                if ((codecType & CodecKindMask) == CodecKindVideo)
+                {
+                    MediaFormatVideoMimeType mimeType = 0;
+                    if (TryGetMimeTypeFromCodecType(codecType, ref mimeType))
+                    {
+                        videoCodecList.Add(mimeType);
+                    }
+                }
+                else
+                {
+                    MediaFormatAudioMimeType mimeType = 0;
+                    if (TryGetMimeTypeFromCodecType(codecType, ref mimeType))
+                    {
+                        audioCodecList.Add(mimeType);
+                    }
+                }
+
+                return true;
+            };
+
+            int ret = Interop.MediaCodec.ForeachSupportedCodec(cb, IntPtr.Zero);
+
+            MultimediaDebug.AssertNoError(ret);
+
+            _supportedVideoCodecs = videoCodecList.AsReadOnly();
+            _supportedAudioCodecs = audioCodecList.AsReadOnly();
+        }
+
+        /// <summary>
+        /// Prepares the MediaCodec for encoding or decoding.
+        /// </summary>
+        /// <exception cref="InvalidOperationException">
+        ///     The codec is not configured, yet.
+        ///     <para>-or-</para>
+        ///     Internal error.
+        /// </exception>
+        public void Prepare()
+        {
+            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);
+        }
+
+        /// <summary>
+        /// Unprepares the MediaCodec.
+        /// </summary>
+        public void Unprepare()
+        {
+            ValidateNotDisposed();
+
+            int ret = Interop.MediaCodec.Unprepare(_handle);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+
+        /// <summary>
+        /// Configures the MediaCodec.
+        /// </summary>
+        /// <param name="format">The <see cref="MediaFormat"/> for properties of media data to decode or encode.</param>
+        /// <param name="encoder">The value indicating whether the codec works as a encoder or a decoder.</param>
+        /// <param name="codecType">The value indicating whether the codec uses hardware acceleration.</param>
+        /// <exception cref="ArgumentNullException">format is null</exception>
+        /// <exception cref="ArgumentException">
+        ///     codecType is invalid.
+        ///     <para>-or-</para>
+        ///     format is neither audio type or video type.
+        ///     </exception>
+        /// <exception cref="NotSupportedException">the mime type of the format is not supported.</exception>
+        /// <see cref="SupportedAudioCodecs"/>
+        /// <see cref="SupportedVideoCodecs"/>
+        public void Configure(MediaFormat format, bool encoder, MediaCodecTypes codecType)
+        {
+            ValidateNotDisposed();
+
+            if (format == null)
+            {
+                throw new ArgumentNullException(nameof(format));
+            }
+
+            if (codecType != MediaCodecTypes.Hardware && codecType != MediaCodecTypes.Software)
+            {
+                throw new ArgumentException("codecType is invalid.");
+            }
+
+            if (format.Type == MediaFormatType.Audio)
+            {
+                ConfigureAudio((AudioMediaFormat)format, encoder, codecType);
+            }
+            else if (format.Type == MediaFormatType.Video)
+            {
+                ConfigureVideo((VideoMediaFormat)format, encoder, codecType);
+            }
+            else
+            {
+                throw new ArgumentException("Only video and audio formats are allowed.");
+            }
+        }
+
+        private void ConfigureAudio(AudioMediaFormat format, bool encoder,
+            MediaCodecTypes supportType)
+        {
+            int codecType = (int)format.MimeType & CodecTypeMask;
+
+            if (!Enum.IsDefined(typeof(SupportedCodecType), codecType))
+            {
+                throw new NotSupportedException("The format is not supported " +
+                    $"mime type : { Enum.GetName(typeof(MediaFormatAudioMimeType), format.MimeType) }");
+            }
+
+            DoConfigure(codecType, encoder, supportType);
+
+            if (encoder)
+            {
+                int ret = Interop.MediaCodec.SetAudioEncoderInfo(_handle, format.SampleRate,
+                    format.Channel, format.Bit, format.BitRate);
+
+                MultimediaDebug.AssertNoError(ret);
+            }
+            else
+            {
+                int ret = Interop.MediaCodec.SetAudioDecoderInfo(_handle, format.SampleRate,
+                    format.Channel, format.Bit);
+
+                MultimediaDebug.AssertNoError(ret);
+            }
+        }
+
+        private void ConfigureVideo(VideoMediaFormat format, bool encoder,
+            MediaCodecTypes supportType)
+        {
+            int codecType = (int)format.MimeType & CodecTypeMask;
+
+            if (!Enum.IsDefined(typeof(SupportedCodecType), codecType))
+            {
+                throw new NotSupportedException("The format is not supported." +
+                    $"mime type : { Enum.GetName(typeof(MediaFormatVideoMimeType), format.MimeType) }");
+            }
+
+            DoConfigure(codecType, encoder, supportType);
+
+            if (encoder)
+            {
+                int ret = Interop.MediaCodec.SetVideoEncoderInfo(_handle, format.Size.Width,
+                    format.Size.Height, format.FrameRate, format.BitRate / 1000);
+
+                MultimediaDebug.AssertNoError(ret);
+            }
+            else
+            {
+                int ret = Interop.MediaCodec.SetVideoDecoderInfo(_handle, format.Size.Width, format.Size.Height);
+
+                MultimediaDebug.AssertNoError(ret);
+            }
+        }
+
+        private void DoConfigure(int codecType, bool encoder, MediaCodecTypes supportType)
+        {
+            Debug.Assert(Enum.IsDefined(typeof(SupportedCodecType), codecType));
+
+            int flags = (int)(encoder ? MediaCodecCodingType.Encoder : MediaCodecCodingType.Decoder);
+
+            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);
+        }
+
+        /// <summary>
+        /// Adds the packet to the internal queue of the codec.
+        /// </summary>
+        /// <param name="packet">The packet to be encoded or decoded.</param>
+        /// <exception cref="ArgumentNullException">packet is null.</exception>
+        /// <exception cref="InvalidOperationException">the current codec is not prepared, yet.</exception>
+        /// <remarks>Any attempts to modify the packet will be failed until the <see cref="InputProcessed"/> event for the packet is invoked.</remarks>
+        public void ProcessInput(MediaPacket packet)
+        {
+            ValidateNotDisposed();
+
+            if (packet == null)
+            {
+                throw new ArgumentNullException(nameof(packet));
+            }
+
+            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);
+        }
+
+        /// <summary>
+        /// Flushes both input and output buffers.
+        /// </summary>
+        public void FlushBuffers()
+        {
+            ValidateNotDisposed();
+
+            int ret = Interop.MediaCodec.FlushBuffers(_handle);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+
+        /// <summary>
+        /// Retrieves supported codec types for the specified params.
+        /// </summary>
+        /// <param name="encoder">The value indicating encoder or decoder.</param>
+        /// <param name="type">The mime type to query.</param>
+        /// <returns>The values indicating which codec types are supported on the current device.</returns>
+        /// <exception cref="ArgumentException">type is invalid.</exception>
+        public MediaCodecTypes GetCodecType(bool encoder, MediaFormatVideoMimeType type)
+        {
+            ValidateNotDisposed();
+
+            if (CheckMimeType(typeof(MediaFormatVideoMimeType), (int)type) == false)
+            {
+                return 0;
+            }
+
+            return GetCodecType((int)type, encoder);
+        }
+
+        /// <summary>
+        /// Retrieves supported codec types for the specified params.
+        /// </summary>
+        /// <param name="encoder">The value indicating encoder or decoder.</param>
+        /// <param name="type">The mime type to query.</param>
+        /// <returns>The values indicating which codec types are supported on the current device.</returns>
+        /// <exception cref="ArgumentException">type is invalid.</exception>
+        public MediaCodecTypes GetCodecType(bool encoder, MediaFormatAudioMimeType type)
+        {
+            ValidateNotDisposed();
+
+            if (CheckMimeType(typeof(MediaFormatAudioMimeType), (int)type) == false)
+            {
+                return 0;
+            }
+
+            return GetCodecType((int)type, encoder);
+        }
+
+        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);
+
+            return (MediaCodecTypes)value;
+        }
+
+        private bool CheckMimeType(Type type, int value)
+        {
+            int codecType = value & CodecTypeMask;
+
+            if (!Enum.IsDefined(type, value))
+            {
+                throw new ArgumentException($"The mime type value is invalid : { value }.");
+            }
+
+            return Enum.IsDefined(typeof(SupportedCodecType), codecType);
+        }
+
+        #region OutputAvailable event
+        private EventHandler<OutputAvailableEventArgs> _outputAvailable;
+        private Interop.MediaCodec.OutputBufferAvailableCallback _outputBufferAvailableCb;
+
+        /// <summary>
+        /// Occurs when an output buffer is available.
+        /// </summary>
+        /// <remarks>The output packet needs to be disposed after it is used to clean up unmanaged resources.</remarks>
+        public event EventHandler<OutputAvailableEventArgs> OutputAvailable
+        {
+            add
+            {
+                ValidateNotDisposed();
+
+                if (_outputAvailable == null)
+                {
+                    RegisterOutputAvailableCallback();
+                }
+                _outputAvailable += value;
+
+            }
+            remove
+            {
+                ValidateNotDisposed();
+
+                _outputAvailable -= value;
+                if (_outputAvailable == null)
+                {
+                    UnregisterOutputAvailableCallback();
+                }
+            }
+        }
+
+        private void RegisterOutputAvailableCallback()
+        {
+            _outputBufferAvailableCb = (packetHandle, _) =>
+            {
+                OutputAvailableEventArgs args = null;
+
+                try
+                {
+                    args = new OutputAvailableEventArgs(packetHandle);
+                }
+                catch (Exception)
+                {
+                    Tizen.Multimedia.Interop.MediaPacket.Destroy(packetHandle);
+
+                    // TODO should we throw it to unmanaged code?
+                    throw;
+                }
+
+                //TODO dispose if no event handler registered
+                _outputAvailable?.Invoke(this, args);
+            };
+
+            int ret = Interop.MediaCodec.SetOutputBufferAvaiableCb(_handle,
+                _outputBufferAvailableCb, IntPtr.Zero);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+
+        private void UnregisterOutputAvailableCallback()
+        {
+            int ret = Interop.MediaCodec.UnsetOutputBufferAvaiableCb(_handle);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+        #endregion
+
+        #region InputProcessed event
+        private Interop.MediaCodec.InputBufferUsedCallback _inputBufferUsedCb;
+
+        /// <summary>
+        /// Occurs when an input packet is processed.
+        /// </summary>
+        /// <see cref="ProcessInput(MediaPacket)"/>
+        public event EventHandler<InputProcessedEventArgs> InputProcessed;
+
+        private void RegisterInputProcessed()
+        {
+            _inputBufferUsedCb = (lockedPacketHandle, _) =>
+            {
+                MediaPacket packet = null;
+
+                // Lock must be disposed here, note that the packet won't be disposed.
+                using (MediaPacket.Lock packetLock =
+                    MediaPacket.Lock.FromHandle(lockedPacketHandle))
+                {
+                    Debug.Assert(packetLock != null);
+
+                    packet = packetLock.MediaPacket;
+                }
+                Debug.Assert(packet != null);
+
+                InputProcessed?.Invoke(this, new InputProcessedEventArgs(packet));
+            };
+
+            int ret = Interop.MediaCodec.SetInputBufferUsedCb(_handle,
+                _inputBufferUsedCb, IntPtr.Zero);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+
+        private void UnregisterInputProcessed()
+        {
+            int ret = Interop.MediaCodec.UnsetInputBufferUsedCb(_handle);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+        #endregion
+
+        #region ErrorOccurred event
+        private Interop.MediaCodec.ErrorCallback _errorCb;
+
+        /// <summary>
+        /// Occurs whenever an error is produced in the codec.
+        /// </summary>
+        public event EventHandler<MediaCodecErrorOccurredEventArgs> ErrorOccurred;
+
+        private void RegisterErrorOccurred()
+        {
+            _errorCb = (errorCode, _) =>
+            {
+                MediaCodecError error = (Enum.IsDefined(typeof(MediaCodecError), errorCode)) ?
+                    (MediaCodecError)errorCode : MediaCodecError.InternalError;
+
+                ErrorOccurred?.Invoke(this, new MediaCodecErrorOccurredEventArgs(error));
+            };
+            int ret = Interop.MediaCodec.SetErrorCb(_handle, _errorCb, IntPtr.Zero);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+
+        private void UnregisterErrorOccurred()
+        {
+            int ret = Interop.MediaCodec.UnsetErrorCb(_handle);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+        #endregion
+
+        #region EosReached event
+        private EventHandler<EventArgs> _eosReached;
+        private Interop.MediaCodec.EosCallback _eosCb;
+
+        // TODO replace
+        /// <summary>
+        /// Occurs when the codec processes all input data.
+        /// </summary>
+        public event EventHandler<EventArgs> EosReached
+        {
+            add
+            {
+                ValidateNotDisposed();
+
+                if (_eosReached == null)
+                {
+                    RegisterEosReached();
+                }
+                _eosReached += value;
+
+            }
+            remove
+            {
+                ValidateNotDisposed();
+
+                _eosReached -= value;
+                if (_eosReached == null)
+                {
+                    UnregisterEosReached();
+                }
+            }
+        }
+
+        private void RegisterEosReached()
+        {
+            _eosCb = _ => _eosReached?.Invoke(this, EventArgs.Empty);
+
+            int ret = Interop.MediaCodec.SetEosCb(_handle, _eosCb, IntPtr.Zero);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+
+        private void UnregisterEosReached()
+        {
+            int ret = Interop.MediaCodec.UnsetEosCb(_handle);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+        #endregion
+
+        #region BufferStatusChanged event
+        private EventHandler<BufferStatusChangedEventArgs> _bufferStatusChanged;
+        private Interop.MediaCodec.BufferStatusCallback _bufferStatusCb;
+
+        /// <summary>
+        /// Occurs when the codec needs more data or has enough data.
+        /// </summary>
+        public event EventHandler<BufferStatusChangedEventArgs> BufferStatusChanged
+        {
+            add
+            {
+                ValidateNotDisposed();
+
+                if (_bufferStatusChanged == null)
+                {
+                    RegisterBufferStatusChanged();
+                }
+                _bufferStatusChanged += value;
+
+            }
+            remove
+            {
+                ValidateNotDisposed();
+
+                _bufferStatusChanged -= value;
+                if (_bufferStatusChanged == null)
+                {
+                    UnregisterBufferStatusChanged();
+                }
+            }
+        }
+
+        private void RegisterBufferStatusChanged()
+        {
+            _bufferStatusCb = (statusCode, _) =>
+            {
+                Debug.Assert(Enum.IsDefined(typeof(MediaCodecStatus), statusCode),
+                    $"{ statusCode } is not defined in MediaCodecStatus!");
+
+                _bufferStatusChanged?.Invoke(this,
+                    new BufferStatusChangedEventArgs((MediaCodecStatus)statusCode));
+            };
+
+            int ret = Interop.MediaCodec.SetBufferStatusCb(_handle, _bufferStatusCb, IntPtr.Zero);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+
+        private void UnregisterBufferStatusChanged()
+        {
+            int ret = Interop.MediaCodec.UnsetBufferStatusCb(_handle);
+
+            MultimediaDebug.AssertNoError(ret);
+        }
+        #endregion
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecError.cs b/src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecError.cs
new file mode 100644 (file)
index 0000000..14508f2
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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 Tizen.Internals.Errors;
+
+namespace Tizen.Multimedia.MediaCodec
+{
+    internal enum MediaCodecErrorCode
+    {
+        CodecDefinedBase = -0x019B0000,
+
+        None = ErrorCode.None,
+        OutOfMemory = ErrorCode.OutOfMemory,
+        InvalidParameter = ErrorCode.InvalidParameter,
+        InvalidOperation = ErrorCode.InvalidParameter,
+        NotSupportedOnDevice = ErrorCode.NotSupported,
+        PermissionDenied = ErrorCode.PermissionDenied,
+
+        InvalidState = CodecDefinedBase | 0x01,
+        InvalidInBuffer = CodecDefinedBase | 0x02,
+        InvalidOutBuffer = CodecDefinedBase | 0x03,
+        Internal = CodecDefinedBase | 0x04,
+        NotInitialized = CodecDefinedBase | 0x05,
+        InvalidStream = CodecDefinedBase | 0x06,
+        CodecNotFound = CodecDefinedBase | 0x07,
+        DecodingError = CodecDefinedBase | 0x08,
+        OutOfStorage = CodecDefinedBase | 0x09,
+        StreamNotFound = CodecDefinedBase | 0x0a,
+        NotSupportedFormat = CodecDefinedBase | 0x0b,
+        NoAvailableBuffer = CodecDefinedBase | 0x0c,
+        OverflowInBuffer = CodecDefinedBase | 0x0d,
+    }
+
+    public enum MediaCodecError
+    {
+        NotSupportedFormat = MediaCodecErrorCode.NotSupportedFormat,
+        InternalError = MediaCodecErrorCode.Internal,
+        OutOfStorage = MediaCodecErrorCode.OutOfStorage,
+        InvalidStream = MediaCodecErrorCode.InvalidStream,
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecErrorOccurredEventArgs.cs b/src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecErrorOccurredEventArgs.cs
new file mode 100644 (file)
index 0000000..0113b6a
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.MediaCodec
+{
+    /// <summary>
+    /// Provides data for the <see cref="MediaCodec.ErrorOccurred"/> event.
+    /// </summary>
+    public class MediaCodecErrorOccurredEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Initializes a new instance of the ErrorOccurredEventArgs class.
+        /// </summary>
+        /// <param name="error">The value representing the type of the error.</param>
+        public MediaCodecErrorOccurredEventArgs(MediaCodecError error)
+        {
+            Error = error;
+        }
+
+        /// <summary>
+        /// Gets the value indicating what kind of the error.
+        /// </summary>
+        public MediaCodecError Error { get; }
+    }
+}
  * limitations under the License.
  */
 
-using System.Runtime.CompilerServices;
+namespace Tizen.Multimedia.MediaCodec
+{
+    /// <summary>
+    /// Specifies the status of a codec.
+    /// </summary>
+    public enum MediaCodecStatus
+    {
+        /// <summary>
+        /// Not enough data to decode or encode.
+        /// </summary>
+        LackOfData,
 
-[assembly: InternalsVisibleTo("Tizen.Multimedia.MediaCodec, " +
-    "PublicKey=002400000480000094000000060200000024000052534131000400000100010085f7b7a5984e7e995" +
-    "d5f86234bfd1d4b2609b9334d5cb6cd3076c5faab98f8c4922d88fec96bea747fec274bceedc2bd1adb28c38a33" +
-    "c66182245adec7fbcee69cc556c337758646936500b770e19a562ebd10a527787f176eba8fdcf58c8e220042580" +
-    "75fe2903b3b5090953ac1d41c587993377cde63269a7cdd6cbf98efda")]
+        /// <summary>
+        /// Enough data to decode or encode.
+        /// </summary>
+        EnoughData
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecType.cs b/src/Tizen.Multimedia.MediaCodec/MediaCodec/MediaCodecType.cs
new file mode 100644 (file)
index 0000000..34da665
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.MediaCodec
+{
+    [Flags]
+    internal enum MediaCodecCodingType
+    {
+        Encoder = 0x1,
+        Decoder = 0x2
+    }
+
+    /// <summary>
+    /// Specifies types of codec.
+    /// </summary>
+    [Flags]
+    public enum MediaCodecTypes
+    {
+        /// <summary>
+        /// The hardware-accelerated codec.
+        /// </summary>
+        Hardware = 0x4,
+
+        /// <summary>
+        /// The software codec.
+        /// </summary>
+        Software = 0x8
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/MediaCodec/OutputAvailableEventArgs.cs b/src/Tizen.Multimedia.MediaCodec/MediaCodec/OutputAvailableEventArgs.cs
new file mode 100644 (file)
index 0000000..9c84828
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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.MediaCodec
+{
+    /// <summary>
+    /// Provides data for the <see cref="MediaCodec.OutputAvailable"/> event.
+    /// </summary>
+    /// <remarks>The output packet needs to be disposed after it is used to clean up unmanaged resources.</remarks>
+    public class OutputAvailableEventArgs : EventArgs
+    {
+        internal OutputAvailableEventArgs(IntPtr packetHandle)
+        {
+            Packet = MediaPacket.From(packetHandle);
+        }
+
+        /// <summary>
+        /// Gets the result packet.
+        /// </summary>
+        public MediaPacket Packet { get; }
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/MediaCodec/SupportedCodecType.cs b/src/Tizen.Multimedia.MediaCodec/MediaCodec/SupportedCodecType.cs
new file mode 100644 (file)
index 0000000..999808f
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+namespace Tizen.Multimedia.MediaCodec
+{
+    internal enum SupportedCodecType
+    {
+        // L16 = 0x1010,
+        // ALaw = 0x1020,
+        // ULaw = 0x1030,
+        Amr = 0x1040,
+        AmrNB = 0x1040,
+        AmrWb = 0x1041,
+        // G729 = 0x1050,
+        Aac = 0x1060,
+        AacLC = 0x1060,
+        AacHE = 0x1061,
+        AacHEPS = 0x1062,
+        MP3 = 0x1070,
+        Vorbis = 0x1080,
+        Flac = 0x1090,
+        Wma1 = 0x10A0,
+        Wma2 = 0x10A1,
+        WmaPro = 0x10A2,
+        WmaLossless = 0x10A3,
+
+        H261 = 0x2010,
+        H263 = 0x2020,
+        H264 = 0x2030,
+        MJpeg = 0x2040,
+        Mpeg1 = 0x2050,
+        Mpeg2 = 0x2060,
+        Mpeg4 = 0x2070,
+        // Hevc = 0x2080,
+        // VP8 = 0x2090,
+        // VP9 = 0x20A0,
+        // VC1 = 0x20B0,
+    }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/Properties/AssemblyInfo.cs b/src/Tizen.Multimedia.MediaCodec/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..1b4c6f4
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.Multimedia.MediaCodec")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Samsung Electronics")]
+[assembly: AssemblyProduct("Tizen.Multimedia.MediaCodec")]
+[assembly: AssemblyCopyright("Copyright © Samsung Electronics 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("c74f30be-bc8d-4d1a-84d6-f7255a6687be")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.csproj b/src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.csproj
new file mode 100644 (file)
index 0000000..b57f568
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{C74F30BE-BC8D-4D1A-84D6-F7255A6687BE}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Tizen.Multimedia.MediaCodec</RootNamespace>
+    <AssemblyName>Tizen.Multimedia.MediaCodec</AssemblyName>
+    <FileAlignment>512</FileAlignment>
+    <DefaultLanguage>en-US</DefaultLanguage>
+  </PropertyGroup>
+  <PropertyGroup>
+    <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
+    <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
+    <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
+    <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+    <NoStdLib>true</NoStdLib>
+    <NoWarn>$(NoWarn);1701</NoWarn>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>Tizen.Multimedia.MediaCodec.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <ItemGroup>
+    <None Include="Tizen.Multimedia.MediaCodec.nuspec" />
+    <None Include="Tizen.Multimedia.MediaCodec.project.json" />
+    <None Include="Tizen.Multimedia.MediaCodec.snk" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Interop\Interop.Libraries.cs" />
+    <Compile Include="Interop\Interop.MediaCodec.cs" />
+    <Compile Include="MediaCodec\BufferStatusChangedEventArgs.cs" />
+    <Compile Include="MediaCodec\InputProcessedEventArgs.cs" />
+    <Compile Include="MediaCodec\MediaCodec.cs" />
+    <Compile Include="MediaCodec\MediaCodecError.cs" />
+    <Compile Include="MediaCodec\MediaCodecErrorOccurredEventArgs.cs" />
+    <Compile Include="MediaCodec\MediaCodecStatus.cs" />
+    <Compile Include="MediaCodec\MediaCodecType.cs" />
+    <Compile Include="MediaCodec\OutputAvailableEventArgs.cs" />
+    <Compile Include="MediaCodec\SupportedCodecType.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Multimedia\Tizen.Multimedia.csproj">
+      <Project>{0ce698b0-4849-4096-9d7f-30e611f50dad}</Project>
+      <Name>Tizen.Multimedia</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+               Other similar extension points exist, see Microsoft.Common.targets.
+       <Target Name="BeforeBuild">
+       </Target>
+       <Target Name="AfterBuild">
+       </Target>
+       -->
+  <PropertyGroup>
+    <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
+                        https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
+               -->
+    <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
+                        properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
+                        to prevent it from outputting a warning (MSB3644).
+               -->
+    <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
+    <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
+    <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.nuspec b/src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.nuspec
new file mode 100644 (file)
index 0000000..ca5b7f9
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<package>
+  <metadata>
+               <id>Tizen.Multimedia.MediaCodec</id>
+               <version>$version$</version>
+               <authors>Samsung Electronics</authors>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
+    <projectUrl>https://www.tizen.org/</projectUrl>
+    <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
+    <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
+               <description>Provides the Multimedia MediaCodec API for Tizen.Net</description>
+    <dependencies>
+         <dependency id="Tizen" version="1.0.2" />
+      <dependency id="Tizen.Applications.Common" version="1.4.2" />
+      <dependency id="Tizen.Multimedia" version="1.1.0" />
+    </dependencies>
+       </metadata>
+  <files>
+    <file src="bin/$Configuration$/Tizen.Multimedia.MediaCodec.dll" target="lib/netstandard1.3" />
+  </files>
+</package>
diff --git a/src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.project.json b/src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.project.json
new file mode 100644 (file)
index 0000000..9ffa67b
--- /dev/null
@@ -0,0 +1,8 @@
+{
+       "dependencies": {
+               "NETStandard.Library": "1.6.0"
+       },
+       "frameworks": {
+               "netstandard1.3": {}
+       }
+}
diff --git a/src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.snk b/src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.snk
new file mode 100644 (file)
index 0000000..876b1f9
Binary files /dev/null and b/src/Tizen.Multimedia.MediaCodec/Tizen.Multimedia.MediaCodec.snk differ
index 1f3097c..0341e7f 100644 (file)
@@ -1,36 +1,43 @@
-using System.Reflection;\r
-using System.Runtime.CompilerServices;\r
-using System.Runtime.InteropServices;\r
-\r
-// General Information about an assembly is controlled through the following \r
-// set of attributes. Change these attribute values to modify the information\r
-// associated with an assembly.\r
-[assembly: AssemblyTitle("Tizen.Multimedia")]\r
-[assembly: AssemblyDescription("")]\r
-[assembly: AssemblyConfiguration("")]\r
-[assembly: AssemblyCompany("")]\r
-[assembly: AssemblyProduct("Tizen.Multimedia")]\r
-[assembly: AssemblyCopyright("Copyright ©  2016")]\r
-[assembly: AssemblyTrademark("")]\r
-[assembly: AssemblyCulture("")]\r
-\r
-// Setting ComVisible to false makes the types in this assembly not visible \r
-// to COM components.  If you need to access a type in this assembly from \r
-// COM, set the ComVisible attribute to true on that type.\r
-[assembly: ComVisible(false)]\r
-\r
-// The following GUID is for the ID of the typelib if this project is exposed to COM\r
-[assembly: Guid("3bbcff7a-1f64-43a8-bdca-ffaee260697a")]\r
-\r
-// Version information for an assembly consists of the following four values:\r
-//\r
-//      Major Version\r
-//      Minor Version \r
-//      Build Number\r
-//      Revision\r
-//\r
-// You can specify all the values or you can default the Build and Revision Numbers \r
-// by using the '*' as shown below:\r
-// [assembly: AssemblyVersion("1.0.*")]\r
-[assembly: AssemblyVersion("1.0.0.0")]\r
-[assembly: AssemblyFileVersion("1.0.0.0")]\r
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.Multimedia")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Samsung Electronics")]
+[assembly: AssemblyProduct("Tizen.Multimedia")]
+[assembly: AssemblyCopyright("Copyright © Samsung Electronics 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("3bbcff7a-1f64-43a8-bdca-ffaee260697a")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+
+
+[assembly: InternalsVisibleTo("Tizen.Multimedia.MediaCodec, " +
+    "PublicKey=002400000480000094000000060200000024000052534131000400000100010085f7b7a5984e7e995" +
+    "d5f86234bfd1d4b2609b9334d5cb6cd3076c5faab98f8c4922d88fec96bea747fec274bceedc2bd1adb28c38a33" +
+    "c66182245adec7fbcee69cc556c337758646936500b770e19a562ebd10a527787f176eba8fdcf58c8e220042580" +
+    "75fe2903b3b5090953ac1d41c587993377cde63269a7cdd6cbf98efda")]
index baafeee..c7103d2 100755 (executable)
@@ -88,7 +88,6 @@
     <Compile Include="Camera\PreviewEventArgs.cs" />
     <Compile Include="Camera\SinglePlane.cs" />
     <Compile Include="Camera\TriplePlane.cs" />
-    <Compile Include="Common\InternalsVisibleDefinitions.cs" />
     <Compile Include="Common\Display.cs" />
     <Compile Include="Common\FileFormatException.cs" />
     <Compile Include="Common\IBufferOwner.cs" />