{
private readonly MediaFormat _audioMediaFormat;
private readonly MediaFormat _videoMediaFormat;
+ private static List<MediaFormatAudioMimeType> _supportedAudioFormats;
+ private static List<MediaFormatVideoMimeType> _supportedVideoFormats;
/// <summary>
/// Gets all supported audio types.
{
get
{
- yield return MediaFormatAudioMimeType.Aac;
+ GetSupportedTypes();
+ return _supportedAudioFormats.AsReadOnly();
}
}
{
get
{
- yield return MediaFormatVideoMimeType.H264SP;
+ GetSupportedTypes();
+ return _supportedVideoFormats.AsReadOnly();
+ }
+ }
+
+ private static void GetSupportedTypes()
+ {
+ if (_supportedAudioFormats == null && _supportedVideoFormats == null)
+ {
+ PlayerHandle _playerHandle;
+ IntPtr _handle;
+
+ NativePlayer.Create(out _playerHandle).ThrowIfFailed(null, "Failed to create player");
+ _handle = _playerHandle.DangerousGetHandle();
+ Debug.Assert(_handle != IntPtr.Zero);
+
+ try
+ {
+ _supportedAudioFormats = new List<MediaFormatAudioMimeType>();
+ _supportedVideoFormats = new List<MediaFormatVideoMimeType>();
+
+ NativePlayer.SupportedMediaFormatCallback callback = (int format, IntPtr userData) =>
+ {
+ if (Enum.IsDefined(typeof(MediaFormatAudioMimeType), format))
+ {
+ Log.Debug(PlayerLog.Tag, "supported audio : " + ((MediaFormatAudioMimeType)format).ToString());
+ _supportedAudioFormats.Add((MediaFormatAudioMimeType)format);
+ }
+ else if (Enum.IsDefined(typeof(MediaFormatVideoMimeType), format))
+ {
+ Log.Debug(PlayerLog.Tag, "supported video : " + ((MediaFormatVideoMimeType)format).ToString());
+ _supportedVideoFormats.Add((MediaFormatVideoMimeType)format);
+ }
+ else
+ {
+ Log.Debug(PlayerLog.Tag, "skipped : " + format.ToString());
+ }
+
+ return true;
+ };
+
+ NativePlayer.SupportedMediaStreamFormat(_handle, callback, IntPtr.Zero).
+ ThrowIfFailed(null, "Failed to get the list");
+ }
+ finally
+ {
+ _playerHandle.Dispose();
+ }
}
}
return new MediaStreamConfiguration(this, StreamType.Video);
}
-
/// <summary>
/// Initializes a new instance of the MediaStreamSource class
/// with the specified <see cref="AudioMediaFormat"/> and <see cref="VideoMediaFormat"/>.
{
if (audioMediaFormat == null && videoMediaFormat == null)
{
- throw new ArgumentNullException(nameof(audioMediaFormat) + " and " + nameof(videoMediaFormat));
+ throw new ArgumentNullException(string.Concat(nameof(_audioMediaFormat), " and ", nameof(_videoMediaFormat)));
}
_audioMediaFormat = audioMediaFormat;
/// <since_tizen> 3 </since_tizen>
public MediaStreamSource(AudioMediaFormat audioMediaFormat)
{
- if (audioMediaFormat == null)
- {
- throw new ArgumentNullException(nameof(audioMediaFormat));
- }
-
- _audioMediaFormat = audioMediaFormat;
-
+ _audioMediaFormat = audioMediaFormat ?? throw new ArgumentNullException(nameof(audioMediaFormat));
AudioConfiguration = CreateAudioConfiguration(audioMediaFormat);
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public MediaStreamSource(VideoMediaFormat videoMediaFormat)
{
- if (videoMediaFormat == null)
- {
- throw new ArgumentNullException(nameof(videoMediaFormat));
- }
-
- _videoMediaFormat = videoMediaFormat;
-
+ _videoMediaFormat = videoMediaFormat ?? throw new ArgumentNullException(nameof(videoMediaFormat));
VideoConfiguration = CreateVideoConfiguration(videoMediaFormat);
}
Log.Error(PlayerLog.Tag, "The source is not set as a source to a player yet.");
throw new InvalidOperationException("The source is not set as a source to a player yet.");
}
+
if (packet == null)
{
Log.Error(PlayerLog.Tag, "packet is null");
throw new ArgumentNullException(nameof(packet));
}
+
if (packet.IsDisposed)
{
Log.Error(PlayerLog.Tag, "packet is disposed");
Log.Error(PlayerLog.Tag, "Video is not configured with the current source.");
throw new ArgumentException("Video is not configured with the current source.");
}
+
if (packet.Format.Type == MediaFormatType.Audio && _audioMediaFormat == null)
{
Log.Error(PlayerLog.Tag, "Audio is not configured with the current source.");
{
if (mediaFormat == null)
{
- Log.Error(PlayerLog.Tag, "invalid media format");
+ Log.Warn(PlayerLog.Tag, "invalid media format");
return;
}