[MediaTool] Add audio channel mapping APIs for PCM format (#1000)
authorhsgwon <haesu.gwon@samsung.com>
Mon, 16 Sep 2019 07:13:05 +0000 (16:13 +0900)
committerGitHub <noreply@github.com>
Mon, 16 Sep 2019 07:13:05 +0000 (16:13 +0900)
* [MediaTool] Add audio channel mapping APIs for PCM format

src/Tizen.Multimedia/Interop/Interop.MediaTool.cs
src/Tizen.Multimedia/MediaTool/AudioMediaFormat.cs
src/Tizen.Multimedia/MediaTool/MediaFormatChannelPosition.cs [new file with mode: 0644]
src/Tizen.Multimedia/MediaTool/MediaPacket.Lock.cs
src/Tizen.Multimedia/MediaTool/MediaPacket.cs
src/Tizen.Multimedia/MediaTool/MediaPacketVideoPlane.cs

index 35c5e4a..3174f14 100644 (file)
@@ -173,6 +173,26 @@ namespace Tizen.Multimedia
 
             [DllImport(Libraries.MediaTool, EntryPoint = "media_format_set_audio_aac_header_type")]
             internal static extern int SetAudioAacType(IntPtr handle, MediaFormatAacType value);
+
+            [DllImport(Libraries.MediaTool, EntryPoint = "media_format_set_audio_channel_mask")]
+            internal static extern int SetAudioChannelMask(IntPtr handle, ulong mask);
+
+            [DllImport(Libraries.MediaTool, EntryPoint = "media_format_get_audio_channel_mask")]
+            internal static extern int GetAudioChannelMask(IntPtr handle, out ulong mask);
+
+            [DllImport(Libraries.MediaTool, EntryPoint = "media_format_is_little_endian")]
+            internal static extern int IsLittleEndian(IntPtr handle, out bool isLittleEndian);
+
+            [DllImport(Libraries.MediaTool, EntryPoint = "media_format_get_audio_bit_depth")]
+            internal static extern int GetAudioBitDepth(IntPtr handle, out int bitDepth);
+
+            [DllImport(Libraries.MediaTool, EntryPoint = "media_format_channel_positions_from_mask")]
+            internal static extern int GetChannelPositionFromMask(IntPtr handle, ulong mask,
+                out MediaFormatAudioChannelPosition[] position);
+
+            [DllImport(Libraries.MediaTool, EntryPoint = "media_format_channel_positions_to_mask")]
+            internal static extern int GetMaskFromChannelPosition(IntPtr handle,
+                MediaFormatAudioChannelPosition[] position, out ulong mask);
             #endregion
 
             [DllImport(Libraries.MediaTool, EntryPoint = "media_format_get_text_info")]
index db99fff..e75bc2e 100644 (file)
  * limitations under the License.
  */
 using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
 using System.Diagnostics;
 using Tizen.Internals.Errors;
+using Native = Tizen.Multimedia.Interop.MediaFormat;
 
 namespace Tizen.Multimedia
 {
@@ -66,6 +70,91 @@ namespace Tizen.Multimedia
         /// <since_tizen> 3 </since_tizen>
         public AudioMediaFormat(MediaFormatAudioMimeType mimeType,
             int channel, int sampleRate, int bit, int bitRate, MediaFormatAacType aacType)
+            : this(mimeType, channel, sampleRate, bit, bitRate, aacType, 0, null)
+        {
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the AudioMediaFormat class with the specified mime type,
+        /// channel, sample rate, bit, bit rate, bit depth, and audio channel map.
+        /// </summary>
+        /// <remarks>
+        /// If <paramref name="audioChannelMap"/> contains <see cref="MediaFormatAudioChannelPosition.None"/>,
+        /// <paramref name="channel"/> should be set greater than 0.<br/>
+        /// If <paramref name="audioChannelMap"/> contains <see cref="MediaFormatAudioChannelPosition.Mono"/>,
+        /// <paramref name="channel"/> should be set 1.<br/>
+        /// User can not set <see cref="MediaFormatAudioChannelPosition.None"/> with another channel positions.<br/>
+        /// User can not set <see cref="MediaFormatAudioChannelPosition.Mono"/> with another channel positions.<br/>
+        /// If same channel position is added in <paramref name="audioChannelMap"/> more than once, the duplicaiton will be removed.
+        /// </remarks>
+        /// <param name="mimeType">The mime type of the format.</param>
+        /// <param name="channel">The channel value of the format.</param>
+        /// <param name="sampleRate">The sample rate value of the format.</param>
+        /// <param name="bit">The bit value of the format.</param>
+        /// <param name="bitRate">The bit rate value of the format.</param>
+        /// <param name="bitDepth">The bit depth value of the PCM audio format.</param>
+        /// <param name="audioChannelMap">The loudspeaker position in PCM audio format.</param>
+        /// <exception cref="ArgumentException">
+        ///     <paramref name="mimeType"/> is invalid (i.e. undefined value).<br/>
+        /// </exception>
+        /// <exception cref="ArgumentException">
+        /// <paramref name="audioChannelMap"/> is invalid or mismatched with <paramref name="channel"/> like the following:<br/>
+        ///     <paramref name="audioChannelMap"/> is not matched correctly with <paramref name="channel"/>.
+        ///     -or-<br/>
+        ///     <paramref name="audioChannelMap"/> is set to <see cref="MediaFormatAudioChannelPosition.Invaild"/>.
+        ///     -or-<br/>
+        ///     <see cref="MediaFormatAudioChannelPosition.Mono"/> or <see cref="MediaFormatAudioChannelPosition.None"/> is set with another channel position.
+        /// </exception>
+        /// <exception cref="ArgumentOutOfRangeException">
+        ///     <paramref name="channel"/>, <paramref name="sampleRate"/>, <paramref name="bit"/>, or <paramref name="bitRate"/> is less than zero.
+        /// </exception>
+        /// <since_tizen> 6 </since_tizen>
+        public AudioMediaFormat(MediaFormatAudioMimeType mimeType,
+            int channel, int sampleRate, int bit, int bitRate, int bitDepth, IList<MediaFormatAudioChannelPosition> audioChannelMap)
+            : this(mimeType, channel, sampleRate, bit, bitRate, MediaFormatAacType.None, bitDepth, audioChannelMap)
+        {
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the AudioMediaFormat class with the specified mime type,
+        /// channel, sample rate, bit, bit rate, bit depth, and audio channel map.
+        /// </summary>
+        /// <remarks>
+        /// If <paramref name="audioChannelMap"/> contains <see cref="MediaFormatAudioChannelPosition.None"/>,
+        /// <paramref name="channel"/> should be set greater than 0.<br/>
+        /// If <paramref name="audioChannelMap"/> contains <see cref="MediaFormatAudioChannelPosition.Mono"/>,
+        /// <paramref name="channel"/> should be set 1.<br/>
+        /// User can not set <see cref="MediaFormatAudioChannelPosition.None"/> with another channel positions.<br/>
+        /// User can not set <see cref="MediaFormatAudioChannelPosition.Mono"/> with another channel positions.<br/>
+        /// If same channel position is added in <paramref name="audioChannelMap"/> more than twice, its duplicaiton will be removed.
+        /// </remarks>
+        /// <param name="mimeType">The mime type of the format.</param>
+        /// <param name="channel">The channel value of the format.</param>
+        /// <param name="sampleRate">The sample rate value of the format.</param>
+        /// <param name="bit">The bit value of the format.</param>
+        /// <param name="bitRate">The bit rate value of the format.</param>
+        /// <param name="aacType">The AAC bitstream format(ADIF or ADTS).</param>
+        /// <param name="bitDepth">The bit depth value of the PCM audio format.</param>
+        /// <param name="audioChannelMap">The loudspeaker position in PCM audio format.</param>
+        /// <exception cref="ArgumentException">
+        ///     <paramref name="mimeType"/> or <paramref name="aacType"/> is invalid (i.e. undefined value).<br/>
+        ///     -or-<br/>
+        ///     <paramref name="aacType"/> is not <see cref="MediaFormatAacType.None"/>, but <paramref name="mimeType"/> is one of the AAC types.
+        /// </exception>
+        /// <exception cref="ArgumentException">
+        /// <paramref name="audioChannelMap"/> is invalid or mismatched with <paramref name="channel"/> like the following:<br/>
+        ///     <paramref name="audioChannelMap"/> is not matched correctly with <paramref name="channel"/>.
+        ///     -or-<br/>
+        ///     <paramref name="audioChannelMap"/> is set to <see cref="MediaFormatAudioChannelPosition.Invaild"/>.
+        ///     -or-<br/>
+        ///     <see cref="MediaFormatAudioChannelPosition.Mono"/> or <see cref="MediaFormatAudioChannelPosition.None"/> is set with another channel position.
+        /// </exception>
+        /// <exception cref="ArgumentOutOfRangeException">
+        ///     <paramref name="channel"/>, <paramref name="sampleRate"/>, <paramref name="bit"/>, or <paramref name="bitRate"/> is less than zero.
+        /// </exception>
+        /// <since_tizen> 6 </since_tizen>
+        public AudioMediaFormat(MediaFormatAudioMimeType mimeType,
+            int channel, int sampleRate, int bit, int bitRate, MediaFormatAacType aacType, int bitDepth, IList<MediaFormatAudioChannelPosition> audioChannelMap)
             : base(MediaFormatType.Audio)
         {
             ValidationUtil.ValidateEnum(typeof(MediaFormatAudioMimeType), mimeType, nameof(mimeType));
@@ -99,11 +188,53 @@ namespace Tizen.Multimedia
             }
 
             MimeType = mimeType;
+            AacType = aacType;
             Channel = channel;
             SampleRate = sampleRate;
             Bit = bit;
             BitRate = bitRate;
-            AacType = aacType;
+            BitDepth = bitDepth;
+
+            if (audioChannelMap != null)
+            {
+                audioChannelMap = audioChannelMap.Distinct().OrderBy(p => p).ToList();
+
+                ValidateAudioChannelMap(audioChannelMap);
+
+                AudioChannelMap = new ReadOnlyCollection<MediaFormatAudioChannelPosition>(audioChannelMap);
+            }
+        }
+
+        private void ValidateAudioChannelMap(IList<MediaFormatAudioChannelPosition> audioChannelMap)
+        {
+            if (audioChannelMap.Contains(MediaFormatAudioChannelPosition.Invaild))
+            {
+                throw new ArgumentException("Invalid channel position.", nameof(audioChannelMap));
+            }
+
+            if ((audioChannelMap.Contains(MediaFormatAudioChannelPosition.Mono) && audioChannelMap.Count > 1) ||
+                (audioChannelMap.Contains(MediaFormatAudioChannelPosition.None) && audioChannelMap.Count > 1))
+            {
+                throw new ArgumentException($"Mono and None can not be set with another channel position.",
+                    nameof(audioChannelMap));
+            }
+
+            if (audioChannelMap.Contains(MediaFormatAudioChannelPosition.None))
+            {
+                if (Channel <= 0)
+                {
+                    throw new ArgumentException($"Channel should be greater than 0 in {MediaFormatAudioChannelPosition.None}.",
+                        nameof(audioChannelMap));
+                }
+            }
+            else
+            {
+                if (audioChannelMap.Count != Channel)
+                {
+                    throw new ArgumentException("Channel should be the same with number of audioChannelMap.",
+                        nameof(audioChannelMap));
+                }
+            }
         }
 
         /// <summary>
@@ -123,6 +254,19 @@ namespace Tizen.Multimedia
             Bit = bit;
             BitRate = bitRate;
             AacType = IsAacSupportedMimeType(mimeType) ? GetAacType(handle) : MediaFormatAacType.None;
+            AudioChannelMap = GetAudioChannelMap(handle);
+        }
+
+        private static ReadOnlyCollection<MediaFormatAudioChannelPosition> GetAudioChannelMap(IntPtr handle)
+        {
+            var ret = Native.GetAudioChannelMask(handle, out ulong mask);
+            MultimediaDebug.AssertNoError(ret);
+
+            ret = Native.GetChannelPositionFromMask(handle, mask, out MediaFormatAudioChannelPosition[] positions);
+            MultimediaDebug.AssertNoError(ret);
+
+            return positions == null ? null :
+                new ReadOnlyCollection<MediaFormatAudioChannelPosition>(positions.Distinct().OrderBy(p => p).ToList());
         }
 
         /// <summary>
@@ -150,7 +294,7 @@ namespace Tizen.Multimedia
         {
             Debug.Assert(handle != IntPtr.Zero, "The handle is invalid!");
 
-            int ret = Interop.MediaFormat.GetAudioInfo(handle,
+            int ret = Native.GetAudioInfo(handle,
                 out mimeType, out channel, out sampleRate, out bit, out bitRate);
 
             MultimediaDebug.AssertNoError(ret);
@@ -167,7 +311,7 @@ namespace Tizen.Multimedia
         {
             Debug.Assert(handle != IntPtr.Zero, "The handle is invalid!");
 
-            int ret = Interop.MediaFormat.GetAudioAacType(handle, out var aacType);
+            int ret = Native.GetAudioAacType(handle, out var aacType);
 
             MultimediaDebug.AssertNoError(ret);
 
@@ -180,23 +324,38 @@ namespace Tizen.Multimedia
         {
             Debug.Assert(Type == MediaFormatType.Audio);
 
-            int ret = Interop.MediaFormat.SetAudioMimeType(handle, MimeType);
+            int ret = Native.SetAudioMimeType(handle, MimeType);
             MultimediaDebug.AssertNoError(ret);
 
-            ret = Interop.MediaFormat.SetAudioChannel(handle, Channel);
+            ret = Native.SetAudioChannel(handle, Channel);
             MultimediaDebug.AssertNoError(ret);
 
-            ret = Interop.MediaFormat.SetAudioSampleRate(handle, SampleRate);
+            ret = Native.SetAudioSampleRate(handle, SampleRate);
             MultimediaDebug.AssertNoError(ret);
 
-            ret = Interop.MediaFormat.SetAudioBit(handle, Bit);
+            ret = Native.SetAudioBit(handle, Bit);
             MultimediaDebug.AssertNoError(ret);
 
-            ret = Interop.MediaFormat.SetAudioAverageBps(handle, BitRate);
+            ret = Native.SetAudioAverageBps(handle, BitRate);
             MultimediaDebug.AssertNoError(ret);
 
-            ret = Interop.MediaFormat.SetAudioAacType(handle, AacType);
+            ret = Native.SetAudioAacType(handle, AacType);
             MultimediaDebug.AssertNoError(ret);
+
+            if (AudioChannelMap != null)
+            {
+                ret = Native.SetAudioChannelMask(handle, GetAudioChannelMask(handle, AudioChannelMap));
+                MultimediaDebug.AssertNoError(ret);
+            }
+        }
+
+        private static ulong GetAudioChannelMask(IntPtr handle, IList<MediaFormatAudioChannelPosition> audioChannelMap)
+        {
+            int ret = Native.GetMaskFromChannelPosition(handle, audioChannelMap.ToArray(),
+                out ulong mask);
+            MultimediaDebug.AssertNoError(ret);
+
+            return mask;
         }
 
         /// <summary>
@@ -212,6 +371,18 @@ namespace Tizen.Multimedia
         public int Channel { get; }
 
         /// <summary>
+        /// Gets or sets the list of channel position value of PCM audio format.
+        /// </summary>
+        /// <remarks>
+        /// The channel mask specifies the mapping of channels to speakers.
+        /// default value is 0.
+        /// </remarks>
+        /// <seealso cref="Channel"/>
+        /// <seealso cref="MediaFormatAudioChannelPosition"/>
+        /// <since_tizen> 6 </since_tizen>
+        public ReadOnlyCollection<MediaFormatAudioChannelPosition> AudioChannelMap { get; }
+
+        /// <summary>
         /// Gets the sample rate value of the current format.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
@@ -230,6 +401,12 @@ namespace Tizen.Multimedia
         public int BitRate { get; }
 
         /// <summary>
+        /// Gets the bit depth value of the current format.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public int BitDepth { get; }
+
+        /// <summary>
         /// Gets the AAC type of the current format.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
@@ -241,8 +418,17 @@ namespace Tizen.Multimedia
         /// <returns>A string that represents the current object.</returns>
         /// <since_tizen> 3 </since_tizen>
         public override string ToString()
-            => $@"MimeType={ MimeType.ToString() }, Channel={ Channel.ToString() }, SampleRate=
-                { SampleRate }, Bit={ Bit.ToString() }, BitRate={ BitRate.ToString() }, AacType={ AacType.ToString() }";
+        {
+            var toString = $@"MimeType={ MimeType.ToString() }, Channel={ Channel.ToString() }, SampleRate={ SampleRate },
+                Bit={ Bit.ToString() }, BitRate={ BitRate.ToString() }, BitDepth={ BitDepth.ToString() }, AacType={ AacType.ToString()}";
+
+            if (AudioChannelMap != null)
+            {
+                toString += ", AudioChannelMap=" + $"{string.Join(",", AudioChannelMap)}";
+            }
+
+            return toString;
+        }
 
         /// <summary>
         /// Compares an object to an instance of <see cref="AudioMediaFormat"/> for equality.
@@ -258,8 +444,23 @@ namespace Tizen.Multimedia
                 return false;
             }
 
+            var mapCompare = true;
+            // We don't care the case of both properties are null.
+            if (AudioChannelMap != null && rhs.AudioChannelMap != null)
+            {
+                for (int i = 0; i < AudioChannelMap.Count; i++)
+                {
+                    mapCompare = AudioChannelMap[i].Equals(rhs.AudioChannelMap[i]);
+                }
+            }
+            else if ((AudioChannelMap == null && rhs.AudioChannelMap != null) ||
+                (AudioChannelMap != null && rhs.AudioChannelMap == null))
+            {
+                mapCompare = false;
+            }
+
             return MimeType == rhs.MimeType && Channel == rhs.Channel && SampleRate == rhs.SampleRate &&
-                Bit == rhs.Bit && BitRate == rhs.BitRate && AacType == rhs.AacType;
+                Bit == rhs.Bit && BitRate == rhs.BitRate && BitDepth == rhs.BitDepth && AacType == rhs.AacType && mapCompare;
         }
 
         /// <summary>
@@ -268,6 +469,6 @@ namespace Tizen.Multimedia
         /// <returns>The hash code for this instance of <see cref="AudioMediaFormat"/>.</returns>
         /// <since_tizen> 3 </since_tizen>
         public override int GetHashCode()
-            => new { MimeType, Channel, SampleRate, Bit, BitRate, AacType }.GetHashCode();
+            => new { MimeType, Channel, SampleRate, Bit, BitRate, BitDepth, AacType, AudioChannelMap }.GetHashCode();
     }
 }
diff --git a/src/Tizen.Multimedia/MediaTool/MediaFormatChannelPosition.cs b/src/Tizen.Multimedia/MediaTool/MediaFormatChannelPosition.cs
new file mode 100644 (file)
index 0000000..9e06ce6
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2019 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
+{
+    /// <summary>
+    /// Specifies the channel position of <see cref="MediaFormatAudioMimeType.Pcm"/> media format.
+    /// </summary>
+    /// <remarks>This type is based on SMPTE 2036-2-2008 standard.</remarks>
+    /// <seealso cref="MediaFormatAudioMimeType"/>
+    /// <since_tizen> 6 </since_tizen>
+    public enum MediaFormatAudioChannelPosition
+    {
+        /// <summary>
+        /// This is used for position-less channels.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        None = -3,
+
+        /// <summary>
+        /// Mono channel.
+        /// </summary>
+        /// <remarks>If user want to set this value, <see cref="AudioMediaFormat.Channel"/> should be 1.</remarks>
+        /// <since_tizen> 6 </since_tizen>
+        Mono = -2,
+
+        /// <summary>
+        /// Invalid position.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        Invaild = -1,
+
+        /// <summary>
+        /// A loudspeaker position located at far left and centered vertically with the middle layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        FrontLeft = 0,
+
+        /// <summary>
+        /// A loudspeaker position located at far right and centered vertically with the middle layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        FrontRight,
+
+        /// <summary>
+        /// A loudspeaker position located at the middle layer corresponding to the center of the television
+        /// screen as viewed from the seating area.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        FrontCenter,
+
+        /// <summary>
+        /// A Low Frequency Effects(band-limited low frequency channel) loudspeaker position located at
+        /// the bottom layer and normally far left front, when LFE2 is used.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        LFE1,
+
+        /// <summary>
+        /// A loudspeaker position located at far left back of the middle layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        BackLeft,
+
+        /// <summary>
+        /// A loudspeaker position located at far right back of the middle layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        BackRight,
+
+        /// <summary>
+        /// A loudspeaker position located mid-way between the front center and front left of the middle layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        FrontLeftOrCenter,
+
+        /// <summary>
+        /// A loudspeaker position located mid-way between the front center and front right of the middle layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        FrontRightOrCenter,
+
+        /// <summary>
+        /// A loudspeaker position located at center back of the middle layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        BackCenter,
+
+        /// <summary>
+        /// A Low Frequency Effects(band-limited low frequency channel) loudspeaker position located at the
+        /// bottom layer, and is normally at far right front of the bottom layer, when LFE1 is used. 
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        LFE2,
+
+        /// <summary>
+        /// A loudspeaker position located at left side of the middle layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        SideLeft,
+
+        /// <summary>
+        /// A loudspeaker position located at right side of the middle layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        SideRight,
+
+        /// <summary>
+        /// A loudspeaker position located at far left front of the top layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        TopFrontLeft,
+
+        /// <summary>
+        /// A loudspeaker position located at far right front of the top layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        TopFrontRight,
+
+        /// <summary>
+        /// A loudspeaker position located at center front of the top layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        TopFrontCenter,
+
+        /// <summary>
+        /// A loudspeaker position located at the center of the top layer directly above the seating area.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        TopCenter,
+
+        /// <summary>
+        /// A loudspeaker position located at far left back of the top layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        TopBackLeft,
+
+        /// <summary>
+        /// A loudspeaker position located at far right back of the top layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        TopBackRight,
+
+        /// <summary>
+        /// A loudspeaker position located at left side of the top layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        TopSideLeft,
+
+        /// <summary>
+        /// A loudspeaker position located at right side of the top layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        TopSideRight,
+
+        /// <summary>
+        /// A loudspeaker position located at center back of the top layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        TopBackCenter,
+
+        /// <summary>
+        /// A loudspeaker position located at center front of the bottom layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        BottomFrontCenter,
+
+        /// <summary>
+        /// A loudspeaker position located at far left front of the bottom layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        BottomFrontLeft,
+
+        /// <summary>
+        /// A loudspeaker position located at far right front of the bottom layer.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        BottomFrontRight,
+
+        /// <summary>
+        /// A loudspeaker position located between front left and side left.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        WideLeft,
+
+        /// <summary>
+        /// A loudspeaker position located between front right and side right.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        WideRight,
+
+        /// <summary>
+        /// A loudspeaker position located between back left and side left.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        SurroundLeft,
+
+        /// <summary>
+        /// A loudspeaker position located between back right and side right.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        SurroundRight
+    }
+}
index 5629119..94706d4 100644 (file)
@@ -19,6 +19,7 @@ using System.Diagnostics;
 using System.Runtime.InteropServices;
 using System.Threading;
 using Tizen.Internals.Errors;
+using Native = Tizen.Multimedia.Interop.MediaPacket;
 
 namespace Tizen.Multimedia
 {
@@ -136,14 +137,14 @@ namespace Tizen.Multimedia
 
             private void SetExtra(IntPtr ptr)
             {
-                int ret = Interop.MediaPacket.SetExtra(_packet._handle, ptr);
+                int ret = Native.SetExtra(_packet._handle, ptr);
 
                 MultimediaDebug.AssertNoError(ret);
             }
 
             private static IntPtr GetExtra(IntPtr handle)
             {
-                int ret = Interop.MediaPacket.GetExtra(handle, out var value);
+                int ret = Native.GetExtra(handle, out var value);
 
                 MultimediaDebug.AssertNoError(ret);
 
index 54ca5b1..43ba0c4 100644 (file)
@@ -16,9 +16,9 @@
 
 using System;
 using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Threading;
 using Tizen.Internals.Errors;
+using Native = Tizen.Multimedia.Interop.MediaPacket;
+using NativeFormat = Tizen.Multimedia.Interop.MediaFormat;
 
 namespace Tizen.Multimedia
 {
@@ -59,7 +59,7 @@ namespace Tizen.Multimedia
         {
             _handle = handle;
 
-            int ret = Interop.MediaPacket.GetFormat(handle, out IntPtr formatHandle);
+            int ret = Native.GetFormat(handle, out IntPtr formatHandle);
 
             MultimediaDebug.AssertNoError(ret);
 
@@ -72,7 +72,7 @@ namespace Tizen.Multimedia
             }
             finally
             {
-                Interop.MediaFormat.Unref(formatHandle);
+                NativeFormat.Unref(formatHandle);
             }
         }
 
@@ -103,7 +103,7 @@ namespace Tizen.Multimedia
             {
                 formatHandle = format.AsNativeHandle();
 
-                int ret = Interop.MediaPacket.Create(formatHandle, IntPtr.Zero, IntPtr.Zero, out _handle);
+                int ret = Native.Create(formatHandle, IntPtr.Zero, IntPtr.Zero, out _handle);
                 MultimediaDebug.AssertNoError(ret);
 
                 Debug.Assert(_handle != IntPtr.Zero, "Created handle must not be null");
@@ -114,7 +114,7 @@ namespace Tizen.Multimedia
             {
                 if (_handle != IntPtr.Zero)
                 {
-                    Interop.MediaPacket.Destroy(_handle);
+                    Native.Destroy(_handle);
                     _handle = IntPtr.Zero;
                 }
 
@@ -124,7 +124,7 @@ namespace Tizen.Multimedia
             {
                 if (formatHandle != IntPtr.Zero)
                 {
-                    Interop.MediaFormat.Unref(formatHandle);
+                    NativeFormat.Unref(formatHandle);
                 }
             }
         }
@@ -135,7 +135,7 @@ namespace Tizen.Multimedia
         /// <exception cref="InvalidOperationException">Operation failed.</exception>
         private void Alloc()
         {
-            ErrorCode ret = (ErrorCode)Interop.MediaPacket.Alloc(_handle);
+            ErrorCode ret = (ErrorCode)Native.Alloc(_handle);
             if (ret == ErrorCode.None)
             {
                 return;
@@ -183,7 +183,7 @@ namespace Tizen.Multimedia
             {
                 ValidateNotDisposed();
 
-                int ret = Interop.MediaPacket.GetPts(_handle, out var value);
+                int ret = Native.GetPts(_handle, out var value);
 
                 MultimediaDebug.AssertNoError(ret);
 
@@ -194,7 +194,7 @@ namespace Tizen.Multimedia
                 ValidateNotDisposed();
                 ValidateNotLocked();
 
-                int ret = Interop.MediaPacket.SetPts(_handle, value);
+                int ret = Native.SetPts(_handle, value);
 
                 MultimediaDebug.AssertNoError(ret);
             }
@@ -214,7 +214,7 @@ namespace Tizen.Multimedia
             {
                 ValidateNotDisposed();
 
-                int ret = Interop.MediaPacket.GetDts(_handle, out var value);
+                int ret = Native.GetDts(_handle, out var value);
                 MultimediaDebug.AssertNoError(ret);
 
                 return value;
@@ -224,7 +224,7 @@ namespace Tizen.Multimedia
                 ValidateNotDisposed();
                 ValidateNotLocked();
 
-                int ret = Interop.MediaPacket.SetDts(_handle, value);
+                int ret = Native.SetDts(_handle, value);
                 MultimediaDebug.AssertNoError(ret);
             }
         }
@@ -243,7 +243,7 @@ namespace Tizen.Multimedia
             {
                 ValidateNotDisposed();
 
-                int ret = Interop.MediaPacket.GetDuration(_handle, out var value);
+                int ret = Native.GetDuration(_handle, out var value);
                 MultimediaDebug.AssertNoError(ret);
 
                 return value;
@@ -253,7 +253,7 @@ namespace Tizen.Multimedia
                 ValidateNotDisposed();
                 ValidateNotLocked();
 
-                int ret = Interop.MediaPacket.SetDuration(_handle, value);
+                int ret = Native.SetDuration(_handle, value);
                 MultimediaDebug.AssertNoError(ret);
             }
         }
@@ -270,7 +270,7 @@ namespace Tizen.Multimedia
             {
                 ValidateNotDisposed();
 
-                int ret = Interop.MediaPacket.IsEncoded(_handle, out var value);
+                int ret = Native.IsEncoded(_handle, out var value);
                 MultimediaDebug.AssertNoError(ret);
 
                 return value;
@@ -292,7 +292,7 @@ namespace Tizen.Multimedia
             {
                 ValidateNotDisposed();
 
-                int ret = Interop.MediaPacket.GetRotation(_handle, out var value);
+                int ret = Native.GetRotation(_handle, out var value);
                 MultimediaDebug.AssertNoError(ret);
 
                 var rotation = value < RotationFlip.HorizontalFlip ? (Rotation)value : Rotation.Rotate0;
@@ -305,7 +305,7 @@ namespace Tizen.Multimedia
                 ValidateNotLocked();
                 ValidationUtil.ValidateEnum(typeof(Rotation), value, nameof(value));
 
-                int ret = Interop.MediaPacket.SetRotation(_handle, (RotationFlip)value);
+                int ret = Native.SetRotation(_handle, (RotationFlip)value);
                 MultimediaDebug.AssertNoError(ret);
             }
         }
@@ -328,7 +328,7 @@ namespace Tizen.Multimedia
             {
                 ValidateNotDisposed();
 
-                int ret = Interop.MediaPacket.GetRotation(_handle, out var value);
+                int ret = Native.GetRotation(_handle, out var value);
                 MultimediaDebug.AssertNoError(ret);
 
                 var flip = (value < RotationFlip.HorizontalFlip) ? Flips.None :
@@ -349,7 +349,7 @@ namespace Tizen.Multimedia
 
                 var flip = value == Flips.Horizontal ? RotationFlip.HorizontalFlip : RotationFlip.VerticalFlip;
 
-                int ret = Interop.MediaPacket.SetRotation(_handle, flip);
+                int ret = Native.SetRotation(_handle, flip);
                 MultimediaDebug.AssertNoError(ret);
             }
         }
@@ -400,7 +400,7 @@ namespace Tizen.Multimedia
             {
                 ValidateNotDisposed();
 
-                int ret = Interop.MediaPacket.GetBufferSize(_handle, out var value);
+                int ret = Native.GetBufferSize(_handle, out var value);
                 MultimediaDebug.AssertNoError(ret);
 
                 Debug.Assert(value < int.MaxValue);
@@ -426,7 +426,7 @@ namespace Tizen.Multimedia
                         "value must be less than Buffer.Size.");
                 }
 
-                int ret = Interop.MediaPacket.SetBufferSize(_handle, (ulong)value);
+                int ret = Native.SetBufferSize(_handle, (ulong)value);
                 MultimediaDebug.AssertNoError(ret);
             }
         }
