[DllImport(Libraries.MediaTool, EntryPoint = "media_packet_get_rotate_method")]
internal static extern int GetRotation(IntPtr handle, out RotationFlip rotationFlip);
+
+ [DllImport(Libraries.MediaTool, EntryPoint = "media_packet_set_duration")]
+ internal static extern int SetDuration(IntPtr handle, ulong value);
+
+ [DllImport(Libraries.MediaTool, EntryPoint = "media_packet_get_duration")]
+ internal static extern int GetDuration(IntPtr handle, out ulong value);
}
internal static class MediaFormat
[DllImport(Libraries.MediaTool, EntryPoint = "media_format_set_video_avg_bps")]
internal static extern int SetVideoAverageBps(IntPtr handle, int value);
+ [DllImport(Libraries.MediaTool, EntryPoint = "media_format_set_video_max_bps")]
+ internal static extern int SetVideoMaxBps(IntPtr handle, int value);
+
[DllImport(Libraries.MediaTool, EntryPoint = "media_format_set_video_frame_rate")]
internal static extern int SetVideoFrameRate(IntPtr handle, int value);
#endregion
{
_handle = handle;
- IntPtr formatHandle;
- int ret = Interop.MediaPacket.GetFormat(handle, out formatHandle);
+ int ret = Interop.MediaPacket.GetFormat(handle, out IntPtr formatHandle);
MultimediaDebug.AssertNoError(ret);
}
/// <summary>
+ /// Gets or sets the duration value of the current packet.
+ /// </summary>
+ /// <exception cref="ObjectDisposedException">The MediaPacket has already been disposed of.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The MediaPacket is not in the writable state, which means it is being used by another module.
+ /// </exception>
+ /// <since_tizen> 6 </since_tizen>
+ public ulong Duration
+ {
+ get
+ {
+ ValidateNotDisposed();
+
+ int ret = Interop.MediaPacket.GetDuration(_handle, out var value);
+ MultimediaDebug.AssertNoError(ret);
+
+ return value;
+ }
+ set
+ {
+ ValidateNotDisposed();
+ ValidateNotLocked();
+
+ int ret = Interop.MediaPacket.SetDuration(_handle, value);
+ MultimediaDebug.AssertNoError(ret);
+ }
+ }
+
+ /// <summary>
/// Gets a value indicating whether the packet is the encoded type.
/// </summary>
/// <value>true if the packet is the encoded type; otherwise, false.</value>
{
private const int DefaultFrameRate = 0;
private const int DefaultBitRate = 0;
+ private const int DefaultMaxBps = 0;
/// <summary>
/// Initializes a new instance of the VideoMediaFormat class with the specified mime type, width, and height.
/// <since_tizen> 3 </since_tizen>
public VideoMediaFormat(MediaFormatVideoMimeType mimeType, Size size,
int frameRate, int bitRate)
+ : this (mimeType, size, frameRate, bitRate, DefaultMaxBps)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the VideoMediaFormat class with the specified mime type,
+ /// size, frame rate, and bit rate.
+ /// </summary>
+ /// <param name="mimeType">The mime type of the format.</param>
+ /// <param name="size">The size of the format.</param>
+ /// <param name="frameRate">The frame rate of the format.</param>
+ /// <param name="bitRate">The bit rate of the format.</param>
+ /// <param name="maxBps">The max bps of the format.</param>
+ /// <exception cref="ArgumentException"><paramref name="mimeType"/> is invalid (i.e. undefined value).</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// The width or the height of <paramref name="size"/> is less than zero.<br/>
+ /// -or-<br/>
+ /// <paramref name="frameRate"/> is less than zero.<br/>
+ /// -or-<br/>
+ /// <paramref name="bitRate"/> is less than zero.
+ /// -or-<br/>
+ /// <paramref name="maxBps"/> is less than zero.
+ /// </exception>
+ /// <since_tizen> 6 </since_tizen>
+ public VideoMediaFormat(MediaFormatVideoMimeType mimeType, Size size, int frameRate, int bitRate, int maxBps)
: base(MediaFormatType.Video)
{
ValidationUtil.ValidateEnum(typeof(MediaFormatVideoMimeType), mimeType, nameof(mimeType));
{
throw new ArgumentOutOfRangeException(nameof(bitRate), bitRate, "Bit rate value can't be less than zero.");
}
+ if (maxBps < 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(maxBps), maxBps, "Max bps value can't be less than zero.");
+ }
MimeType = mimeType;
Size = size;
FrameRate = frameRate;
BitRate = bitRate;
+ MaxBps = maxBps;
}
/// <summary>
Size = new Size(width, height);
FrameRate = frameRate;
BitRate = bitRate;
+ MaxBps = maxBps;
}
internal override void AsNativeHandle(IntPtr handle)
ret = Interop.MediaFormat.SetVideoFrameRate(handle, FrameRate);
MultimediaDebug.AssertNoError(ret);
+
+ ret = Interop.MediaFormat.SetVideoMaxBps(handle, MaxBps);
+ MultimediaDebug.AssertNoError(ret);
}
/// <summary>
public int BitRate { get; }
/// <summary>
+ /// Gets the max bps value of the current format.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public int MaxBps { get; }
+
+ /// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
/// <since_tizen> 3 </since_tizen>
public override string ToString()
=> $@"MimeType={ MimeType.ToString() }, Size=({ Size.ToString() }), FrameRate=
- { FrameRate.ToString() }, BitRate={ BitRate.ToString() }";
+ { FrameRate.ToString() }, BitRate={ BitRate.ToString() }, MaxBps = { MaxBps.ToString() }";
/// <summary>
/// Compares an object to an instance of <see cref="VideoMediaFormat"/> for equality.
}
return MimeType == rhs.MimeType && Size == rhs.Size &&
- FrameRate == rhs.FrameRate && BitRate == rhs.BitRate;
+ FrameRate == rhs.FrameRate && BitRate == rhs.BitRate && MaxBps == rhs.MaxBps;
}
/// <summary>
/// <returns>The hash code for this instance of <see cref="VideoMediaFormat"/>.</returns>
/// <since_tizen> 3 </since_tizen>
public override int GetHashCode()
- => new { MimeType, Size, FrameRate, BitRate }.GetHashCode();
+ => new { MimeType, Size, FrameRate, BitRate, MaxBps }.GetHashCode();
}
}