[MediaPlayer] Add new API to set video codec type (#5359)
authorHaesu Gwon <haesu.gwon@samsung.com>
Tue, 11 Jul 2023 06:28:52 +0000 (15:28 +0900)
committerGitHub <noreply@github.com>
Tue, 11 Jul 2023 06:28:52 +0000 (15:28 +0900)
* [MediaPlayer] Add new API to set video codec type

src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
src/Tizen.Multimedia.MediaPlayer/Player/PlayerEnums.cs

index 585510f..e48e241 100644 (file)
@@ -387,6 +387,12 @@ internal static partial class Interop
 
         [DllImport(Libraries.Player, EntryPoint = "player_get_audio_codec_type")]
         internal static extern PlayerErrorCode GetAudioCodecType(IntPtr player, out CodecType type);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_set_video_codec_type")]
+        internal static extern PlayerErrorCode SetVideoCodecType(IntPtr player, CodecType type);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_get_video_codec_type")]
+        internal static extern PlayerErrorCode GetVideoCodecType(IntPtr player, out CodecType type);
     }
 
     internal class PlayerHandle : SafeHandle
index e180bb5..9decb5c 100644 (file)
  * limitations under the License.
  */
 using System;
-using System.Threading.Tasks;
-using System.Runtime.InteropServices;
 using System.Diagnostics;
-using System.IO;
-using System.Threading;
 using NativeDisplay = Interop.Display;
 using static Interop;
 
@@ -740,6 +736,48 @@ namespace Tizen.Multimedia
             }
         }
 
+        /// <summary>
+        /// Gets or sets the codec type of the video decoder.
+        /// </summary>
+        /// <value>A <see cref="CodecType"/> specifies the type.
+        /// The default codec type could be different depending on the device capability.</value>
+        /// <remarks>
+        /// <para>To set, the player must be in the <see cref="PlayerState.Idle"/> state.</para>
+        /// <para>If H/W video codec type is not supported in some cases, S/W video codec type could be used instead.</para>
+        /// <para>The availability could be changed depending on the codec capability.</para>
+        /// </remarks>
+        /// <exception cref="ObjectDisposedException">The player has already been disposed.</exception>
+        /// <exception cref="ArgumentException">The value is not valid.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     The player is not in the valid state.
+        ///     -or-<br/>
+        ///     Operation failed; internal error.
+        /// </exception>
+        /// <exception cref="CodecNotSupportedException">The selected codec is not supported.</exception>
+        /// <since_tizen> 11 </since_tizen>
+        public CodecType VideoCodecType
+        {
+            get
+            {
+                ValidateNotDisposed();
+
+                NativePlayer.GetVideoCodecType(Handle, out var value).
+                    ThrowIfFailed(this, "Failed to get the type of the video codec");
+
+                return value;
+            }
+            set
+            {
+                ValidateNotDisposed();
+                ValidatePlayerState(PlayerState.Idle);
+
+                ValidationUtil.ValidateEnum(typeof(CodecType), value, nameof(value));
+
+                NativePlayer.SetVideoCodecType(Handle, value).
+                    ThrowIfFailed(this, "Failed to set the type of the video codec");
+            }
+        }
+
         private SphericalVideo _sphericalVideo;
 
         /// <summary>
index ac58ce4..137fc1a 100644 (file)
@@ -327,7 +327,6 @@ namespace Tizen.Multimedia
         NoSyncAndDeinterleave = 0x03,
     }
 
-
     /// <summary>
     /// Specifies the types of a codec for <see cref="Player"/>.
     /// </summary>