@@ -476,7 +476,7 @@ namespace Tizen.Multimedia
             {
                 ValidateNotDisposed();
 
-                int ret = Interop.MediaPacket.GetBufferFlags(_handle, out var value);
+                int ret = Native.GetBufferFlags(_handle, out var value);
 
                 MultimediaDebug.AssertNoError(ret);
 
@@ -488,11 +488,11 @@ namespace Tizen.Multimedia
                 ValidateNotDisposed();
                 ValidateNotLocked();
 
-                int ret = Interop.MediaPacket.ResetBufferFlags(_handle);
+                int ret = Native.ResetBufferFlags(_handle);
 
                 MultimediaDebug.AssertNoError(ret);
 
-                ret = Interop.MediaPacket.SetBufferFlags(_handle, (int)value);
+                ret = Native.SetBufferFlags(_handle, (int)value);
 
                 MultimediaDebug.AssertNoError(ret);
             }
@@ -543,7 +543,7 @@ namespace Tizen.Multimedia
 
             if (_handle != IntPtr.Zero)
             {
-                Interop.MediaPacket.Destroy(_handle);
+                Native.Destroy(_handle);
                 _handle = IntPtr.Zero;
             }
 
@@ -606,7 +606,7 @@ namespace Tizen.Multimedia
         {
             Debug.Assert(_handle != IntPtr.Zero, "The handle is invalid!");
 
-            int ret = Interop.MediaPacket.GetNumberOfVideoPlanes(_handle, out var numberOfPlanes);
+            int ret = Native.GetNumberOfVideoPlanes(_handle, out var numberOfPlanes);
 
             MultimediaDebug.AssertNoError(ret);
 
@@ -630,12 +630,12 @@ namespace Tizen.Multimedia
 
             Debug.Assert(_handle != IntPtr.Zero, "The handle is invalid!");
 
-            int ret = Interop.MediaPacket.GetBufferData(_handle, out var dataHandle);
+            int ret = Native.GetBufferData(_handle, out var dataHandle);
             MultimediaDebug.AssertNoError(ret);
 
             Debug.Assert(dataHandle != IntPtr.Zero, "Data handle is invalid!");
 
-            ret = Interop.MediaPacket.GetAllocatedBufferSize(_handle, out var size);
+            ret = Native.GetAllocatedBufferSize(_handle, out var size);
             MultimediaDebug.AssertNoError(ret);
 
             Debug.Assert(size >= 0, "size must not be negative!");
index a751126..31ffcb2 100644 (file)
@@ -16,6 +16,7 @@
 
 using System;
 using System.Diagnostics;
+using Native = Tizen.Multimedia.Interop.MediaPacket;
 
 namespace Tizen.Multimedia
 {
@@ -39,15 +40,15 @@ namespace Tizen.Multimedia
 
             _packet = packet;
 
-            int ret = Interop.MediaPacket.GetVideoStrideWidth(packet.GetHandle(), index, out _strideWidth);
+            int ret = Native.GetVideoStrideWidth(packet.GetHandle(), index, out _strideWidth);
             MultimediaDebug.AssertNoError(ret);
 
-            ret = Interop.MediaPacket.GetVideoStrideHeight(packet.GetHandle(), index, out _strideHeight);
+            ret = Native.GetVideoStrideHeight(packet.GetHandle(), index, out _strideHeight);
             MultimediaDebug.AssertNoError(ret);
 
             Debug.Assert(_strideWidth >= 0 && _strideHeight >= 0, "size must not be negative!");
 
-            ret = Interop.MediaPacket.GetVideoPlaneData(packet.GetHandle(), index, out var dataHandle);
+            ret = Native.GetVideoPlaneData(packet.GetHandle(), index, out var dataHandle);
             MultimediaDebug.AssertNoError(ret);
 
             Debug.Assert(dataHandle != IntPtr.Zero, "Data handle is invalid!");