Skip to content

Commit

Permalink
[MediaPlayer] Add new API to set video codec type (#5359)
Browse files Browse the repository at this point in the history
* [MediaPlayer] Add new API to set video codec type
  • Loading branch information
hsgwon authored Jul 11, 2023
1 parent 31f7768 commit 176e2b8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ internal static extern PlayerErrorCode GetTrackLanguageCode(IntPtr player, Strea

[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
Expand Down
46 changes: 42 additions & 4 deletions src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
* 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;

Expand Down Expand Up @@ -740,6 +736,48 @@ public CodecType AudioCodecType
}
}

/// <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>
Expand Down
1 change: 0 additions & 1 deletion src/Tizen.Multimedia.MediaPlayer/Player/PlayerEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ public enum PlayerAudioExtractOption
NoSyncAndDeinterleave = 0x03,
}


/// <summary>
/// Specifies the types of a codec for <see cref="Player"/>.
/// </summary>
Expand Down

0 comments on commit 176e2b8

Please sign in to comment.