--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ */
+
+using Tizen.System;
+
+namespace Tizen.Multimedia
+{
+ internal static class Features
+ {
+ internal static string AudioEffect = "http://tizen.org/feature/multimedia.custom_audio_effect";
+ internal static string RawVideo = "http://tizen.org/feature/multimedia.raw_video";
+
+ internal static bool IsSupported(string featureKey)
+ {
+ bool supported = false;
+ SystemInfo.TryGetValue(featureKey, out supported);
+ return supported;
+ }
+
+ }
+}
private Interop.Player.PlaybackErrorCallback _playbackErrorCallback;
/// <summary>
- /// Occurs when a video frame is decoded
- /// </summary>
- /// <remarks>
- /// <para>The event handler will be executed on an internal thread.</para>
- /// <para>The <see cref="VideoFrameDecodedEventArgs.Packet"/> in event args should be disposed after use.</para>
- /// </remarks>
- /// <see cref="VideoFrameDecodedEventArgs.Packet"/>
- public event EventHandler<VideoFrameDecodedEventArgs> VideoFrameDecoded;
- private Interop.Player.VideoFrameDecodedCallback _videoFrameDecodedCallback;
-
- /// <summary>
/// Occurs when the video stream changed.
/// </summary>
/// <remarks>The event handler will be executed on an internal thread.</remarks>
RetrieveProperties();
- AudioEffect = new AudioEffect(this);
- DisplaySettings = new PlayerDisplaySettings(this);
+ if (Features.IsSupported(Features.AudioEffect))
+ {
+ _audioEffect = new AudioEffect(this);
+ }
- RegisterVideoFrameDecodedCallback();
+ if (Features.IsSupported(Features.RawVideo))
+ {
+ RegisterVideoFrameDecodedCallback();
+ }
}
private void RetrieveProperties()
}
}
+ private readonly AudioEffect _audioEffect;
+
/// <summary>
- /// Gets audio effect.
+ /// Gets the audio effect.
/// </summary>
- public AudioEffect AudioEffect { get; }
+ /// <feature>http://tizen.org/feature/multimedia.custom_audio_effect</feature>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+ public AudioEffect AudioEffect
+ {
+ get
+ {
+ if (_audioEffect == null)
+ {
+ throw new NotSupportedException($"The feature({Features.AudioEffect}) is not supported.");
+ }
+
+ return _audioEffect;
+ }
+ }
#endregion
/// <summary>
/// Captures a video frame asynchronously.
/// </summary>
+ /// <feature>http://tizen.org/feature/multimedia.raw_video</feature>
/// <remarks>The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
/// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
/// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public async Task<CapturedFrame> CaptureVideoAsync()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
+
+ ValidationUtil.ValidateFeatureSupported(Features.RawVideo);
+
ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);
TaskCompletionSource<CapturedFrame> t = new TaskCompletionSource<CapturedFrame>();
ThrowIfFailed("Failed to set PlaybackError");
}
+ #region VideoFrameDecoded event
+
+ private EventHandler<VideoFrameDecodedEventArgs> _videoFrameDecoded;
+
+ private Interop.Player.VideoFrameDecodedCallback _videoFrameDecodedCallback;
+
+ /// <summary>
+ /// Occurs when a video frame is decoded
+ /// </summary>
+ /// <remarks>
+ /// <para>The event handler will be executed on an internal thread.</para>
+ /// <para>The <see cref="VideoFrameDecodedEventArgs.Packet"/> in event args should be disposed after use.</para>
+ /// </remarks>
+ /// <feature>http://tizen.org/feature/multimedia.raw_video</feature>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+ /// <seealso cref="VideoFrameDecodedEventArgs.Packet"/>
+ public event EventHandler<VideoFrameDecodedEventArgs> VideoFrameDecoded
+ {
+ add
+ {
+ ValidationUtil.ValidateFeatureSupported(Features.RawVideo);
+
+ _videoFrameDecoded += value;
+ }
+ remove
+ {
+ ValidationUtil.ValidateFeatureSupported(Features.RawVideo);
+
+ _videoFrameDecoded -= value;
+ }
+ }
+
private void RegisterVideoFrameDecodedCallback()
{
_videoFrameDecodedCallback = (packetHandle, _) =>
{
- var handler = VideoFrameDecoded;
+ var handler = _videoFrameDecoded;
if (handler != null)
{
Log.Debug(PlayerLog.Tag, "packet : " + packetHandle);
Interop.Player.SetVideoFrameDecodedCb(Handle, _videoFrameDecodedCallback).
ThrowIfFailed("Failed to register the VideoFrameDecoded");
}
+ #endregion
private void RegisterVideoStreamChangedCallback()
{