Name: csapi-multimedia
Summary: Tizen Multimedia API for C#
-Version: 1.0.14
+Version: 1.0.19
Release: 0
Group: Development/Libraries
License: Apache-2.0
# C# API Requries
BuildRequires: csapi-tizen-nuget
+BuildRequires: csapi-application-nuget
BuildRequires: elm-sharp-nuget
%description
--- /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 System;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// Provides the ability to directly manage the system audio input devices.
+ /// </summary>
+ /// <remarks>The recorder privilege(http://tizen.org/privilege/recorder) is required.</remarks>
+ public abstract class AudioCaptureBase : IDisposable
+ {
+ public const int MinSampleRate = 8000;
+ public const int MaxSampleRate = 48000;
+
+ internal IntPtr _handle = IntPtr.Zero;
+
+ private AudioIOState _state = AudioIOState.Idle;
+
+ internal AudioCaptureBase(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
+ {
+ if (sampleRate < MinSampleRate || MaxSampleRate < sampleRate)
+ {
+ throw new ArgumentOutOfRangeException(nameof(sampleRate), sampleRate,
+ $"Valid sampleRate range is { MinSampleRate } <= x <= { MaxSampleRate }.");
+ }
+
+ ValidationUtil.ValidateEnum(typeof(AudioChannel), channel);
+ ValidationUtil.ValidateEnum(typeof(AudioSampleType), sampleType);
+
+ SampleRate = sampleRate;
+ Channel = channel;
+ SampleType = sampleType;
+
+ AudioIOUtil.ThrowIfError(
+ Interop.AudioIO.AudioInput.Create(SampleRate, (int)Channel, (int)SampleType, out _handle));
+
+ RegisterStateChangedCallback();
+ }
+
+ ~AudioCaptureBase()
+ {
+ Dispose(false);
+ }
+
+ /// <summary>
+ /// Occurs when the state of the AudioCapture is changed.
+ /// </summary>
+ public event EventHandler<AudioIOStateChangedEventArgs> StateChanged;
+
+ private Interop.AudioIO.AudioStateChangedCallback _stateChangedCallback;
+
+ private void RegisterStateChangedCallback()
+ {
+ _stateChangedCallback = (IntPtr handle, int previous, int current, bool byPolicy, IntPtr _) =>
+ {
+ _state = (AudioIOState)current;
+
+ StateChanged?.Invoke(this,
+ new AudioIOStateChangedEventArgs((AudioIOState)previous, _state, byPolicy));
+ };
+
+ AudioIOUtil.ThrowIfError(
+ Interop.AudioIO.AudioInput.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero));
+ }
+
+ #region Dispose support
+ private bool _isDisposed = false;
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (_isDisposed)
+ {
+ return;
+ }
+
+ if (_handle != IntPtr.Zero)
+ {
+ if (_state != AudioIOState.Idle)
+ {
+ try
+ {
+ Unprepare();
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ Interop.AudioIO.AudioInput.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ _isDisposed = true;
+ }
+ }
+
+ internal void ValidateNotDisposed()
+ {
+ if (_isDisposed)
+ {
+ throw new ObjectDisposedException(GetType().Name);
+ }
+ }
+ #endregion
+
+ internal void ValidateState(params AudioIOState[] desiredStates)
+ {
+ ValidateNotDisposed();
+
+ AudioIOUtil.ValidateState(_state, desiredStates);
+ }
+
+ /// <summary>
+ /// Gets the sample rate of the audio input data stream.
+ /// </summary>
+ public int SampleRate { get; }
+
+ /// <summary>
+ /// Gets the channel type of the audio input data stream.
+ /// </summary>
+ public AudioChannel Channel { get; }
+
+ /// <summary>
+ /// Gets the sample type of the audio input data stream.
+ /// </summary>
+ public AudioSampleType SampleType { get; }
+
+ /// <summary>
+ /// Gets the size to be allocated for the audio input buffer.
+ /// </summary>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The current state is <see cref="AudioIOState.Idle"/>.</exception>
+ public int GetBufferSize()
+ {
+ ValidateState(AudioIOState.Running, AudioIOState.Paused);
+
+ int size;
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioInput.GetBufferSize(_handle, out size));
+ return size;
+ }
+
+ /// <summary>
+ /// Prepares the AudioCapture for reading audio data by starting buffering of audio data from the device.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// Operation failed due to internal error.
+ /// <para>-or-</para>
+ /// The current state is not <see cref="AudioIOState.Idle"/>.
+ /// </exception>
+ /// <seealso cref="Unprepare"/>
+ public void Prepare()
+ {
+ ValidateState(AudioIOState.Idle);
+
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioInput.Prepare(_handle),
+ "Failed to prepare the AudioCapture");
+ }
+
+ /// <summary>
+ /// Unprepares the AudioCapture.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// Operation failed due to internal error.
+ /// <para>-or-</para>
+ /// The current state is <see cref="AudioIOState.Idle"/>.
+ /// </exception>
+ /// <seealso cref="Prepare"/>
+ public void Unprepare()
+ {
+ ValidateState(AudioIOState.Running, AudioIOState.Paused);
+
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioInput.Unprepare(_handle),
+ "Failed to unprepare the AudioCapture");
+ }
+
+ /// <summary>
+ /// Pauses buffering of audio data from the device.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// The current state is <see cref="AudioState.Idle"/>.
+ /// <para>-or-</para>
+ /// The method is called in the <see cref="AsyncAudioCapture.DataAvailable"/> event handler.
+ /// </exception>
+ /// <seealso cref="Resume"/>
+ public void Pause()
+ {
+ if (_state == AudioIOState.Paused)
+ {
+ return;
+ }
+ ValidateState(AudioIOState.Running);
+
+ int ret = Interop.AudioIO.AudioInput.Pause(_handle);
+
+ // Here, we convert the not supported error into InvalidOperationException.
+ // It is because this exception is more appropriate in C# for this kind of situation.
+ if ((int)AudioIOError.NotSupported == ret)
+ {
+ throw new InvalidOperationException("Cannot change the state in event handlers.");
+ }
+
+ MultimediaDebug.AssertNoError(ret);
+ }
+ /// <summary>
+ /// Resumes buffering audio data from the device.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// The current state is <see cref="AudioState.Idle"/>.
+ /// <para>-or-</para>
+ /// The method is called in the <see cref="AsyncAudioCapture.DataAvailable"/> event handler.
+ /// </exception>
+ /// <seealso cref="Pause"/>
+ public void Resume()
+ {
+ if (_state == AudioIOState.Running)
+ {
+ return;
+ }
+ ValidateState(AudioIOState.Paused);
+
+ int ret = Interop.AudioIO.AudioInput.Resume(_handle);
+
+ // Here, we convert the not supported error into InvalidOperationException.
+ // It is because this exception is more appropriate in C# for this kind of situation.
+ if ((int)AudioIOError.NotSupported == ret)
+ {
+ throw new InvalidOperationException("Cannot change the state in event handlers.");
+ }
+
+ MultimediaDebug.AssertNoError(ret);
+ }
+ /// <summary>
+ /// Flushes and discards buffered audio data from the input stream.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">The current state is <see cref="AudioState.Idle"/>.</exception>
+ public void Flush()
+ {
+ ValidateState(AudioIOState.Running, AudioIOState.Paused);
+
+ int ret = Interop.AudioIO.AudioInput.Flush(_handle);
+
+ MultimediaDebug.AssertNoError(ret);
+ }
+
+ /// <summary>
+ /// Sets the sound stream information to the audio input.
+ /// </summary>
+ /// <param name="streamPolicy">The <see cref="AudioStreamPolicy"/> to apply for the AudioCapture.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="streamPolicy"/> is null.</exception>
+ /// <exception cref="ObjectDisposedException"><paramref name="streamPolicy"/> has already been disposed.</exception>
+ /// <exception cref="NotSupportedException"><paramref name="streamPolicy"/> is not supported.</exception>
+ /// <exception cref="ArgumentException">Not able to retrieve information from <paramref name="streamPolicy"/>.</exception>
+ public void ApplyStreamPolicy(AudioStreamPolicy streamPolicy)
+ {
+ if (streamPolicy == null)
+ {
+ throw new ArgumentNullException(nameof(streamPolicy));
+ }
+
+ if (streamPolicy.Handle == IntPtr.Zero)
+ {
+ throw new ObjectDisposedException(nameof(streamPolicy));
+ }
+
+ ValidateNotDisposed();
+
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioInput.SetStreamInfo(_handle, streamPolicy.Handle));
+ }
+ }
+
+ /// <summary>
+ /// Provides the ability to record audio from system audio input devices in synchronous way.
+ /// </summary>
+ /// <remarks>The recorder privilege(http://tizen.org/privilege/recorder) is required.</remarks>
+ public class AudioCapture : AudioCaptureBase
+ {
+ /// <summary>
+ /// Initializes a new instance of the AudioCapture class with the specified sample rate, channel and sampleType.
+ /// </summary>
+ /// <param name="sampleRate">The audio sample rate.(8000 ~ 48000Hz)</param>
+ /// <param name="channel">The audio channel type.</param>
+ /// <param name="sampleType">The audio sample type.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="sampleRate"/> is less than <see cref="MinSampleRate"/>.
+ /// <para>-or-</para>
+ /// <paramref name="sampleRate"/> is greater than <see cref="MaxSampleRate"/>.
+ /// </exception>
+ /// <exception cref="ArgumentException">
+ /// The value of <paramref name="channel"/> is invalid.
+ /// <para>-or-</para>
+ /// The value of <paramref name="sampleType"/> is invalid.
+ /// </exception>
+ /// <exception cref="InvalidOperationException">The required privilege is not specified.</exception>
+ /// <exception cref="NotSupportedException">The system does not support microphone.</exception>
+ public AudioCapture(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
+ : base(sampleRate, channel, sampleType)
+ {
+ }
+
+ /// <summary>
+ /// Reads audio data from the audio input buffer.
+ /// </summary>
+ /// <param name="length"></param>
+ /// <returns>The buffer of audio data receiving an input</returns>
+ /// <exception cref="InvalidOperationException">The current state is not <see cref="AudioIOState.Running"/>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="length"/> is equal to or less than zero.</exception>
+ public byte[] Read(int length)
+ {
+ if (length <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(length), length,
+ $"{ nameof(length) } can't be equal to or less than zero.");
+ }
+ ValidateState(AudioIOState.Running);
+
+ byte[] buffer = new byte[length];
+
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioInput.Read(_handle, buffer, length),
+ "Failed to read");
+
+ return buffer;
+ }
+ }
+
+ /// <summary>
+ /// Provides the ability to record audio from system audio input devices in asynchronous way.
+ /// </summary>
+ /// <remarks>The recorder privilege(http://tizen.org/privilege/recorder) is required.</remarks>
+ public class AsyncAudioCapture : AudioCaptureBase
+ {
+
+ /// <summary>
+ /// Occurs when audio data is available.
+ /// </summary>
+ public event EventHandler<AudioDataAvailableEvetnArgs> DataAvailable;
+
+ /// <summary>
+ /// Initializes a new instance of the AsyncAudioCapture class with the specified sample rate, channel and sampleType.
+ /// </summary>
+ /// <param name="sampleRate">The audio sample rate.(8000 ~ 48000Hz)</param>
+ /// <param name="channel">The audio channel type.</param>
+ /// <param name="sampleType">The audio sample type.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="sampleRate"/> is less than <see cref="MinSampleRate"/>.
+ /// <para>-or-</para>
+ /// <paramref name="sampleRate"/> is greater than <see cref="MaxSampleRate"/>.
+ /// </exception>
+ /// <exception cref="ArgumentException">
+ /// The value of <paramref name="channel"/> is invalid.
+ /// <para>-or-</para>
+ /// The value of <paramref name="sampleType"/> is invalid.
+ /// </exception>
+ /// <exception cref="InvalidOperationException">The required privilege is not specified.</exception>
+ /// <exception cref="NotSupportedException">The system does not support microphone.</exception>
+ public AsyncAudioCapture(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
+ : base(sampleRate, channel, sampleType)
+ {
+ _streamCallback = (IntPtr handle, uint length, IntPtr _) => { OnInputDataAvailable(handle, length); };
+
+ AudioIOUtil.ThrowIfError(
+ Interop.AudioIO.AudioInput.SetStreamCallback(_handle, _streamCallback, IntPtr.Zero),
+ $"Failed to initialize a { nameof(AsyncAudioCapture) }");
+ }
+
+ private Interop.AudioIO.AudioStreamCallback _streamCallback;
+
+ private void OnInputDataAvailable(IntPtr handle, uint length)
+ {
+ if (length == 0U)
+ {
+ return;
+ }
+
+ IntPtr ptr = IntPtr.Zero;
+ try
+ {
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioInput.Peek(_handle, out ptr, ref length));
+
+ byte[] buffer = new byte[length];
+ Marshal.Copy(ptr, buffer, 0, (int)length);
+
+ Interop.AudioIO.AudioInput.Drop(_handle);
+
+ DataAvailable?.Invoke(this, new AudioDataAvailableEvetnArgs(buffer));
+ }
+ catch (Exception e)
+ {
+ Log.Error(nameof(AsyncAudioCapture), e.Message);
+ }
+ }
+ }
+}
--- /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 System;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// Provides data for the <see cref="AsyncAudioCapture.DataAvailable"/> event.
+ /// </summary>
+ public class AudioDataAvailableEvetnArgs : EventArgs
+ {
+ internal AudioDataAvailableEvetnArgs(byte[] data)
+ {
+ Data = data;
+ }
+
+ public byte[] Data { get; }
+ }
+}
+++ /dev/null
- /*\r
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-using Tizen.Internals.Errors;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- public enum AudioChannel\r
- {\r
- Mono = 0x80, // 1 channel, mono\r
- Stereo // 2 cahnnel, stereo\r
- };\r
-\r
- public enum AudioIOError\r
- {\r
- None = ErrorCode.None, // Successful\r
- OutOfMemory = ErrorCode.OutOfMemory, //Out of memory\r
- InvalidParameter = ErrorCode.InvalidParameter, //Invalid parameter\r
- InvalidOperation = ErrorCode.InvalidOperation, //Invalid operation\r
- PermissionDenied = ErrorCode.PermissionDenied, //Device open error by security\r
- NotSupported = ErrorCode.NotSupported, //Not supported\r
- DevicePolicyRestriction = (-2147483648 / 2) + 4,\r
- DeviceNotOpened = -0x01900000 | 0x01, //Device open error\r
- DeviceNotClosed = -0x01900000 | 0x02, //Device close error\r
- InvalidBuffer = -0x01900000 | 0x03, //Invalid buffer pointer\r
- SoundPolicy = -0x01900000 | 0x04, //Sound policy error\r
- InvalidState = -0x01900000 | 0x05, //Invalid state (Since 3.0)\r
- NotSupportedType = -0x01900000 | 0x06, //Not supported stream type (Since 3.0)\r
- };\r
-\r
- public enum AudioState\r
- {\r
- Idle = 0, /** Audio-io handle is created, but not prepared */\r
- Running = 1, /** Audio-io handle is ready and the stream is running */\r
- Paused = 2 /** Audio-io handle is ready and the stream is paused */\r
- };\r
-}\r
--- /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.Internals.Errors;
+
+namespace Tizen.Multimedia
+{
+ public enum AudioChannel
+ {
+ Mono = 0x80,
+ Stereo
+ };
+
+ internal enum AudioIOError
+ {
+ None = ErrorCode.None,
+ OutOfMemory = ErrorCode.OutOfMemory,
+ InvalidParameter = ErrorCode.InvalidParameter,
+ InvalidOperation = ErrorCode.InvalidOperation,
+ PermissionDenied = ErrorCode.PermissionDenied, //Device open error by security
+ NotSupported = ErrorCode.NotSupported, //Not supported
+ DevicePolicyRestriction = (-2147483648 / 2) + 4,
+ DeviceNotOpened = -0x01900000 | 0x01,
+ DeviceNotClosed = -0x01900000 | 0x02,
+ InvalidBuffer = -0x01900000 | 0x03,
+ SoundPolicy = -0x01900000 | 0x04,
+ InvalidState = -0x01900000 | 0x05,
+ NotSupportedType = -0x01900000 | 0x06,
+ }
+
+ /// <summary>
+ /// Specifies the states for the <see cref="AudioPlayback"/>, <see cref="AudioCapture"/> and <see cref="AsyncAudioCapture"/>.
+ /// </summary>
+ public enum AudioIOState
+ {
+ /// <summary>
+ /// Not prepared.
+ /// </summary>
+ Idle = 0,
+
+ /// <summary>
+ /// The stream is running.
+ /// </summary>
+ Running = 1,
+
+ /// <summary>
+ /// The stream is paused.
+ /// </summary>
+ Paused = 2
+ }
+}
--- /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 System;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// Argument for the event that is Audio State Changed.
+ /// </summary>
+ public class AudioIOStateChangedEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Initializes the instance of the AudioStateChangedEventArgs class.
+ /// </summary>
+ /// <param name="previous"></param>
+ /// <param name="current"></param>
+ /// <param name="byPolicy"></param>
+ internal AudioIOStateChangedEventArgs(AudioIOState previous, AudioIOState current, bool byPolicy)
+ {
+ Previous = previous;
+ Current = current;
+ ByPolicy = byPolicy;
+ }
+
+ public AudioIOState Previous { get; }
+
+ public AudioIOState Current { get; }
+
+ public bool ByPolicy { get; }
+ }
+}
- /*\r
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-using System;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- internal class AudioErrorHelper\r
- {\r
- public static void Try(int errorCode)\r
- {\r
- AudioIOError code = (AudioIOError)errorCode;\r
- // 현재는 에러코드 최상위 exception으로 전달, 추후 상황에 맞게 케이스 처리해야 함.\r
-\r
- Log.Info("Audio", "Error code = " + code);\r
- if (code > 0)\r
- {\r
- Log.Info("Audio", "Code > 0, no error!!!!");\r
- return;\r
- }\r
-\r
- switch (code)\r
- {\r
- case AudioIOError.None:\r
- break;\r
- case AudioIOError.OutOfMemory:\r
- Log.Info("Audio", "OutOfMemoryException");\r
- throw new OutOfMemoryException();\r
- case AudioIOError.InvalidParameter:\r
- Log.Info("Audio", "ArgumentException");\r
- throw new ArgumentException();\r
- case AudioIOError.InvalidOperation:\r
- Log.Info("Audio", "InvalidOperationException");\r
- throw new InvalidOperationException();\r
- case AudioIOError.PermissionDenied:\r
- Log.Info("Audio", "Permission Denied Error");\r
- throw new Exception("Permission Denied Error");\r
- case AudioIOError.NotSupported:\r
- Log.Info("Audio", "NotSupportedException");\r
- throw new NotSupportedException();\r
- case AudioIOError.DevicePolicyRestriction:\r
- Log.Info("Audio", "Device_policy_restriction");\r
- throw new Exception("Device_policy_restriction");\r
- case AudioIOError.DeviceNotOpened:\r
- Log.Info("Audio", "Device Not Opened Error");\r
- throw new Exception("Device Not Opened Error");\r
- case AudioIOError.DeviceNotClosed:\r
- Log.Info("Audio", "Device Not Closed Error");\r
- throw new Exception("Device Not Closed Error");\r
- case AudioIOError.InvalidBuffer:\r
- Log.Info("Audio", "Invalid Buffer Error");\r
- throw new InvalidOperationException("Invalid Buffer Error");\r
- case AudioIOError.SoundPolicy:\r
- Log.Info("Audio", "Sound Policy Error");\r
- throw new Exception("Sound Policy Error");\r
- case AudioIOError.InvalidState:\r
- Log.Info("Audio", "Invalid State Error");\r
- throw new Exception("Invalid State Error");\r
- case AudioIOError.NotSupportedType:\r
- Log.Info("Audio", "Not supported stream type Error");\r
- throw new Exception("Not supported stream type Error");\r
- default:\r
- Log.Info("Audio", "Unknown Exception" + code);\r
- throw new Exception("Unknown Exception");\r
- } \r
- }\r
- }\r
-}\r
+/*
+* 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 System;
+using System.Diagnostics;
+using System.Linq;
+
+namespace Tizen.Multimedia
+{
+ internal static class AudioIOUtil
+ {
+ internal static void ThrowIfError(int errorCode, string msg = null)
+ {
+ AudioIOError code = (AudioIOError)errorCode;
+ // 현재는 에러코드 최상위 exception으로 전달, 추후 상황에 맞게 케이스 처리해야 함.
+
+ msg = (msg == null ? "" : msg + " ") + $": { code }";
+
+ if (code > 0)
+ {
+ Log.Info("Audio", "Code > 0, no error!!!!");
+ return;
+ }
+
+ switch (code)
+ {
+ case AudioIOError.None:
+ break;
+ case AudioIOError.OutOfMemory:
+ Log.Info("Audio", "OutOfMemoryException");
+ throw new OutOfMemoryException();
+ case AudioIOError.InvalidParameter:
+ Log.Info("Audio", "ArgumentException");
+ throw new ArgumentException(msg);
+ case AudioIOError.InvalidOperation:
+ throw new InvalidOperationException(msg);
+ case AudioIOError.PermissionDenied:
+ Log.Info("Audio", "Permission Denied Error");
+ throw new InvalidOperationException(msg);
+ case AudioIOError.NotSupported:
+ throw new NotSupportedException(msg);
+ case AudioIOError.DevicePolicyRestriction:
+ Log.Info("Audio", "Device_policy_restriction");
+ throw new Exception("Device_policy_restriction");
+ case AudioIOError.DeviceNotOpened:
+ Log.Info("Audio", "Device Not Opened Error");
+ throw new Exception("Device Not Opened Error");
+ case AudioIOError.DeviceNotClosed:
+ Log.Info("Audio", "Device Not Closed Error");
+ throw new Exception("Device Not Closed Error");
+ case AudioIOError.InvalidBuffer:
+ Log.Info("Audio", "Invalid Buffer Error");
+ throw new InvalidOperationException(msg);
+ case AudioIOError.SoundPolicy:
+ Log.Info("Audio", "Sound Policy Error");
+ throw new Exception(msg);
+ case AudioIOError.InvalidState:
+ Log.Info("Audio", "Invalid State Error");
+ throw new InvalidOperationException(msg);
+ case AudioIOError.NotSupportedType:
+ Log.Info("Audio", "Not supported stream type Error");
+ throw new NotSupportedException(msg);
+ default:
+ Log.Info("Audio", "Unknown Exception" + code);
+ throw new Exception(msg);
+ }
+ }
+
+ internal static void ValidateState(AudioIOState curState, params AudioIOState[] desiredStates)
+ {
+ Debug.Assert(desiredStates.Length > 0);
+
+ if (desiredStates.Contains(curState))
+ {
+ return;
+ }
+
+ throw new InvalidOperationException($"The audio is not in a valid state. " +
+ $"Current State : { curState }, Valid State : { string.Join(", ", desiredStates) }.");
+ }
+ }
+}
+++ /dev/null
- /*\r
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-using System;\r
-using System.Runtime.InteropServices;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- /// <summary>\r
- /// The Audio Input class provides a set of functions to directly manage the system audio input devices.\r
- /// </summary>\r
- public class AudioInput : BaseAudio\r
- {\r
- /// <summary>\r
- /// Gets the sample rate of the audio input data stream. \r
- /// </summary>\r
- public override int SampleRate\r
- {\r
- get\r
- {\r
- int sampleRate;\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.GetSampleRate(_handle, out sampleRate));\r
- return sampleRate;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets the channel type of the audio input data stream. \r
- /// The audio channel type defines whether the audio is mono or stereo.\r
- /// </summary>\r
- public override AudioChannel Channel\r
- {\r
- get\r
- {\r
- int channel;\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.GetChannel(_handle, out channel));\r
- return (AudioChannel)channel;\r
- }\r
- }\r
- /// <summary>\r
- /// Gets the sample audio format (8-bit or 16-bit) of the audio input data stream.\r
- /// </summary>\r
- public override AudioSampleType SampleType\r
- {\r
- get\r
- {\r
- int type;\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.GetSampleType(_handle, out type));\r
- return (AudioSampleType)type;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets the size to be allocated for the audio input buffer. \r
- /// </summary>\r
- public override int BufferSize\r
- {\r
- get\r
- {\r
- int size;\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.GetBufferSize(_handle, out size));\r
- return size;\r
- }\r
- }\r
- /// <summary>\r
- /// Reads audio data from the audio input buffer. \r
- /// </summary>\r
- /// <param name="length"></param>\r
- /// <returns>The buffer of audio data receiving an input</returns>\r
- public byte[] Read(int length)\r
- {\r
- byte[] dataArray = new byte[length];\r
-\r
- if (dataArray.Length <= 0)\r
- throw new IndexOutOfRangeException("Bed Buffer Length");\r
-\r
- IntPtr ptrByteArray = Marshal.AllocHGlobal(length);\r
- try\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Read(_handle, ptrByteArray, length));\r
- Marshal.Copy(ptrByteArray, dataArray, 0, dataArray.Length);\r
- }\r
- catch (Exception e)\r
- {\r
- Log.Info("Audio", "Read Exception : " + e.ToString());\r
- Console.WriteLine("read error" + e.ToString());\r
- }\r
- finally\r
- {\r
- if (ptrByteArray != IntPtr.Zero)\r
- {\r
- Marshal.FreeHGlobal(ptrByteArray);\r
- ptrByteArray = IntPtr.Zero;\r
- }\r
- }\r
- return dataArray;\r
- }\r
- /// <summary>\r
- /// peek from audio in buffer \r
- /// This function works correctly only with read, write callback.Otherwise it won't operate as intended.\r
- /// </summary>\r
- /// <param name="length"></param>\r
- /// <returns> The allocated buffer - byte[] </returns>\r
- public byte[] Peek(uint length)\r
- {\r
- IntPtr ptrByteArray = IntPtr.Zero;\r
- uint nBytes = 0;\r
- try\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Peek(_handle, out ptrByteArray, out nBytes));\r
- byte[] dataArray = new byte[nBytes];\r
- Marshal.Copy(ptrByteArray, dataArray, 0, (int)nBytes);\r
-\r
- return dataArray;\r
- }\r
- finally\r
- {\r
- if (ptrByteArray != IntPtr.Zero)\r
- {\r
- ptrByteArray = IntPtr.Zero;\r
- }\r
- }\r
- }\r
- /// <summary>\r
- /// drop peeked audio buffer. \r
- /// This function works correctly only with read, write callback.Otherwise it won't operate as intended.\r
- /// </summary>\r
- public void Drop()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Drop(_handle));\r
- }\r
- /// <summary>\r
- /// Releases the audio input handle and all its resources associated with an audio stream.\r
- /// </summary>\r
- protected override void Destroy()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Destroy(_handle));\r
- }\r
- /// <summary>\r
- /// Sets an asynchronous(event) callback function to handle recording PCM (pulse-code modulation) data. \r
- /// </summary>\r
- protected override void RegisterAudioStreamLengthChanged()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.SetAudioInputStreamChangedCallback(_handle, OnStream, IntPtr.Zero));\r
- }\r
- /// <summary>\r
- /// Unregisters the callback function. \r
- /// </summary>\r
- protected override void UnregisterAudioStreamLengthChanged()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.UnsetAudioInputStreamChangedCallback(_handle));\r
- }\r
- /// <summary>\r
- /// Sets the state changed callback function to the audio input handle. \r
- /// </summary>\r
- protected override void RegisterAudioStateChangedCallback()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.SetAudioInputStateChangedCallback(_handle, OnStateChanged, IntPtr.Zero));\r
- }\r
- /// <summary>\r
- /// Unregisters the state changed callback function of the audio input handle. \r
- /// </summary>\r
- protected override void UnregisterAudioStateChangedmCallback()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.UnsetAudioInputStateChangedCallback(_handle));\r
- }\r
- /// <summary>\r
- /// Prepares the audio input for reading audio data by starting buffering of audio data from the device. \r
- /// </summary>\r
- public override void Prepare()\r
- {\r
- if(_bReady == false)\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Prepare(_handle));\r
- _bReady = true;\r
- }\r
- }\r
- /// <summary>\r
- /// Unprepares the audio input. \r
- /// </summary>\r
- public override void Unprepare()\r
- {\r
- if (_bReady)\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Unprepare(_handle));\r
- _bReady = false;\r
- }\r
- }\r
- /// <summary>\r
- /// Pauses buffering of audio data from the device. \r
- /// </summary>\r
- public override void Pause()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Pause(_handle));\r
- }\r
- /// <summary>\r
- /// Resumes buffering audio data from the device. \r
- /// </summary>\r
- public override void Resume()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Resume(_handle));\r
- }\r
- /// <summary>\r
- /// Flushes and discards buffered audio data from the input stream. \r
- /// </summary>\r
- public override void Flush()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Flush(_handle));\r
- }\r
- /// <summary>\r
- /// Sets the sound stream information to the audio input. \r
- /// </summary>\r
- /// <param name="stream_info"></param>\r
- /// <returns></returns>\r
- public override void SetStreamInfo(AudioStreamPolicy streamPolicy)\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.SetStreamInfo(_handle, streamPolicy.Handle));\r
- }\r
- /// <summary>\r
- /// Initializes the instance of the AudioInput class with the SafeAudioInputHandle.\r
- /// </summary>\r
- /// <param name="_sample_rate"></param>\r
- /// <param name="_channel"></param>\r
- /// <param name="_type"></param>\r
- public AudioInput(int sample_rate, AudioChannel channel, AudioSampleType type)\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Create(sample_rate, (int)channel, (int)type, out _handle));\r
- }\r
- private AudioInput() { }\r
- }\r
-}\r
+++ /dev/null
- /*\r
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-using System;\r
-using System.Runtime.InteropServices;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- /// <summary>\r
- /// The Audio Output class provides a set of functions to directly manage the system audio output devices. \r
- /// </summary>\r
- public class AudioOutput : BaseAudio\r
- {\r
- /// <summary>\r
- /// Gets the sample rate of the audio output data stream. \r
- /// </summary>\r
- public override int SampleRate\r
- {\r
- get\r
- {\r
- int sampleRate;\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetSampleRate(_handle, out sampleRate));\r
- return sampleRate;\r
- }\r
- }\r
- /// <summary>\r
- /// Gets the channel type of the audio output data stream. \r
- /// The audio channel type defines whether the audio is mono or stereo.\r
- /// </summary>\r
- public override AudioChannel Channel\r
- {\r
- get\r
- {\r
- int channel;\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetChannel(_handle, out channel));\r
- return (AudioChannel)channel;\r
- }\r
- }\r
- /// <summary>\r
- /// Gets the sample audio format (8-bit or 16-bit) of the audio output data stream. \r
- /// </summary>\r
- public override AudioSampleType SampleType\r
- {\r
- get\r
- {\r
- int type;\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetSampleType(_handle, out type));\r
- return (AudioSampleType)type;\r
- }\r
- }\r
- /// <summary>\r
- /// Gets the size to be allocated for the audio output buffer. \r
- /// </summary>\r
- public override int BufferSize\r
- {\r
- get\r
- {\r
- int size = 0;\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetBufferSize(_handle, out size));\r
- return size;\r
- }\r
- }\r
- /// <summary>\r
- /// Gets the sound type supported by the audio output device. \r
- /// </summary>\r
- public AudioStreamType SoundStreamType\r
- {\r
- get\r
- {\r
- int audioType = 0;\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetSoundType(_handle, out audioType));\r
- return (AudioStreamType)audioType;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Drains buffered audio data from the output stream. \r
- /// This function waits until drains stream buffer completely. (e.g end of playback)\r
- /// </summary>\r
- public void Drain()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Drain(_handle));\r
- }\r
- object _lock = new object();\r
- /// <summary>\r
- /// Starts writing the audio data to the device. \r
- /// </summary>\r
- /// <param name="buffer"></param>\r
- public void Write(byte[] buffer)\r
- {\r
- if (buffer.Length <= 0)\r
- {\r
- throw new IndexOutOfRangeException("Bed File Length");\r
- }\r
- IntPtr ptrByteArray = Marshal.AllocHGlobal(buffer.Length);\r
- try\r
- {\r
- Marshal.Copy(buffer, 0, ptrByteArray, buffer.Length);\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Write(_handle, ptrByteArray, (uint)buffer.Length));\r
- }\r
- finally\r
- {\r
- if (ptrByteArray != IntPtr.Zero)\r
- {\r
- Marshal.FreeHGlobal(ptrByteArray);\r
- ptrByteArray = IntPtr.Zero;\r
- }\r
- }\r
- }\r
- /// <summary>\r
- /// Sets an asynchronous(event) callback function to handle playing PCM (pulse-code modulation) data. \r
- /// </summary>\r
- protected override void RegisterAudioStreamLengthChanged()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.SetAudioOutputStreamChangedCallback(_handle, OnStream, IntPtr.Zero));\r
- }\r
- /// <summary>\r
- /// Unregisters the callback function. \r
- /// </summary>\r
- protected override void UnregisterAudioStreamLengthChanged()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.UnsetAudioOutputStreamChangedCallback(_handle));\r
- }\r
- /// <summary>\r
- /// Sets the state changed callback function to the audio output handle. \r
- /// </summary>\r
- protected override void RegisterAudioStateChangedCallback()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.SetAudioOutputStateChangedCallback(_handle, OnStateChanged, IntPtr.Zero));\r
- }\r
- /// <summary>\r
- /// Unregisters the state changed callback function of the audio output handle. \r
- /// </summary>\r
- protected override void UnregisterAudioStateChangedmCallback()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.UnsetAudioOutputStateChangedCallback(_handle));\r
- }\r
- /// <summary>\r
- /// Releases the audio output handle, along with all its resources. \r
- /// </summary>\r
- protected override void Destroy()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Destroy(_handle));\r
- }\r
- /// <summary>\r
- /// Prepares the audio output for playback, this must be called before audio_out_write(). \r
- /// </summary>\r
- public override void Prepare()\r
- {\r
- if (_bReady == false)\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Prepare(_handle));\r
- _bReady = true;\r
- }\r
- }\r
- /// <summary>\r
- /// Unprepares the audio output. \r
- /// </summary>\r
- public override void Unprepare()\r
- {\r
- if (_bReady)\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Unprepare(_handle));\r
- _bReady = false;\r
- }\r
- }\r
- /// <summary>\r
- /// Pauses feeding of audio data to the device. \r
- /// </summary>\r
- public override void Pause()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Pause(_handle));\r
-\r
- }\r
- /// <summary>\r
- /// Resumes feeding of audio data to the device. \r
- /// </summary>\r
- public override void Resume()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Resume(_handle));\r
- }\r
- /// <summary>\r
- /// Flushes and discards buffered audio data from the output stream. \r
- /// </summary>\r
- public override void Flush()\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Flush(_handle));\r
- }\r
- /// <summary>\r
- /// Sets the sound stream information to the audio output. \r
- /// </summary>\r
- /// <param name="stream_info"></param>\r
- /// <returns></returns>\r
- public override void SetStreamInfo(AudioStreamPolicy streamPolicy)\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.SetStreamInfo(_handle, streamPolicy.Handle));\r
- }\r
- /// <summary>\r
- /// Initializes the instance of the AudioOutput class with the SafeAudioInputHandle.\r
- /// </summary>\r
- /// <param name="_sample_rate"></param>\r
- /// <param name="_channel"></param>\r
- /// <param name="_type"></param>\r
- public AudioOutput(int sample_rate, AudioChannel channel, AudioSampleType type)\r
- {\r
- AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Create(sample_rate, (int)channel, (int)type, out _handle));\r
- }\r
- private AudioOutput() { }\r
- }\r
-}\r
--- /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 System;
+
+namespace Tizen.Multimedia
+{
+ public class AudioPlaybackBufferAvailableEventArgs : EventArgs
+ {
+ internal AudioPlaybackBufferAvailableEventArgs(int length)
+ {
+ Length = length;
+ }
+
+ public int Length { get; }
+ }
+}
--- /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 System;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// Provides the ability to directly manage the system audio output devices and play PCM (pulse-code modulation) data.
+ /// </summary>
+ public class AudioPlayback : IDisposable
+ {
+ public const int MinSampleRate = 8000;
+ public const int MaxSampleRate = 48000;
+
+ private IntPtr _handle = IntPtr.Zero;
+
+ private AudioIOState _state = AudioIOState.Idle;
+
+ #region Event
+ /// <summary>
+ /// Occurs when audio playback data can be written.
+ /// </summary>
+ /// <seealso cref="Write(byte[])"/>
+ public event EventHandler<AudioPlaybackBufferAvailableEventArgs> BufferAvailable;
+
+ private Interop.AudioIO.AudioStreamCallback _streamCallback;
+
+ private void RegisterStreamCallback()
+ {
+ _streamCallback = (IntPtr handle, uint bytes, IntPtr _) =>
+ {
+ BufferAvailable?.Invoke(this, new AudioPlaybackBufferAvailableEventArgs((int)bytes));
+ };
+
+ AudioIOUtil.ThrowIfError(
+ Interop.AudioIO.AudioOutput.SetStreamChangedCallback(_handle, _streamCallback, IntPtr.Zero),
+ $"Failed to create {nameof(AudioPlayback)}");
+ }
+
+ /// <summary>
+ /// Occurs when the state of the AudioPlayback is changed.
+ /// </summary>
+ public event EventHandler<AudioIOStateChangedEventArgs> StateChanged;
+
+ private Interop.AudioIO.AudioStateChangedCallback _stateChangedCallback;
+
+ private void RegisterStateChangedCallback()
+ {
+ _stateChangedCallback = (IntPtr handle, int previous, int current, bool byPolicy, IntPtr _) =>
+ {
+ _state = (AudioIOState)current;
+
+ StateChanged?.Invoke(this,
+ new AudioIOStateChangedEventArgs((AudioIOState)previous, _state, byPolicy));
+ };
+
+ AudioIOUtil.ThrowIfError(
+ Interop.AudioIO.AudioOutput.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero),
+ $"Failed to create {nameof(AudioPlayback)}");
+ }
+ #endregion
+
+ /// <summary>
+ /// Initializes a new instance of the AudioPlayback class with the specified sample rate, channel and sample type.
+ /// </summary>
+ /// <param name="sampleRate">The audio sample rate.(8000 ~ 48000Hz)</param>
+ /// <param name="channel">The audio channel type.</param>
+ /// <param name="sampleType">The audio sample type.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="sampleRate"/> is less than <see cref="MinSampleRate"/>.
+ /// <para>-or-</para>
+ /// <paramref name="sampleRate"/> is greater than <see cref="MaxSampleRate"/>.
+ /// </exception>
+ /// <exception cref="ArgumentException">
+ /// The value of <paramref name="channel"/> is invalid.
+ /// <para>-or-</para>
+ /// The value of <paramref name="sampleType"/> is invalid.
+ /// </exception>
+ public AudioPlayback(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
+ {
+ if (sampleRate < MinSampleRate || MaxSampleRate < sampleRate)
+ {
+ throw new ArgumentOutOfRangeException(nameof(sampleRate), sampleRate,
+ $"Valid sampleRate range is { MinSampleRate } <= x <= { MaxSampleRate }.");
+ }
+
+ ValidationUtil.ValidateEnum(typeof(AudioChannel), channel);
+ ValidationUtil.ValidateEnum(typeof(AudioSampleType), sampleType);
+
+ SampleRate = sampleRate;
+ Channel = channel;
+ SampleType = sampleType;
+
+ AudioIOUtil.ThrowIfError(
+ Interop.AudioIO.AudioOutput.Create(SampleRate, (int)Channel, (int)SampleType, out _handle),
+ $"Failed to create {nameof(AudioPlayback)}");
+
+ RegisterStreamCallback();
+ RegisterStateChangedCallback();
+ }
+
+ ~AudioPlayback()
+ {
+ Dispose(false);
+ }
+
+ #region Dispose support
+ private bool _isDisposed = false;
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (_isDisposed)
+ {
+ return;
+ }
+
+ if (_handle != IntPtr.Zero)
+ {
+ if (_state != AudioIOState.Idle)
+ {
+ try
+ {
+ Unprepare();
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ Interop.AudioIO.AudioOutput.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ _isDisposed = true;
+ }
+ }
+
+ private void ValidateNotDisposed()
+ {
+ if (_isDisposed)
+ {
+ throw new ObjectDisposedException(GetType().Name);
+ }
+ }
+ #endregion
+
+ private void ValidateState(params AudioIOState[] desiredStates)
+ {
+ ValidateNotDisposed();
+
+ AudioIOUtil.ValidateState(_state, desiredStates);
+ }
+
+ /// <summary>
+ /// Gets the sample rate of the audio output data stream.
+ /// </summary>
+ public int SampleRate { get; }
+
+ /// <summary>
+ /// Gets the channel type of the audio output data stream.
+ /// </summary>
+ public AudioChannel Channel { get; }
+
+ /// <summary>
+ /// Gets the sample type of the audio output data stream.
+ /// </summary>
+ public AudioSampleType SampleType { get; }
+
+ /// <summary>
+ /// Gets the sound type supported by the audio output device.
+ /// </summary>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ public AudioStreamType StreamType
+ {
+ get
+ {
+ ValidateNotDisposed();
+
+ int audioType = 0;
+ int ret = Interop.AudioIO.AudioOutput.GetSoundType(_handle, out audioType);
+ MultimediaDebug.AssertNoError(ret);
+
+ return (AudioStreamType)audioType;
+ }
+ }
+
+ /// <summary>
+ /// Gets the size to be allocated for the audio output buffer.
+ /// </summary>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The current state is <see cref="AudioIOState.Idle"/>.</exception>
+ public int GetBufferSize()
+ {
+ ValidateState(AudioIOState.Running, AudioIOState.Paused);
+
+ int size = 0;
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioOutput.GetBufferSize(_handle, out size));
+ return size;
+ }
+
+ /// <summary>
+ /// Drains buffered audio data from the output stream.
+ /// It blocks the calling thread until draining the stream buffer completely. (e.g end of playback)
+ /// </summary>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The current state is <see cref="AudioIOState.Idle"/>.</exception>
+ public void Drain()
+ {
+ ValidateState(AudioIOState.Running, AudioIOState.Paused);
+
+ int ret = Interop.AudioIO.AudioOutput.Drain(_handle);
+
+ MultimediaDebug.AssertNoError(ret);
+ }
+
+ /// <summary>
+ /// Starts writing the audio data to the device.
+ /// </summary>
+ /// <param name="buffer">The buffer to write.</param>
+ /// <returns>The written size.</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="buffer"/> is null.</exception>
+ /// <exception cref="ArgumentException">The length of <paramref name="buffer"/> is zero.</exception>
+ /// <exception cref="InvalidOperationException">The current state is not <see cref="AudioIOState.Running"/>.</exception>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ public int Write(byte[] buffer)
+ {
+ ValidateState(AudioIOState.Running);
+
+ if (buffer == null)
+ {
+ throw new ArgumentNullException(nameof(buffer));
+ }
+
+ if (buffer.Length == 0)
+ {
+ throw new ArgumentException("buffer has no data.(the Length is zero.)", nameof(buffer));
+ }
+
+ int ret = Interop.AudioIO.AudioOutput.Write(_handle, buffer, (uint)buffer.Length);
+
+ AudioIOUtil.ThrowIfError(ret, "Failed to write buffer");
+
+ return ret;
+ }
+
+ /// <summary>
+ /// Prepares the AudioPlayback.
+ /// </summary>
+ /// <remarks>
+ /// This must be called before <see cref="Write(byte[])"/>.
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">
+ /// Operation failed due to internal error.
+ /// <para>-or-</para>
+ /// The current state is not <see cref="AudioIOState.Idle"/>.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ /// <seealso cref="Unprepare"/>
+ public void Prepare()
+ {
+ ValidateState(AudioIOState.Idle);
+
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioOutput.Prepare(_handle),
+ $"Failed to prepare the {nameof(AudioPlayback)}");
+ }
+
+ /// <summary>
+ /// Unprepares the AudioPlayback.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// Operation failed due to internal error.
+ /// <para>-or-</para>
+ /// The current state is <see cref="AudioIOState.Idle"/>.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ /// <seealso cref="Prepare"/>
+ public void Unprepare()
+ {
+ ValidateState(AudioIOState.Running, AudioIOState.Paused);
+
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioOutput.Unprepare(_handle),
+ $"Failed to unprepare the {nameof(AudioPlayback)}");
+ }
+
+ /// <summary>
+ /// Pauses feeding of audio data to the device.
+ /// </summary>
+ /// <remarks>It has no effect if the current is the <see cref="AudioIOState.Paused"/>.</remarks>
+ /// <exception cref="InvalidOperationException">
+ /// The current state is <see cref="AudioIOState.Idle"/>.
+ /// <para>-or-</para>
+ /// The method is called in the <see cref="BufferAvailable"/> event handler.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ /// <seealso cref="Resume"/>
+ public void Pause()
+ {
+ if (_state == AudioIOState.Paused)
+ {
+ return;
+ }
+ ValidateState(AudioIOState.Running);
+
+ int ret = Interop.AudioIO.AudioOutput.Pause(_handle);
+
+ // Here, we convert the not supported error into InvalidOperationException.
+ // It is because this exception is more appropriate in C# for this kind of situation.
+ if ((int)AudioIOError.NotSupported == ret)
+ {
+ throw new InvalidOperationException("Cannot change the state in event handlers.");
+ }
+
+ MultimediaDebug.AssertNoError(ret);
+ }
+
+ /// <summary>
+ /// Resumes feeding of audio data to the device.
+ /// </summary>
+ /// <remarks>It has no effect if the current is the <see cref="AudioIOState.Running"/>.</remarks>
+ /// <exception cref="InvalidOperationException">
+ /// The current state is <see cref="AudioIOState.Idle"/>.
+ /// <para>-or-</para>
+ /// The method is called in an event handler.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ /// <seealso cref="Pause"/>
+ public void Resume()
+ {
+ if (_state == AudioIOState.Running)
+ {
+ return;
+ }
+ ValidateState(AudioIOState.Paused);
+
+ int ret = Interop.AudioIO.AudioOutput.Resume(_handle);
+
+ // Here, we convert the not supported error into InvalidOperationException.
+ // It is because this exception is more appropriate in C# for this kind of situation.
+ if ((int)AudioIOError.NotSupported == ret)
+ {
+ throw new InvalidOperationException("Cannot change the state in event handlers.");
+ }
+
+ MultimediaDebug.AssertNoError(ret);
+ }
+
+ /// <summary>
+ /// Flushes and discards buffered audio data from the output stream.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">The current state is <see cref="AudioIOState.Idle"/>.</exception>
+ /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed.</exception>
+ public void Flush()
+ {
+ ValidateState(AudioIOState.Running, AudioIOState.Paused);
+
+ int ret = Interop.AudioIO.AudioOutput.Flush(_handle);
+
+ MultimediaDebug.AssertNoError(ret);
+ }
+
+ /// <summary>
+ /// Applies the sound stream information to the AudioPlayback.
+ /// </summary>
+ /// <param name="streamPolicy">The <see cref="AudioStreamPolicy"/> to apply for the AudioPlayback.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="streamPolicy"/> is null.</exception>
+ /// <exception cref="ObjectDisposedException">
+ /// <paramref name="streamPolicy"/> has already been disposed.
+ /// <para>-or-</para>
+ /// The AudioPlayback has already been disposed.
+ /// </exception>
+ /// <exception cref="NotSupportedException"><paramref name="streamPolicy"/> is not supported.</exception>
+ /// <exception cref="ArgumentException">Not able to retrieve information from <paramref name="streamPolicy"/>.</exception>
+ public void ApplyStreamPolicy(AudioStreamPolicy streamPolicy)
+ {
+ if (streamPolicy == null)
+ {
+ throw new ArgumentNullException(nameof(streamPolicy));
+ }
+
+ if (streamPolicy.Handle == IntPtr.Zero)
+ {
+ throw new ObjectDisposedException(nameof(streamPolicy));
+ }
+
+ ValidateNotDisposed();
+
+ AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioOutput.SetStreamInfo(_handle, streamPolicy.Handle));
+ }
+ }
+}
+++ /dev/null
- /*\r
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-using System;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- /// <summary>\r
- /// Argument for the event that is Audio State Changed.\r
- /// </summary>\r
- public class AudioStateChangedEventArgs : EventArgs\r
- {\r
- private readonly AudioState _previous;\r
- private readonly AudioState _current;\r
- private readonly bool _by_policy;\r
- /// <summary>\r
- /// Initializes the instance of the AudioStateChangedEventArgs class. \r
- /// </summary>\r
- /// <param name="_prev"></param>\r
- /// <param name="_current"></param>\r
- /// <param name="by_policy"></param>\r
- internal AudioStateChangedEventArgs(AudioState previous, AudioState current, bool by_policy) \r
- {\r
- this._previous = previous;\r
- this._current = current;\r
- this._by_policy = by_policy;\r
- }\r
-\r
- public AudioState Previous { get { return _previous; } }\r
- public AudioState Current { get { return _current; } }\r
- public bool Policy { get { return _by_policy; } }\r
- }\r
-}\r
+++ /dev/null
- /*\r
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-using System;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- public abstract class BaseAudio : IDisposable\r
- {\r
- #region Event\r
- private EventHandler<AudioStreamLengthChangedEventArgs> streamCallback;\r
- private EventHandler<AudioStateChangedEventArgs> stateChanged;\r
-\r
- public event EventHandler<AudioStreamLengthChangedEventArgs> StreamLengthChanged\r
- {\r
- add\r
- {\r
- if (streamCallback == null)\r
- {\r
- RegisterAudioStreamLengthChanged();\r
- }\r
- streamCallback += value;\r
- }\r
- remove\r
- {\r
- streamCallback -= value;\r
- if (streamCallback == null)\r
- {\r
- UnregisterAudioStreamLengthChanged();\r
- }\r
- }\r
- }\r
- public event EventHandler<AudioStateChangedEventArgs> StateChanged\r
- {\r
- add\r
- {\r
- if (streamCallback == null)\r
- {\r
- RegisterAudioStateChangedCallback();\r
- }\r
- stateChanged += value;\r
- }\r
- remove\r
- {\r
- stateChanged -= value;\r
- if (streamCallback == null)\r
- {\r
- UnregisterAudioStateChangedmCallback();\r
- }\r
- }\r
- }\r
-\r
- protected void OnStream(IntPtr handle, uint nbytes, IntPtr userdata)\r
- {\r
- if (streamCallback != null)\r
- {\r
- streamCallback(this, new AudioStreamLengthChangedEventArgs(nbytes));\r
- }\r
- }\r
- protected void OnStateChanged(IntPtr handle, int previous, int current, bool by_policy, IntPtr user_data)\r
- {\r
- if (streamCallback != null)\r
- {\r
- stateChanged(this, new AudioStateChangedEventArgs((AudioState)previous, (AudioState)current, by_policy));\r
- }\r
- } \r
- #endregion\r
- protected IntPtr _handle = IntPtr.Zero;\r
- protected bool _bReady = false;\r
-\r
- public abstract int SampleRate { get;}\r
- public abstract AudioChannel Channel { get; }\r
- public abstract AudioSampleType SampleType { get; }\r
- public abstract int BufferSize{ get; }\r
-\r
- public abstract void Prepare();\r
- public abstract void Unprepare();\r
- public abstract void Pause();\r
- public abstract void Resume();\r
- public abstract void Flush();\r
- public abstract void SetStreamInfo(AudioStreamPolicy streamPolicy); // 현재는 임의의 타입으로 실제 AudioPolicy가 들어와야 함.\r
- protected abstract void Destroy();\r
- protected abstract void RegisterAudioStreamLengthChanged();\r
- protected abstract void UnregisterAudioStreamLengthChanged();\r
- protected abstract void UnregisterAudioStateChangedmCallback();\r
- protected abstract void RegisterAudioStateChangedCallback();\r
-\r
- public BaseAudio() { }\r
- ~BaseAudio()\r
- {\r
- Dispose(false);\r
- }\r
- public void Dispose()\r
- {\r
- Dispose(true);\r
- }\r
- protected virtual void Dispose(bool _bDisposing)\r
- {\r
- if (_bDisposing) // // Free managed objects.\r
- {\r
- // to be used if there are any other disposable objects\r
- }\r
- // // Free Unmanaged objects.\r
- if (_bReady)\r
- Unprepare();\r
- if (_handle != IntPtr.Zero)\r
- Destroy();\r
-\r
- GC.SuppressFinalize(this);\r
- }\r
- } \r
-}\r
using System.Diagnostics;
-namespace Tizen.Multimedia.MediaCodec
+namespace Tizen.Multimedia
{
- internal class MediaCodecDebug
+ internal class MultimediaDebug
{
-
- [ConditionalAttribute("DEBUG")]
+ [Conditional("DEBUG")]
internal static void AssertNoError(int errorCode)
{
- Debug.Assert(errorCode == (int)MediaCodecErrorCode.None,
- $"The API is supposed not to return an error! But it returns error({ errorCode}).",
+ Debug.Assert(errorCode == (int)Internals.Errors.ErrorCode.None,
+ $"The API is supposed not to return an error! But it returns error({ errorCode }).",
"Implementation of core may have been changed, modify the call to throw if the return code is not ok.");
}
}
* limitations under the License.
*/
-using System.Diagnostics;
-using Tizen.Internals.Errors;
-
namespace Tizen.Multimedia
{
- internal class MediaToolDebug
+ public struct Size
{
- [ConditionalAttribute("DEBUG")]
- internal static void AssertNoError(int errorCode)
+ public Size(int width, int height)
+ {
+ Width = width;
+ Height = height;
+ }
+
+ public int Width
+ {
+ get;
+ set;
+ }
+
+ public int Height
+ {
+ get;
+ set;
+ }
+
+ public override string ToString()
{
- Debug.Assert(errorCode == (int)ErrorCode.None, "The API is supposed not to return an error!",
- "Implementation of core may have been changed, modify code to throw if the return code is not zero.");
+ return $"Width : { Width }, Height : { Height }";
}
}
}
- /*\r
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-using System;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- public class AudioStreamLengthChangedEventArgs : EventArgs\r
- {\r
- private readonly uint _length;\r
-\r
- internal AudioStreamLengthChangedEventArgs( uint length )\r
- {\r
- this._length = length;\r
- }\r
- public uint Length { get { return _length; } }\r
- }\r
-}\r
+/*
+ * 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 System;
+
+namespace Tizen.Multimedia
+{
+ internal static class ValidationUtil
+ {
+ internal static void ValidateEnum(Type enumType, object value)
+ {
+ if (!Enum.IsDefined(enumType, value))
+ {
+ throw new ArgumentException($"Invalid { enumType.Name } value : { value }");
+ }
+ }
+ }
+}
-using System;\r
-using System.Runtime.InteropServices;\r
-\r
-internal static partial class Interop\r
-{\r
- internal static partial class AudioIO\r
- {\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
- public delegate void AudioStreamCallback(IntPtr handle, uint nbytes, IntPtr userdata);\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
- public delegate void AudioStateChangedCallback(IntPtr handle, int previous, int current, bool byPolicy, IntPtr userData);\r
-\r
- internal static partial class AudioInput\r
- {\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_state_changed_cb")]\r
- internal static extern int SetAudioInputStateChangedCallback(IntPtr handle, AudioStateChangedCallback callback, IntPtr user_data);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_unset_state_changed_cb")]\r
- internal static extern int UnsetAudioInputStateChangedCallback(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_stream_cb")]\r
- internal static extern int SetAudioInputStreamChangedCallback(IntPtr handle, AudioStreamCallback callback, IntPtr user_data);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_unset_stream_cb")]\r
- internal static extern int UnsetAudioInputStreamChangedCallback(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_create")]\r
- internal static extern int Create(int sampleRate, int channel, int type, out IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_destroy")]\r
- internal static extern int Destroy(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_stream_info")]\r
- internal static extern int SetStreamInfo(IntPtr handle, IntPtr streamInfoHandle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_prepare")]\r
- internal static extern int Prepare(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_unprepare")]\r
- internal static extern int Unprepare(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_pause")]\r
- internal static extern int Pause(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_resume")]\r
- internal static extern int Resume(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_flush")]\r
- internal static extern int Flush(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_read")]\r
- internal static extern int Read(IntPtr handle, IntPtr buffer, int length);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_buffer_size")]\r
- internal static extern int GetBufferSize(IntPtr handle, out int size);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_sample_rate")]\r
- internal static extern int GetSampleRate(IntPtr handle, out int sampleRate);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_channel")]\r
- internal static extern int GetChannel(IntPtr handle, out int channel);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_sample_type")]\r
- internal static extern int GetSampleType(IntPtr handle, out int sampleType);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_peek")]\r
- internal static extern int Peek(IntPtr handle, out IntPtr buffer, out uint length);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_drop")]\r
- internal static extern int Drop(IntPtr handle);\r
- }\r
- internal static partial class AudioOutput\r
- {\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_set_state_changed_cb")]\r
- internal static extern int SetAudioOutputStateChangedCallback(IntPtr handle, AudioStateChangedCallback callback, IntPtr user_data);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_unset_state_changed_cb")]\r
- internal static extern int UnsetAudioOutputStateChangedCallback(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_set_stream_cb")]\r
- internal static extern int SetAudioOutputStreamChangedCallback(IntPtr handle, AudioStreamCallback callback, IntPtr user_data);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_unset_stream_cb")]\r
- internal static extern int UnsetAudioOutputStreamChangedCallback(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_create_new")]\r
- internal static extern int Create(int sampleRate, int channel, int type, out IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_destroy")]\r
- internal static extern int Destroy(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_drain")]\r
- internal static extern int Drain(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_flush")]\r
- internal static extern int Flush(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_buffer_size")]\r
- internal static extern int GetBufferSize(IntPtr handle, out int size);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_channel")]\r
- internal static extern int GetChannel(IntPtr handle, out int channel);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_sample_rate")]\r
- internal static extern int GetSampleRate(IntPtr handle, out int sampleRate);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_sample_type")]\r
- internal static extern int GetSampleType(IntPtr handle, out int sampleType);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_sound_type")]\r
- internal static extern int GetSoundType(IntPtr handle, out int soundType);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_pause")]\r
- internal static extern int Pause(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_prepare")]\r
- internal static extern int Prepare(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_resume")]\r
- internal static extern int Resume(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_set_stream_info")]\r
- internal static extern int SetStreamInfo(IntPtr handle, IntPtr streamInfoHandle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_unprepare")]\r
- internal static extern int Unprepare(IntPtr handle);\r
-\r
- [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_write")]\r
- internal static extern int Write(IntPtr handle, IntPtr buffer, uint length);\r
- }\r
- }\r
-}\r
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class AudioIO
+ {
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void AudioStreamCallback(IntPtr handle, uint nbytes, IntPtr userdata);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void AudioStateChangedCallback(IntPtr handle, int previous, int current, bool byPolicy, IntPtr userData);
+
+ internal static partial class AudioInput
+ {
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_state_changed_cb")]
+ internal static extern int SetStateChangedCallback(IntPtr handle, AudioStateChangedCallback callback, IntPtr user_data);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_stream_cb")]
+ internal static extern int SetStreamCallback(IntPtr handle, AudioStreamCallback callback, IntPtr user_data);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_create")]
+ internal static extern int Create(int sampleRate, int channel, int type, out IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_destroy")]
+ internal static extern int Destroy(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_stream_info")]
+ internal static extern int SetStreamInfo(IntPtr handle, IntPtr streamInfoHandle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_prepare")]
+ internal static extern int Prepare(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_unprepare")]
+ internal static extern int Unprepare(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_pause")]
+ internal static extern int Pause(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_resume")]
+ internal static extern int Resume(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_flush")]
+ internal static extern int Flush(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_read")]
+ internal static extern int Read(IntPtr handle, byte[] buffer, int length);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_buffer_size")]
+ internal static extern int GetBufferSize(IntPtr handle, out int size);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_sample_rate")]
+ internal static extern int GetSampleRate(IntPtr handle, out int sampleRate);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_channel")]
+ internal static extern int GetChannel(IntPtr handle, out int channel);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_sample_type")]
+ internal static extern int GetSampleType(IntPtr handle, out int sampleType);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_peek")]
+ internal static extern int Peek(IntPtr handle, out IntPtr buffer, ref uint length);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_drop")]
+ internal static extern int Drop(IntPtr handle);
+ }
+ internal static partial class AudioOutput
+ {
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_set_state_changed_cb")]
+ internal static extern int SetStateChangedCallback(IntPtr handle, AudioStateChangedCallback callback, IntPtr user_data);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_set_stream_cb")]
+ internal static extern int SetStreamChangedCallback(IntPtr handle, AudioStreamCallback callback, IntPtr user_data);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_create_new")]
+ internal static extern int Create(int sampleRate, int channel, int type, out IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_destroy")]
+ internal static extern int Destroy(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_drain")]
+ internal static extern int Drain(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_flush")]
+ internal static extern int Flush(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_buffer_size")]
+ internal static extern int GetBufferSize(IntPtr handle, out int size);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_channel")]
+ internal static extern int GetChannel(IntPtr handle, out int channel);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_sample_rate")]
+ internal static extern int GetSampleRate(IntPtr handle, out int sampleRate);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_sample_type")]
+ internal static extern int GetSampleType(IntPtr handle, out int sampleType);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_sound_type")]
+ internal static extern int GetSoundType(IntPtr handle, out int soundType);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_pause")]
+ internal static extern int Pause(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_prepare")]
+ internal static extern int Prepare(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_resume")]
+ internal static extern int Resume(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_set_stream_info")]
+ internal static extern int SetStreamInfo(IntPtr handle, IntPtr streamInfoHandle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_unprepare")]
+ internal static extern int Unprepare(IntPtr handle);
+
+ [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_write")]
+ internal static extern int Write(IntPtr handle, byte[] buffer, uint length);
+ }
+ }
+}
public const string Recorder = "libcapi-media-recorder.so.0";
public const string SoundManager = "libcapi-media-sound-manager.so.0";
public const string AudioIO = "libcapi-media-audio-io.so.0";
- public const string ScreenMirroring = "libcapi-screen-mirroring-io.so.0";
+ public const string ScreenMirroring = "libcapi-media-screen-mirroring.so.0";
public const string MetadataExtractor = "libcapi-media-metadata-extractor.so";
public const string MediaController = "libcapi-media-controller.so.0";
public const string MediaTool = "libcapi-media-tool.so.0";
using System;
using System.Runtime.InteropServices;
+using Tizen.Applications;
internal static partial class Interop
{
internal delegate void RepeatModeUpdatedCallback(string serverName, int repeatMode, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void CommandReplyRecievedCallback(string serverName, int result, IntPtr bundleData, IntPtr userData);
+ internal delegate void CommandReplyRecievedCallback(string serverName, int result, IntPtr bundle, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate bool SubscribedServerCallback(string serverName, IntPtr userData);
internal static extern int SendPlaybackStateCommand(IntPtr handle, string serverName, int state);
[DllImport(Libraries.MediaController, EntryPoint = "mc_client_send_custom_command")]
- internal static extern int SendCustomCommand(IntPtr handle, string serverName, string command, IntPtr bundle, CommandReplyRecievedCallback callback, IntPtr userData);
+ internal static extern int SendCustomCommand(IntPtr handle, string serverName, string command, SafeBundleHandle bundle, CommandReplyRecievedCallback callback, IntPtr userData);
[DllImport(Libraries.MediaController, EntryPoint = "mc_client_foreach_server_subscribed")]
internal static extern int ForeachSubscribedServer(IntPtr handle, int subscriptionType, SubscribedServerCallback callback, IntPtr userData);
internal delegate void PlaybackStateCommandRecievedCallback(string clientName, int state, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void CustomCommandRecievedCallback(string clientName, string command, IntPtr bundleData, IntPtr userData);
+ internal delegate void CustomCommandRecievedCallback(string clientName, string command, IntPtr bundle, IntPtr userData);
[DllImport(Libraries.MediaController, EntryPoint = "mc_server_create")]
internal static extern int Create(out IntPtr handle);
[DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_playback_state_command_received_cb")]
internal static extern int UnsetPlaybackStateCmdRecvCb(IntPtr handle);
- [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_custom_command_received_cb ")]
+ [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_custom_command_received_cb")]
internal static extern int SetCustomCmdRecvCb(IntPtr handle, CustomCommandRecievedCallback callback, IntPtr userData);
- [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_custom_command_received_cb ")]
+ [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_custom_command_received_cb")]
internal static extern int UnsetCustomCmdRecvCb(IntPtr handle);
- [DllImport(Libraries.MediaController, EntryPoint = "mc_server_send_command_reply ")]
- internal static extern int SendCommandReply(IntPtr handle, string clientName, int result, IntPtr bundleData);
+ [DllImport(Libraries.MediaController, EntryPoint = "mc_server_send_command_reply")]
+ internal static extern int SendCommandReply(IntPtr handle, string clientName, int result, SafeBundleHandle bundle);
}
}
internal static partial class Player
{
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void PlaybackCompletedCallback(IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void PlaybackCompletedCallback(IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void PlaybackInterruptedCallback(int code, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void PlaybackInterruptedCallback(int code, IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void PlaybackErrorCallback(int code, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void PlaybackErrorCallback(int code, IntPtr userData);
- //[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- //internal delegate void VideoFrameDecodedCallback(MediaPacket packet, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VideoFrameDecodedCallback(IntPtr packetHandle, IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void SubtitleUpdatedCallback(uint duration, string text, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void SubtitleUpdatedCallback(uint duration, string text, IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void BufferingProgressCallback(int percent, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void BufferingProgressCallback(int percent, IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void ProgressiveDownloadMessageCallback(int type, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VideoStreamChangedCallback(int width, int height, int fps, int bitrate, IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void VideoStreamChangedCallback(int width, int height, int fps, int bitrate, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void MediaStreamBufferStatusCallback(int status, IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void BufferStatusCallback(int status, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void MediaStreamSeekCallback(ulong offset, IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void SeekOffsetChangedCallback(UInt64 offset, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VideoCaptureCallback(IntPtr data, int width, int height, uint size, IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void VideoCaptureCallback(byte[] data, int width, int height, uint size, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void PrepareCallback(IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void PrepareCallback(IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void SeekCompletedCallback(IntPtr userData);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void SeekCompletedCallback(IntPtr userData);
+ [DllImport(Libraries.Player, EntryPoint = "player_create")]
+ internal static extern int Create(out IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_create")]
- internal static extern int Create(out IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_destroy")]
+ internal static extern int Destroy(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_destroy")]
- internal static extern int Destroy(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_prepare")]
+ internal static extern int Prepare(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_prepare")]
- internal static extern int Prepare(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_prepare_async")]
+ internal static extern int PrepareAsync(IntPtr player, PrepareCallback cb, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_prepare_async")]
- internal static extern int PrepareAsync(IntPtr player, PrepareCallback cb, IntPtr userData);
+ [DllImport(Libraries.Player, EntryPoint = "player_unprepare")]
+ internal static extern int Unprepare(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_unprepare")]
- internal static extern int Unprepare(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_uri")]
+ internal static extern int SetUri(IntPtr player, string uri);
- [DllImport(Libraries.Player, EntryPoint = "player_set_uri")]
- internal static extern int SetUri(IntPtr player, string uri);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_display")]
+ internal static extern int SetDisplay(IntPtr player, int type, IntPtr display);
- [DllImport(Libraries.Player, EntryPoint = "player_set_display")]
- internal static extern int SetDisplay(IntPtr player, int type, IntPtr display);
+ [DllImport(Libraries.Player, EntryPoint = "player_start")]
+ internal static extern int Start(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_start")]
- internal static extern int Start(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_stop")]
+ internal static extern int Stop(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_stop")]
- internal static extern int Stop(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_pause")]
+ internal static extern int Pause(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_pause")]
- internal static extern int Pause(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_memory_buffer")]
+ internal static extern int SetMemoryBuffer(IntPtr player, byte[] data, int size);
- [DllImport(Libraries.Player, EntryPoint = "player_set_memory_buffer")]
- internal static extern int SetMemoryBuffer(IntPtr player, IntPtr data, int size);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_state")]
+ internal static extern int GetState(IntPtr player, out int state);
- [DllImport(Libraries.Player, EntryPoint = "player_get_state")]
- internal static extern int GetState(IntPtr player, out int state);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_volume")]
+ internal static extern int SetVolume(IntPtr player, float left, float right);
- [DllImport(Libraries.Player, EntryPoint = "player_set_volume")]
- internal static extern int SetVolume(IntPtr player, float left, float right);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_volume")]
+ internal static extern int GetVolume(IntPtr player, out float left, out float right);
- [DllImport(Libraries.Player, EntryPoint = "player_get_volume")]
- internal static extern int GetVolume(IntPtr player, out float left, out float right);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_audio_policy_info")]
+ internal static extern int SetAudioPolicyInfo(IntPtr player, IntPtr streamInfo);
- [DllImport(Libraries.Player, EntryPoint = "player_set_audio_policy_info")]
- internal static extern int SetAudioPolicyInfo(IntPtr player, IntPtr stream_info);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_audio_latency_mode")]
+ internal static extern int SetAudioLatencyMode(IntPtr player, int latencyMode);
- [DllImport(Libraries.Player, EntryPoint = "player_set_audio_latency_mode")]
- internal static extern int SetAudioLatencyMode(IntPtr player, int latency_mode);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_audio_latency_mode")]
+ internal static extern int GetAudioLatencyMode(IntPtr player, out int latencyMode);
- [DllImport(Libraries.Player, EntryPoint = "player_get_audio_latency_mode")]
- internal static extern int GetAudioLatencyMode(IntPtr player, out int latency_mode);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_play_position")]
+ internal static extern int GetPlayPosition(IntPtr player, out int millisecond);
- [DllImport(Libraries.Player, EntryPoint = "player_get_play_position")]
- internal static extern int GetPlayPosition(IntPtr player, out int millisecond);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_play_position")]
+ internal static extern int SetPlayPosition(IntPtr player, int millisecond, bool accurate, SeekCompletedCallback cb, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_set_play_position")]
- internal static extern int SetPlayPosition(IntPtr player, int millisecond, bool accurate, SeekCompletedCallback cb, IntPtr userData);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_mute")]
+ internal static extern int SetMute(IntPtr player, bool muted);
- [DllImport(Libraries.Player, EntryPoint = "player_set_mute")]
- internal static extern int SetMute(IntPtr player, bool muted);
+ [DllImport(Libraries.Player, EntryPoint = "player_is_muted")]
+ internal static extern int IsMuted(IntPtr player, out bool muted);
- [DllImport(Libraries.Player, EntryPoint = "player_is_muted")]
- internal static extern int IsMuted(IntPtr player, out bool muted);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_looping")]
+ internal static extern int SetLooping(IntPtr player, bool looping);
- [DllImport(Libraries.Player, EntryPoint = "player_set_looping")]
- internal static extern int SetLooping(IntPtr player, bool looping);
+ [DllImport(Libraries.Player, EntryPoint = "player_is_looping")]
+ internal static extern int IsLooping(IntPtr player, out bool looping);
- [DllImport(Libraries.Player, EntryPoint = "player_is_looping")]
- internal static extern int IsLooping(IntPtr player, out bool looping);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_completed_cb")]
+ internal static extern int SetCompletedCb(IntPtr player, PlaybackCompletedCallback callback, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_set_completed_cb")]
- internal static extern int SetCompletedCb(IntPtr player, PlaybackCompletedCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_unset_completed_cb")]
+ internal static extern int UnsetCompletedCb(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_unset_completed_cb")]
- internal static extern int UnsetCompletedCb(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_interrupted_cb")]
+ internal static extern int SetInterruptedCb(IntPtr player, PlaybackInterruptedCallback callback, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_set_interrupted_cb")]
- internal static extern int SetInterruptedCb(IntPtr player, PlaybackInterruptedCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_unset_interrupted_cb")]
+ internal static extern int UnsetInterruptedCb(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_unset_interrupted_cb")]
- internal static extern int UnsetInterruptedCb(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_error_cb")]
+ internal static extern int SetErrorCb(IntPtr player, PlaybackErrorCallback callback, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_set_error_cb")]
- internal static extern int SetErrorCb(IntPtr player, PlaybackErrorCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_unset_error_cb")]
+ internal static extern int UnsetErrorCb(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_unset_error_cb")]
- internal static extern int UnsetErrorCb(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_capture_video")]
+ internal static extern int CaptureVideo(IntPtr player, VideoCaptureCallback callback, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_capture_video")]
- internal static extern int CaptureVideo(IntPtr player, VideoCaptureCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_media_packet_video_frame_decoded_cb")]
+ internal static extern int SetVideoFrameDecodedCb(IntPtr player, VideoFrameDecodedCallback callback, IntPtr userData);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_media_packet_video_frame_decoded_cb")]
- //internal static extern int SetMediaPacketVideoFrameDecodedCb(IntPtr player, _videoFrameDecodedCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_unset_media_packet_video_frame_decoded_cb")]
+ internal static extern int UnsetVideoFrameDecodedCb(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_unset_media_packet_video_frame_decoded_cb")]
- internal static extern int UnsetMediaPacketVideoFrameDecodedCb(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_streaming_cookie")]
+ internal static extern int SetStreamingCookie(IntPtr player, string cookie, int size);
- [DllImport(Libraries.Player, EntryPoint = "player_set_streaming_cookie")]
- internal static extern int SetStreamingCookie(IntPtr player, string cookie, int size);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_streaming_user_agent")]
+ internal static extern int SetStreamingUserAgent(IntPtr player, string userAgent, int size);
- [DllImport(Libraries.Player, EntryPoint = "player_set_streaming_user_agent")]
- internal static extern int SetStreamingUserAgent(IntPtr player, string user_agent, int size);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_streaming_download_progress")]
+ internal static extern int GetStreamingDownloadProgress(IntPtr player, out int start, out int current);
- [DllImport(Libraries.Player, EntryPoint = "player_get_streaming_download_progress")]
- internal static extern int GetStreamingDownloadProgress(IntPtr player, out int start, out int current);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_buffering_cb")]
+ internal static extern int SetBufferingCb(IntPtr player, BufferingProgressCallback callback, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_set_buffering_cb")]
- internal static extern int SetBufferingCb(IntPtr player, BufferingProgressCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_unset_buffering_cb")]
+ internal static extern int UnsetBufferingCb(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_unset_buffering_cb")]
- internal static extern int UnsetBufferingCb(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_playback_rate")]
+ internal static extern int SetPlaybackRate(IntPtr player, float rate);
- [DllImport(Libraries.Player, EntryPoint = "player_set_progressive_download_path")]
- internal static extern int SetProgressiveDownloadPath(IntPtr player, string path);
+ [DllImport(Libraries.Player, EntryPoint = "player_push_media_stream")]
+ internal static extern int PushMediaStream(IntPtr player, IntPtr packet);
- [DllImport(Libraries.Player, EntryPoint = "player_get_progressive_download_status")]
- internal static extern int GetProgressiveDownloadStatus(IntPtr player, out ulong current, out ulong total_size);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_info")]
+ internal static extern int SetMediaStreamInfo(IntPtr player, int type, IntPtr format);
- [DllImport(Libraries.Player, EntryPoint = "player_set_progressive_download_message_cb")]
- internal static extern int SetProgressiveDownloadMessageCb(IntPtr player, ProgressiveDownloadMessageCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_status_cb")]
+ internal static extern int SetMediaStreamBufferStatusCb(IntPtr player, int type, MediaStreamBufferStatusCallback callback, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_unset_progressive_download_message_cb")]
- internal static extern int UnsetProgressiveDownloadMessageCb(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_unset_media_stream_buffer_status_cb")]
+ internal static extern int UnsetMediaStreamBufferStatusCb(IntPtr player, int type);
- [DllImport(Libraries.Player, EntryPoint = "player_set_playback_rate")]
- internal static extern int SetPlaybackRate(IntPtr player, float rate);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_seek_cb")]
+ internal static extern int SetMediaStreamSeekCb(IntPtr player, int type, MediaStreamSeekCallback callback, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_push_media_stream")]
- internal static extern int PushMediaStream(IntPtr player, IntPtr packet);
+ [DllImport(Libraries.Player, EntryPoint = "player_unset_media_stream_seek_cb")]
+ internal static extern int UnsetMediaStreamSeekCb(IntPtr player, int type);
- [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_info")]
- internal static extern int SetMediaStreamInfo(IntPtr player, int type, IntPtr format);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_max_size")]
+ internal static extern int SetMediaStreamBufferMaxSize(IntPtr player, int type, ulong maxSize);
- [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_status_cb")]
- internal static extern int SetMediaStreamBufferStatusCb(IntPtr player, int type, BufferStatusCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_media_stream_buffer_max_size")]
+ internal static extern int GetMediaStreamBufferMaxSize(IntPtr player, int type, out ulong maxSize);
- [DllImport(Libraries.Player, EntryPoint = "player_unset_media_stream_buffer_status_cb")]
- internal static extern int UnsetMediaStreamBufferStatusCb(IntPtr player, int type);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_min_threshold")]
+ internal static extern int SetMediaStreamBufferMinThreshold(IntPtr player, int type, uint percent);
- [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_seek_cb")]
- internal static extern int SetMediaStreamSeekCb(IntPtr player, int type, SeekOffsetChangedCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_media_stream_buffer_min_threshold")]
+ internal static extern int GetMediaStreamBufferMinThreshold(IntPtr player, int type, out uint percent);
- [DllImport(Libraries.Player, EntryPoint = "player_unset_media_stream_seek_cb")]
- internal static extern int UnsetMediaStreamSeekCb(IntPtr player, int type);
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_bands_count")]
+ internal static extern int AudioEffectGetEqualizerBandsCount(IntPtr player, out int count);
- [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_max_size")]
- internal static extern int SetMediaStreamBufferMaxSize(IntPtr player, int type, ulong max_size);
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_set_equalizer_band_level")]
+ internal static extern int AudioEffectSetEqualizerBandLevel(IntPtr player, int index, int level);
- [DllImport(Libraries.Player, EntryPoint = "player_get_media_stream_buffer_max_size")]
- internal static extern int GetMediaStreamBufferMaxSize(IntPtr player, int type, out ulong max_size);
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_level")]
+ internal static extern int AudioEffectGetEqualizerBandLevel(IntPtr player, int index, out int level);
- [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_min_threshold")]
- internal static extern int SetMediaStreamBufferMinThreshold(IntPtr player, int type, uint percent);
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_set_equalizer_all_bands")]
+ internal static extern int AudioEffectSetEqualizerAllBands(IntPtr player, out int band_levels, int length);
- [DllImport(Libraries.Player, EntryPoint = "player_get_media_stream_buffer_min_threshold")]
- internal static extern int GetMediaStreamBufferMinThreshold(IntPtr player, int type, out uint percent);
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_level_range")]
+ internal static extern int AudioEffectGetEqualizerLevelRange(IntPtr player, out int min, out int max);
- [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_bands_count")]
- internal static extern int AudioEffectGetEqualizerBandsCount(IntPtr player, out int count);
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_frequency")]
+ internal static extern int AudioEffectGetEqualizerBandFrequency(IntPtr player, int index, out int frequency);
- [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_set_equalizer_band_level")]
- internal static extern int AudioEffectSetEqualizerBandLevel(IntPtr player, int index, int level);
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_frequency_range")]
+ internal static extern int AudioEffectGetEqualizerBandFrequencyRange(IntPtr player, int index, out int range);
- [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_level")]
- internal static extern int AudioEffectGetEqualizerBandLevel(IntPtr player, int index, out int level);
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_equalizer_clear")]
+ internal static extern int AudioEffectEqualizerClear(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_set_equalizer_all_bands")]
- internal static extern int AudioEffectSetEqualizerAllBands(IntPtr player, out int band_levels, int length);
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_equalizer_is_available")]
+ internal static extern int AudioEffectEqualizerIsAvailable(IntPtr player, out bool available);
- [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_level_range")]
- internal static extern int AudioEffectGetEqualizerLevelRange(IntPtr player, out int min, out int max);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_display_mode")]
+ internal static extern int SetDisplayMode(IntPtr player, int mode);
- [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_frequency")]
- internal static extern int AudioEffectGetEqualizerBandFrequency(IntPtr player, int index, out int frequency);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_display_mode")]
+ internal static extern int GetDisplayMode(IntPtr player, out int mode);
- [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_frequency_range")]
- internal static extern int AudioEffectGetEqualizerBandFrequencyRange(IntPtr player, int index, out int range);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_display_visible")]
+ internal static extern int SetDisplayVisible(IntPtr player, bool visible);
- [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_equalizer_clear")]
- internal static extern int AudioEffectEqualizerClear(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_is_display_visible")]
+ internal static extern int IsDisplayVisible(IntPtr player, out bool visible);
- [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_equalizer_is_available")]
- internal static extern int AudioEffectEqualizerIsAvailable(IntPtr player, out bool available);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_display_rotation")]
+ internal static extern int SetDisplayRotation(IntPtr player, int rotation);
- [DllImport(Libraries.Player, EntryPoint = "player_set_display_mode")]
- internal static extern int SetDisplayMode(IntPtr player, int mode);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_display_rotation")]
+ internal static extern int GetDisplayRotation(IntPtr player, out int rotation);
- [DllImport(Libraries.Player, EntryPoint = "player_get_display_mode")]
- internal static extern int GetDisplayMode(IntPtr player, out int mode);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_content_info")]
+ internal static extern int GetContentInfo(IntPtr player, int key, out IntPtr value);
- [DllImport(Libraries.Player, EntryPoint = "player_set_display_visible")]
- internal static extern int SetDisplayVisible(IntPtr player, bool visible);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_codec_info")]
+ internal static extern int GetCodecInfo(IntPtr player, out IntPtr audioCodec, out IntPtr videoCodec);
- [DllImport(Libraries.Player, EntryPoint = "player_is_display_visible")]
- internal static extern int IsDisplayVisible(IntPtr player, out bool visible);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_audio_stream_info")]
+ internal static extern int GetAudioStreamInfo(IntPtr player, out int sampleRate, out int channel, out int bitRate);
- [DllImport(Libraries.Player, EntryPoint = "player_set_display_rotation")]
- internal static extern int SetDisplayRotation(IntPtr player, int rotation);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_video_stream_info")]
+ internal static extern int GetVideoStreamInfo(IntPtr player, out int fps, out int bitRate);
- [DllImport(Libraries.Player, EntryPoint = "player_get_display_rotation")]
- internal static extern int GetDisplayRotation(IntPtr player, out int rotation);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_album_art")]
+ internal static extern int GetAlbumArt(IntPtr player, out IntPtr albumArt, out int size);
- [DllImport(Libraries.Player, EntryPoint = "player_get_content_info")]
- internal static extern int GetContentInfo(IntPtr player, int key, out IntPtr value);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_video_size")]
+ internal static extern int GetVideoSize(IntPtr player, out int width, out int height);
- [DllImport(Libraries.Player, EntryPoint = "player_get_codec_info")]
- internal static extern int GetCodecInfo(IntPtr player, out IntPtr audio_codec, out IntPtr video_codec);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_duration")]
+ internal static extern int GetDuration(IntPtr player, out int duration);
- [DllImport(Libraries.Player, EntryPoint = "player_get_audio_stream_info")]
- internal static extern int GetAudioStreamInfo(IntPtr player, out int sample_rate, out int channel, out int bit_rate);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_path")]
+ internal static extern int SetSubtitlePath(IntPtr player, string path);
- [DllImport(Libraries.Player, EntryPoint = "player_get_video_stream_info")]
- internal static extern int GetVideoStreamInfo(IntPtr player, out int fps, out int bit_rate);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_updated_cb")]
+ internal static extern int SetSubtitleUpdatedCb(IntPtr player, SubtitleUpdatedCallback callback, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_get_album_art")]
- internal static extern int GetAlbumArt(IntPtr player, out IntPtr album_art, out int size);
+ [DllImport(Libraries.Player, EntryPoint = "player_unset_subtitle_updated_cb")]
+ internal static extern int UnsetSubtitleUpdatedCb(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_get_video_size")]
- internal static extern int GetVideoSize(IntPtr player, out int width, out int height);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_position_offset")]
+ internal static extern int SetSubtitlePositionOffset(IntPtr player, int millisecond);
- [DllImport(Libraries.Player, EntryPoint = "player_get_duration")]
- internal static extern int GetDuration(IntPtr player, out int duration);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_video_stream_changed_cb")]
+ internal static extern int SetVideoStreamChangedCb(IntPtr player, VideoStreamChangedCallback callback, IntPtr userData);
- [DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_path")]
- internal static extern int SetSubtitlePath(IntPtr player, string path);
+ [DllImport(Libraries.Player, EntryPoint = "player_unset_video_stream_changed_cb")]
+ internal static extern int UnsetVideoStreamChangedCb(IntPtr player);
- [DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_updated_cb")]
- internal static extern int SetSubtitleUpdatedCb(IntPtr player, SubtitleUpdatedCallback callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_track_count")]
+ internal static extern int GetTrackCount(IntPtr player, int type, out int count);
- [DllImport(Libraries.Player, EntryPoint = "player_unset_subtitle_updated_cb")]
- internal static extern int UnsetSubtitleUpdatedCb(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_select_track")]
+ internal static extern int SelectTrack(IntPtr player, int type, int index);
- [DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_position_offset")]
- internal static extern int SetSubtitlePositionOffset(IntPtr player, int millisecond);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_current_track")]
+ internal static extern int GetCurrentTrack(IntPtr player, int type, out int index);
- [DllImport(Libraries.Player, EntryPoint = "player_set_video_stream_changed_cb")]
- internal static extern int SetVideoStreamChangedCb(IntPtr player, VideoStreamChangedCallback callback, IntPtr user_data);
-
- [DllImport(Libraries.Player, EntryPoint = "player_unset_video_stream_changed_cb")]
- internal static extern int UnsetVideoStreamChangedCb(IntPtr player);
-
- [DllImport(Libraries.Player, EntryPoint = "player_get_track_count")]
- internal static extern int GetTrackCount(IntPtr player, int type, out int count);
-
- [DllImport(Libraries.Player, EntryPoint = "player_select_track")]
- internal static extern int SelectTrack(IntPtr player, int type, int index);
-
- [DllImport(Libraries.Player, EntryPoint = "player_get_current_track")]
- internal static extern int GetCurrentTrack(IntPtr player, int type, out int index);
-
- [DllImport(Libraries.Player, EntryPoint = "player_get_track_language_code")]
- internal static extern int GetTrackLanguageCode(IntPtr player, int type, int index, out string code);
+ [DllImport(Libraries.Player, EntryPoint = "player_get_track_language_code")]
+ internal static extern int GetTrackLanguageCode(IntPtr player, int type, int index, out IntPtr code);
}
}
/// </summary>
public class BufferStatusChangedEventArgs : EventArgs
{
- private readonly MediaCodecStatus _status;
-
/// <summary>
/// Initializes a new instance of the BufferStatusChangedEventArgs class.
/// </summary>
/// <param name="status">The value representing new status of the codec.</param>
public BufferStatusChangedEventArgs(MediaCodecStatus status)
{
- _status = status;
+ Status = status;
}
/// <summary>
/// Gets the value indicating new status of the codec.
/// </summary>
- public MediaCodecStatus Status
- {
- get
- {
- return _status;
- }
- }
+ public MediaCodecStatus Status { get; }
}
}
/// </summary>
public class InputProcessedEventArgs : EventArgs
{
- private readonly MediaPacket _packet;
-
/// <summary>
/// Initializes a new instance of the InputProcessedEventArgs class.
/// </summary>
/// <param name="packet">The packet that the codec has processed.</param>
- public InputProcessedEventArgs(MediaPacket packet)
+ internal InputProcessedEventArgs(MediaPacket packet)
{
Debug.Assert(packet != null);
- _packet = packet;
+ Packet = packet;
}
/// <summary>
/// Gets the packet that the codec has processed.
/// </summary>
- public MediaPacket Packet
- {
- get
- {
- return _packet;
- }
- }
+ public MediaPacket Packet { get; }
}
}
throw new InvalidOperationException("Not able to initialize a new media codec.");
}
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
#region IDisposable-support
var videoCodecList = new List<MediaFormatVideoMimeType>();
var audioCodecList = new List<MediaFormatAudioMimeType>();
- Interop.MediaCodec.SupportedCodecCallback cb = (int codecType, IntPtr arg) =>
+ Interop.MediaCodec.SupportedCodecCallback cb = (codecType, _) =>
{
if ((codecType & CodecKindMask) == CodecKindVideo)
{
int ret = Interop.MediaCodec.ForeachSupportedCodec(cb, IntPtr.Zero);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
_supportedVideoCodecs = videoCodecList.AsReadOnly();
_supportedAudioCodecs = audioCodecList.AsReadOnly();
throw new InvalidOperationException("Operation failed.");
}
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
/// <summary>
int ret = Interop.MediaCodec.Unprepare(_handle);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
/// <summary>
int ret = Interop.MediaCodec.SetAudioEncoderInfo(_handle, format.SampleRate,
format.Channel, format.Bit, format.BitRate);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
else
{
int ret = Interop.MediaCodec.SetAudioDecoderInfo(_handle, format.SampleRate,
format.Channel, format.Bit);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
}
int ret = Interop.MediaCodec.SetVideoEncoderInfo(_handle, format.Width,
format.Height, format.FrameRate, format.BitRate / 1000);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
else
{
int ret = Interop.MediaCodec.SetVideoDecoderInfo(_handle, format.Width, format.Height);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
}
{
throw new NotSupportedException("The format is not supported.");
}
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
/// <summary>
throw new InvalidOperationException("The codec is in invalid state.");
}
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
/// <summary>
int ret = Interop.MediaCodec.FlushBuffers(_handle);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
/// <summary>
int ret = Interop.MediaCodec.GetSupportedType(_handle, codecType, isEncoder, out value);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
return (MediaCodecTypes)value;
}
private void RegisterOutputAvailableCallback()
{
- _outputBufferAvailableCb = (IntPtr packetHandle, IntPtr arg) =>
+ _outputBufferAvailableCb = (packetHandle, _) =>
{
OutputAvailableEventArgs args = null;
int ret = Interop.MediaCodec.SetOutputBufferAvaiableCb(_handle,
_outputBufferAvailableCb, IntPtr.Zero);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
private void UnregisterOutputAvailableCallback()
{
int ret = Interop.MediaCodec.UnsetOutputBufferAvaiableCb(_handle);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
#endregion
private void RegisterInputProcessed()
{
- _inputBufferUsedCb = (IntPtr lockedPacketHandle, IntPtr arg) =>
+ _inputBufferUsedCb = (lockedPacketHandle, _) =>
{
MediaPacket packet = null;
int ret = Interop.MediaCodec.SetInputBufferUsedCb(_handle,
_inputBufferUsedCb, IntPtr.Zero);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
private void UnregisterInputProcessed()
{
int ret = Interop.MediaCodec.UnsetInputBufferUsedCb(_handle);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
#endregion
#region ErrorOccurred event
- private EventHandler<ErrorOccurredEventArgs> _errorOccurred;
+ private EventHandler<MediaCodecErrorOccurredEventArgs> _errorOccurred;
private Interop.MediaCodec.ErrorCallback _errorCb;
+ // TODO replace
/// <summary>
/// Occurs whenever an error is produced in the codec.
/// </summary>
- public event EventHandler<ErrorOccurredEventArgs> ErrorOccurred
+ public event EventHandler<MediaCodecErrorOccurredEventArgs> ErrorOccurred
{
add
{
private void RegisterErrorOccurred()
{
- _errorCb = (int errorCode, IntPtr arg) =>
+ _errorCb = (errorCode, _) =>
{
MediaCodecError error = (Enum.IsDefined(typeof(MediaCodecError), errorCode)) ?
(MediaCodecError)errorCode : MediaCodecError.InternalError;
- _errorOccurred?.Invoke(this, new ErrorOccurredEventArgs(error));
+ _errorOccurred?.Invoke(this, new MediaCodecErrorOccurredEventArgs(error));
};
int ret = Interop.MediaCodec.SetErrorCb(_handle, _errorCb, IntPtr.Zero);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
private void UnregisterErrorOccurred()
{
int ret = Interop.MediaCodec.UnsetErrorCb(_handle);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
#endregion
#region EosReached event
- private EventHandler<EosReachedEventArgs> _eosReached;
+ private EventHandler<EventArgs> _eosReached;
private Interop.MediaCodec.EosCallback _eosCb;
+ // TODO replace
/// <summary>
/// Occurs when the codec processes all input data.
/// </summary>
- public event EventHandler<EosReachedEventArgs> EosReached
+ public event EventHandler<EventArgs> EosReached
{
add
{
private void RegisterEosReached()
{
- _eosCb = (IntPtr arg) => _eosReached?.Invoke(this, new EosReachedEventArgs());
+ _eosCb = _ => _eosReached?.Invoke(this, EventArgs.Empty);
int ret = Interop.MediaCodec.SetEosCb(_handle, _eosCb, IntPtr.Zero);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
private void UnregisterEosReached()
{
int ret = Interop.MediaCodec.UnsetEosCb(_handle);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
#endregion
private void RegisterBufferStatusChanged()
{
- _bufferStatusCb = (int statusCode, IntPtr arg) =>
+ _bufferStatusCb = (statusCode, _) =>
{
Debug.Assert(Enum.IsDefined(typeof(MediaCodecStatus), statusCode),
$"{ statusCode } is not defined in MediaCodecStatus!");
int ret = Interop.MediaCodec.SetBufferStatusCb(_handle, _bufferStatusCb, IntPtr.Zero);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
private void UnregisterBufferStatusChanged()
{
int ret = Interop.MediaCodec.UnsetBufferStatusCb(_handle);
- MediaCodecDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
#endregion
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
using System;
namespace Tizen.Multimedia.MediaCodec
/// <summary>
/// Provides data for the <see cref="MediaCodec.ErrorOccurred"/> event.
/// </summary>
- public class ErrorOccurredEventArgs : EventArgs
+ public class MediaCodecErrorOccurredEventArgs : EventArgs
{
- private readonly MediaCodecError _error;
-
/// <summary>
/// Initializes a new instance of the ErrorOccurredEventArgs class.
/// </summary>
/// <param name="error">The value representing the type of the error.</param>
- public ErrorOccurredEventArgs(MediaCodecError error)
+ public MediaCodecErrorOccurredEventArgs(MediaCodecError error)
{
- _error = error;
+ Error = error;
}
/// <summary>
/// Gets the value indicating what kind of the error.
/// </summary>
- public MediaCodecError Error
- {
- get
- {
- return _error;
- }
- }
+ public MediaCodecError Error { get; }
}
}
/// <remarks>The output packet needs to be disposed after it is used to clean up unmanaged resources.</remarks>
public class OutputAvailableEventArgs : EventArgs
{
- private readonly MediaPacket _packet;
-
internal OutputAvailableEventArgs(IntPtr packetHandle)
{
- _packet = MediaPacket.From(packetHandle);
+ Packet = MediaPacket.From(packetHandle);
}
/// <summary>
/// Gets the result packet.
/// </summary>
- public MediaPacket Packet
- {
- get
- {
- return _packet;
- }
- }
+ public MediaPacket Packet { get; }
}
}
*/
using System;
+using Tizen.Applications;
namespace Tizen.Multimedia.MediaController
{
{
internal string _clientName;
internal string _command;
- internal IntPtr _bundle;
- internal IntPtr _userData;
+ internal Bundle _bundle;
- public CustomCommandEventArgs (string name, string command, IntPtr bundle, IntPtr userData)
+ public CustomCommandEventArgs (string name, string command, Bundle bundle)
{
_clientName = name;
_command = command;
_bundle = bundle;
- _userData = userData;
}
/// <summary>
/// Get bundle data.
/// </summary>
/// <value> 0 - 100 </value>
- public IntPtr BundleData
+ public Bundle BundleData
{
get
{
return _bundle;
}
}
-
- /// <summary>
- /// Get user data.
- /// </summary>
- /// <value> 0 - 100 </value>
- public IntPtr UserData
- {
- get
- {
- return _userData;
- }
- }
}
}
using System;
+using Tizen.Applications;
namespace Tizen.Multimedia.MediaController
{
/// <remarks>
/// CustomCommandRecieved event arguments
/// </remarks>
- public class CommandReplyEventArgs : EventArgs
+ public class CustomCommandReplyEventArgs : EventArgs
{
internal string _serverName;
internal int _result;
- internal IntPtr _bundle;
- internal IntPtr _userData;
+ internal Bundle _bundle;
- public CommandReplyEventArgs (string serverName, int result, IntPtr bundle, IntPtr userData)
+ public CustomCommandReplyEventArgs (string serverName, int result, Bundle bundle)
{
_serverName = serverName;
_result = result;
_bundle = bundle;
- _userData = userData;
}
/// <summary>
/// Get bundle data.
/// </summary>
/// <value> 0 - 100 </value>
- public IntPtr BundleData
+ public Bundle BundleData
{
get
{
return _bundle;
}
}
-
- /// <summary>
- /// Get user data.
- /// </summary>
- /// <value> 0 - 100 </value>
- public IntPtr UserData
- {
- get
- {
- return _userData;
- }
- }
}
}
using System;
using System.Collections.Generic;
-using System.Threading;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
+using Tizen.Applications;
namespace Tizen.Multimedia.MediaController
{
private Interop.MediaControllerClient.ShuffleModeUpdatedCallback _shufflemodeUpdatedCallback;
private EventHandler<RepeatModeUpdatedEventArgs> _repeatmodeUpdated;
private Interop.MediaControllerClient.RepeatModeUpdatedCallback _repeatmodeUpdatedCallback;
- private EventHandler<CommandReplyEventArgs> _commandReply;
- private Interop.MediaControllerClient.CommandReplyRecievedCallback _commandReplyCallback;
+ private EventHandler<CustomCommandReplyEventArgs> _customcommandReply;
+ private Interop.MediaControllerClient.CommandReplyRecievedCallback _customcommandReplyCallback;
public MediaControllerClient ()
{
/// <summary>
/// CommandReply event is raised when reply for command is recieved
/// </summary>
- public event EventHandler<CommandReplyEventArgs> CommandReply
+ public event EventHandler<CustomCommandReplyEventArgs> CustomCommandReply
{
add
{
- if(_commandReply == null)
+ if(_customcommandReply == null)
{
- _commandReplyCallback = (string serverName, int result, IntPtr bundle, IntPtr userData) =>
+ _customcommandReplyCallback = (string serverName, int result, IntPtr bundle, IntPtr userData) =>
{
- CommandReplyEventArgs eventArgs = new CommandReplyEventArgs(serverName, result, bundle, userData);
- _commandReply?.Invoke(this, eventArgs);
+ SafeBundleHandle bundleHandle = new SafeBundleHandle(bundle, true);
+ Applications.Bundle _bundle = new Bundle(bundleHandle);
+ CustomCommandReplyEventArgs eventArgs = new CustomCommandReplyEventArgs(serverName, result, _bundle);
+ _customcommandReply?.Invoke(this, eventArgs);
};
}
- _commandReply += value;
+ _customcommandReply += value;
}
remove
{
- _commandReply -= value;
- if(_commandReply == null)
+ _customcommandReply -= value;
+ if(_customcommandReply == null)
{
- _commandReplyCallback = null;
+ _customcommandReplyCallback = null;
}
}
}
MediaControllerErrorFactory.ThrowException(res, "Get Latest server failed");
}
- ServerInformation _serverInfo = new ServerInformation (_name, (ServerState)_state);
+ ServerInformation _serverInfo = new ServerInformation (_name, (MediaControllerServerState)_state);
return _serverInfo;
}
/// <summary>
/// gets playback information for specific server </summary>
/// <param name="serverName"> Server Name </param>
- public Playback GetPlayback(String serverName)
+ public MediaControllerPlayback GetPlayback(String serverName)
{
MediaControllerError res = MediaControllerError.None;
IntPtr _playbackHandle = IntPtr.Zero;
MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
}
- Playback _playback = new Playback (_playbackHandle);
+ MediaControllerPlayback _playback = new MediaControllerPlayback (_playbackHandle);
return _playback;
}
/// <summary>
/// gets metadata information for specific server </summary>
/// <param name="serverName"> Server Name </param>
- public Metadata GetMetadata(String serverName)
+ public MediaControllerMetadata GetMetadata(String serverName)
{
MediaControllerError res = MediaControllerError.None;
IntPtr _metadataHandle = IntPtr.Zero;
MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
}
- Metadata _metadata = new Metadata (_metadataHandle);
+ MediaControllerMetadata _metadata = new MediaControllerMetadata (_metadataHandle);
return _metadata;
}
/// <summary>
/// gets shuffle mode for specific server </summary>
/// <param name="serverName"> Server Name </param>
- public ShuffleMode GetShuffleMode(String serverName)
+ public MediaControllerShuffleMode GetShuffleMode(String serverName)
{
MediaControllerError res = MediaControllerError.None;
int _shuffleMode;
MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
}
- return (ShuffleMode)_shuffleMode;
+ return (MediaControllerShuffleMode)_shuffleMode;
}
/// <summary>
/// gets repeat mode for specific server </summary>
/// <param name="serverName"> Server Name </param>
- public RepeatMode GetRepeatMode(String serverName)
+ public MediaControllerRepeatMode GetRepeatMode(String serverName)
{
MediaControllerError res = MediaControllerError.None;
int _repeatMode;
MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
}
- return (RepeatMode)_repeatMode;
+ return (MediaControllerRepeatMode)_repeatMode;
}
/// <summary>
/// Send command of playback state to server application </summary>
/// <param name="serverName"> Server Name </param>
/// <param name="state"> Playback State </param>
- public void SendPlaybackStateCommand(string serverName, PlaybackState state)
+ public void SendPlaybackStateCommand(string serverName, MediaControllerPlaybackState state)
{
MediaControllerError res = MediaControllerError.None;
res = (MediaControllerError)Interop.MediaControllerClient.SendPlaybackStateCommand(_handle, serverName, (int)state);
/// <param name="command"> Command </param>
/// <param name="bundle"> Bundle data </param>
/// <param name="userData"> User Data </param>
- public void SendCustomCommand(string serverName, string command, IntPtr bundle, IntPtr userData)
+ public void SendCustomCommand(string serverName, string command, Bundle bundle)
{
MediaControllerError res = MediaControllerError.None;
- if (_commandReply == null) {
- res = (MediaControllerError)Interop.MediaControllerClient.SendCustomCommand(_handle, serverName, command, bundle, _commandReplyCallback, IntPtr.Zero);
- } else {
- res = (MediaControllerError)Interop.MediaControllerClient.SendCustomCommand(_handle, serverName, command, bundle, _commandReplyCallback, userData);
- }
+ res = (MediaControllerError)Interop.MediaControllerClient.SendCustomCommand(_handle, serverName, command, bundle.SafeBundleHandle, _customcommandReplyCallback, IntPtr.Zero);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Send custom command failed" + res);
/// Subscribe subscription type from specific server application </summary>
/// <param name="type"> Subscription Type </param>
/// <param name="serverName"> Server Name </param>
- public void Subscribe(SubscriptionType type, string serverName)
+ public void Subscribe(MediaControllerSubscriptionType type, string serverName)
{
MediaControllerError res = MediaControllerError.None;
res = (MediaControllerError)Interop.MediaControllerClient.Subscribe(_handle, (int)type, serverName);
/// Subscribe subscription type from specific server application </summary>
/// <param name="type"> Subscription Type </param>
/// <param name="serverName"> Server Name </param>
- public void Unsubscribe(SubscriptionType type, string serverName)
+ public void Unsubscribe(MediaControllerSubscriptionType type, string serverName)
{
MediaControllerError res = MediaControllerError.None;
res = (MediaControllerError)Interop.MediaControllerClient.Unsubscribe(_handle, (int)type, serverName);
/// <summary>
/// gets subscribed server list </summary>
/// <param name="subscriptionType"> Subscription Type </param>
- public Task<IEnumerable<string>> GetSubscribedServerList(SubscriptionType subscriptionType)
+ public Task<IEnumerable<string>> GetSubscribedServerList(MediaControllerSubscriptionType subscriptionType)
{
var task = new TaskCompletionSource<IEnumerable<string>>();
{
_serverUpdatedCallback = (string serverName, int serverState, IntPtr userData) =>
{
- ServerUpdatedEventArgs eventArgs = new ServerUpdatedEventArgs(serverName, (ServerState)serverState, userData);
+ ServerUpdatedEventArgs eventArgs = new ServerUpdatedEventArgs(serverName, (MediaControllerServerState)serverState);
_serverUpdated?.Invoke(this, eventArgs);
};
Interop.MediaControllerClient.SetServerUpdatedCb(_handle, _serverUpdatedCallback, IntPtr.Zero);
{
_playbackUpdatedCallback = (string serverName, IntPtr playback, IntPtr userData) =>
{
- PlaybackUpdatedEventArgs eventArgs = new PlaybackUpdatedEventArgs(serverName, playback, userData);
+ PlaybackUpdatedEventArgs eventArgs = new PlaybackUpdatedEventArgs(serverName, playback);
_playbackUpdated?.Invoke(this, eventArgs);
};
Interop.MediaControllerClient.SetPlaybackUpdatedCb(_handle, _playbackUpdatedCallback, IntPtr.Zero);
{
_metadataUpdatedCallback = (string serverName, IntPtr metadata, IntPtr userData) =>
{
- MetadataUpdatedEventArgs eventArgs = new MetadataUpdatedEventArgs(serverName, metadata, userData);
+ MetadataUpdatedEventArgs eventArgs = new MetadataUpdatedEventArgs(serverName, metadata);
_metadataUpdated?.Invoke(this, eventArgs);
};
Interop.MediaControllerClient.SetMetadataUpdatedCb(_handle, _metadataUpdatedCallback, IntPtr.Zero);
MediaControllerError res = MediaControllerError.None;
_shufflemodeUpdatedCallback = (string serverName, int shuffleMode, IntPtr userData) =>
{
- ShuffleModeUpdatedEventArgs eventArgs = new ShuffleModeUpdatedEventArgs(serverName, (ShuffleMode)shuffleMode, userData);
+ ShuffleModeUpdatedEventArgs eventArgs = new ShuffleModeUpdatedEventArgs(serverName, (MediaControllerShuffleMode)shuffleMode);
_shufflemodeUpdated?.Invoke(this, eventArgs);
};
res = (MediaControllerError)Interop.MediaControllerClient.SetShuffleModeUpdatedCb(_handle, _shufflemodeUpdatedCallback, IntPtr.Zero);
MediaControllerError res = MediaControllerError.None;
_repeatmodeUpdatedCallback = (string serverName, int repeatMode, IntPtr userData) =>
{
- RepeatModeUpdatedEventArgs eventArgs = new RepeatModeUpdatedEventArgs(serverName, (RepeatMode)repeatMode, userData);
+ RepeatModeUpdatedEventArgs eventArgs = new RepeatModeUpdatedEventArgs(serverName, (MediaControllerRepeatMode)repeatMode);
_repeatmodeUpdated?.Invoke(this, eventArgs);
};
res = (MediaControllerError)Interop.MediaControllerClient.SetRepeatModeUpdatedCb(_handle, _repeatmodeUpdatedCallback, IntPtr.Zero);
/// <summary>
/// Enumeration for server state
/// </summary>
- public enum ServerState
+ public enum MediaControllerServerState
{
/// <summary>
/// Server state is unknown
/// <summary>
/// Enumeration for playback state
/// </summary>
- public enum PlaybackState
+ public enum MediaControllerPlaybackState
{
/// <summary>
/// Playback state is unknown
/// <summary>
/// Enumeration for shuffle mode
/// </summary>
- public enum ShuffleMode
+ public enum MediaControllerShuffleMode
{
/// <summary>
/// Shuffle mode is On
/// <summary>
/// Enumeration for repeat mode
/// </summary>
- public enum RepeatMode
+ public enum MediaControllerRepeatMode
{
/// <summary>
/// Repeat mode is On
/// <summary>
/// Enumeration for repeat mode
/// </summary>
- public enum SubscriptionType
+ public enum MediaControllerSubscriptionType
{
/// <summary>
/// Repeat mode is Off
/// <summary>
/// Enumeration for metadata attributes
/// </summary>
- internal enum Attributes
+ internal enum MediaControllerAttributes
{
/// <summary>
/// Attribute is title
Author,
/// <summary>
+ /// Attribute is genre
+ /// </summary>
+ Genre,
+
+ /// <summary>
/// Attribute is duration
/// </summary>
Duration,
/// <summary>
/// Metadata represents a metadata of media for server application to play
/// </summary>
- public class Metadata
+ public class MediaControllerMetadata
{
/// <summary>
/// The title of media
public string Author;
/// <summary>
+ /// The genre of media
+ /// </summary>
+ public string Genre;
+
+ /// <summary>
/// The duration of media
/// </summary>
public string Duration;
/// </summary>
public string Picture;
- internal Metadata(IntPtr _metadataHandle) {
+ public MediaControllerMetadata()
+ {
+
+ }
+
+ internal MediaControllerMetadata(IntPtr _metadataHandle) {
MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.Title, out Title);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Title, out Title);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.Artist, out Artist);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Artist, out Artist);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.Album, out Album);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Album, out Album);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.Author, out Author);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Author, out Author);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.Duration, out Duration);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Genre, out Genre);
+ if (res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Duration, out Duration);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.Date, out Date);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Date, out Date);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.Copyright, out Copyright);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Copyright, out Copyright);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.Description, out Description);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Description, out Description);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.TrackNumber, out TrackNumber);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.TrackNumber, out TrackNumber);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)Attributes.Picture, out Picture);
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Picture, out Picture);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
}
-
- res = (MediaControllerError)Interop.MediaControllerClient.DestroyMetadata(_metadataHandle);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Destroy Metadata handle failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Destroy Metadata handle failed");
- }
}
}
}
/// <summary>
/// Playback represents a playback state and playback position.
/// </summary>
- public class Playback
+ public class MediaControllerPlayback
{
- public Playback(PlaybackState state, ulong position) {
+ public MediaControllerPlayback(MediaControllerPlaybackState state, ulong position) {
State = state;
Position = position;
}
- internal Playback(IntPtr _playbackHandle) {
+ internal MediaControllerPlayback(IntPtr _playbackHandle) {
MediaControllerError res = MediaControllerError.None;
int _state = 0;
ulong _position = 0L;
MediaControllerErrorFactory.ThrowException(res, "Get Playback position failed");
}
- res = (MediaControllerError)Interop.MediaControllerClient.DestroyPlayback(_playbackHandle);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Destroy Playback handle failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Destroy Playback handle failed");
- }
- State = (PlaybackState)_state;
+ State = (MediaControllerPlaybackState)_state;
Position = _position;
}
/// <summary>
/// The state of playback of media application
/// </summary>
- public PlaybackState State;
+ public MediaControllerPlaybackState State;
/// <summary>
/// The position of playback of media application
using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications;
namespace Tizen.Multimedia.MediaController
{
/// <summary>
/// Update playback state and playback position</summary>
/// <param name="playback"> playback state and playback position </param>
- public void UpdatePlayback(Playback playback)
+ public void UpdatePlayback(MediaControllerPlayback playback)
{
MediaControllerError res = MediaControllerError.None;
res = (MediaControllerError)Interop.MediaControllerServer.SetPlaybackState(_handle, (int)playback.State);
/// <summary>
/// Update metadata information </summary>
/// <param name="metadata"> metadata information </param>
- public void UpdateMetadata(Metadata metadata)
+ public void UpdateMetadata(MediaControllerMetadata metadata)
{
MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.Title, metadata.Title);
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Title, metadata.Title);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
}
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.Artist, metadata.Artist);
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Artist, metadata.Artist);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
}
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.Album, metadata.Album);
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Album, metadata.Album);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
}
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.Author, metadata.Author);
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Author, metadata.Author);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.Duration, metadata.Duration);
+ }\r
+\r
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Genre, metadata.Genre);\r
+ if (res != MediaControllerError.None)\r
+ {\r
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);\r
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");\r
+ }\r
+\r
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Duration, metadata.Duration);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
}
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.Date, metadata.Date);
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Date, metadata.Date);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
}
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.Copyright, metadata.Copyright);
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Copyright, metadata.Copyright);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
}
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.Description, metadata.Description);
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Description, metadata.Description);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
}
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.TrackNumber, metadata.TrackNumber);
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.TrackNumber, metadata.TrackNumber);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
}
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)Attributes.Picture, metadata.Picture);
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Picture, metadata.Picture);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
/// <summary>
/// Update shuffle mode </summary>
/// <param name="mode"> shuffle mode </param>
- public void UpdateShuffleMode(ShuffleMode mode)
+ public void UpdateShuffleMode(MediaControllerShuffleMode mode)
{
MediaControllerError res = MediaControllerError.None;
res = (MediaControllerError)Interop.MediaControllerServer.UpdateShuffleMode(_handle, (int)mode);
/// <summary>
/// Update repeat mode </summary>
/// <param name="mode"> repeat mode </param>
- public void UpdateRepeatMode(RepeatMode mode)
+ public void UpdateRepeatMode(MediaControllerRepeatMode mode)
{
MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerServer.UpdateShuffleMode(_handle, (int)mode);
+ res = (MediaControllerError)Interop.MediaControllerServer.UpdateRepeatMode(_handle, (int)mode);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Update Repeat Mode failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Repeat Shuffle Mode failed");
+ MediaControllerErrorFactory.ThrowException(res, "Update Repeat Mode failed");
}
}
/// <param name="clientName"> client name to recieve reply </param>
/// <param name="result"> result to run command </param>
/// <param name="bundleData"> Bundle data </param>
- public void SendCommandReply(string clientName, int result, IntPtr bundle)
+ public void SendCustomCommandReply(string clientName, int result, Bundle bundle)
{
MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerServer.SendCommandReply (_handle, clientName, result, (IntPtr)bundle);
+ res = (MediaControllerError)Interop.MediaControllerServer.SendCommandReply (_handle, clientName, result, bundle.SafeBundleHandle);
if(res != MediaControllerError.None)
{
Log.Error(MediaControllerLog.LogTag, "Send reply for command failed" + res);
{
_playbackCommandCallback = (string clientName, int state, IntPtr userData) =>
{
- PlaybackStateCommandEventArgs eventArgs = new PlaybackStateCommandEventArgs(clientName, (PlaybackState)state, userData);
+ PlaybackStateCommandEventArgs eventArgs = new PlaybackStateCommandEventArgs(clientName, (MediaControllerPlaybackState)state);
_playbackCommand?.Invoke(this, eventArgs);
};
Interop.MediaControllerServer.SetPlaybackStateCmdRecvCb(_handle, _playbackCommandCallback, IntPtr.Zero);
private void RegisterCustomCommandEvent()
{
- _customCommandCallback = (string clientName, string command, IntPtr bundleData, IntPtr userData) =>
+ _customCommandCallback = (string clientName, string command, IntPtr bundle, IntPtr userData) =>
{
- CustomCommandEventArgs eventArgs = new CustomCommandEventArgs(clientName, command, bundleData, userData);
+ SafeBundleHandle bundleHandle = new SafeBundleHandle(bundle, true);
+ Applications.Bundle _bundle = new Bundle(bundleHandle);
+ CustomCommandEventArgs eventArgs = new CustomCommandEventArgs(clientName, command, _bundle);
_customCommand?.Invoke(this, eventArgs);
};
Interop.MediaControllerServer.SetCustomCmdRecvCb(_handle, _customCommandCallback, IntPtr.Zero);
public class MetadataUpdatedEventArgs : EventArgs
{
internal string _serverName;
- internal Metadata _metadata;
- internal IntPtr _userData;
+ internal MediaControllerMetadata _metadata;
- public MetadataUpdatedEventArgs (string name, IntPtr handle, IntPtr userData)
+ public MetadataUpdatedEventArgs (string name, IntPtr handle)
{
_serverName = name;
- _metadata = new Metadata (handle);
- _userData = userData;
+ _metadata = new MediaControllerMetadata (handle);
}
/// <summary>
/// Get playback information.
/// </summary>
/// <value> 0 - 100 </value>
- public Metadata Metadata
+ public MediaControllerMetadata Metadata
{
get
{
return _metadata;
}
}
-
- /// <summary>
- /// Get user data.
- /// </summary>
- /// <value> 0 - 100 </value>
- public IntPtr UserData
- {
- get
- {
- return _userData;
- }
- }
}
}
public class PlaybackStateCommandEventArgs : EventArgs
{
internal string _clientName;
- internal PlaybackState _state;
- internal IntPtr _userData;
+ internal MediaControllerPlaybackState _state;
- public PlaybackStateCommandEventArgs (string name, PlaybackState state, IntPtr userData)
+ public PlaybackStateCommandEventArgs (string name, MediaControllerPlaybackState state)
{
_clientName = name;
_state = state;
- _userData = userData;
}
/// <summary>
/// Get playback state.
/// </summary>
/// <value> 0 - 100 </value>
- public PlaybackState State
+ public MediaControllerPlaybackState State
{
get
{
return _state;
}
}
-
- /// <summary>
- /// Get user data.
- /// </summary>
- /// <value> 0 - 100 </value>
- public IntPtr UserData
- {
- get
- {
- return _userData;
- }
- }
}
}
public class PlaybackUpdatedEventArgs : EventArgs
{
internal string _serverName;
- internal Playback _playback;
- internal IntPtr _userData;
+ internal MediaControllerPlayback _playback;
- public PlaybackUpdatedEventArgs (string name, IntPtr handle, IntPtr userData)
+ public PlaybackUpdatedEventArgs (string name, IntPtr handle)
{
_serverName = name;
- _playback = new Playback (handle);
- _userData = userData;
+ _playback = new MediaControllerPlayback (handle);
}
/// <summary>
/// Get playback information.
/// </summary>
/// <value> 0 - 100 </value>
- public Playback PlaybackInfo
+ public MediaControllerPlayback PlaybackInfo
{
get
{
return _playback;
}
}
-
- /// <summary>
- /// Get user data.
- /// </summary>
- /// <value> 0 - 100 </value>
- public IntPtr UserData
- {
- get
- {
- return _userData;
- }
- }
}
}
public class RepeatModeUpdatedEventArgs : EventArgs
{
internal string _serverName;
- internal RepeatMode _mode;
- internal IntPtr _userData;
+ internal MediaControllerRepeatMode _mode;
- public RepeatModeUpdatedEventArgs (string name, RepeatMode mode, IntPtr userData)
+ public RepeatModeUpdatedEventArgs (string name, MediaControllerRepeatMode mode)
{
_serverName = name;
_mode = mode;
- _userData = userData;
}
/// <summary>
/// Get repeat mode.
/// </summary>
/// <value> 0 - 100 </value>
- public RepeatMode RepeatMode
+ public MediaControllerRepeatMode RepeatMode
{
get
{
return _mode;
}
}
-
- /// <summary>
- /// Get user data.
- /// </summary>
- /// <value> 0 - 100 </value>
- public IntPtr UserData
- {
- get
- {
- return _userData;
- }
- }
}
}
/// </summary>
public class ServerInformation
{
- internal ServerInformation(string _name, ServerState _state)
+ internal ServerInformation(string _name, MediaControllerServerState _state)
{
Name = _name;
State = _state;
/// <summary>
/// The state of server
/// </summary>
- public readonly ServerState State;
+ public readonly MediaControllerServerState State;
}
}
public class ServerUpdatedEventArgs : EventArgs
{
internal ServerInformation _serverInfo;
- internal ServerState _serverState;
- internal IntPtr _userData;
/// <summary>
/// Constructor.
/// </summary>
- internal ServerUpdatedEventArgs(string name, ServerState state, IntPtr userData)
+ internal ServerUpdatedEventArgs(string name, MediaControllerServerState state)
{
_serverInfo = new ServerInformation (name, state);
- _userData = userData;
}
/// <summary>
return _serverInfo;
}
}
-
- /// <summary>
- /// Get userData.
- /// </summary>
- /// <value> 0 - 100 </value>
- public IntPtr userData
- {
- get
- {
- return _userData;
- }
- }
}
}
public class ShuffleModeUpdatedEventArgs : EventArgs
{
internal string _serverName;
- internal ShuffleMode _mode;
- internal IntPtr _userData;
+ internal MediaControllerShuffleMode _mode;
- public ShuffleModeUpdatedEventArgs (string name, ShuffleMode mode, IntPtr userData)
+ public ShuffleModeUpdatedEventArgs (string name, MediaControllerShuffleMode mode)
{
_serverName = name;
_mode = mode;
- _userData = userData;
}
/// <summary>
/// Get shuffle mode.
/// </summary>
/// <value> 0 - 100 </value>
- public ShuffleMode ShuffleMode
+ public MediaControllerShuffleMode ShuffleMode
{
get
{
return _mode;
}
}
-
- /// <summary>
- /// Get user data.
- /// </summary>
- /// <value> 0 - 100 </value>
- public IntPtr UserData
- {
- get
- {
- return _userData;
- }
- }
}
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
using System;
using System.Diagnostics;
using Tizen.Internals.Errors;
/// <param name="type">A type for the format.</param>
internal MediaFormat(MediaFormatType type)
{
- _type = type;
+ Type = type;
}
- private readonly MediaFormatType _type;
-
/// <summary>
/// Gets the type of the current format.
/// </summary>
public MediaFormatType Type
{
- get
- {
- return _type;
- }
+ get;
}
/// <summary>
if (ret != (int)ErrorCode.InvalidOperation)
{
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
switch ((MediaFormatType)type)
{
IntPtr handle;
int ret = Interop.MediaFormat.Create(out handle);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
AsNativeHandle(handle);
{
throw new ArgumentException($"Invalid mime type value : { (int)mimeType }");
}
- _mimeType = mimeType;
+ MimeType = mimeType;
}
/// <summary>
int ret = Interop.MediaFormat.GetContainerMimeType(handle, out mimeType);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
Debug.Assert(Enum.IsDefined(typeof(MediaFormatContainerMimeType), mimeType),
"Invalid container mime type!");
- _mimeType = (MediaFormatContainerMimeType)mimeType;
+ MimeType = (MediaFormatContainerMimeType)mimeType;
}
- private readonly MediaFormatContainerMimeType _mimeType;
-
/// <summary>
/// Gets the mime type of the current format.
/// </summary>
public MediaFormatContainerMimeType MimeType
{
- get
- {
- return _mimeType;
- }
+ get;
}
protected override void AsNativeHandle(IntPtr handle)
{
Debug.Assert(Type == MediaFormatType.Container);
- int ret = Interop.MediaFormat.SetContainerMimeType(handle, (int)_mimeType);
+ int ret = Interop.MediaFormat.SetContainerMimeType(handle, (int)MimeType);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
public override string ToString()
{
- return $"[{ nameof(ContainerMediaFormat) }] MimeType : { _mimeType }";
+ return $"[{ nameof(ContainerMediaFormat) }] MimeType : { MimeType }";
}
+ public override bool Equals(object obj)
+ {
+ var rhs = obj as ContainerMediaFormat;
+ if (rhs == null)
+ {
+ return false;
+ }
+
+ return MimeType == rhs.MimeType;
+ }
+
+ public override int GetHashCode()
+ {
+ return (int)MimeType;
+ }
}
/// <summary>
throw new ArgumentOutOfRangeException("Bit rate value can't be less than zero.");
}
- _mimeType = mimeType;
- _width = width;
- _height = height;
- _frameRate = frameRate;
- _bitRate = bitRate;
+ MimeType = mimeType;
+ Width = width;
+ Height = height;
+ FrameRate = frameRate;
+ BitRate = bitRate;
}
/// <summary>
{
Debug.Assert(handle != IntPtr.Zero, "The handle is invalid!");
- GetInfo(handle, out _width, out _height, out _bitRate, out _mimeType);
+ int width = 0;
+ int height = 0;
+ int bitRate = 0;
+ int frameRate = 0;
+ MediaFormatVideoMimeType mimeType;
+ GetInfo(handle, out width, out height, out bitRate, out mimeType);
- GetFrameRate(handle, out _frameRate);
+ GetFrameRate(handle, out frameRate);
+
+ MimeType = mimeType;
+ Width = width;
+ Height = height;
+ FrameRate = frameRate;
+ BitRate = bitRate;
}
/// <summary>
int ret = Interop.MediaFormat.GetVideoInfo(handle,
out mimeTypeValue, out width, out height, out bitRate, out maxBps);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
mimeType = (MediaFormatVideoMimeType)mimeTypeValue;
int ret = Interop.MediaFormat.GetVideoFrameRate(handle, out frameRate);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
protected override void AsNativeHandle(IntPtr handle)
{
Debug.Assert(Type == MediaFormatType.Video);
- int ret = Interop.MediaFormat.SetVideoMimeType(handle, (int)_mimeType);
- MediaToolDebug.AssertNoError(ret);
+ int ret = Interop.MediaFormat.SetVideoMimeType(handle, (int)MimeType);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetVideoWidth(handle, _width);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetVideoWidth(handle, Width);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetVideoHeight(handle, _height);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetVideoHeight(handle, Height);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetVideoAverageBps(handle, _bitRate);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetVideoAverageBps(handle, BitRate);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetVideoFrameRate(handle, _frameRate);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetVideoFrameRate(handle, FrameRate);
+ MultimediaDebug.AssertNoError(ret);
}
- private readonly MediaFormatVideoMimeType _mimeType;
-
/// <summary>
/// Gets the mime type of the current format.
/// </summary>
- public MediaFormatVideoMimeType MimeType
- {
- get
- {
- return _mimeType;
- }
- }
-
- private readonly int _width;
+ public MediaFormatVideoMimeType MimeType { get; }
/// <summary>
/// Gets the width value of the current format.
/// </summary>
- public int Width
- {
- get
- {
- return _width;
- }
- }
-
- private readonly int _height;
+ public int Width { get; }
/// <summary>
/// Gets the width value of the current format.
/// </summary>
- public int Height
- {
- get
- {
- return _height;
- }
- }
-
- private readonly int _frameRate;
+ public int Height { get; }
/// <summary>
/// Gets the frame rate value of the current format.
/// </summary>
- public int FrameRate
- {
- get
- {
- return _frameRate;
- }
- }
-
- private readonly int _bitRate;
+ public int FrameRate { get; }
/// <summary>
/// Gets the bit rate value of the current format.
/// </summary>
- public int BitRate
+ public int BitRate { get; }
+
+ public override string ToString()
{
- get
+ return $"MimeType : { MimeType }, Width : { Width }, "
+ + $"Height : { Height }, FrameRate : { FrameRate }, BitRate : { BitRate }";
+ }
+
+ public override bool Equals(object obj)
+ {
+ var rhs = obj as VideoMediaFormat;
+ if (rhs == null)
{
- return _bitRate;
+ return false;
}
+
+ return MimeType == rhs.MimeType && Width == rhs.Width && Height == rhs.Height &&
+ FrameRate == rhs.FrameRate && BitRate == rhs.BitRate;
}
- public override string ToString()
+ public override int GetHashCode()
{
- return $"[{ nameof(VideoMediaFormat) }] MimeType : { _mimeType }, Width : { _width }, "
- + $"Height : { _height }, FrameRate : { _frameRate }, BitRate : { _bitRate }";
+ return new { MimeType, Width, Height, FrameRate, BitRate }.GetHashCode();
}
}
throw new ArgumentException("Aac is supported only with aac mime types.");
}
- _mimeType = mimeType;
- _channel = channel;
- _sampleRate = sampleRate;
- _bit = bit;
- _bitRate = bitRate;
- _aacType = aacType;
+ MimeType = mimeType;
+ Channel = channel;
+ SampleRate = sampleRate;
+ Bit = bit;
+ BitRate = bitRate;
+ AacType = aacType;
}
/// <summary>
{
Debug.Assert(handle != IntPtr.Zero, "The handle is invalid!");
- GetInfo(handle, out _mimeType, out _channel, out _sampleRate, out _bit, out _bitRate);
+ MediaFormatAudioMimeType mimeType;
+ int channel = 0;
+ int sampleRate = 0;
+ int bit = 0;
+ int bitRate = 0;
+ MediaFormatAacType aacType;
+ GetInfo(handle, out mimeType, out channel, out sampleRate, out bit, out bitRate);
- if (IsAacSupportedMimeType(_mimeType))
+ if (IsAacSupportedMimeType(mimeType))
{
- GetAacType(handle, out _aacType);
+ GetAacType(handle, out aacType);
}
else
{
- _aacType = MediaFormatAacType.None;
+ aacType = MediaFormatAacType.None;
}
+ MimeType = mimeType;
+ Channel = channel;
+ SampleRate = sampleRate;
+ Bit = bit;
+ BitRate = bitRate;
+ AacType = aacType;
}
/// <summary>
mimeType = (MediaFormatAudioMimeType)mimeTypeValue;
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
Debug.Assert(Enum.IsDefined(typeof(MediaFormatAudioMimeType), mimeType),
"Invalid audio mime type!");
int ret = Interop.MediaFormat.GetAudioAacType(handle, out aacTypeValue);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
aacType = (MediaFormatAacType)aacTypeValue;
{
Debug.Assert(Type == MediaFormatType.Audio);
- int ret = Interop.MediaFormat.SetAudioMimeType(handle, (int)_mimeType);
- MediaToolDebug.AssertNoError(ret);
+ int ret = Interop.MediaFormat.SetAudioMimeType(handle, (int)MimeType);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetAudioChannel(handle, _channel);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetAudioChannel(handle, Channel);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetAudioSampleRate(handle, _sampleRate);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetAudioSampleRate(handle, SampleRate);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetAudioBit(handle, _bit);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetAudioBit(handle, Bit);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetAudioAverageBps(handle, _bitRate);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetAudioAverageBps(handle, BitRate);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetAudioAacType(handle, (int)_aacType);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetAudioAacType(handle, (int)AacType);
+ MultimediaDebug.AssertNoError(ret);
}
- private readonly MediaFormatAudioMimeType _mimeType;
-
/// <summary>
/// Gets the mime type of the current format.
/// </summary>
- public MediaFormatAudioMimeType MimeType
- {
- get
- {
- return _mimeType;
- }
- }
-
- private readonly int _channel;
+ public MediaFormatAudioMimeType MimeType { get; }
/// <summary>
/// Gets the channel value of the current format.
/// </summary>
- public int Channel
- {
- get
- {
- return _channel;
- }
- }
-
- private readonly int _sampleRate;
+ public int Channel { get; }
/// <summary>
/// Gets the sample rate value of the current format.
/// </summary>
- public int SampleRate
- {
- get
- {
- return _sampleRate;
- }
- }
-
- private readonly int _bit;
+ public int SampleRate { get; }
/// <summary>
/// Gets the bit value of the current format.
/// </summary>
- public int Bit
- {
- get
- {
- return _bit;
- }
- }
-
- private readonly int _bitRate;
+ public int Bit { get; }
/// <summary>
/// Gets the bit rate value of the current format.
/// </summary>
- public int BitRate
- {
- get
- {
- return _bitRate;
- }
- }
-
- private readonly MediaFormatAacType _aacType;
+ public int BitRate { get; }
/// <summary>
/// Gets the aac type of the current format.
/// </summary>
- public MediaFormatAacType AacType
+ public MediaFormatAacType AacType { get; }
+ public override string ToString()
+ {
+ return $"MimeType : {MimeType }, Channel : { Channel }, SampleRate : { SampleRate }, "
+ + $"Bit : { Bit }, BitRate : { BitRate }, AacType : { AacType }";
+ }
+
+ public override bool Equals(object obj)
{
- get
+ var rhs = obj as AudioMediaFormat;
+ if (rhs == null)
{
- return _aacType;
+ return false;
}
+
+ return MimeType == rhs.MimeType && Channel == rhs.Channel && SampleRate == rhs.SampleRate &&
+ Bit == rhs.Bit && BitRate == rhs.BitRate;
}
- public override string ToString()
+ public override int GetHashCode()
{
- return $"[{ nameof(AudioMediaFormat) }] MimeType : { _mimeType }, Channel : { _channel }, "
- + $"SampleRate : { _sampleRate }, Bit : { _bit }, BitRate : { _bitRate }, AacType : { _aacType }";
+ return new { MimeType, Channel, SampleRate, Bit, BitRate }.GetHashCode();
}
}
{
throw new ArgumentException($"Invalid text type value : { (int)textType }");
}
- _mimeType = mimeType;
- _textType = textType;
+ MimeType = mimeType;
+ TextType = textType;
}
/// <summary>
{
Debug.Assert(handle != IntPtr.Zero, "The handle is invalid!");
- GetInfo(handle, out _mimeType, out _textType);
+ MediaFormatTextMimeType mimeType;
+ MediaFormatTextType textType;
+
+ GetInfo(handle, out mimeType, out textType);
+
+ MimeType = mimeType;
+ TextType = textType;
}
/// <summary>
int ret = Interop.MediaFormat.GetTextInfo(handle, out mimeTypeValue, out textTypeValue);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
mimeType = (MediaFormatTextMimeType)mimeTypeValue;
textType = (MediaFormatTextType)textTypeValue;
{
Debug.Assert(Type == MediaFormatType.Text);
- int ret = Interop.MediaFormat.SetTextMimeType(handle, (int)_mimeType);
- MediaToolDebug.AssertNoError(ret);
+ int ret = Interop.MediaFormat.SetTextMimeType(handle, (int)MimeType);
+ MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetTextType(handle, (int)_textType);
- MediaToolDebug.AssertNoError(ret);
+ ret = Interop.MediaFormat.SetTextType(handle, (int)TextType);
+ MultimediaDebug.AssertNoError(ret);
}
- private readonly MediaFormatTextMimeType _mimeType;
-
/// <summary>
/// Gets the mime type of the current format.
/// </summary>
- public MediaFormatTextMimeType MimeType
- {
- get
- {
- return _mimeType;
- }
- }
-
- private readonly MediaFormatTextType _textType;
+ public MediaFormatTextMimeType MimeType { get; }
/// <summary>
/// Gets the text type of the current format.
/// </summary>
- public MediaFormatTextType TextType
+ public MediaFormatTextType TextType { get; }
+
+ public override string ToString()
{
- get
+ return $"[{ nameof(TextMediaFormat) }] MimeType : { MimeType }, TextType : { TextType }";
+ }
+
+ public override bool Equals(object obj)
+ {
+ var rhs = obj as TextMediaFormat;
+ if (rhs == null)
{
- return _textType;
+ return false;
}
+
+ return MimeType == rhs.MimeType && TextType == rhs.TextType;
}
- public override string ToString()
+ public override int GetHashCode()
{
- return $"[{ nameof(TextMediaFormat) }] MimeType : { _mimeType }, TextType : { _textType }";
+ return new { MimeType, TextType }.GetHashCode();
}
}
}
namespace Tizen.Multimedia
{
+ /// <summary>
+ /// Specifies aac types for <see cref="AudioMediaFormat"/>.
+ /// </summary>
public enum MediaFormatAacType
{
None,
/// <summary>
/// The mp4 type.
/// </summary>
- Mp4,
+ MP4,
/// <summary>
/// The 3gp type.
/// <exception cref="System.ArgumentNullException">format is null.</exception>
/// <exception cref="System.ArgumentException">
/// <see cref="MediaFormatType"/> of the specified format is <see cref="MediaFormatType.Container"/>.</exception>
- /// <exception cref="NotEnoughMemoryException">Out of memory.</exception>
/// <exception cref="System.InvalidOperationException">Operation failed.</exception>
internal MediaPacket(MediaFormat format)
{
{
_handle = handle;
- IntPtr formatHandle = IntPtr.Zero;
+ IntPtr formatHandle;
int ret = Interop.MediaPacket.GetFormat(handle, out formatHandle);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
try
{
/// Creates and initializes a native handle for the current object.
/// </summary>
/// <param name="format">The format to be set to the media format.</param>
- /// <exception cref="NotEnoughMemoryException">Out of memory.</exception>
/// <exception cref="System.InvalidOperationException">Operation failed.</exception>
private void Initialize(MediaFormat format)
{
- IntPtr formatHandle = IntPtr.Zero;
-
if (format.Type == MediaFormatType.Container)
{
throw new ArgumentException("Creating a packet for container is not supported.");
}
+ IntPtr formatHandle = IntPtr.Zero;
+
try
{
formatHandle = format.AsNativeHandle();
int ret = Interop.MediaPacket.Create(formatHandle, IntPtr.Zero, IntPtr.Zero, out _handle);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
Debug.Assert(_handle != IntPtr.Zero, "Created handle must not be null");
/// <summary>
/// Allocates internal buffer.
/// </summary>
- /// <exception cref="NotEnoughMemoryException">Out of memory.</exception>
/// <exception cref="System.InvalidOperationException">Operation failed.</exception>
private void Alloc()
{
switch (ret)
{
case ErrorCode.OutOfMemory:
- throw new NotEnoughMemoryException("Failed to allocate buffer for the packet.");
+ throw new OutOfMemoryException("Failed to allocate buffer for the packet.");
default:
throw new InvalidOperationException("Failed to create a packet.");
ulong value = 0;
int ret = Interop.MediaPacket.GetPts(_handle, out value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
return value;
}
int ret = Interop.MediaPacket.SetPts(_handle, value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
}
ulong value = 0;
int ret = Interop.MediaPacket.GetDts(_handle, out value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
return value;
}
int ret = Interop.MediaPacket.SetDts(_handle, value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
}
bool value = false;
int ret = Interop.MediaPacket.IsEncoded(_handle, out value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
return value;
}
ulong value = 0;
int ret = Interop.MediaPacket.GetBufferSize(_handle, out value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
Debug.Assert(value < int.MaxValue);
}
int ret = Interop.MediaPacket.SetBufferSize(_handle, (ulong)value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
}
int ret = Interop.MediaPacket.GetBufferFlags(_handle, out value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
return (MediaPacketBufferFlags)value;
}
int ret = Interop.MediaPacket.ResetBufferFlags(_handle);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
ret = Interop.MediaPacket.SetBufferFlags(_handle, (int)value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
}
uint numberOfPlanes = 0;
int ret = Interop.MediaPacket.GetNumberOfVideoPlanes(_handle, out numberOfPlanes);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
MediaPacketVideoPlane[] planes = new MediaPacketVideoPlane[numberOfPlanes];
{
Debug.Assert(_handle != IntPtr.Zero, "The handle is invalid!");
- IntPtr dataHandle = IntPtr.Zero;
+ IntPtr dataHandle;
int ret = Interop.MediaPacket.GetBufferData(_handle, out dataHandle);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
Debug.Assert(dataHandle != IntPtr.Zero, "Data handle is invalid!");
int size = 0;
ret = Interop.MediaPacket.GetAllocatedBufferSize(_handle, out size);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
return new MediaPacketBuffer(this, dataHandle, size);
}
{
int ret = Interop.MediaPacket.SetExtra(_packet._handle, ptr);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
}
private static IntPtr GetExtra(IntPtr handle)
{
- IntPtr value = IntPtr.Zero;
+ IntPtr value;
int ret = Interop.MediaPacket.GetExtra(handle, out value);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
return value;
}
_packet = packet;
int ret = Interop.MediaPacket.GetVideoStrideWidth(packet.GetHandle(), index, out _strideWidth);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
ret = Interop.MediaPacket.GetVideoStrideWidth(packet.GetHandle(), index, out _strideHeight);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
- IntPtr dataHandle = IntPtr.Zero;
+ IntPtr dataHandle;
ret = Interop.MediaPacket.GetVideoPlaneData(packet.GetHandle(), index, out dataHandle);
- MediaToolDebug.AssertNoError(ret);
+ MultimediaDebug.AssertNoError(ret);
_buffer = new MediaPacketBuffer(packet, dataHandle, _strideWidth * _strideHeight);
}
public BarcodeDetectorEngineConfiguration()
: base()
{
+ TargetAttribute = _targetAttr;
}
/// <summary>
public BarcodeGeneratorEngineConfiguration()
: base()
{
+ TextAttribute = _textAttr;
+ FrontColor = _frontColor;
+ BackColor = _backColor;
}
/// <summary>
internal void Add<T>(string key, T value)
{
- int ret = 0;
object val = (object)value;
- if (typeof(T) == typeof(double))
- {
- ret = Interop.MediaVision.EngineConfig.SetDouble(_engineHandle, key, (double)val);
- }
- else if (typeof(T) == typeof(int))
- {
- ret = Interop.MediaVision.EngineConfig.SetInt(_engineHandle, key, (int)val);
- }
- else if (typeof(T) == typeof(bool))
+
+ if (!_config.ContainsKey(key))
{
- ret = Interop.MediaVision.EngineConfig.SetBool(_engineHandle, key, (bool)val);
+ _config.Add(key, val);
}
- else if (typeof(T) == typeof(string))
+ else
{
- ret = Interop.MediaVision.EngineConfig.SetString(_engineHandle, key, (string)val);
- }
+ int ret = 0;
+ if (typeof(T) == typeof(double))
+ {
+ ret = Interop.MediaVision.EngineConfig.SetDouble(_engineHandle, key, (double)val);
+ }
+ else if (typeof(T) == typeof(int))
+ {
+ ret = Interop.MediaVision.EngineConfig.SetInt(_engineHandle, key, (int)val);
+ }
+ else if (typeof(T) == typeof(bool))
+ {
+ ret = Interop.MediaVision.EngineConfig.SetBool(_engineHandle, key, (bool)val);
+ }
+ else if (typeof(T) == typeof(string))
+ {
+ ret = Interop.MediaVision.EngineConfig.SetString(_engineHandle, key, (string)val);
+ }
- MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to add attribute");
- _config.Add(key, val);
+ MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to add attribute");
+ _config[key] = val;
+ }
}
internal object Get(string key)
}
}
- /// <summary>
- /// Releases any unmanaged resources used by this object.
- /// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
- /// <summary>
- /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
- /// </summary>
- /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposed)
public FaceEngineConfiguration()
: base()
{
+ ModelFilePath = _faceDetectionModelFilePathValue;
+ ModelType = _faceRecognitionModelTypeValue; ;
+ MinimumHeight = _faceDetectionMinHeightValue;
+ MinimumWidth = _faceDetectionMinWidthValue;
+ RoiHeight = _faceDetectionRoiHeightValue;
+ RoiWidth = _faceDetectionRoiWidthValue;
+ RoiX = _faceDetectionRoiXValue;
+ RoiY = _faceDetectionRoiYValue;
}
/// <summary>
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to learn");
}
- /// <summary>
- /// Releases any unmanaged resources used by this object.
- /// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
- /// <summary>
- /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
- /// </summary>
- /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposed)
{
try
{
+ int faceLabel = 0;
+ if (faceLabelPtr != IntPtr.Zero)
+ {
+ faceLabel = Marshal.ReadInt32(faceLabelPtr);
+ }
+
Rectangle faceLocation = null;
if (faceLocationPtr != IntPtr.Zero)
{
Height = loc.height,
Point = new Point(loc.x, loc.y)
};
+ Log.Info(MediaVisionLog.Tag, String.Format("Face label {0} recognized at : ({1}, {2}), Width : {3}, Height : {4}, confidence : {5}", faceLabel, faceLocation.Point.X, faceLocation.Point.Y, faceLocation.Width, faceLocation.Height, confidence));
}
- int faceLabel = 0;
- if (faceLabelPtr != IntPtr.Zero)
- {
- faceLabel = Marshal.ReadInt32(faceLabelPtr);
- }
-
- Log.Info(MediaVisionLog.Tag, String.Format("Face label {0} recognized at : ({1}, {2}), Width : {3}, Height : {4}, confidence : {5}", faceLabel, faceLocation.Point.X, faceLocation.Point.Y, faceLocation.Width, faceLocation.Height, confidence));
FaceRecognitionResult result = new FaceRecognitionResult()
{
Location = faceLocation,
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to save tracking model to file");
}
- /// <summary>
- /// Releases any unmanaged resources used by this object.
- /// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
- /// <summary>
- /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
- /// </summary>
- /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposed)
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to save the image object");
}
- /// <summary>
- /// Releases any unmanaged resources used by this object.
- /// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
- /// <summary>
- /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
- /// </summary>
- /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposed)
private int _imageTrackingHistoryAmountValue = 3;
private double _imageTrackingExpectedOffsetValue = 0;
private bool _imageTrackingUseStabilizationValue = true;
- private double _imageTrackingStabilizationTolerantShiftValue;
+ private double _imageTrackingStabilizationTolerantShiftValue = 0.00006;
private double _imageTrackingStabilizationSpeedValue = 0.3;
private double _imageTrackingStabilizationAccelarationValue = 0.1;
public ImageEngineConfiguration()
: base()
{
+ ObjectScaleFactor = _imageRecognitionObjectScaleFactorValue;
+ ObjectMaxKeyPoints = _imageRecognitionObjectMaxKeypointsValue;
+ SceneScaleFactor = _imageRecognitionSceneScaleFactorValue;
+ SceneMaxKeyPoints = _imageRecognitionSceneMaxKeypointsValue;
+ MinKeyPointsMatches = _imageRecognitionMinKeypointsMatchValue;
+ RequiredMatchingPart = _imageRecognitionReqMatchPartValue;
+ TolerantPartMatchingError = _imageRecognitionTolerantPartMatchingErrorValue;
+ TrackingHistoryAmount = _imageTrackingHistoryAmountValue;
+ ExpectedTrackingOffset = _imageTrackingExpectedOffsetValue;
+ UseTrackingStabilization = _imageTrackingUseStabilizationValue;
+ TrackingStabilizationTolerantShift = _imageTrackingStabilizationTolerantShiftValue;
+ TrackingStabilizationSpeed = _imageTrackingStabilizationSpeedValue;
+ TrackingStabilizationAccelaration = _imageTrackingStabilizationAccelarationValue;
}
/// <summary>
* limitations under the License.
*/
+using System;
using System.Collections.Generic;
namespace Tizen.Multimedia
{
+ /// <summary>
+ /// This class represents result of image recognition.
+ /// </summary>
public class ImageRecognitionResult
{
- /// <summary>
- /// This class represents result of image recognition operation.
- /// </summary>
internal ImageRecognitionResult()
{
}
/// <summary>
- /// The locations of image objects on the source image.
+ /// The indexes of recognized image objects and their locations on the source image.
/// </summary>
- public List<Quadrangle> Locations { get; internal set; }
+ public List<Tuple<int, Quadrangle>> Results { get; internal set; }
}
}
{
try
{
- List<Quadrangle> locations = new List<Quadrangle>();
+ List<Tuple<int, Quadrangle>> recognitionResults = new List<Tuple<int, Quadrangle>>();
if (numberOfObjects > 0)
{
IntPtr[] imageLocationsPtr = new IntPtr[numberOfObjects];
Marshal.Copy(locationsPtr, imageLocationsPtr, 0, (int)numberOfObjects);
- // Prepare list of locations
+ // Prepare list of locations and its indexes
for (int i = 0; i < numberOfObjects; i++)
{
+ if (imageLocationsPtr[i] == null)
+ {
+ continue;
+ }
+
Interop.MediaVision.Quadrangle location = (Interop.MediaVision.Quadrangle)Marshal.PtrToStructure(imageLocationsPtr[i], typeof(Interop.MediaVision.Quadrangle));
Quadrangle quadrangle = new Quadrangle()
{
}
};
Log.Info(MediaVisionLog.Tag, String.Format("Image recognized, Location : {0}", quadrangle.ToString()));
- locations.Add(quadrangle);
+ recognitionResults.Add(Tuple.Create(i, quadrangle));
}
}
ImageRecognitionResult result = new ImageRecognitionResult()
{
- Locations = locations
+ Results = recognitionResults
};
if (!tcsResult.TrySetResult(result))
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to save tracking model to file");
}
- /// <summary>
- /// Releases any unmanaged resources used by this object.
- /// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
- /// <summary>
- /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
- /// </summary>
- /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposed)
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to clear media source buffer");
}
- /// <summary>
- /// Releases any unmanaged resources used by this object.
- /// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
- /// <summary>
- /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
- /// </summary>
- /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposed)
public SurveillanceEngineConfiguration()
: base()
{
+ FaceRecognitionModelFilePath = _faceRecognitionModelFilePathValue;
+ MovementDetectionThreshold = _movementDetectionThresholdValue;
+ SkipFramesCount = _skipFramesCountValue;
}
/// <summary>
internal event EventHandler<PersonAppearanceChangedEventArgs> PersonAppearanceChangedEvent;
internal event EventHandler<MovementDetectedEventArgs> MovementDetectedEvent;
+ private Interop.MediaVision.Surveillance.MvSurveillanceEventOccurredCallback eventOccurredCb;
+
/// <summary>
/// Constructor of the SurveillanceEventTrigger class.
/// </summary>
/// </code>
public void Subscribe(int videoStreamId, SurveillanceEngineConfiguration config = null)
{
- Interop.MediaVision.Surveillance.MvSurveillanceEventOccurredCallback eventOccurredCb = (IntPtr trigger, IntPtr source, int streamId, IntPtr eventResult, IntPtr userData) =>
+ eventOccurredCb = (IntPtr trigger, IntPtr source, int streamId, IntPtr eventResult, IntPtr userData) =>
{
Tizen.Log.Info(MediaVisionLog.Tag, string.Format("Surveillance event occurred, video stream id : {0}", streamId));
if (eventResult != null)
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to push source");
}
- /// <summary>
- /// Releases any unmanaged resources used by this object.
- /// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
- /// <summary>
- /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
- /// </summary>
- /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposed)
int ret = Interop.MediaVision.Surveillance.GetResultCount(handle, _movementNumberOfRegionsKey, out count);
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result count");
- resultPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * count);
- ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _movementRegionsKey, resultPtr);
- MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
-
- for (int i = 0; i < count; i++)
+ if (count > 0)
{
- Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(resultPtr, typeof(Interop.MediaVision.Rectangle));
- regions.Add(new Rectangle()
+ resultPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * count);
+ ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _movementRegionsKey, resultPtr);
+ MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
+
+ for (int i = 0; i < count; i++)
{
- Point = new Point()
+ Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(resultPtr, typeof(Interop.MediaVision.Rectangle));
+ regions.Add(new Rectangle()
{
- X = rect.x,
- Y = rect.y
- },
- Width = rect.width,
- Height = rect.height
- });
- resultPtr = IntPtr.Add(resultPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ Point = new Point()
+ {
+ X = rect.x,
+ Y = rect.y
+ },
+ Width = rect.width,
+ Height = rect.height
+ });
+ resultPtr = IntPtr.Add(resultPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ }
}
MovementDetectedEventArgs e = new MovementDetectedEventArgs()
int ret = Interop.MediaVision.Surveillance.GetResultCount(handle, _personsRecognizedNumberKey, out count);
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result count");
- IntPtr locationPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * count);
- ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsRecognizedLocationsKey, locationPtr);
- MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get location");
-
- IntPtr labelPtr = Marshal.AllocHGlobal(sizeof(int) * count);
- ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsRecognizedLabelsKey, labelPtr);
- MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get label");
- int[] labelsArray = new int[count];
- Marshal.Copy(labelPtr, labelsArray, 0, count);
-
- IntPtr confidencePtr = Marshal.AllocHGlobal(sizeof(double) * count);
- ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsRecognizedConfidencesKey, confidencePtr);
- MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get confidence");
- double[] confidencesArray = new double[count];
- Marshal.Copy(confidencePtr, confidencesArray, 0, count);
-
- for (int i = 0; i < count; i++)
+ if (count > 0)
{
- Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(locationPtr, typeof(Interop.MediaVision.Rectangle));
- Rectangle location = new Rectangle()
+ IntPtr locationPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * count);
+ ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsRecognizedLocationsKey, locationPtr);
+ MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get location");
+
+ IntPtr labelPtr = Marshal.AllocHGlobal(sizeof(int) * count);
+ ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsRecognizedLabelsKey, labelPtr);
+ MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get label");
+ int[] labelsArray = new int[count];
+ Marshal.Copy(labelPtr, labelsArray, 0, count);
+
+ IntPtr confidencePtr = Marshal.AllocHGlobal(sizeof(double) * count);
+ ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsRecognizedConfidencesKey, confidencePtr);
+ MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get confidence");
+ double[] confidencesArray = new double[count];
+ Marshal.Copy(confidencePtr, confidencesArray, 0, count);
+
+ for (int i = 0; i < count; i++)
{
- Point = new Point()
+ Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(locationPtr, typeof(Interop.MediaVision.Rectangle));
+ Rectangle location = new Rectangle()
{
- X = rect.x,
- Y = rect.y
- },
- Width = rect.width,
- Height = rect.height
- };
-
- result.Add(new PersonRecognitionResult()
- {
- Location = location,
- Label = labelsArray[i],
- Confidence = confidencesArray[i]
- });
+ Point = new Point()
+ {
+ X = rect.x,
+ Y = rect.y
+ },
+ Width = rect.width,
+ Height = rect.height
+ };
+
+ result.Add(new PersonRecognitionResult()
+ {
+ Location = location,
+ Label = labelsArray[i],
+ Confidence = confidencesArray[i]
+ });
- locationPtr = IntPtr.Add(locationPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ locationPtr = IntPtr.Add(locationPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ }
}
PersonRecognizedEventArgs e = new PersonRecognizedEventArgs()
int ret = Interop.MediaVision.Surveillance.GetResultCount(handle, _personsAppearedNumber, out numOfAppearedPersons);
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
- IntPtr appearedLocationPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * numOfAppearedPersons);
- ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsAppearedLocations, appearedLocationPtr);
- MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
-
- for (int i = 0; i < numOfAppearedPersons; i++)
+ if (numOfAppearedPersons > 0)
{
- Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(appearedLocationPtr, typeof(Interop.MediaVision.Rectangle));
- appearedLocations.Add(new Rectangle()
+ IntPtr appearedLocationPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * numOfAppearedPersons);
+ ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsAppearedLocations, appearedLocationPtr);
+ MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
+
+ for (int i = 0; i < numOfAppearedPersons; i++)
{
- Point = new Point()
+ Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(appearedLocationPtr, typeof(Interop.MediaVision.Rectangle));
+ appearedLocations.Add(new Rectangle()
{
- X = rect.x,
- Y = rect.y
- },
- Width = rect.width,
- Height = rect.height
- });
-
- appearedLocationPtr = IntPtr.Add(appearedLocationPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ Point = new Point()
+ {
+ X = rect.x,
+ Y = rect.y
+ },
+ Width = rect.width,
+ Height = rect.height
+ });
+
+ appearedLocationPtr = IntPtr.Add(appearedLocationPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ }
}
ret = Interop.MediaVision.Surveillance.GetResultCount(handle, _personsDisappearedNumber, out numOfDisappearedPersons);
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
- IntPtr disAppearedLocationPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * numOfDisappearedPersons);
- ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsDisappearedLocations, disAppearedLocationPtr);
- MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
-
- for (int i = 0; i < numOfDisappearedPersons; i++)
+ if (numOfDisappearedPersons > 0)
{
- Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(disAppearedLocationPtr, typeof(Interop.MediaVision.Rectangle));
- disappearedLocations.Add(new Rectangle()
+ IntPtr disAppearedLocationPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * numOfDisappearedPersons);
+ ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsDisappearedLocations, disAppearedLocationPtr);
+ MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
+
+ for (int i = 0; i < numOfDisappearedPersons; i++)
{
- Point = new Point()
+ Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(disAppearedLocationPtr, typeof(Interop.MediaVision.Rectangle));
+ disappearedLocations.Add(new Rectangle()
{
- X = rect.x,
- Y = rect.y
- },
- Width = rect.width,
- Height = rect.height
- });
-
- disAppearedLocationPtr = IntPtr.Add(disAppearedLocationPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ Point = new Point()
+ {
+ X = rect.x,
+ Y = rect.y
+ },
+ Width = rect.width,
+ Height = rect.height
+ });
+
+ disAppearedLocationPtr = IntPtr.Add(disAppearedLocationPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ }
}
ret = Interop.MediaVision.Surveillance.GetResultCount(handle, _personsTrackedNumber, out numOfTrackedPersons);
MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
- IntPtr trackedLocationPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * numOfTrackedPersons);
- ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsTrackedLocations, trackedLocationPtr);
- MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
-
- for (int i = 0; i < numOfTrackedPersons; i++)
+ if (numOfTrackedPersons > 0)
{
- Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(trackedLocationPtr, typeof(Interop.MediaVision.Rectangle));
- trackedLocations.Add(new Rectangle()
+ IntPtr trackedLocationPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)) * numOfTrackedPersons);
+ ret = Interop.MediaVision.Surveillance.GetResultValue(handle, _personsTrackedLocations, trackedLocationPtr);
+ MediaVisionErrorFactory.CheckAndThrowException(ret, "Failed to get result");
+
+ for (int i = 0; i < numOfTrackedPersons; i++)
{
- Point = new Point()
+ Interop.MediaVision.Rectangle rect = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(trackedLocationPtr, typeof(Interop.MediaVision.Rectangle));
+ trackedLocations.Add(new Rectangle()
{
- X = rect.x,
- Y = rect.y
- },
- Width = rect.width,
- Height = rect.height
- });
-
- trackedLocationPtr = IntPtr.Add(trackedLocationPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ Point = new Point()
+ {
+ X = rect.x,
+ Y = rect.y
+ },
+ Width = rect.width,
+ Height = rect.height
+ });
+
+ trackedLocationPtr = IntPtr.Add(trackedLocationPtr, Marshal.SizeOf(typeof(Interop.MediaVision.Rectangle)));
+ }
}
PersonAppearanceChangedEventArgs e = new PersonAppearanceChangedEventArgs()
-/// Audio effect
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
+/*
+ * 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 System;
-using System.Collections.Generic;
-using System.Linq;
-
namespace Tizen.Multimedia
{
/// <summary>
- /// Audio effect
+ /// Provides the ability to control the audio effects for <see cref="Multimedia.Player"/>.
/// </summary>
- /// <remarks>
- /// This class provides properties and API that are required for setting/getting
- /// audio effects of a player.
- /// </remarks>
public class AudioEffect
{
- internal IntPtr _playerHandle;
- private List<EqualizerBand> _bands;
+ private readonly EqualizerBand[] _bands;
- internal AudioEffect()
+ internal AudioEffect(Player owner)
{
+ Player = owner;
+
+ bool available = false;
+ int ret = Interop.Player.AudioEffectEqualizerIsAvailable(Player.GetHandle(), out available);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the AudioEffect");
+
+ int count = 0;
+ ret = Interop.Player.AudioEffectGetEqualizerBandsCount(Player.GetHandle(), out count);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the AudioEffect");
+
+ int min = 0;
+ int max = 0;
+ ret = Interop.Player.AudioEffectGetEqualizerLevelRange(Player.GetHandle(), out min, out max);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the AudioEffect");
+
+ IsAvailable = available;
+ Count = count;
+ MinBandLevel = min;
+ MaxBandLevel = max;
+
+ _bands = new EqualizerBand[count];
}
/// <summary>
- /// Set/Get Equalizer band level.
- /// Get frequency and range.
+ /// Gets a <see cref="EqualizerBand"/> at the specified index.
/// </summary>
- /// <value> EqualizerBand </value>
- public IEnumerable<EqualizerBand> EqualizerBands
+ /// <param name="index">The index of the band to get</param>
+ /// <exception cref="ObjectDisposedException">The <see cref="Player"/> has already been disposed of.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// index is less than zero.
+ /// <para>-or-</para>
+ /// index is equal to or greater than <see cref="Count"/>.
+ /// </exception>
+ public EqualizerBand this[int index]
{
- set
- {
- int ret;
- _bands = value.ToList();
- foreach(EqualizerBand band in _bands)
- {
- ret = Interop.Player.AudioEffectSetEqualizerBandLevel(_playerHandle, _bands.IndexOf(band), band.Level);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to set equalizer band" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to set equalizer band");
- }
- }
- }
get
{
- int ret;
- int count = 0, level = 0, frequency = 0, range = 0;
+ Player.ValidateNotDisposed();
- if(_bands == null)
- {
- _bands = new List<EqualizerBand>();
- } else
+ if (index < 0 || Count <= index)
{
- _bands.Clear();
+ throw new ArgumentOutOfRangeException(nameof(index), index,
+ $"Valid index is 0 <= x < { nameof(Count) } ");
}
- ret = Interop.Player.AudioEffectGetEqualizerBandsCount(_playerHandle, out count);
- if(ret == (int)PlayerError.None)
- {
- for(int idx = 0; idx < count; idx++)
- {
- ret = Interop.Player.AudioEffectGetEqualizerBandLevel(_playerHandle, idx, out level);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get equalizer band level");
- }
-
- ret = Interop.Player.AudioEffectGetEqualizerBandFrequency(_playerHandle, idx, out frequency);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get equalizer band frequency");
- }
-
- ret = Interop.Player.AudioEffectGetEqualizerBandFrequencyRange(_playerHandle, idx, out range);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get equalizer band frequency range");
- }
-
- EqualizerBand band = new EqualizerBand(level, frequency, range);
- _bands.Add(band);
- }
- } else
+ if (_bands[index] == null)
{
- Log.Error(PlayerLog.LogTag, "Failed to get equalizer band count");
+ _bands[index] = new EqualizerBand(this, index);
}
-
- return _bands;
+ return _bands[index];
}
}
/// <summary>
- /// Get Minimum Level of the bands in dB.
+ /// Clears the equalizer effect.
/// </summary>
- /// <value> Minimum level </value>
- public int MinLevel
+ /// <exception cref="ObjectDisposedException">The <see cref="Player"/> has already been disposed of.</exception>
+ public void Clear()
{
- get
- {
- int min, max, ret;
- ret = Interop.Player.AudioEffectGetEqualizerLevelRange(_playerHandle, out min, out max);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get min level" + (PlayerError)ret);
- }
- return min;
- }
+ Player.ValidateNotDisposed();
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.AudioEffectEqualizerClear(Player.GetHandle()),
+ "Failed to clear equalizer effect");
}
+ public int Count{ get; }
+
+ // TODO replace with range struct
/// <summary>
- /// Get Maximum Level of the bands in dB.
+ /// Get the minimum band level of the bands in dB.
/// </summary>
- /// <value> Maximum level </value>
- public int MaxLevel
- {
- get
- {
- int min, max, ret;
- ret = Interop.Player.AudioEffectGetEqualizerLevelRange(_playerHandle, out min, out max);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get max level" + (PlayerError)ret);
- }
- return max;
- }
- }
+ public int MinBandLevel { get; }
/// <summary>
- /// Get Equalizer Avaialbility.
+ /// Gets the maximum band level of the bands in dB.
/// </summary>
- /// <value> true, false </value>
- public bool Available
- {
- get
- {
- bool available = false;
- int ret = Interop.Player.AudioEffectEqualizerIsAvailable(_playerHandle, out available);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get equalizer availability" + (PlayerError)ret);
- }
- return available;
- }
- }
+ public int MaxBandLevel { get; }
+
+ /// <summary>
+ /// Gets the value whether the AudioEffect is available or not.
+ /// </summary>
+ public bool IsAvailable { get; }
+
+ /// <summary>
+ /// Gets the player that this AudioEffect belongs to.
+ /// </summary>
+ public Player Player { get; }
}
-}
\ No newline at end of file
+}
+++ /dev/null
-/// This File contains BufferStatusEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-namespace Tizen.Multimedia
-{
-
- /// <summary>
- /// BufferStatus event arguments
- /// </summary>
- /// <remarks>
- /// BufferStatus event arguments
- /// </remarks>
- public class BufferStatusEventArgs : EventArgs
- {
- internal StreamingBufferStatus _status;
- internal StreamType _streamType;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- internal BufferStatusEventArgs(StreamingBufferStatus status, StreamType type)
- {
- _status = status;
- _streamType = type;
- }
-
- /// <summary>
- /// Get stream type.
- /// </summary>
- /// <value> Audio, Video, Text </value>
- public StreamType StreamType
- {
- get
- {
- return _streamType;
- }
- }
-
- /// <summary>
- /// Get buffering status.
- /// </summary>
- /// <value> Underrun, Overflow </value>
- public StreamingBufferStatus Status
- {
- get
- {
- return _status;
- }
- }
- }
-}
\ No newline at end of file
-/// This File contains BufferingProgressChangedEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
+/*
+ * 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 System;
namespace Tizen.Multimedia
{
-
/// <summary>
- /// BufferingProgress event arguments
+ /// Provides data for the <see cref="Player.BufferingProgressChanged"/> event.
/// </summary>
- /// <remarks>
- /// BufferingProgress event arguments
- /// </remarks>
- public class BufferingProgressEventArgs : EventArgs
+ public class BufferingProgressChangedEventArgs : EventArgs
{
- internal int _percent;
-
- /// <summary>
- /// constructor </summary>
- internal BufferingProgressEventArgs(int percent)
- {
- _percent = percent;
- }
+ public BufferingProgressChangedEventArgs(int percent)
+ {
+ Percent = percent;
+ }
- /// <summary>
- /// Get buffering percentage.
+ /// <summary>
+ /// Gets the value indicating the buffering percentage.
/// </summary>
- /// <value> 0 - 100 </value>
- public int Percent
+ /// <value>The percentage of the buffering.</value>
+ public int Percent { get; }
+
+ public override string ToString()
{
- get
- {
- return _percent;
- }
+ return $"Percent : { Percent }";
}
}
-}
\ No newline at end of file
+}
--- /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 System.Diagnostics;
+
+namespace Tizen.Multimedia
+{
+ //TODO we need a better name.
+ /// <summary>
+ /// Represents data for a video frame captured.
+ /// </summary>
+ public class CapturedFrame
+ {
+ internal CapturedFrame(byte[] imageBuffer, int width, int height)
+ {
+ Debug.Assert(imageBuffer != null, "imageBuffer is null!");
+ Debug.Assert(width > 0, $"Width is invalid : {width}!");
+ Debug.Assert(height > 0, $"height is invalid : {height}!");
+
+ Buffer = imageBuffer;
+ Size = new Size(width, height);
+ }
+
+ /// <summary>
+ /// Gets the raw buffer of the captured image.
+ /// </summary>
+ /// <remarks>The color space format is RGB888.</remarks>
+ public byte[] Buffer { get; }
+
+ /// <summary>
+ /// Gets the size.
+ /// </summary>
+ public Size Size { get; }
+ }
+}
+++ /dev/null
-/// Display
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// Display
- /// </summary>
- /// <remarks>
- /// This class provides properties and API that are required for setting
- /// display configurations of a player.
- /// </remarks>
- public class Display
- {
- internal IntPtr _playerHandle;
- internal bool _isVisible;
- internal DisplayMode _displayMode;
- internal DisplayRotation _rotation;
-
- /// <summary>
- /// Constructor - sets video display </summary>
- /// <param name="displayType"> display type</param>
- public Display(DisplayType displayType)
- {
- }
-
- /// <summary>
- /// Set/Get Display mode.
- /// </summary>
- /// <value> LetterBox, OriginalSize, FullScreen, CroppedFull, OriginalOrFull, DstRoi </value>
- public DisplayMode Mode
- {
- set
- {
- int ret = Interop.Player.SetDisplayMode(_playerHandle, (int)value);
- if( ret == (int)PlayerError.None)
- {
- _displayMode = value;
- }
- else
- {
- Log.Error(PlayerLog.LogTag, "Setting display mode failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting display mode failed");
- }
- }
- get
- {
- return _displayMode;
- }
- }
-
- /// <summary>
- /// Set/Get IsVisible.
- /// </summary>
- /// <value> true, false </value>
- public bool IsVisible
- {
- set
- {
- int ret = Interop.Player.SetDisplayVisible(_playerHandle, value);
- if(ret == (int)PlayerError.None)
- {
- _isVisible = value;
- }
- else
- {
- Log.Error(PlayerLog.LogTag, "Setting display visible failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting display visible failed");
- }
- }
- get
- {
- return _isVisible;
- }
- }
-
- /// <summary>
- /// Set/Get Display rotation.
- /// </summary>
- /// <value> RotationNone, Rotation90, Rotation180, Rotation270 </value>
- public DisplayRotation Rotation
- {
- set
- {
- int ret = Interop.Player.SetDisplayRotation(_playerHandle, (int)value);
- if(ret == (int)PlayerError.None)
- {
- _rotation = value;
- } else
- {
- Log.Error(PlayerLog.LogTag, "Setting display rotation failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting display rotation failed");
- }
- }
- get
- {
- return _rotation;
- }
- }
- }
-}
\ No newline at end of file
-/// Download progress
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
+/*
+ * 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.
+ */
namespace Tizen.Multimedia
{
/// <summary>
- /// DownloadProgress
+ /// Represents data for a downloading status.
/// </summary>
- /// <remarks>
- /// Contains DownloadProgress of streaming playback. DownloadProgress object is null initially.
- /// It is created only when playback starts.
- /// </remarks>
- public class DownloadProgress
+ public struct DownloadProgress
{
- internal int _start;
- internal int _current;
-
- internal DownloadProgress(int start, int current)
+ /// <summary>
+ /// Initialize a new instance of the DownloadProgress struct.
+ /// </summary>
+ /// <param name="start">The position that downloading started in percentage.</param>
+ /// <param name="current">The position indicating the current downloading progress in percentage.</param>
+ public DownloadProgress(int start, int current)
{
- _start = start;
- _current = current;
+ Start = start;
+ Current = current;
}
/// <summary>
- /// Get Start position in percentage.
+ /// Gets or sets the start position.
/// </summary>
- /// <value> 0 to 100 </value>
+ /// <value>The position that downloading started in percentage.</value>
public int Start
{
- get
- {
- return _start;
- }
+ get;
+ set;
}
/// <summary>
- /// Get Current position in percentage.
+ /// Gets or sets the current position.
/// </summary>
- /// <value> 0 to 100 </value>
+ /// <value>The position indicating the current downloading progress in percentage.</value>
public int Current
{
- get
- {
- return _current;
- }
+ get;
+ set;
+ }
+
+ public override string ToString()
+ {
+ return $"Start : { Start }, Current: { Current }";
}
}
-}
\ No newline at end of file
+}
-/// Equalizer Band
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
+/*
+ * 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 System;
+using System.Diagnostics;
namespace Tizen.Multimedia
{
/// <summary>
- /// Equalizer band
+ /// Represents a equalizer band of <see cref="AudioEffect"/>.
/// </summary>
- /// <remarks>
- /// Contains Equalizer properties
- /// </remarks>
public class EqualizerBand
{
- internal int _level;
- internal int _frequency;
- internal int _range;
+ private readonly AudioEffect _owner;
+ private readonly int _index;
- internal EqualizerBand(int level, int frequency, int range)
+ internal EqualizerBand(AudioEffect owner, int index)
{
- _level = level;
- _frequency = frequency;
- _range = range;
+ Debug.Assert(owner != null);
+
+ _owner = owner;
+ _index = index;
+
+ int frequency = 0;
+ int range = 0;
+
+ int ret = Interop.Player.AudioEffectGetEqualizerBandFrequency(_owner.Player.GetHandle(), _index, out frequency);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize equalizer band");
+
+ ret = Interop.Player.AudioEffectGetEqualizerBandFrequencyRange(_owner.Player.GetHandle(), _index, out range);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize equalizer band");
+
+ Frequency = frequency;
+ FrequencyRange = range;
}
/// <summary>
- /// Set/Get new gain in decibel that is set to the given band [dB]
+ /// Sets the gain for the equalizer band.
/// </summary>
- /// <value> int level </value>
- public int Level
+ /// <param name="value">The value indicating new gain in decibel(dB).</param>
+ /// <exception cref="ObjectDisposedException">The player that this EqualuzerBand belongs to has already been disposed of.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// value is less than <see cref="AudioEffect.MinBandLevel"/>.
+ /// <para>-or-</para>
+ /// value is greater than <see cref="AudioEffect.MaxBandLevel"/>.
+ /// </exception>
+ public void SetLevel(int value)
{
- set
- {
- _level = value;
- }
- get
+ _owner.Player.ValidateNotDisposed();
+
+ if (value < _owner.MinBandLevel || _owner.MaxBandLevel < value)
{
- return _level;
+ throw new ArgumentOutOfRangeException(nameof(value), value,
+ $"valid value range is { nameof(AudioEffect.MinBandLevel) } <= level <= { nameof(AudioEffect.MaxBandLevel) }. " +
+ $"but got {value}.");
}
+
+ int ret = Interop.Player.AudioEffectSetEqualizerBandLevel(_owner.Player.GetHandle(), _index, value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the level of the equalizer band");
}
/// <summary>
- /// Get frequency of the given band [dB] .
+ /// Gets the gain for the equalizer band.
/// </summary>
- /// <value> int frequency</value>
- public int Frequency
+ /// <exception cref="ObjectDisposedException">The player that this EqualuzerBand belongs to has already been disposed of.</exception>
+ public int GetLevel()
{
- get
- {
- return _frequency;
- }
+ _owner.Player.ValidateNotDisposed();
+
+ int value = 0;
+ int ret = Interop.Player.AudioEffectGetEqualizerBandLevel(_owner.Player.GetHandle(),
+ _index, out value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize equalizer band");
+
+ return value;
}
/// <summary>
- /// Get frequency range of the given band [dB].
+ /// Gets the frequency in dB.
/// </summary>
- /// <value> int range </value>
- public int Range
- {
- get
- {
- return _range;
- }
- }
+ public int Frequency { get; }
+
+ /// <summary>
+ /// Gets the frequency range oin dB.
+ /// </summary>
+ public int FrequencyRange { get; }
+
}
-}
\ No newline at end of file
+}
-/// Media buffer source
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
+/*
+ * 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 System;
namespace Tizen.Multimedia
{
/// <summary>
- /// The MediaBufferSource class used to set source to the player.
+ /// Represents a media source using memory.
/// </summary>
/// <remarks>
- /// MediaBufferSource object is created using buffer containing
- /// media content. Then the object is set to the player as source.
+ /// The buffer has to be filled with appropriate data which means it must be well-formatted.
+ /// If you provide invalid data, you won't receive an error until <see cref="Player.Start"/> is called.
/// </remarks>
- public class MediaBufferSource : MediaSource
+ /// <seealso cref="Player.SetSource(MediaSource)"/>
+ public sealed class MediaBufferSource : MediaSource
{
- internal byte[] _buffer;
+ private byte[] _buffer;
+
+ /// <summary>
+ /// Initialize a new instance of the MediaBufferSource class with an allocated buffer.
+ /// </summary>
+ /// <param name="length">The value indicating the size of the buffer.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// length is zero.
+ /// <para>-or-</para>
+ /// length is less than zero.
+ /// </exception>
+ public MediaBufferSource(int length)
+ {
+ if (length <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(length), length,
+ "length can't be equal to or less than zero.");
+ }
+ _buffer = new byte[length];
+ }
+
+ /// <summary>
+ /// Initialize a new instance of the MediaBufferSource class from the buffer.
+ /// </summary>
+ /// <param name="buffer">The source array to be copied into the buffer.</param>
+ /// <exception cref="ArgumentNullException">buffer is null.</exception>
+ public MediaBufferSource(byte[] buffer) : this(buffer, buffer == null ? 0 : buffer.Length)
+ {
+ }
/// <summary>
- /// Constructor - sets media buffer </summary>
- /// <param name="buffer"> source buffer </param>
- public MediaBufferSource(byte[] buffer)
+ /// Initialize a new instance of the MediaBufferSource class from the buffer
+ /// with the specified length and the specified offset.
+ /// </summary>
+ /// <param name="buffer">The source array to be copied into the buffer.</param>
+ /// <param name="length">The value indicating the number of bytes to copy from the buffer.</param>
+ /// <param name="offset">The value indicating the offset in the buffer of the first byte to copy.</param>
+ /// <exception cref="ArgumentNullException">buffer is null.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// offset is less than zero.
+ /// <para>-or-</para>
+ /// length is equal to or less than zero.
+ /// <para>-or-</para>
+ /// offset+length is greater than buffer.Length.
+ /// </exception>
+ public MediaBufferSource(byte[] buffer, int length, int offset = 0)
{
- _buffer = buffer;
+ if (buffer == null)
+ {
+ throw new ArgumentNullException(nameof(buffer));
+ }
+ if (offset < 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(offset), offset, "offset can't be less than zero.");
+ }
+ if (length <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(length), length, "length can't be equal to or less than zero.");
+ }
+ if (length + offset > buffer.Length)
+ {
+ throw new ArgumentOutOfRangeException($"length + offset can't be greater than the length of the { nameof(buffer) }.");
+ }
+
+ _buffer = new byte[length];
+
+ Array.Copy(buffer, offset, _buffer, 0, length);
}
+ private MediaBufferSource()
+ {
+ }
+
+ /// <summary>
+ /// Create a MediaBufferSource that wraps a byte array.
+ /// </summary>
+ /// <param name="buffer">The array to be wrapped.</param>
+ /// <returns>A MediaBufferSource wrapping the byte array.</returns>
+ public static MediaBufferSource Wrap(byte[] buffer)
+ {
+ if (buffer == null)
+ {
+ throw new ArgumentNullException(nameof(buffer));
+ }
+
+ MediaBufferSource source = new MediaBufferSource();
+ source._buffer = buffer;
+ return source;
+ }
+
+ /// <summary>
+ /// Gets the byte array of this buffer.
+ /// </summary>
+ public byte[] Buffer => _buffer;
+
+ internal override void OnAttached(Player player)
+ {
+ // TODO test buffer if we need to use GCHandle
+ int ret = Interop.Player.SetMemoryBuffer(player.GetHandle(), _buffer, _buffer.Length);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the memory buffer");
+ }
}
}
-/// Mediasource
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-
+/*
+ * 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.
+ */
namespace Tizen.Multimedia
{
/// <summary>
- /// The MediaSource class used to set source to the player.
+ /// MediaSource is a base class for <see cref="Player"/> sources.
/// </summary>
- /// <remarks>
- /// This is abstract class. Actual source classes
- /// should inherit this class.
- /// </remarks>
public abstract class MediaSource
{
+ internal MediaSource()
+ {
+ }
+
+ internal void AttachTo(Player player)
+ {
+ OnAttached(player);
+ }
+
+ internal void DetachFrom(Player player)
+ {
+ OnDetached(player);
+ }
+
+ internal abstract void OnAttached(Player player);
+
+ internal virtual void OnDetached(Player player)
+ {
+ }
}
}
--- /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 System;
+
+namespace Tizen.Multimedia
+{
+
+ /// <summary>
+ /// Provides data for the <see cref="MediaStreamConfiguration.BufferStatusChanged"/> event.
+ /// </summary>
+ public class MediaStreamBufferStatusChangedEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Initialize a new instance of the MediaStreamBufferStatusChangedEventArgs class.
+ /// </summary>
+ /// <param name="status">The value indicating the status of the stream.</param>
+ public MediaStreamBufferStatusChangedEventArgs(MediaStreamBufferStatus status)
+ {
+ Status = status;
+ }
+
+ /// <summary>
+ /// Gets the status.
+ /// </summary>
+ public MediaStreamBufferStatus Status { get; }
+
+ public override string ToString()
+ {
+ return $"Status : { Status }";
+ }
+ }
+}
-/// Media Stream configuration
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
+/*
+ * 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 System;
+using System.Diagnostics;
namespace Tizen.Multimedia
{
/// <summary>
- /// MediaStream configuration
+ /// Provides means to configure properties and handle events for <see cref="MediaStreamSource"/>.
/// </summary>
- /// <remarks>
- /// MediaStreamConfiguration class for media stream configuration.
- /// </remarks>
-
+ /// <seealso cref="MediaStreamSource"/>
public class MediaStreamConfiguration
{
- internal IntPtr _playerHandle;
- internal StreamType _streamType;
- #if _MEDIA_FORMAT_
- TODO: Uncomment this when MediaFormat is implemented.
- private EventHandler<BufferStatusEventArgs> _bufferStatusChanged;
- private Interop.Player.BufferStatusCallback _bufferStatusChangedCallback;
- private EventHandler<SeekOffsetEventArgs> _seekOffsetChanged;
- private Interop.Player.SeekOffsetChangedCallback _seekOffsetChangedCallback;
- #endif
-
- internal MediaStreamConfiguration()
- {
- }
-
- #if _MEDIA_FORMAT_
- TODO: Uncomment this when MediaFormat is implemented.
+ private const ulong DefaultBufferMaxSize = 200000;
+ private const uint DefaultBufferMinThreshold = 0;
+
+ private readonly MediaStreamSource _owner;
+ private readonly StreamType _streamType;
+
+ private ulong _bufferMaxSize = DefaultBufferMaxSize;
+ private uint _threshold = DefaultBufferMinThreshold;
+
+ internal MediaStreamConfiguration(MediaStreamSource owner, StreamType streamType)
+ {
+ _owner = owner;
+ _streamType = streamType;
+ }
+
/// <summary>
- /// BufferStatusChanged event is raised when buffer underrun or overflow occurs.
+ /// Occurs when the buffer underrun or overflow.
/// </summary>
- public event EventHandler<BufferStatusEventArgs> BufferStatusChanged
- {
- add
- {
- if(_bufferStatusChanged == null) {
- RegisterBufferStatusEvent();
- }
- _bufferStatusChanged += value;
- }
- remove
- {
- _bufferStatusChanged -= value;
- if(_bufferStatusChanged == null) {
- UnregisterBufferStatusEvent();
- }
- }
- }
+ /// <remarks>The event handler will be executed on an internal thread.</remarks>
+ /// <seealso cref="BufferMaxSize"/>
+ /// <seealso cref="BufferMinThreshold"/>
+ public event EventHandler<MediaStreamBufferStatusChangedEventArgs> BufferStatusChanged;
/// <summary>
- /// SeekOffsetChanged event is raised when seeking occurs.
+ /// Occurs when the seeking is requested.
/// </summary>
- public event EventHandler<SeekOffsetEventArgs> SeekOffsetChanged
- {
- add
- {
- if(_seekOffsetChanged == null) {
- RegisterSeekOffsetChangedEvent();
- }
- _seekOffsetChanged += value;
- }
- remove
- {
- _seekOffsetChanged -= value;
- if(_seekOffsetChanged == null) {
- UnregisterSeekOffsetChangedEvent();
- }
- }
- }
- #endif
+ /// <remarks>The event handler will be executed on an internal thread.</remarks>
+ public event EventHandler<MediaStreamSeekingOccurredEventArgs> SeekingOccurred;
/// <summary>
- /// max size bytes of buffer </summary>
- /// <value> Max size in bytes </value>
- public ulong BufferMaxSize
- {
- set
- {
- int ret = Interop.Player.SetMediaStreamBufferMaxSize(_playerHandle, (int)_streamType, value);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Set Buffer Max size failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Set Buffer Max size failed");
- }
-
- }
- get
- {
- ulong size;
- int ret = Interop.Player.GetMediaStreamBufferMaxSize(_playerHandle, (int)_streamType, out size);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Set Buffer Max size failed" + (PlayerError)ret);
- }
- return size;
- }
- }
+ /// Gets the max size of the buffer.
+ /// </summary>
+ /// <value>The max size of the buffer. The default is 200000.</value>
+ /// <remarks>If the buffer level over the max size, <see cref="BufferStatusChanged"/> will be raised with <see cref="MediaStreamBufferStatus.Overflow"/>.</remarks>
+ /// <exception cref="InvalidOperationException">The <see cref="MediaStreamSource"/> is not assigned to a player.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">value is zero.</exception>
+ /// <seealso cref="BufferStatusChanged"/>
+ public ulong BufferMaxSize
+ {
+ get
+ {
+ return _bufferMaxSize;
+ }
+ set
+ {
+ if (_owner.Player == null)
+ {
+ throw new InvalidOperationException("The source is not assigned to a player yet.");
+ }
+
+ Debug.Assert(_owner.Player.IsDisposed == false);
+
+ if (value == 0UL)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), value, "the buffer max size can't be zero.");
+ }
+
+ int ret = Interop.Player.SetMediaStreamBufferMaxSize(_owner.Player.GetHandle(), (int)_streamType, value);
+
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the buffer max size");
+
+ _bufferMaxSize = value;
+ }
+ }
/// <summary>
- /// Min threshold </summary>
- /// <value> min threshold in percent </value>
- public uint BufferMinThreshold
- {
- set
- {
- int ret = Interop.Player.SetMediaStreamBufferMinThreshold(_playerHandle, (int)_streamType, value);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Set Buffer Min threshold failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Set Buffer Min threshold failed");
- }
-
- }
- get
- {
- uint percent;
- int ret = Interop.Player.GetMediaStreamBufferMinThreshold(_playerHandle, (int)_streamType, out percent);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Get Buffer Min threshold failed" + (PlayerError)ret);
- }
- return percent;
- }
- }
-
- internal void SetHandle(IntPtr handle)
- {
- _playerHandle = handle;
- }
-
- #if _MEDIA_FORMAT_
- TODO: Uncomment this when MediaFormat is implemented.
- private void RegisterBufferStatusEvent()
- {
- _bufferStatusChangedCallback = (int status, IntPtr userData) =>
- {
- BufferStatusEventArgs eventArgs = new BufferStatusEventArgs();
- _bufferStatusChanged?.Invoke(this, eventArgs);
- };
- Interop.Player.SetMediaStreamBufferStatusCb(_playerHandle, _bufferStatusChangedCallback, IntPtr.Zero);
- }
-
- private void UnregisterBufferStatusEvent()
- {
- Interop.Player.UnsetMediaStreamBufferStatusCb(_playerHandle);
- }
-
- private void RegisterSeekOffsetChangedEvent()
- {
- _seekOffsetChangedCallback = (UInt64 offset, IntPtr userData) =>
- {
- SeekOffsetEventArgs eventArgs = new SeekOffsetEventArgs();
- _seekOffsetChanged?.Invoke(this, eventArgs);
- };
- Interop.Player.SetMediaStreamSeekCb(_playerHandle, _seekOffsetChangedCallback, IntPtr.Zero);
- }
-
- private void UnregisterSeekOffsetChangedEvent()
- {
- Interop.Player.UnsetMediaStreamSeekCb(_playerHandle);
- }
- #endif
-
+ /// Gets the min threshold of the buffer or zero if the <see cref="MediaStreamSource"/> is not assigned to a player.
+ /// </summary>
+ /// <value>The minimum threshold of the buffer in percentage. The default is zero.</value>
+ /// <remarks>If the buffer level drops below the threshold value, <see cref="BufferStatusChanged"/> will be raised with <see cref="MediaStreamBufferStatus.Underrun"/>.</remarks>
+ /// <exception cref="InvalidOperationException">The <see cref="MediaStreamSource"/> is not assigned to a player.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">value is greater than 100.</exception>
+ /// <seealso cref="BufferStatusChanged"/>
+ public uint BufferMinThreshold
+ {
+ get
+ {
+ return _threshold;
+ }
+ set
+ {
+ if (_owner.Player == null)
+ {
+ throw new InvalidOperationException("The source is not assigned to a player yet.");
+ }
+
+ Debug.Assert(_owner.Player.IsDisposed == false);
+
+ if (100 < value)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), value,
+ $"The threshold can't be greater than 100, but got { value }.");
+ }
+
+ int ret = Interop.Player.SetMediaStreamBufferMinThreshold(_owner.Player.GetHandle(), (int)_streamType, value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the buffer minimum threshold");
+
+ _threshold = value;
+ }
+ }
+
+ internal void OnPlayerSet(Player player)
+ {
+ if (_streamType == StreamType.Audio)
+ {
+ player.MediaStreamAudioSeekingOccurred += MediaStreamSeekingOccurred;
+ player.MediaStreamAudioBufferStatusChanged += MediaStreamBufferStatusChanged;
+ }
+ else
+ {
+ player.MediaStreamVideoSeekingOccurred += MediaStreamSeekingOccurred;
+ player.MediaStreamVideoBufferStatusChanged += MediaStreamBufferStatusChanged;
+ }
+
+ int ret = Interop.Player.SetMediaStreamBufferMaxSize(player.GetHandle(), (int)_streamType, _bufferMaxSize);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the media stream configuration");
+
+ ret = Interop.Player.SetMediaStreamBufferMinThreshold(player.GetHandle(), (int)_streamType, _threshold);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the media stream configuration");
+ }
+
+ internal void OnPlayerUnset(Player player)
+ {
+ if (_streamType == StreamType.Audio)
+ {
+ player.MediaStreamAudioSeekingOccurred -= MediaStreamSeekingOccurred;
+ player.MediaStreamAudioBufferStatusChanged -= MediaStreamBufferStatusChanged;
+ }
+ else
+ {
+ player.MediaStreamVideoSeekingOccurred -= MediaStreamSeekingOccurred;
+ player.MediaStreamVideoBufferStatusChanged -= MediaStreamBufferStatusChanged;
+ }
+ }
+
+ private void MediaStreamBufferStatusChanged(object sender, MediaStreamBufferStatusChangedEventArgs e)
+ {
+ BufferStatusChanged?.Invoke(this, e);
+ }
+
+ private void MediaStreamSeekingOccurred(object sender, MediaStreamSeekingOccurredEventArgs e)
+ {
+ SeekingOccurred?.Invoke(this, e);
+ }
}
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
using System;
namespace Tizen.Multimedia
{
/// <summary>
- /// The exception that is thrown when there is no memory to allocate a new buffer for the packet.
+ /// Provides data for the <see cref="MediaStreamConfiguration.SeekingOccurred"/> event.
/// </summary>
- public class NotEnoughMemoryException : Exception
+ public class MediaStreamSeekingOccurredEventArgs : EventArgs
{
- /// <summary>
- /// Initializes a new instance of the NotEnoughMemoryException class with a specified error message.
+ /// <summary>
+ /// Initialize a new instance of the MediaStreamSeekingOccurredEventArgs class.
/// </summary>
- /// <param name="message">Error description.</param>
- public NotEnoughMemoryException(string message) : base(message)
+ /// <param name="status">The value indicating the new position to seek.</param>
+ public MediaStreamSeekingOccurredEventArgs(ulong offset)
{
+ Offset = offset;
}
+
+ /// <summary>
+ /// Gets the offset.
+ /// </summary>
+ public ulong Offset { get; }
+
+ public override string ToString() => $"Offset : { Offset }";
}
}
-/// Media Stream source
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
+/*
+ * 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 System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
namespace Tizen.Multimedia
{
- /// <summary>
- /// MediaStreamSource
- /// </summary>
- /// <remarks>
- /// MediaStreamSource class for media stream configuration.
- /// </remarks>
-
- public class MediaStreamSource : MediaSource
- {
- internal MediaStreamConfiguration _audioConfiguration;
- internal MediaStreamConfiguration _videoConfiguration;
-
- /// <summary>
- /// Constructor </summary>
- public MediaStreamSource()
- {
- _audioConfiguration = new MediaStreamConfiguration();
- _videoConfiguration = new MediaStreamConfiguration();
- _audioConfiguration._streamType = StreamType.Audio;
- _videoConfiguration._streamType = StreamType.Video;
- }
-
- #if _MEDIA_FORMAT_
- TODO: Uncomment this when MediaFormat is implemented
- /// <summary>
- /// Get/Set Audio Media format.
- /// </summary>
- /// <value> MediaFormat </value>
- //public MediaFormat AudioMediaFormat { get; set; }
-
- /// <summary>
- /// Get/Set Video Media format.
- /// </summary>
- /// <value> MediaFormat </value>
- //public MediaFormat VideoMediaFormat { get; set; }
- #endif
-
- /// <summary>
- /// Get/Set Audio configuration.
- /// </summary>
- /// <value> MediaStreamConfiguration </value>
- public MediaStreamConfiguration AudioConfiguration
- {
- get
- {
- return _audioConfiguration;
- }
- }
-
- /// <summary>
- /// Get/Set Video configuration.
- /// </summary>
- /// <value> MediaStreamConfiguration </value>
- public MediaStreamConfiguration VideoConfiguration
- {
- get
- {
- return _videoConfiguration;
- }
- }
-
- #if _MEDIA_PACKET_
- /// <summary>
- /// Push Media stream </summary>
- /// <param name="packet"> media packet</param>
- /// TODO: Implement this when MediaPacket is ready
- public void PushMediaStream(MediaPacket packet)
- {
- }
- #endif
-
- internal void SetHandle(IntPtr handle)
- {
- _audioConfiguration.SetHandle(handle);
- _videoConfiguration.SetHandle(handle);
- }
- }
+
+ /// <summary>
+ /// Provides the ability to push packets as the source of <see cref="Player"/>
+ /// </summary>
+ /// <remarks>The source must be set as a source to a player before pushing.</remarks>
+ /// <seealso cref="Player.SetSource(MediaSource)"/>
+ // TODO is this name appropriate?
+ public sealed class MediaStreamSource : MediaSource
+ {
+ private readonly MediaFormat _audioMediaFormat;
+ private readonly MediaFormat _videoMediaFormat;
+
+ public static IEnumerable<MediaFormatAudioMimeType> SupportedAudioTypes
+ {
+ get
+ {
+ yield return MediaFormatAudioMimeType.Aac;
+ }
+ }
+
+ public static IEnumerable<MediaFormatVideoMimeType> SupportedVideoTypes
+ {
+ get
+ {
+ yield return MediaFormatVideoMimeType.H264SP;
+ }
+ }
+
+ private Player _player;
+
+ private MediaStreamConfiguration CreateAudioConfiguration(AudioMediaFormat format)
+ {
+ if( format == null )
+ {
+ return null;
+ }
+
+ if (!SupportedAudioTypes.Contains(format.MimeType))
+ {
+ throw new ArgumentException($"The audio format is not supported, Type : {format.MimeType}.");
+ }
+
+ return new MediaStreamConfiguration(this, StreamType.Audio);
+ }
+
+ private MediaStreamConfiguration CreateVideoConfiguration(VideoMediaFormat format)
+ {
+ if (format == null)
+ {
+ return null;
+ }
+
+ if (!SupportedVideoTypes.Contains(format.MimeType))
+ {
+ throw new ArgumentException($"The video format is not supported, Type : {format.MimeType}.");
+ }
+
+ return new MediaStreamConfiguration(this, StreamType.Video);
+ }
+
+
+ /// <summary>
+ /// Initialize a new instance of the MediaStreamSource class
+ /// with the specified <see cref="AudioMediaFormat"/> and <see cref="VideoMediaFormat"/>.
+ /// </summary>
+ /// <param name="audioMediaFormat">The <see cref="AudioMediaFormat"/> for this source.</param>
+ /// <param name="videoMediaFormat">The <see cref="VideoMediaFormat"/> for this source.</param>
+ /// <remarks>AAC and H.264 are supported.</remarks>
+ /// <exception cref="ArgumentNullException">both <paramref name="audioMediaFormat"/> and <paramref name="videoMediaFormat"/> are null.</exception>
+ /// <exception cref="ArgumentException">
+ /// <paramref name="audioMediaFormat"/> is not supported.
+ /// <para>-or-</para>
+ /// <paramref name="videoMediaFormat"/> is not supported.
+ /// </exception>
+ /// <seealso cref="SupportedAudioTypes"/>
+ /// <seealso cref="SupportedVideoTypes"/>
+ public MediaStreamSource(AudioMediaFormat audioMediaFormat, VideoMediaFormat videoMediaFormat)
+ {
+ if (audioMediaFormat == null && videoMediaFormat == null)
+ {
+ throw new ArgumentNullException(nameof(audioMediaFormat) + " and " + nameof(videoMediaFormat));
+ }
+
+ _audioMediaFormat = audioMediaFormat;
+ _videoMediaFormat = videoMediaFormat;
+
+ AudioConfiguration = CreateAudioConfiguration(audioMediaFormat);
+ VideoConfiguration = CreateVideoConfiguration(videoMediaFormat);
+ }
+
+ /// <summary>
+ /// Initialize a new instance of the MediaStreamSource class with the specified <see cref="AudioMediaFormat"/>.
+ /// </summary>
+ /// <param name="audioMediaFormat">The <see cref="AudioMediaFormat"/> for this source.</param>
+ /// <remarks>AAC is supported.</remarks>
+ /// <exception cref="ArgumentNullException"><paramref name="audioMediaFormat"/> is null.</exception>
+ /// <exception cref="ArgumentException"><paramref name="audioMediaFormat"/> is not supported.</exception>
+ /// <seealso cref="SupportedAudioTypes"/>
+ public MediaStreamSource(AudioMediaFormat audioMediaFormat)
+ {
+ if (audioMediaFormat == null)
+ {
+ throw new ArgumentNullException(nameof(audioMediaFormat));
+ }
+
+ _audioMediaFormat = audioMediaFormat;
+
+ AudioConfiguration = CreateAudioConfiguration(audioMediaFormat);
+ }
+ /// <summary>
+ /// Initialize a new instance of the MediaStreamSource class with the specified <see cref="VideoMediaFormat"/>.
+ /// </summary>
+ /// <remarks>H.264 can is supported.</remarks>
+ /// <param name="videoMediaFormat">The <see cref="VideoMediaFormat"/> for this source.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="videoMediaFormat"/> is null.</exception>
+ /// <exception cref="ArgumentException"><paramref name="videoMediaFormat"/> is not supported.</exception>
+ /// <seealso cref="SupportedVideoTypes"/>
+ public MediaStreamSource(VideoMediaFormat videoMediaFormat)
+ {
+ if (videoMediaFormat == null)
+ {
+ throw new ArgumentNullException(nameof(videoMediaFormat));
+ }
+
+ _videoMediaFormat = videoMediaFormat;
+
+ VideoConfiguration = CreateVideoConfiguration(videoMediaFormat);
+ }
+
+ /// <summary>
+ /// Gets the audio configuration or null if no AudioMediaFormat is specified in the constructor.
+ /// </summary>
+ public MediaStreamConfiguration AudioConfiguration { get; }
+
+ /// <summary>
+ /// Gets the video configuration or null if no VideoMediaFormat is specified in the constructor.
+ /// </summary>
+ public MediaStreamConfiguration VideoConfiguration { get; }
+
+ /// <summary>
+ /// Pushes elementary stream to decode audio or video.
+ /// </summary>
+ /// <remarks>This source must be set as a source to a player and the player must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <param name="packet">The <see cref="MediaPacket"/> to decode.</param>
+ /// <exception cref="InvalidOperationException">
+ /// This source is not set as a source to a player.
+ /// <para>-or-</para>
+ /// The player is not in the valid state.
+ /// </exception>
+ /// <exception cref="ArgumentNullException">packet is null.</exception>
+ /// <exception cref="ObjectDisposedException">packet has been disposed.</exception>
+ /// <exception cref="ArgumentException">
+ /// <paramref name="packet"/> is neither video nor audio type.
+ /// <para>-or-</para>
+ /// The format of packet is not matched with the specified format in the constructor.
+ /// </exception>
+ /// <exception cref="NoBufferSpaceException">the internal buffer reaches limits.</exception>
+ /// <seealso cref="Player.SetSource(MediaSource)"/>
+ /// <seealso cref="MediaStreamConfiguration.BufferMaxSize"/>
+ /// <seealso cref="MediaPacket"/>
+ public void Push(MediaPacket packet)
+ {
+ if (_player == null)
+ {
+ throw new InvalidOperationException("The source is not set as a source to a player yet.");
+ }
+ if (packet == null)
+ {
+ throw new ArgumentNullException(nameof(packet));
+ }
+ if (packet.IsDisposed)
+ {
+ throw new ObjectDisposedException(nameof(packet));
+ }
+
+ if (packet.Format.Type == MediaFormatType.Text || packet.Format.Type == MediaFormatType.Container)
+ {
+ throw new ArgumentException($"The format of the packet is invalid : { packet.Format.Type }.");
+ }
+
+ if (!packet.Format.Equals(_audioMediaFormat) && !packet.Format.Equals(_videoMediaFormat))
+ {
+ throw new ArgumentException($"The format of the packet is invalid : Unmatched format.");
+ }
+
+ if (packet.Format.Type == MediaFormatType.Video && _videoMediaFormat == null)
+ {
+ throw new ArgumentException("Video is not configured with the current source.");
+ }
+ if (packet.Format.Type == MediaFormatType.Audio && _audioMediaFormat == null)
+ {
+ throw new ArgumentException("Audio is not configured with the current source.");
+ }
+
+ _player.ValidatePlayerState(PlayerState.Paused, PlayerState.Playing, PlayerState.Ready);
+
+ int ret = Interop.Player.PushMediaStream(_player.GetHandle(), packet.GetHandle());
+
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to push the packet to the player");
+ }
+
+ private void SetMediaStreamInfo(StreamType streamType, MediaFormat mediaFormat)
+ {
+ if (mediaFormat == null)
+ {
+ return;
+ }
+
+ IntPtr ptr = IntPtr.Zero;
+
+ try
+ {
+ ptr = mediaFormat.AsNativeHandle();
+ int ret = Interop.Player.SetMediaStreamInfo(_player.GetHandle(), (int)streamType, ptr);
+
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the media stream info");
+ }
+ finally
+ {
+ MediaFormat.ReleaseNativeHandle(ptr);
+ }
+ }
+
+ internal override void OnAttached(Player player)
+ {
+ Debug.Assert(player != null);
+
+ if (_player != null)
+ {
+ throw new InvalidOperationException("The source is has already been assigned to another player.");
+ }
+
+ AudioConfiguration?.OnPlayerSet(player);
+ VideoConfiguration?.OnPlayerSet(player);
+
+ _player = player;
+
+ SetMediaStreamInfo(StreamType.Audio, _audioMediaFormat);
+ SetMediaStreamInfo(StreamType.Video, _videoMediaFormat);
+ }
+
+ internal override void OnDetached(Player player)
+ {
+ base.OnDetached(player);
+
+ AudioConfiguration?.OnPlayerUnset(player);
+ VideoConfiguration?.OnPlayerUnset(player);
+
+ _player = null;
+ }
+
+ /// <summary>
+ /// Gets the <see cref="Player"/> that this source is assigned to as a source or null if this source is not assigned.
+ /// </summary>
+ /// <seealso cref="Player.SetSource(MediaSource)"/>
+ public Player Player => _player;
+
+ }
}
-/// Media Uri source
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
+/// Media Uri source
+/*
+ * 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 System;
namespace Tizen.Multimedia
{
/// <summary>
- /// The MediaUriSource class used to set source to the player.
+ /// Represents a media source with a uri.
/// </summary>
/// <remarks>
- /// MediaUriSource object is created using url string of the media
- /// Then the object is set to the player as source.
+ /// The internet privilege(http://tizen.org/privilege/internet) must be added if any URLs are used to play from network.
+ /// The mediastorage privilege(http://tizen.org/privilege/mediastorage) must be added if any video/audio files are used to play located in the internal storage.
+ /// The externalstorage privilege(http://tizen.org/privilege/externalstorage) must be added if any video/audio files are used to play located in the external storage.
/// </remarks>
- public class MediaUriSource : MediaSource
+ /// <seealso cref="Player.SetSource(MediaSource)"/>
+ public sealed class MediaUriSource : MediaSource
{
- private string _uri;
-
/// <summary>
- /// Constructor </summary>
- /// <param name="uri"> uri string </param>
+ /// Initialize a new instance of the MediaUriSource class with the specified uri.</summary>
+ /// <param name="uri">The uri string.</param>
+ /// <remarks>For HTTP or RSTP, uri should start with "http://" or "rtsp://".
+ /// The default protocol is "file://".
+ /// If you provide an invalid uri, you won't receive an error until <see cref="Player.Start"/> is called.</remarks>
public MediaUriSource(string uri)
{
- _uri = uri;
+ if (uri == null)
+ {
+ throw new ArgumentNullException(nameof(uri));
+ }
+ Uri = uri;
}
- internal string GetUri()
+ /// <summary>
+ /// Gets the uri.
+ /// </summary>
+ public string Uri { get; }
+
+ internal override void OnAttached(Player player)
{
- return _uri;
+ PlayerErrorConverter.ThrowIfError(Interop.Player.SetUri(player.GetHandle(), Uri),
+ "Failed to set the source with specified uri");
}
-
}
}
+++ /dev/null
-/// This File contains PlaybackCompletedEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-namespace Tizen.Multimedia
-{
-
- /// <summary>
- /// PlaybackCompleted event arguments
- /// </summary>
- /// <remarks>
- /// PlaybackCompleted event arguments
- /// </remarks>
- public class PlaybackCompletedEventArgs : EventArgs
- {
- internal PlaybackCompletedEventArgs()
- {
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/// This File contains PlaybackErrorEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-namespace Tizen.Multimedia
-{
-
- /// <summary>
- /// PlaybackError event arguments
- /// </summary>
- /// <remarks>
- /// PlaybackError event arguments
- /// </remarks>
- public class PlaybackErrorEventArgs : EventArgs
- {
- internal int _errorCode;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="errocode"> Playback error code </param>
- internal PlaybackErrorEventArgs(int errorCode)
- {
- _errorCode = errorCode;
- }
-
- /// <summary>
- /// Get the error code.
- /// </summary>
- /// <value> integer error code</value>
- public int ErrorCode
- {
- get
- {
- return _errorCode;
- }
- }
- }
-}
\ No newline at end of file
-/// This File contains PlaybackInterruptedEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
+/*
+ * 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 System;
namespace Tizen.Multimedia
{
-
/// <summary>
- /// PlaybackInterrupted event arguments
+ /// Provides data for the <see cref="Player.PlaybackInterrupted"/> event.
/// </summary>
- /// <remarks>
- /// PlaybackInterrupted event arguments
- /// </remarks>
public class PlaybackInterruptedEventArgs : EventArgs
{
- internal int _interruptedCode;
-
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="interruptedCode"> Playback interrupted code </param>
- internal PlaybackInterruptedEventArgs(int interruptedCode)
- {
- _interruptedCode = interruptedCode;
- }
+ /// <summary>
+ /// Initialize a new instance of the PlaybackInterruptedEventArgs class.
+ /// </summary>
+ /// <param name="status">The enum value indicating the reason.</param>
+ public PlaybackInterruptedEventArgs(PlaybackIntrruptionReason reason)
+ {
+ Reason = reason;
+ }
/// <summary>
- /// Get the error code.
+ /// Gets the reason.
/// </summary>
- /// <value> integer error code</value>
- public int InterruptedCode
+ public PlaybackIntrruptionReason Reason { get; }
+
+ public override string ToString()
{
- get
- {
- return _interruptedCode;
- }
+ return $"Reason : { Reason }";
}
}
-}
\ No newline at end of file
+}
-/// Player
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
+/*
+ * 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 System;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
+using System.Diagnostics;
+using System.IO;
+using System.Threading;
namespace Tizen.Multimedia
{
- static internal class PlayerLog
- {
- internal const string LogTag = "Tizen.Multimedia.Player";
- }
-
/// <summary>
- /// The Player class provides APIs required for playback.
+ /// Provides the ability to control media playback.
/// </summary>
/// <remarks>
- /// The Player APIs provides functions to create a player, set media filename/url
- /// and play the media content. It also provides APIs to adjust the configurations
- /// of the player such as playback rate, volume, looping etc. And, event handlers
- /// handles are provided to handle various playback events (like playback error/completion)
+ /// The Player provides functions to play a media content.
+ /// It also provides functions to adjust the configurations of the player such as playback rate, volume, looping etc.
+ /// Note that only one video player can be played at one time.
/// </remarks>
- public class Player : IDisposable
+ public sealed class Player : IDisposable
{
- internal PlayerState _state;
- internal float _leftVolume;
- internal float _rightVolume;
- internal int _audioLatencyMode;
- internal bool _mute;
- internal bool _isLooping;
- internal Display _display;
- internal Subtitle _subtitle;
- internal AudioEffect _audioEffect;
- internal StreamInformation _streamInformation;
- internal StreamingConfiguration _streamingConfiguration;
- internal IntPtr _playerHandle;
-
- private bool _disposed = false;
- private EventHandler<PlaybackCompletedEventArgs> _playbackCompleted;
+ private IntPtr _handle = IntPtr.Zero;
+
+ /// <summary>
+ /// Occurs when playback of a media is finished.
+ /// </summary>
+ public event EventHandler<EventArgs> PlaybackCompleted;
private Interop.Player.PlaybackCompletedCallback _playbackCompletedCallback;
- private EventHandler<PlaybackInterruptedEventArgs> _playbackInterrupted;
+
+ /// <summary>
+ /// Occurs when playback of a media is interrupted.
+ /// </summary>
+ public event EventHandler<PlaybackInterruptedEventArgs> PlaybackInterrupted;
private Interop.Player.PlaybackInterruptedCallback _playbackInterruptedCallback;
- private EventHandler<PlaybackErrorEventArgs> _playbackError;
+
+ /// <summary>
+ /// Occurs when any error occurs.
+ /// </summary>
+ /// <remarks>The event handler will be executed on an internal thread.</remarks>
+ public event EventHandler<PlayerErrorOccurredEventArgs> ErrorOccurred;
private Interop.Player.PlaybackErrorCallback _playbackErrorCallback;
- //TODO: Uncomment this after MediaPacket is implemented.
- //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>
+ /// <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>
+ public event EventHandler<VideoStreamChangedEventArgs> VideoStreamChanged;
+ private Interop.Player.VideoStreamChangedCallback _videoStreamChangedCallback;
/// <summary>
- /// Player constructor.</summary>
- public Player()
- {
- int ret;
+ /// Occurs when the subtitle is updated.
+ /// </summary>
+ /// <remarks>The event handler will be executed on an internal thread.</remarks>
+ public EventHandler<SubtitleUpdatedEventArgs> SubtitleUpdated;
+ private Interop.Player.SubtitleUpdatedCallback _subtitleUpdatedCallback;
- ret = Interop.Player.Create(out _playerHandle);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to create player" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to create player");
- }
+ /// <summary>
+ /// Occurs when there is a change in the buffering status of streaming.
+ /// </summary>
+ public event EventHandler<BufferingProgressChangedEventArgs> BufferingProgressChanged;
+ private Interop.Player.BufferingProgressCallback _bufferingProgressCallback;
- // Initial get values
- ret = Interop.Player.GetVolume(_playerHandle, out _leftVolume, out _rightVolume);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get volume levels" + ret);
- }
+ internal event EventHandler<MediaStreamBufferStatusChangedEventArgs> MediaStreamAudioBufferStatusChanged;
+ private Interop.Player.MediaStreamBufferStatusCallback _mediaStreamAudioBufferStatusChangedCallback;
- ret = Interop.Player.GetAudioLatencyMode(_playerHandle, out _audioLatencyMode);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get Audio latency mode" + ret);
- }
+ internal event EventHandler<MediaStreamBufferStatusChangedEventArgs> MediaStreamVideoBufferStatusChanged;
+ private Interop.Player.MediaStreamBufferStatusCallback _mediaStreamVideoBufferStatusChangedCallback;
- ret = Interop.Player.IsMuted(_playerHandle, out _mute);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get mute status" + ret);
- }
+ internal event EventHandler<MediaStreamSeekingOccurredEventArgs> MediaStreamAudioSeekingOccurred;
+ private Interop.Player.MediaStreamSeekCallback _mediaStreamAudioSeekCallback;
- ret = Interop.Player.IsLooping(_playerHandle, out _isLooping);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get loop status" + ret);
- }
+ internal event EventHandler<MediaStreamSeekingOccurredEventArgs> MediaStreamVideoSeekingOccurred;
+ private Interop.Player.MediaStreamSeekCallback _mediaStreamVideoSeekCallback;
+ /// <summary>
+ /// Initialize a new instance of the Player class.
+ /// </summary>
+ public Player()
+ {
+ try
+ {
+ int ret = Interop.Player.Create(out _handle);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to create player");
- // AudioEffect
- _audioEffect = new AudioEffect();
- _audioEffect._playerHandle = _playerHandle;
+ RetrieveProperties();
+ RegisterCallbacks();
- // Display
- _display = new Display(DisplayType.Evas /* Default value? */);
- _display._playerHandle = _playerHandle;
+ AudioEffect = new AudioEffect(this);
+ }
+ catch (Exception)
+ {
+ if (_handle != IntPtr.Zero)
+ {
+ Interop.Player.Destroy(_handle);
+ }
+ throw;
+ }
+ }
- // StreamingConfiguration
- _streamingConfiguration = new StreamingConfiguration(_playerHandle);
+ private void RetrieveProperties()
+ {
+ PlayerErrorConverter.ThrowIfError(Interop.Player.GetVolume(_handle, out _volume, out _volume),
+ "Failed to initialize the player");
- // StreamInformation
- _streamInformation = new StreamInformation();
- _streamInformation._playerHandle = _playerHandle;
- _streamInformation._contentInfo = new PlayerContentInfo();
- _streamInformation._contentInfo._playerHandle = _playerHandle;
+ int value = 0;
+ PlayerErrorConverter.ThrowIfError(Interop.Player.GetAudioLatencyMode(_handle, out value),
+ "Failed to initialize the player");
+ _audioLatencyMode = (AudioLatencyMode)value;
+ PlayerErrorConverter.ThrowIfError(Interop.Player.IsLooping(_handle, out _isLooping),
+ "Failed to initialize the player");
+ }
- Log.Debug(PlayerLog.LogTag, "player created : " + _playerHandle);
+ private void RegisterCallbacks()
+ {
+ RegisterSubtitleUpdatedCallback();
+ RegisterErrorOccuuredCallback();
+ RegisterPlaybackInterruptedCallback();
+ RegisterVideoStreamChangedCallback();
+ RegisterBufferingCallback();
+ RegisterMediaStreamBufferStatusCallback();
+ RegisterMediaStreamSeekCallback();
+ RegisterPlaybackCompletedCallback();
+ RegisterVideoFrameDecodedCallback();
}
- /// <summary>
- /// Player destructor
- /// </summary>
~Player()
{
Dispose(false);
}
+ internal IntPtr GetHandle()
+ {
+ ValidateNotDisposed();
+ return _handle;
+ }
- /// <summary>
- /// PlaybackCompleted event is raised when playback of a media is finished
- /// </summary>
- public event EventHandler<PlaybackCompletedEventArgs> PlaybackCompleted
+ internal void ValidatePlayerState(params PlayerState[] desiredStates)
{
- add
- {
- if (_playbackCompleted == null)
- {
- RegisterPlaybackCompletedEvent();
- }
- _playbackCompleted += value;
+ Debug.Assert(desiredStates.Length > 0);
- }
- remove
+ ValidateNotDisposed();
+
+ var curState = State;
+ if (curState.IsAnyOf(desiredStates))
{
- _playbackCompleted -= value;
- if (_playbackCompleted == null)
- {
- UnregisterPlaybackCompletedEvent();
- }
+ return;
}
+
+ throw new InvalidOperationException($"The player is not in a valid state. " +
+ $"Current State : { curState }, Valid State : { string.Join(", ", desiredStates) }.");
}
+ #region Properties
+ #region Network configuration
+ private string _cookie = "";
+ private string _userAgent = "";
+
/// <summary>
- /// PlaybackInterruped event is raised when playback of a media is interrupted
+ /// Gets or Sets the cookie for streaming playback.
/// </summary>
- public event EventHandler<PlaybackInterruptedEventArgs> PlaybackInterruped
+ /// <remarks>To set, the player must be in the <see cref="PlayerState.Idle"/> state.</remarks>
+ /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="ArgumentNullException">The value to set is null.</exception>
+ public string Cookie
{
- add
+ get
{
- if (_playbackInterrupted == null)
- {
- RegisterPlaybackInterruptedEvent();
- }
- _playbackInterrupted += value;
+ return _cookie;
}
- remove
+ set
{
- _playbackInterrupted -= value;
- if (_playbackInterrupted == null)
+ ValidatePlayerState(PlayerState.Idle);
+
+ if (value == null)
{
- UnregisterPlaybackInterruptedEvent();
+ throw new ArgumentNullException(nameof(value), "Cookie can't be null.");
}
+
+ int ret = Interop.Player.SetStreamingCookie(_handle, value, value.Length);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the cookie to the player");
+
+ _cookie = value;
}
}
/// <summary>
- /// PlaybackErrorOccured event is raised when any error occurs
+ /// Gets or Sets the user agent for streaming playback.
/// </summary>
- public event EventHandler<PlaybackErrorEventArgs> PlaybackErrorOccured
+ /// <remarks>To set, the player must be in the <see cref="PlayerState.Idle"/> state.</remarks>
+ /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="ArgumentNullException">The value to set is null.</exception>
+ public string UserAgent
{
- add
+ get
{
- if (_playbackError == null)
- {
- RegisterPlaybackErrorEvent();
- }
- _playbackError += value;
+ return _userAgent;
}
- remove
+ set
{
- _playbackError -= value;
- if (_playbackError == null)
+ ValidatePlayerState(PlayerState.Idle);
+
+ if (value == null)
{
- UnregisterPlaybackErrorEvent();
+ throw new ArgumentNullException(nameof(value), "UserAgent can't be null.");
}
- }
- }
+ int ret = Interop.Player.SetStreamingUserAgent(_handle, value, value.Length);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the user agent to the player");
-#if _MEDIA_PACKET_
- TODO: Uncomment this after MediaPacket is implemented.
- /// <summary>
- /// VideoFrameCaptured event is raised when a video frame is decoded
- /// </summary>
- public event EventHandler<VideoFrameDecodedEventArgs> VideoFrameDecoded
- {
- add
- {
- if(_videoFrameDecoded == null) {
- RegisterVideoFrameDecodedEvent();
- }
- _videoFrameDecoded += value;
- }
- remove
- {
- _videoFrameDecoded -= value;
- if(_videoFrameDecoded == null) {
- UnregisterVideoFrameDecodedEvent();
- }
- }
- }
-#endif
-
+ _userAgent = value;
+ }
+ }
+ #endregion
/// <summary>
- /// Get Player state.
+ /// Gets the state of the player.
/// </summary>
- /// <value> PlayerState </value>
+ /// <value>The current state of the player.</value>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
public PlayerState State
{
get
{
- int state;
- int ret = Interop.Player.GetState(_playerHandle, out state);
+ ValidateNotDisposed();
- if (ret != (int)PlayerError.None)
- PlayerErrorFactory.ThrowException(ret, "Get player state failed");
+ //TODO is this needed?
+ if (IsPreparing())
+ {
+ return PlayerState.Preparing;
+ }
+
+ int state = 0;
+ int ret = Interop.Player.GetState(_handle, out state);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to retrieve the state of the player");
+
+ Debug.Assert(Enum.IsDefined(typeof(PlayerState), state));
return (PlayerState)state;
}
}
+ private AudioLatencyMode _audioLatencyMode;
+
/// <summary>
- /// Set/Get the left volume level.
+ /// Gets or sets the audio latency mode.
/// </summary>
- /// <value> 0 to 1.0 that indicates left volume level </value>
- public float LeftVolume
+ /// <value>A <see cref="AudioLatencyMode"/> that specifies the mode. The default is <see cref="AudioLatencyMode.Mid"/>.</value>
+ /// <remarks>
+ /// If the mode is <see cref="AudioLatencyMode.AudioLatencyMode"/>,
+ /// audio output interval can be increased so, it can keep more audio data to play.
+ /// But, state transition like pause or resume can be more slower than default(<see cref="AudioLatencyMode.Mid"/>) mode.
+ /// </remarks>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="ArgumentException">The value is not valid.</exception>
+ public AudioLatencyMode AudioLatencyMode
{
+ get
+ {
+ return _audioLatencyMode;
+ }
set
{
- int ret = Interop.Player.SetVolume(_playerHandle, value, value);
+ ValidateNotDisposed();
- if (ret == (int)PlayerError.None)
- {
- _leftVolume = value;
- }
- else
+ if (_audioLatencyMode == value)
{
- Log.Error(PlayerLog.LogTag, "Set volume failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "set volume failed");
+ return;
}
- }
- get
- {
- //Interop.Player.GetVolume(_playerHandle, out _leftVolume, out _rightVolume);
- return _leftVolume;
+ ValidationUtil.ValidateEnum(typeof(AudioLatencyMode), value);
+
+ int ret = Interop.Player.SetAudioLatencyMode(_handle, (int)value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the audio latency mode of the player");
+
+ _audioLatencyMode = value;
}
}
+ private bool _isLooping;
+
/// <summary>
- /// Set/Get the right volume level.
+ /// Gets or sets the looping state.
/// </summary>
- /// <value> 0 to 1.0 that indicates right volume level </value>
- public float RightVolume
+ /// <value>true if the playback is looping; otherwise, false. The default value is false.</value>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ public bool IsLooping
{
+ get
+ {
+ return _isLooping;
+ }
set
{
- int ret = Interop.Player.SetVolume(_playerHandle, value, value);
+ ValidateNotDisposed();
- if (ret == (int)PlayerError.None)
+ if (_isLooping == value)
{
- _rightVolume = value;
- }
- else
- {
- Log.Error(PlayerLog.LogTag, "Set volume failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "set volume failed");
+ return;
}
+
+ int ret = Interop.Player.SetLooping(_handle, value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the mute state of the player");
+
+ _isLooping = value;
+
}
- get
+ }
+
+ #region Display methods
+ private PlayerDisplay _display;
+
+ private int SetDisplay(PlayerDisplay display)
+ {
+ if (display == null)
+ {
+ return Interop.Player.SetDisplay(_handle, (int)PlayerDisplayType.None, IntPtr.Zero);
+ }
+
+ Debug.Assert(Enum.IsDefined(typeof(PlayerDisplayType), display.Type));
+ Debug.Assert(display.EvasObject != null);
+
+ return Interop.Player.SetDisplay(_handle, (int)display.Type, display.EvasObject);
+ }
+
+ private void ReplaceDisplay(PlayerDisplay newDisplay)
+ {
+ if (_display != null)
{
- //Interop.Player.GetVolume(_playerHandle, out _leftVolume, out _rightVolume);
- return _rightVolume;
+ _display.Player = null;
}
+
+ _display = newDisplay;
+ _display.Player = this;
}
/// <summary>
- /// Set/Get the Audio Latency Mode.
+ /// Gets or sets the display.
/// </summary>
- /// <value> Low, Mid, High </value>
- public AudioLatencyMode AudioLatencyMode
+ /// <value>A <see cref="PlayerDisplay"/> that specifies the display configurations.</value>
+ /// <remarks>The player must be in the <see cref="PlayerState.Idle"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="ArgumentException">The value has already been assigned to another player.</exception>
+ /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+ public PlayerDisplay Display
{
+ get
+ {
+ return _display;
+ }
set
{
- if (_audioLatencyMode != (int)value)
+ ValidatePlayerState(PlayerState.Idle);
+
+ if (value != null && value.Player != null)
{
- int ret = Interop.Player.SetAudioLatencyMode(_playerHandle, (int)value);
- if (ret != (int)PlayerError.None)
+ if (ReferenceEquals(this, value.Player))
{
- Log.Error(PlayerLog.LogTag, "Set audio latency mode failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "set audio latency mode failed");
+ return;
}
else
{
- _audioLatencyMode = (int)value;
+ throw new ArgumentException("The display has already been assigned to another player.");
}
}
+
+ PlayerErrorConverter.ThrowIfError(SetDisplay(value), "Failed to set the display to the player");
+
+ ReplaceDisplay(value);
}
+ }
+ #endregion
+ private PlayerTrackInfo _audioTrack;
+
+ /// <summary>
+ /// Gets the track info for audio.
+ /// </summary>
+ /// <value>A <see cref="PlayerTrackInfo"/> for audio.</value>
+ public PlayerTrackInfo AudioTrackInfo
+ {
get
{
- return (AudioLatencyMode)_audioLatencyMode;
+ if (_audioTrack == null)
+ {
+ _audioTrack = new PlayerTrackInfo(this, StreamType.Audio);
+ }
+ return _audioTrack;
}
}
+ private PlayerTrackInfo _subtitleTrackInfo;
+
/// <summary>
- /// Set/Get mute.
+ /// Gets the track info for subtitle.
/// </summary>
- /// <value> true, false </value>
- public bool Mute
+ /// <value>A <see cref="PlayerTrackInfo"/> for subtitle.</value>
+ public PlayerTrackInfo SubtitleTrackInfo
{
- set
+ get
{
- if (_mute != value)
+ if (_subtitleTrackInfo == null)
{
- int ret = Interop.Player.SetMute(_playerHandle, value);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Set mute failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "set mute failed");
- }
- else
- {
- _mute = value;
- }
+ _subtitleTrackInfo = new PlayerTrackInfo(this, StreamType.Text);
}
+ return _subtitleTrackInfo;
}
+ }
+
+ private StreamInfo _streamInfo;
+
+ /// <summary>
+ /// Gets the stream information.
+ /// </summary>
+ /// <value>A <see cref="StreamInfo"/> for this player.</value>
+ public StreamInfo StreamInfo
+ {
get
{
- //Interop.Player.IsMuted(_playerHandle, out _mute);
- return _mute;
+ if (_streamInfo == null)
+ {
+ _streamInfo = new StreamInfo(this);
+ }
+ return _streamInfo;
}
}
/// <summary>
- /// Set/Get Loop play.
+ /// Gets audio effect.
/// </summary>
- /// <value> true, false </value>
- public bool IsLooping
+ public AudioEffect AudioEffect { get; }
+
+ #endregion
+
+ #region Dispose support
+ private bool _disposed;
+
+ public void Dispose()
{
- set
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (!_disposed)
{
- if (_isLooping != value)
+ if (_source != null)
{
- int ret = Interop.Player.SetLooping(_playerHandle, value);
- if (ret != (int)PlayerError.None)
+ try
{
- Log.Error(PlayerLog.LogTag, "Set loop failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "set loop failed");
+ _source.DetachFrom(this);
}
- else
+ catch (Exception e)
{
- _isLooping = value;
+ Log.Error(nameof(Player), e.ToString());
}
}
+ _source = null;
+
+ if (_handle != IntPtr.Zero)
+ {
+ Interop.Player.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+ _disposed = true;
}
- get
+ }
+
+ internal void ValidateNotDisposed()
+ {
+ if (_disposed)
{
- //Interop.Player.IsLooping(_playerHandle, out _isLooping);
- return _isLooping;
+ throw new ObjectDisposedException(nameof(Player));
}
}
- /// <summary>
- /// Get play position.
- /// </summary>
- /// <value> play position in milli seconds </value>
- public int PlayPosition
+ internal bool IsDisposed
{
get
{
- int playPosition;
- int ret = Interop.Player.GetPlayPosition(_playerHandle, out playPosition);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get play position, " + (PlayerError)ret);
- }
- return playPosition;
+ return _disposed;
}
}
+ #endregion
+
+ #region Methods
/// <summary>
- /// Set/Get Display.
+ /// Gets the mute state.
/// </summary>
- /// <value> Display configuration </value>
- public Display Display
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ public bool IsMuted()
{
- set
- {
- _display = value;
- _display._playerHandle = _playerHandle;
- }
- get
- {
- return _display;
- }
+ ValidateNotDisposed();
+
+ bool value = false;
+ PlayerErrorConverter.ThrowIfError(Interop.Player.IsMuted(_handle, out value),
+ "Failed to get the mute state of the player");
+ return value;
}
/// <summary>
- /// Set/Get Subtitle.
+ /// Sets the mute state.
/// </summary>
- /// <value> Subtitle configuration </value>
- public Subtitle Subtitle
+ /// <param name="mute">true to mute the player; otherwise, false.</value>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ public void SetMute(bool mute)
{
- set
- {
- _subtitle = value;
- _subtitle._playerHandle = _playerHandle;
- _subtitle._subPath = _subtitle._path;
- }
- get
- {
- return _subtitle;
- }
+ ValidateNotDisposed();
+
+ int ret = Interop.Player.SetMute(_handle, mute);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the mute state of the player");
}
+ /// <summary>
+ /// Get Streaming download Progress.
+ /// </summary>
+ /// <remarks>The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <exception cref="InvalidOperationException">
+ /// The player is not streaming.
+ /// <para>-or-</para>
+ /// The player is not in the valid state.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ public DownloadProgress GetDownloadProgress()
+ {
+ ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);
+
+ int start = 0;
+ int current = 0;
+ int ret = Interop.Player.GetStreamingDownloadProgress(_handle, out start, out current);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to get download progress");
+
+ return new DownloadProgress(start, current);
+ }
+
+ #region Volume
+ private float _volume;
/// <summary>
- /// Get AudioEffect.
+ /// Sets the current volume.
/// </summary>
- /// <value> AudioEffect object </value>
- public AudioEffect AudioEffect
+ /// <remarks>Valid volume range is from 0 to 1.0, inclusive.</remarks>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// value is less than zero.
+ /// <para>-or-</para>
+ /// value is greater than 1.0.
+ /// </exception>
+ public void SetVolume(float value)
{
- get
+ ValidateNotDisposed();
+
+ if (value < 0F || 1.0F < value)
{
- return _audioEffect;
+ throw new ArgumentOutOfRangeException(nameof(value), value,
+ $"Valid volume range is 0 <= value <= 1.0, but got { value }.");
}
+
+ int ret = Interop.Player.SetVolume(_handle, value, value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the volume of the player");
}
/// <summary>
- /// Get stream information.
+ /// Gets the current volume.
/// </summary>
- /// <value> StreamInformation object </value>
- public StreamInformation StreamInformation
+ /// <remarks>the volume range is from 0 to 1.0, inclusive.</remarks>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ public float GetVolume()
{
- get
- {
- return _streamInformation;
- }
+ ValidateNotDisposed();
+
+ float value = 0.0F;
+ int ret = Interop.Player.GetVolume(_handle, out value, out value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to get the volume of the player");
+ return value;
}
+ #endregion
/// <summary>
- /// Get StreamingConfiguration.
+ /// Sets the subtitle path for playback.
/// </summary>
- /// <value> StreamingConfiguration object </value>
- public StreamingConfiguration StreamingConfiguration
+ /// <remarks>Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported.
+ /// <para>The mediastorage privilege(http://tizen.org/privilege/mediastorage) must be added if any files are used to play located in the internal storage.
+ /// The externalstorage privilege(http://tizen.org/privilege/externalstorage) must be added if any files are used to play located in the external storage.</para>
+ /// </remarks>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="ArgumentException">The specified path does not exist.</exception>
+ /// <exception cref="ArgumentNullException">The path is null.</exception>
+ public void SetSubtitle(string path)
{
- get
+ ValidateNotDisposed();
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
+ if (!File.Exists(path))
{
- return _streamingConfiguration;
+ throw new ArgumentException($"The specified file does not exist : { path }.");
}
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.SetSubtitlePath(_handle, path),
+ "Failed to set the subtitle path to the player");
}
+ /// <summary>
+ /// Removes the subtitle path.
+ /// </summary>
+ /// <remarks>The player must be in the <see cref="PlayerState.Idle"/> 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>
+ public void ClearSubtitle()
+ {
+ ValidatePlayerState(PlayerState.Idle);
- public void Dispose()
+ PlayerErrorConverter.ThrowIfError(Interop.Player.SetSubtitlePath(_handle, null),
+ "Failed to clear the subtitle of the player");
+ }
+
+ /// <summary>
+ /// Sets the offset for the subtitle.
+ /// </summary>
+ /// <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>
+ public void SetSubtitleOffset(int offset)
{
- Dispose(true);
- GC.SuppressFinalize(this);
+ ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.SetSubtitlePositionOffset(_handle, offset),
+ "Failed to the subtitle offset of the player");
+ }
+
+ private void Prepare()
+ {
+ int ret = Interop.Player.Prepare(_handle);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to prepare the player");
}
/// <summary>
- /// Prepares the media player for playback. </summary>
- public Task<bool> PrepareAsync()
+ /// Prepares the media player for playback, asynchronously.
+ /// </summary>
+ /// <remarks>To prepare the player, the player must be in the <see cref="PlayerState.Idle"/> state,
+ /// and a source must be set.</remarks>
+ /// <exception cref="InvalidOperationException">No source is set.</exception>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+ public Task PrepareAsync()
{
- int ret;
- var task = new TaskCompletionSource<bool>();
+ if (_source == null)
+ {
+ throw new InvalidOperationException("No source is set.");
+ }
+
+ ValidatePlayerState(PlayerState.Idle);
- Task.Factory.StartNew(() =>
+ var completionSource = new TaskCompletionSource<bool>();
+
+ SetPreparing();
+
+ Task.Run(() =>
{
- Interop.Player.PrepareCallback cb = (IntPtr userData) =>
+ try
{
- task.SetResult(true);
- return;
- };
- ret = Interop.Player.PrepareAsync(_playerHandle, cb, IntPtr.Zero);
- if (ret != (int)PlayerError.None)
+ Prepare();
+ ClearPreparing();
+ completionSource.SetResult(true);
+ }
+ catch (Exception e)
{
- task.SetResult(false);
- Log.Error(PlayerLog.LogTag, "Failed to prepare player" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to prepare player");
+ ClearPreparing();
+ completionSource.TrySetException(e);
}
});
- return task.Task;
+ return completionSource.Task;
}
/// <summary>
- /// The most recently used media is reset and no longer associated with the player. Playback is no longer possible.
- /// If you want to use the player again, you will have to set the data URI and call prepare() again. </summary>
+ /// Unprepares the player.
+ /// </summary>
+ /// <remarks>
+ /// The most recently used source is reset and no longer associated with the player. Playback is no longer possible.
+ /// If you want to use the player again, you have to set a source and call <see cref="PrepareAsync"/> again.
+ /// <para>
+ /// The player must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.
+ /// It has no effect if the player is already in the <see cref="PlayerState.Idle"/> state.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
public void Unprepare()
{
- int ret = Interop.Player.Unprepare(_playerHandle);
- if (ret != (int)PlayerError.None)
+ if (State == PlayerState.Idle)
{
- Log.Error(PlayerLog.LogTag, "Failed to unprepare player" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to unprepare player");
+ return;
}
+ ValidatePlayerState(PlayerState.Ready, PlayerState.Paused, PlayerState.Playing);
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.Unprepare(_handle),
+ "Failed to unprepare the player");
+
+ if (_source != null)
+ {
+ _source.DetachFrom(this);
+ }
+ _source = null;
}
+
+ //TODO remarks needs to be updated. see the native reference.
/// <summary>
- /// Starts or resumes playback. </summary>
+ /// Starts or resumes playback.
+ /// </summary>
+ /// <remarks>
+ /// The player must be in the <see cref="PlayerState.Ready"/> or <see cref="PlayerState.Paused"/> state.
+ /// It has no effect if the player is already in the <see cref="PlayerState.Playing"/> 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>
+ /// <seealso cref="PrepareAsync"/>
+ /// <seealso cref="Stop"/>
+ /// <seealso cref="Pause"/>
+ /// <seealso cref="PlaybackCompleted"/>
public void Start()
{
- int ret = Interop.Player.Start(_playerHandle);
- if (ret != (int)PlayerError.None)
+ if (State == PlayerState.Playing)
{
- Log.Error(PlayerLog.LogTag, "Failed to start player" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to start player");
+ return;
}
+ ValidatePlayerState(PlayerState.Ready, PlayerState.Paused);
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.Start(_handle), "Failed to start the player");
}
/// <summary>
- /// Stops playing media content. </summary>
+ /// Stops playing media content.
+ /// </summary>
+ /// <remarks>
+ /// The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.
+ /// It has no effect if the player is already in the <see cref="PlayerState.Ready"/> 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>
+ /// <seealso cref="Start"/>
+ /// <seealso cref="Pause"/>
public void Stop()
{
- int ret = Interop.Player.Stop(_playerHandle);
- if (ret != (int)PlayerError.None)
+ if (State == PlayerState.Ready)
{
- Log.Error(PlayerLog.LogTag, "Failed to stop player" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to stop player");
+ return;
}
+ ValidatePlayerState(PlayerState.Paused, PlayerState.Playing);
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.Stop(_handle), "Failed to stop the player");
}
/// <summary>
- /// Pauses the player. </summary>
+ /// Pauses the player.
+ /// </summary>
+ /// <remarks>
+ /// The player must be in the <see cref="PlayerState.Playing"/> state.
+ /// It has no effect if the player is already in the <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>
+ /// <seealso cref="Start"/>
public void Pause()
{
- int ret = Interop.Player.Pause(_playerHandle);
- if (ret != (int)PlayerError.None)
+ if (State == PlayerState.Paused)
{
- Log.Error(PlayerLog.LogTag, "Failed to pause player" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to pause player");
+ return;
}
+
+ ValidatePlayerState(PlayerState.Playing);
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.Pause(_handle), "Failed to pause the player");
}
+ private MediaSource _source;
+
/// <summary>
- /// sets media source for the player. </summary>
- /// <param name="source"> Mediasource </param>
+ /// Sets a media source for the player.
+ /// </summary>
+ /// <param name="source">A <see cref="MediaSource"/> that specifies the source for playback.</param>
+ /// <remarks>The player must be in the <see cref="PlayerState.Idle"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The player is not in the valid state.
+ /// <para>-or-</para>
+ /// It is not able to assign the source to the player.
+ /// </exception>
+ /// <seealso cref="PrepareAsync"/>
public void SetSource(MediaSource source)
{
- int ret;
- if (source.GetType() == typeof(MediaUriSource))
+ ValidatePlayerState(PlayerState.Idle);
+
+ if (source != null)
{
- ret = Interop.Player.SetUri(_playerHandle, ((MediaUriSource)source).GetUri());
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to seturi" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to set uri");
- }
+ source.AttachTo(this);
}
- else if (source.GetType() == typeof(MediaBufferSource))
+
+ if (_source != null)
{
- GCHandle pinnedArray = GCHandle.Alloc(((MediaBufferSource)source)._buffer, GCHandleType.Pinned);
- IntPtr mem = pinnedArray.AddrOfPinnedObject();
- ret = Interop.Player.SetMemoryBuffer(_playerHandle, mem, ((MediaBufferSource)source)._buffer.Length);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to set memory buffer" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to set memory buffer");
- }
+ _source.DetachFrom(this);
+ }
+
+ _source = source;
+ }
+
+ /// <summary>
+ /// Captures a video frame asynchronously.
+ /// </summary>
+ /// <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>
+ public Task<CapturedFrame> CaptureVideoAsync()
+ {
+ ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);
+
+ TaskCompletionSource<CapturedFrame> t = new TaskCompletionSource<CapturedFrame>();
+
+ Interop.Player.VideoCaptureCallback cb = (data, width, height, size, gchPtr) =>
+ {
+ Debug.Assert(size <= int.MaxValue);
+
+ byte[] buf = new byte[size];
+ Marshal.Copy(data, buf, 0, (int)size);
+
+ t.TrySetResult(new CapturedFrame(buf, width, height));
+
+ GCHandle.FromIntPtr(gchPtr).Free();
+ };
+
+ var gch = GCHandle.Alloc(cb);
+ try
+ {
+ PlayerErrorConverter.ThrowIfError(
+ Interop.Player.CaptureVideo(_handle, cb, GCHandle.ToIntPtr(gch)),
+ "Failed to capture the video");
}
- else if (source.GetType() == typeof(MediaStreamSource))
+ catch(Exception)
{
- // TODO: Handle MediaStream source after implementing MediaPacket module
- ((MediaStreamSource)source).SetHandle(_playerHandle);
+ gch.Free();
+ throw;
}
- }
+ return t.Task;
+ }
/// <summary>
- /// Captures a video frame asynchronously. </summary>
- public Task<VideoFrameCapture> CaptureVideoAsync()
+ /// Gets the play position in milliseconds.
+ /// </summary>
+ /// <remarks>The player must be in the <see cref="PlayerState.Ready"/>, <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>
+ /// <seealso cref="SetPlayPositionAsync(int, bool)"/>
+ public int GetPlayPosition()
{
- return Task.Factory.StartNew(() => CaptureVideoAsyncTask()).Result;
+ ValidatePlayerState(PlayerState.Ready, PlayerState.Paused, PlayerState.Playing);
+
+ int playPosition = 0;
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.GetPlayPosition(_handle, out playPosition),
+ "Failed to get the play position of the player");
+
+ return playPosition;
+ }
+
+ private void SetPlayPosition(int milliseconds, bool accurate,
+ Interop.Player.SeekCompletedCallback cb)
+ {
+ int ret = Interop.Player.SetPlayPosition(_handle, milliseconds, accurate, cb, IntPtr.Zero);
+
+ //Note that we assume invalid param error is returned only when the position value is invalid.
+ if (ret == (int)PlayerErrorCode.InvalidArgument)
+ {
+ throw new ArgumentOutOfRangeException(nameof(milliseconds), milliseconds,
+ "The position is not valid.");
+ }
+
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set play position");
}
/// <summary>
- ///Sets the seek position for playback, asynchronously. </summary>
- /// <param name="milliseconds"> Position to be set in milliseconds</param>
- /// <param name="accurate"> accurate seek or not</param>
- public Task<bool> SetPlayPositionAsync(int milliseconds, bool accurate)
+ /// Sets the seek position for playback, asynchronously.
+ /// </summary>
+ /// <param name="position">The value indicating a desired position in milliseconds.</param>
+ /// <param name="accurate">The value indicating whether the operation performs with accuracy.</param>
+ /// <remarks>
+ /// <para>The player must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</para>
+ /// <para>If the <paramref name="accurate"/> is true, the play position will be adjusted as the specified <paramref name="position"/> value,
+ /// but this might be considerably slow. If false, the play position will be a nearest keyframe position.</para>
+ /// </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="ArgumentOutOfRangeException">The specified position is not valid.</exception>
+ /// <seealso cref="GetPlayPosition"/>
+ public Task SetPlayPositionAsync(int position, bool accurate)
{
- var task = new TaskCompletionSource<bool>();
+ ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ var taskCompletionSource = new TaskCompletionSource<bool>();
- Task.Factory.StartNew(() =>
+ bool immediateResult = _source is MediaStreamSource;
+
+ Interop.Player.SeekCompletedCallback cb = _ => taskCompletionSource.TrySetResult(true);
+
+ SetPlayPosition(position, accurate, cb);
+ if (immediateResult)
{
- Interop.Player.SeekCompletedCallback cb = (IntPtr userData) =>
- {
- task.SetResult(true);
- return;
- };
- int ret = Interop.Player.SetPlayPosition(_playerHandle, milliseconds, accurate, cb, IntPtr.Zero);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to set playposition" + (PlayerError)ret);
- task.SetResult(false);
- PlayerErrorFactory.ThrowException(ret, "Failed to set playposition");
- }
- });
+ taskCompletionSource.TrySetResult(true);
+ }
- return task.Task;
+ return taskCompletionSource.Task;
}
/// <summary>
- /// sets playback rate </summary>
- /// <param name="rate"> playback rate -5.0x to 5.0x </param>
+ /// Sets playback rate.
+ /// </summary>
+ /// <param name="rate">The value for the playback rate. Valid range is -5.0 to 5.0, inclusive.</param>
+ /// <remarks>
+ /// <para>The player must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</para>
+ /// <para>The sound will be muted, when the playback rate is under 0.0 or over 2.0.</para>
+ /// </remarks>
+ /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The player is not in the valid state.
+ /// <para>-or-</para>
+ /// Streaming playback.
+ /// </exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="rate"/> is less than 5.0.
+ /// <para>-or-</para>
+ /// <paramref name="rate"/> is greater than 5.0.
+ /// <para>-or-</para>
+ /// <paramref name="rate"/> is zero.
+ /// </exception>
public void SetPlaybackRate(float rate)
{
- int ret = Interop.Player.SetPlaybackRate(_playerHandle, rate);
- if (ret != (int)PlayerError.None)
+ if (rate < -5.0F || 5.0F < rate || rate == 0.0F)
{
- Log.Error(PlayerLog.LogTag, "Set playback rate failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "set playback rate failed");
+ throw new ArgumentOutOfRangeException(nameof(rate), rate, "Valid range is -5.0 to 5.0 (except 0.0)");
}
+
+ ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.SetPlaybackRate(_handle, rate),
+ "Failed to set the playback rate.");
}
/// <summary>
- /// sets audio stream policy </summary>
- /// <param name="policy"> Audio Stream Policy </param>
- public void SetAudioStreamPolicy(AudioStreamPolicy policy)
+ /// Applies the audio stream policy.
+ /// </summary>
+ /// <param name="policy">The <see cref="AudioStreamPolicy"/> to apply.</param>
+ /// <remarks>The player must be in the <see cref="PlayerState.Idle"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">
+ /// The player has already been disposed of.
+ /// <para>-or-</para>
+ /// <paramref name="poilcy"/> has already been disposed of.
+ /// </exception>
+ /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+ /// <exception cref="ArgumentNullException"><paramref name="policy"/> is null.</exception>
+ public void ApplyAudioStreamPolicy(AudioStreamPolicy policy)
{
- int ret = Interop.Player.SetAudioPolicyInfo(_playerHandle, policy.Handle);
- if (ret != (int)PlayerError.None)
+ if (policy == null)
+ {
+ throw new ArgumentNullException(nameof(policy));
+ }
+
+ if (policy.Handle == IntPtr.Zero)
{
- Log.Error(PlayerLog.LogTag, "Set Audio stream policy failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Set Audio stream policy failed");
+ throw new ObjectDisposedException(nameof(policy));
}
+
+ ValidatePlayerState(PlayerState.Idle);
+
+ PlayerErrorConverter.ThrowIfError(Interop.Player.SetAudioPolicyInfo(_handle, policy.Handle),
+ "Failed to set the audio stream policy to the player");
}
+ #endregion
- protected virtual void Dispose(bool disposing)
+ #region Callback registrations
+ private void RegisterSubtitleUpdatedCallback()
{
- if (!_disposed)
+ _subtitleUpdatedCallback = (duration, text, _) =>
{
- if (disposing)
- {
- // To be used if there are any other disposable objects
- }
- if (_playerHandle != IntPtr.Zero)
- {
- Interop.Player.Destroy(_playerHandle);
- _playerHandle = IntPtr.Zero;
- }
- _disposed = true;
- }
+ SubtitleUpdated?.Invoke(this, new SubtitleUpdatedEventArgs(duration, text));
+ };
+
+ int ret = Interop.Player.SetSubtitleUpdatedCb(_handle, _subtitleUpdatedCallback, IntPtr.Zero);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the player");
}
- private void RegisterPlaybackCompletedEvent()
+ private void RegisterPlaybackCompletedCallback()
{
- _playbackCompletedCallback = (IntPtr userData) =>
+ _playbackCompletedCallback = _ =>
{
- PlaybackCompletedEventArgs eventArgs = new PlaybackCompletedEventArgs();
- _playbackCompleted?.Invoke(this, eventArgs);
+ PlaybackCompleted?.Invoke(this, EventArgs.Empty);
};
- int ret = Interop.Player.SetCompletedCb(_playerHandle, _playbackCompletedCallback, IntPtr.Zero);
- if (ret != (int)PlayerError.None)
+ int ret = Interop.Player.SetCompletedCb(_handle, _playbackCompletedCallback, IntPtr.Zero);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set PlaybackCompleted");
+ }
+
+ private void RegisterPlaybackInterruptedCallback()
+ {
+ _playbackInterruptedCallback = (code, _) =>
{
- Log.Error(PlayerLog.LogTag, "Setting PlaybackCompleted callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting PlaybackCompleted callback failed");
- }
+ if (!Enum.IsDefined(typeof(PlaybackIntrruptionReason), code))
+ {
+ return;
+ }
+ PlaybackInterrupted?.Invoke(this,
+ new PlaybackInterruptedEventArgs((PlaybackIntrruptionReason)code));
+ };
+ int ret = Interop.Player.SetInterruptedCb(_handle, _playbackInterruptedCallback, IntPtr.Zero);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set PlaybackInterrupted");
}
- private void UnregisterPlaybackCompletedEvent()
+ private void RegisterErrorOccuuredCallback()
{
- int ret = Interop.Player.UnsetCompletedCb(_playerHandle);
- if (ret != (int)PlayerError.None)
+ _playbackErrorCallback = (code, _) =>
{
- Log.Error(PlayerLog.LogTag, "Unsetting PlaybackCompleted callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Unsetting PlaybackCompleted callback failed");
- }
+ if (!Enum.IsDefined(typeof(PlayerError), code))
+ {
+ return;
+ }
+ //TODO handle service disconnected error.
+ ErrorOccurred?.Invoke(this, new PlayerErrorOccurredEventArgs((PlayerError)code));
+ };
+ int ret = Interop.Player.SetErrorCb(_handle, _playbackErrorCallback, IntPtr.Zero);
+ PlayerErrorConverter.ThrowIfError(ret, "Setting PlaybackError callback failed");
}
- private void RegisterPlaybackInterruptedEvent()
+ private void RegisterVideoFrameDecodedCallback()
{
- _playbackInterruptedCallback = (int code, IntPtr userData) =>
+ _videoFrameDecodedCallback = (packetHandle,_) =>
{
- PlaybackInterruptedEventArgs eventArgs = new PlaybackInterruptedEventArgs(code);
- _playbackInterrupted?.Invoke(this, eventArgs);
+ var handler = VideoFrameDecoded;
+ if (handler != null)
+ {
+ handler.Invoke(this,
+ new VideoFrameDecodedEventArgs(MediaPacket.From(packetHandle)));
+ }
+ else
+ {
+ MediaPacket.From(packetHandle).Dispose();
+ }
};
- int ret = Interop.Player.SetInterruptedCb(_playerHandle, _playbackInterruptedCallback, IntPtr.Zero);
- if (ret != (int)PlayerError.None)
+
+ int ret = Interop.Player.SetVideoFrameDecodedCb(_handle, _videoFrameDecodedCallback, IntPtr.Zero);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to register the VideoFrameDecoded");
+ }
+
+ private void RegisterVideoStreamChangedCallback()
+ {
+ ValidatePlayerState(PlayerState.Idle);
+
+ _videoStreamChangedCallback = (width, height, fps, bitrate, _) =>
{
- Log.Error(PlayerLog.LogTag, "Setting PlaybackInterrupted callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting PlaybackInterrupted callback failed");
- }
+ VideoStreamChangedEventArgs eventArgs = new VideoStreamChangedEventArgs(height, width, fps, bitrate);
+ VideoStreamChanged?.Invoke(this, eventArgs);
+ };
+ int ret = Interop.Player.SetVideoStreamChangedCb(GetHandle(), _videoStreamChangedCallback, IntPtr.Zero);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the video stream changed callback");
}
- private void UnregisterPlaybackInterruptedEvent()
+ private void RegisterBufferingCallback()
{
- int ret = Interop.Player.UnsetInterruptedCb(_playerHandle);
- if (ret != (int)PlayerError.None)
+ _bufferingProgressCallback = (percent, _) =>
{
- Log.Error(PlayerLog.LogTag, "Unsetting PlaybackInterrupted callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Unsetting PlaybackInterrupted callback failed");
- }
+ Log.Debug(nameof(Player), $"Buffering callback with percent { percent }");
+ BufferingProgressChanged?.Invoke(this, new BufferingProgressChangedEventArgs(percent));
+ };
+
+ int ret = Interop.Player.SetBufferingCb(_handle, _bufferingProgressCallback, IntPtr.Zero);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set BufferingProgress");
}
- private void RegisterPlaybackErrorEvent()
+ private void RegisterMediaStreamBufferStatusCallback()
{
- _playbackErrorCallback = (int code, IntPtr userData) =>
+ _mediaStreamAudioBufferStatusChangedCallback = (status, _) =>
{
- PlaybackErrorEventArgs eventArgs = new PlaybackErrorEventArgs(code);
- _playbackError?.Invoke(this, eventArgs);
+ Debug.Assert(Enum.IsDefined(typeof(MediaStreamBufferStatus), status));
+
+ MediaStreamAudioBufferStatusChanged?.Invoke(this,
+ new MediaStreamBufferStatusChangedEventArgs((MediaStreamBufferStatus)status));
};
- int ret = Interop.Player.SetErrorCb(_playerHandle, _playbackErrorCallback, IntPtr.Zero);
- if (ret != (int)PlayerError.None)
+ _mediaStreamVideoBufferStatusChangedCallback = (status, _) =>
{
- Log.Error(PlayerLog.LogTag, "Setting PlaybackError callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting PlaybackError callback failed");
- }
+ Debug.Assert(Enum.IsDefined(typeof(MediaStreamBufferStatus), status));
+ MediaStreamVideoBufferStatusChanged?.Invoke(this,
+ new MediaStreamBufferStatusChangedEventArgs((MediaStreamBufferStatus)status));
+ };
+
+ RegisterMediaStreamBufferStatusCallback(StreamType.Audio, _mediaStreamAudioBufferStatusChangedCallback);
+ RegisterMediaStreamBufferStatusCallback(StreamType.Video, _mediaStreamVideoBufferStatusChangedCallback);
}
- private void UnregisterPlaybackErrorEvent()
+ private void RegisterMediaStreamBufferStatusCallback(StreamType streamType,
+ Interop.Player.MediaStreamBufferStatusCallback cb)
{
- int ret = Interop.Player.UnsetErrorCb(_playerHandle);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Unsetting PlaybackError callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Unsetting PlaybackError callback failed");
- }
+ int ret = Interop.Player.SetMediaStreamBufferStatusCb(_handle, (int)streamType,
+ cb, IntPtr.Zero);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the player");
}
- private Task<VideoFrameCapture> CaptureVideoAsyncTask()
+ private void RegisterMediaStreamSeekCallback()
{
- TaskCompletionSource<VideoFrameCapture> t = new TaskCompletionSource<VideoFrameCapture>();
- Interop.Player.VideoCaptureCallback cb = (byte[] data, int width, int height, uint size, IntPtr userData) =>
+ _mediaStreamAudioSeekCallback = (offset, _) =>
{
- VideoFrameCapture v = new VideoFrameCapture(data, width, height, size);
- t.SetResult(v);
+ MediaStreamAudioSeekingOccurred?.Invoke(this, new MediaStreamSeekingOccurredEventArgs(offset));
};
-
- int ret = Interop.Player.CaptureVideo(_playerHandle, cb, IntPtr.Zero);
- if (ret != (int)PlayerError.None)
+ _mediaStreamVideoSeekCallback = (offset, _) =>
{
- Log.Error(PlayerLog.LogTag, "Failed to capture video" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Failed to capture video");
- }
- return t.Task;
+ MediaStreamVideoSeekingOccurred?.Invoke(this, new MediaStreamSeekingOccurredEventArgs(offset));
+ };
+
+ RegisterMediaStreamSeekCallback(StreamType.Audio, _mediaStreamAudioSeekCallback);
+ RegisterMediaStreamSeekCallback(StreamType.Video, _mediaStreamVideoSeekCallback);
}
+ private void RegisterMediaStreamSeekCallback(StreamType streamType, Interop.Player.MediaStreamSeekCallback cb)
+ {
+ int ret = Interop.Player.SetMediaStreamSeekCb(_handle, (int)streamType,
+ cb, IntPtr.Zero);
+
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the player");
+ }
+ #endregion
+ #region Preparing state
-#if _MEDIA_PACKET_
- //TODO: Uncomment this when MediaPacket is implemented
- private void RegisterVideoFrameDecodedEvent()
+ private int _isPreparing;
+
+ private bool IsPreparing()
{
- _videoFrameDecoded = (MediaPacket packet, IntPtr userData) =>
- {
- VideoFrameDecodedEventArgs eventArgs = new VideoFrameDecodedEventArgs();
- _videoFrameDecoded?.Invoke(this, eventArgs);
- };
- Interop.Player.SetErrorCb(_playerHandle, _videoFrameDecodedCallback, IntPtr.Zero);
+ return Interlocked.CompareExchange(ref _isPreparing, 1, 1) == 1;
}
- private void UnregisterVideoFrameDecodedEvent()
+ private void SetPreparing()
{
- Interop.Player.UnsetMediaPacketVideoFrameDecodedCb(_playerHandle);
+ Interlocked.Exchange(ref _isPreparing, 1);
}
-#endif
+ private void ClearPreparing()
+ {
+ Interlocked.Exchange(ref _isPreparing, 0);
+ }
+ #endregion
}
}
+++ /dev/null
-/// PlayerContentInfo
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// PlayerContentInfo
- /// </summary>
- /// <remarks>
- /// This class provides properties for metadata information of media file.
- /// </remarks>
-
- public class PlayerContentInfo
- {
- internal IntPtr _playerHandle;
-
- internal PlayerContentInfo()
- {
- }
-
- private string GetContentInfo(ContentInfoKey key)
- {
- IntPtr ptr = IntPtr.Zero;
-
- try
- {
- int ret = Interop.Player.GetContentInfo(_playerHandle, (int)key, out ptr);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get album info" + (PlayerError)ret);
- return "";
- }
-
- return Marshal.PtrToStringAnsi(ptr);
- }
- finally
- {
- Interop.Libc.Free(ptr);
- }
- }
-
- /// <summary>
- /// Metadata - Album
- /// </summary>
- /// <value> album string </value>
- public string Album
- {
- get
- {
- return GetContentInfo(ContentInfoKey.Album);
- }
- }
-
- /// <summary>
- /// Metadata - Artist
- /// </summary>
- /// <value> artist string </value>
- public string Artist
- {
- get
- {
- return GetContentInfo(ContentInfoKey.Artist);
- }
- }
-
- /// <summary>
- /// Metadata - Author
- /// </summary>
- /// <value> Author string </value>
- public string Author
- {
- get
- {
- return GetContentInfo(ContentInfoKey.Author);
- }
- }
-
- /// <summary>
- /// Metadata - Genre
- /// </summary>
- /// <value> genre string </value>
- public string Genre
- {
- get
- {
- return GetContentInfo(ContentInfoKey.Genre);
- }
- }
-
- /// <summary>
- /// Metadata - Title
- /// </summary>
- /// <value> title string </value>
- public string Title
- {
- get
- {
- return GetContentInfo(ContentInfoKey.Title);
- }
- }
-
- /// <summary>
- /// Metadata - Year
- /// </summary>
- /// <value> year string </value>
- public string Year
- {
- get
- {
- return GetContentInfo(ContentInfoKey.Year);
- }
- }
-
- }
-}
--- /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 System;
+using ElmSharp;
+
+namespace Tizen.Multimedia
+{
+ //TODO reimplementation needed
+ /// <summary>
+ /// Provides means to configure display settings for video <see cref="Player"/>.
+ /// </summary>
+ public class PlayerDisplay
+ {
+ private readonly EvasObject _evasObject;
+
+ private PlayerDisplay(PlayerDisplayType type, EvasObject evasObject)
+ {
+ if (evasObject == null)
+ {
+ throw new ArgumentNullException(nameof(evasObject));
+ }
+
+ if (evasObject == IntPtr.Zero)
+ {
+ throw new ArgumentException("The evas object is not realized.");
+ }
+
+ Type = type;
+ _evasObject = evasObject;
+ }
+
+ public PlayerDisplay(Window window) : this(PlayerDisplayType.Overlay, window)
+ {
+ }
+
+ public PlayerDisplay(ElmSharp.Image image) : this(PlayerDisplayType.Surface, image)
+ {
+ }
+
+ public EvasObject EvasObject
+ {
+ get
+ {
+ return _evasObject;
+ }
+ }
+
+ internal PlayerDisplayType Type { get; }
+
+ /// <summary>
+ /// Gets the player that the display is assigned to.
+ /// </summary>
+ public Player Player
+ {
+ get;
+ internal set;
+ }
+
+ private void ValidatePlayer()
+ {
+ if (Player == null)
+ {
+ throw new InvalidOperationException("The display is not assigned, yet.");
+ }
+
+ Player.ValidateNotDisposed();
+ }
+
+ private PlayerDisplayMode _displayMode = PlayerDisplayMode.LetterBox;
+
+ /// <summary>
+ /// Set/Get Display mode.
+ /// </summary>
+ /// <value> LetterBox, OriginalSize, FullScreen, CroppedFull, OriginalOrFull, DstRoi </value>
+ /// <exception cref="InvalidOperationException">
+ /// The display is not assigned.
+ /// <para>-or-</para>
+ /// Operation failed; internal error.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
+ /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
+ public PlayerDisplayMode Mode
+ {
+ get
+ {
+ return _displayMode;
+ }
+ set
+ {
+ ValidatePlayer();
+
+ if (_displayMode == value)
+ {
+ return;
+ }
+
+ ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
+
+ int ret = Interop.Player.SetDisplayMode(Player.GetHandle(), (int)value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set display mode");
+
+ _displayMode = value;
+ }
+ }
+
+ private bool _isVisible = true;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value></value>
+ /// <exception cref="InvalidOperationException">
+ /// The display is not assigned.
+ /// <para>-or-</para>
+ /// Operation failed; internal error.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
+ public bool IsVisible
+ {
+ get
+ {
+ return _isVisible;
+ }
+ set
+ {
+ ValidatePlayer();
+
+ if (_isVisible == value)
+ {
+ return;
+ }
+
+ int ret = Interop.Player.SetDisplayVisible(Player.GetHandle(), value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the visible state of the display");
+
+ _isVisible = value;
+ }
+ }
+
+ private PlayerDisplayRotation _rotation = PlayerDisplayRotation.RotationNone;
+
+ /// <summary>
+ /// Set/Get Display rotation.
+ /// </summary>
+ /// <value> RotationNone, Rotation90, Rotation180, Rotation270 </value>
+ /// <exception cref="InvalidOperationException">
+ /// The display is not assigned.
+ /// <para>-or-</para>
+ /// Operation failed; internal error.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
+ /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
+ public PlayerDisplayRotation Rotation
+ {
+ get
+ {
+ return _rotation;
+ }
+ set
+ {
+ ValidatePlayer();
+
+ if (_rotation == value)
+ {
+ return;
+ }
+
+ ValidationUtil.ValidateEnum(typeof(PlayerDisplayRotation), value);
+
+ int ret = Interop.Player.SetDisplayRotation(Player.GetHandle(), (int)value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the rotation state of the display");
+
+ _rotation = value;
+ }
+ }
+ }
+}
-using System;
+/*
+ * 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 System;
+using Tizen.Internals.Errors;
namespace Tizen.Multimedia
{
/// <summary>
- /// Enumeration for player state
+ /// Specifies errors.
/// </summary>
- public enum PlayerState
+ /// <seealso cref="Player.ErrorOccurred"/>
+ /// <seealso cref="PlayerErrorOccurredEventArgs"/>
+ public enum PlayerError
{
- /// <summary>
- /// Player is not created
- /// </summary>
- None,
+ NoSuchFile = ErrorCode.NoSuchFile,
+ InternalError = ErrorCode.InvalidOperation,
+ NoSpaceOnDevice = PlayerErrorCode.NoSpaceOnDevice,
+ FeatureNotSupported = ErrorCode.NotSupported,
+ PermissionDenied = ErrorCode.PermissionDenied,
+ BufferSpace = ErrorCode.BufferSpace,
+ SeekFailed = PlayerErrorCode.SeekFailed,
+ InvalidState = PlayerErrorCode.InvalidState,
+ NotSupportedFile = PlayerErrorCode.NotSupportedFile,
+ InvalidUri = PlayerErrorCode.InvalidUri,
+ SoundPolicy = PlayerErrorCode.SoundPolicyError,
+ ConnectionFailed = PlayerErrorCode.ConnectionFailed,
+ VideoCaptureFailed = PlayerErrorCode.VideoCaptureFailed,
+ DrmExpired = PlayerErrorCode.DrmExpired,
+ DrmNoLicense = PlayerErrorCode.DrmNoLicense,
+ DrmFutureUse = PlayerErrorCode.DrmFutureUse,
+ DrmNotPermitted = PlayerErrorCode.DrmNotPermitted,
+ ResourceLimit = PlayerErrorCode.ResourceLimit,
+ ServiceDisconnected = PlayerErrorCode.ServiceDisconnected
+ }
+ /// <summary>
+ /// Specifies states that a <see cref="Player"/> can have.
+ /// </summary>
+ public enum PlayerState
+ {
/// <summary>
- /// Player is created, but not prepared
+ /// Initial state, unprepared.
/// </summary>
- Idle,
+ /// <see cref="Player.Unprepare"/>
+ Idle = 1,
/// <summary>
- /// Player is ready to play media
+ /// Prepared.
/// </summary>
+ /// <see cref="Player.PrepareAsync"/>
Ready,
/// <summary>
- /// Player is playing media
+ /// Playing.
/// </summary>
+ /// <seealso cref="Player.Start"/>
Playing,
/// <summary>
- /// Player is paused while playing media
+ /// Paused while playing media.
/// </summary>
+ /// <seealso cref="Player.Pause"/>
Paused,
+
+
+ //TODO is this needed?
+ /// <summary>
+ /// Preparing in progress.
+ /// </summary>
+ /// <seealso cref="Player.PrepareAsync"/>/>
+ Preparing,
}
- /// <summary>
- /// Enumeration for player display type
- /// </summary>
- public enum DisplayType
+ internal static class PlayerStateExtensions
+ {
+ internal static bool IsAnyOf(this PlayerState thisState, params PlayerState[] states)
+ {
+ return Array.IndexOf(states, thisState) != -1;
+ }
+ }
+
+ internal enum PlayerDisplayType
{
/// <summary>
- /// Overlay surface display
+ /// Overlay surface display
/// </summary>
Overlay,
/// <summary>
- /// Evas image object surface display
+ /// Evas image object surface display
/// </summary>
- Evas,
+ Surface,
/// <summary>
- /// This disposes off buffers
+ /// This disposes off buffers
/// </summary>
None,
}
-
/// <summary>
- /// Enumeration for player audio latency mode
+ /// Specifies audio latency modes for <see cref="Player"/> .
/// </summary>
+ /// <seealso cref="Player.AudioLatencyMode"/>
public enum AudioLatencyMode
{
/// <summary>
- /// Low audio latency mode
+ /// Low audio latency mode.
/// </summary>
Low,
/// <summary>
- /// Middle audio latency mode
+ /// Middle audio latency mode.
/// </summary>
Mid,
/// <summary>
- /// High audio latency mode
+ /// High audio latency mode.
/// </summary>
High,
}
/// <summary>
- /// Enumeration for player display rotation
+ /// Specifies display rotation modes for <see cref="Player"/>.
/// </summary>
- public enum DisplayRotation
+ /// <seealso cref="PlayerDisplay.Rotation"/>
+ public enum PlayerDisplayRotation
{
/// <summary>
- /// Display is not rotated
+ /// Display is not rotated
/// </summary>
RotationNone,
/// <summary>
- /// Display is rotated 90 degrees
+ /// Display is rotated 90 degrees
/// </summary>
Rotation90,
/// <summary>
- /// Display is rotated 180 degrees
+ /// Display is rotated 180 degrees
/// </summary>
Rotation180,
/// <summary>
- /// Display is rotated 270 degrees
+ /// Display is rotated 270 degrees
/// </summary>
Rotation270
}
/// <summary>
- /// Enumeration for player display mode
+ /// Specifies display modes for <see cref="Player"/>
/// </summary>
- public enum DisplayMode
+ /// <seealso cref="PlayerDisplay.Mode"/>
+ public enum PlayerDisplayMode
{
/// <summary>
- /// Letter box
+ /// Letter box.
/// </summary>
LetterBox,
/// <summary>
- /// Origin size
+ /// Original size.
/// </summary>
OriginalSize,
/// <summary>
- /// Full-screen
+ /// Full-screen.
/// </summary>
FullScreen,
/// <summary>
- /// Cropped full-screen
+ /// Cropped full-screen.
/// </summary>
CroppedFull,
/// <summary>
- /// Origin size (if surface size is larger than video size(width/height)) or
- /// Letter box (if video size(width/height) is larger than surface size)
+ /// Origin size (if surface size is larger than video size(width/height)) or
+ /// Letter box (if video size(width/height) is larger than surface size).
/// </summary>
OriginalOrFull,
}
-
- /// <summary>
- /// Enumeration for player stream type
- /// </summary>
- public enum StreamType
+ internal enum StreamType
{
/// <summary>
- /// Container type
- /// </summary>
- Default,
-
- /// <summary>
- /// Audio element stream type
+ /// Audio element stream type
/// </summary>
- Audio,
+ Audio = 1,
/// <summary>
- /// Video element stream type
+ /// Video element stream type
/// </summary>
Video,
/// <summary>
- /// Text type
+ /// Text type
/// </summary>
Text
}
-
-
/// <summary>
- /// Enumeration for Progressive download message
+ /// Specifies the streaming buffer status.
/// </summary>
- public enum ProgressiveDownloadMessage
+ /// <seealso cref="MediaStreamConfiguration.BufferStatusChanged"/>
+ /// <seealso cref="MediaStreamBufferStatusChangedEventArgs"/>
+ public enum MediaStreamBufferStatus
{
/// <summary>
- /// Progressive download is started
+ /// Underrun.
/// </summary>
- Started,
+ Underrun,
/// <summary>
- /// Progressive download is completed
+ /// Completed.
/// </summary>
- Completed,
+ Overflow,
}
/// <summary>
- /// Streaming buffer status
+ /// Specifies the reason for the playback interruption.
/// </summary>
- public enum StreamingBufferStatus
+ /// <seealso cref="Player.PlaybackInterrupted"/>
+ public enum PlaybackIntrruptionReason
{
- /// <summary>
- /// Underrun
- /// </summary>
- Underrun,
-
- /// <summary>
- /// Completed
- /// </summary>
- Overflow,
+ ResourceConflict = 4
}
-
/// <summary>
- /// Enumeration for source type
+ /// Specifies keys for the metadata.
/// </summary>
- public enum PlayerSourceType
+ /// <seealso cref="StreamInfo.GetMetadata(StreamMetadataKey)"/>
+ public enum StreamMetadataKey
{
- /// <summary>
- /// Uri source
- /// </summary>
- Uri,
-
- /// <summary>
- /// memory buffer source
- /// </summary>
- Memory,
-
- /// <summary>
- /// stream source
- /// </summary>
- Stream,
+ Album,
+ Artist,
+ Author,
+ Genre,
+ Title,
+ Year
}
-
- /// <summary>
- /// Enumeration for Content info
- /// </summary>
- internal enum ContentInfoKey
- {
- Album,
- Artist,
- Author,
- Genre,
- Title,
- Year
- }
-
-
}
--- /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 System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Multimedia
+{
+ internal enum PlayerErrorCode
+ {
+ None = ErrorCode.None,
+ InvalidArgument = ErrorCode.InvalidParameter,
+ OutOfMemory = ErrorCode.OutOfMemory,
+ NoSuchFile = ErrorCode.NoSuchFile,
+ InvalidOperation = ErrorCode.InvalidOperation,
+ NoSpaceOnDevice = ErrorCode.FileNoSpaceOnDevice,
+ FeatureNotSupported = ErrorCode.NotSupported,
+ PermissionDenied = ErrorCode.PermissionDenied,
+ NoBufferSpace = ErrorCode.BufferSpace,
+ TizenPlayerError = -0x01940000,
+ PlayerErrorClass = TizenPlayerError | 0x20,
+ SeekFailed = PlayerErrorClass | 0x01,
+ InvalidState = PlayerErrorClass | 0x02,
+ NotSupportedFile = PlayerErrorClass | 0x03,
+ InvalidUri = PlayerErrorClass | 0x04,
+ SoundPolicyError = PlayerErrorClass | 0x05,
+ ConnectionFailed = PlayerErrorClass | 0x06,
+ VideoCaptureFailed = PlayerErrorClass | 0x07,
+ DrmExpired = PlayerErrorClass | 0x08,
+ DrmNoLicense = PlayerErrorClass | 0x09,
+ DrmFutureUse = PlayerErrorClass | 0x0a,
+ DrmNotPermitted = PlayerErrorClass | 0x0b,
+ ResourceLimit = PlayerErrorClass | 0x0c,
+ ServiceDisconnected = PlayerErrorClass | 0x0d
+ }
+
+ internal static class PlayerErrorConverter
+ {
+ internal static void ThrowIfError(int errorCode, string errorMessage)
+ {
+ if (errorCode == (int)PlayerErrorCode.None)
+ {
+ return;
+ }
+ PlayerErrorCode err = (PlayerErrorCode)errorCode;
+
+ string msg = $"{ (errorMessage ?? "Operation failed") } : { err.ToString() }.";
+
+ switch ((PlayerErrorCode)errorCode)
+ {
+ case PlayerErrorCode.InvalidArgument:
+ case PlayerErrorCode.InvalidUri:
+ case PlayerErrorCode.NoSuchFile:
+ throw new ArgumentException(msg);
+
+ case PlayerErrorCode.OutOfMemory:
+ case PlayerErrorCode.NoSpaceOnDevice:
+ throw new OutOfMemoryException(msg);
+
+ case PlayerErrorCode.PermissionDenied:
+ case PlayerErrorCode.InvalidOperation:
+ case PlayerErrorCode.InvalidState:
+ case PlayerErrorCode.FeatureNotSupported:
+ case PlayerErrorCode.SeekFailed:
+ case PlayerErrorCode.NotSupportedFile:
+ case PlayerErrorCode.ConnectionFailed:
+ case PlayerErrorCode.VideoCaptureFailed:
+ case PlayerErrorCode.DrmExpired:
+ case PlayerErrorCode.DrmNoLicense:
+ case PlayerErrorCode.DrmFutureUse:
+ case PlayerErrorCode.DrmNotPermitted:
+ throw new InvalidOperationException(msg);
+
+ case PlayerErrorCode.NoBufferSpace:
+ throw new NoBufferSpaceException(msg);
+
+ case PlayerErrorCode.ResourceLimit:
+ throw new ResouceLimitException(msg);
+ }
+
+ throw new Exception(msg);
+ }
+ }
+ /// <summary>
+ /// The exception that is thrown when there is no available space in a buffer.
+ /// </summary>
+ public class NoBufferSpaceException : InvalidOperationException
+ {
+ /// <summary>
+ /// Initializes a new instance of the NoBufferSpaceException class with a specified error message.
+ /// </summary>
+ /// <param name="message">Error description.</param>
+ public NoBufferSpaceException(string message) : base(message)
+ {
+ }
+ }
+
+ /// <summary>
+ /// The exception that is thrown when there is no available resource for internal use.
+ /// </summary>
+ public class ResouceLimitException : InvalidOperationException
+ {
+ /// <summary>
+ /// Initializes a new instance of the ResouceLimitException class with a specified error message.
+ /// </summary>
+ /// <param name="message">Error description.</param>
+ public ResouceLimitException(string message) : base(message)
+ {
+ }
+ }
+}
+
+++ /dev/null
-/// Player Error factory
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.using System;
-///
-
-using System;
-using Tizen.Internals.Errors;
-
-namespace Tizen.Multimedia
-{
- internal enum PlayerError
- {
- None = ErrorCode.None,
- InvalidParameter = ErrorCode.InvalidParameter,
- OutOfMemory = ErrorCode.OutOfMemory,
- NoSuchFile = ErrorCode.NoSuchFile,
- InvalidOperation = ErrorCode.InvalidOperation,
- NoSpaceOnDevice = ErrorCode.FileNoSpaceOnDevice,
- FeatureNotSupported = ErrorCode.NotSupported,
- PermissionDenied = ErrorCode.PermissionDenied,
- BufferSpace = ErrorCode.BufferSpace,
- TizenPlayerError = -0x01940000,
- PlayerErrorClass = TizenPlayerError | 0x20,
- SeekFailed = PlayerErrorClass | 0x01,
- InvalidState = PlayerErrorClass | 0x02,
- FileNotSupported = PlayerErrorClass | 0x03,
- InvalidUri = PlayerErrorClass | 0x04,
- SoundPolicyError = PlayerErrorClass | 0x05,
- ConnectionFailed = PlayerErrorClass | 0x06,
- VideoCaptureFailed = PlayerErrorClass | 0x07,
- DrmExpired = PlayerErrorClass | 0x08,
- DrmNoLicense = PlayerErrorClass | 0x09,
- DrmFutureUse = PlayerErrorClass | 0x0a,
- DrmNotPermitted = PlayerErrorClass | 0x0b,
- ResourceLimit = PlayerErrorClass | 0x0c,
- ServiceDisconnected = PlayerErrorClass | 0x0d
- };
-
- internal static class PlayerErrorFactory
- {
- internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null)
- {
- PlayerError err = (PlayerError) errorCode;
- if(string.IsNullOrEmpty(errorMessage))
- {
- errorMessage = err.ToString();
- }
- switch((PlayerError)errorCode)
- {
- case PlayerError.InvalidParameter:
- throw new ArgumentException(errorMessage, paramName);
-
- case PlayerError.InvalidState:
- case PlayerError.OutOfMemory:
- case PlayerError.NoSuchFile:
- case PlayerError.InvalidOperation:
- case PlayerError.NoSpaceOnDevice:
- case PlayerError.FeatureNotSupported:
- case PlayerError.SeekFailed:
- case PlayerError.FileNotSupported:
- case PlayerError.InvalidUri:
- case PlayerError.SoundPolicyError:
- case PlayerError.ConnectionFailed:
- case PlayerError.VideoCaptureFailed:
- case PlayerError.DrmExpired:
- case PlayerError.DrmNoLicense:
- case PlayerError.DrmFutureUse:
- case PlayerError.DrmNotPermitted:
- case PlayerError.ResourceLimit:
- case PlayerError.PermissionDenied:
- throw new InvalidOperationException(errorMessage);
- }
- }
- }
-}
-
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
using System;
-namespace Tizen.Multimedia.MediaCodec
+namespace Tizen.Multimedia
{
/// <summary>
- /// Provides data for the <see cref="MediaCodec.EosReached"/> event.
+ /// Provides data for the <see cref="Player.ErrorOccurred"/> event.
/// </summary>
- public class EosReachedEventArgs : EventArgs
+ public class PlayerErrorOccurredEventArgs : EventArgs
{
/// <summary>
- /// Initializes a new instance of the EosReachedEventArgs class.
+ /// Initialize a new instance of the PlayerErrorOccurredEventArgs class.
/// </summary>
- public EosReachedEventArgs()
+ /// <param name="error">The value indicating what kind of error occurred.</param>
+ public PlayerErrorOccurredEventArgs(PlayerError error)
+ {
+ Error = error;
+ }
+
+ /// <summary>
+ /// Gets the error.
+ /// </summary>
+ public PlayerError Error { get; }
+
+ public override string ToString()
{
+ return $"Error : { Error }";
}
}
}
--- /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 System;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// Provides means to retrieve track information.
+ /// </summary>
+ /// <seealso cref="Player.SubtitleTrackInfo"/>
+ /// <seealso cref="Player.AudioTrackInfo"/>
+ public class PlayerTrackInfo
+ {
+ private readonly int _streamType;
+ private readonly Player _owner;
+
+ internal PlayerTrackInfo(Player player, StreamType streamType)
+ {
+ Debug.Assert(player != null);
+
+ _streamType = (int)streamType;
+ _owner = player;
+ }
+
+ /// <summary>
+ /// Gets the number of tracks.
+ /// </summary>
+ /// <returns>The number of tracks.</returns>
+ /// <remarks>The <see cref="Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
+ public int GetCount()
+ {
+ _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ int count = 0;
+ int ret = Interop.Player.GetTrackCount(_owner.GetHandle(), _streamType, out count);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the track of the player");
+
+ return count;
+ }
+
+ /// <summary>
+ /// Gets the language code for the specified index or null if the language is undefined.
+ /// </summary>
+ /// <returns>The number of tracks.</returns>
+ /// <remarks>
+ /// <para>The <see cref="Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</para>
+ /// <para>The language codes are defined in ISO 639-1.</para>
+ /// </remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// index is less than zero.
+ /// <para>-or-</para>
+ /// index is equal to or greater than <see cref="GetCount()"/>
+ /// </exception>
+ public string GetLanguageCode(int index)
+ {
+ _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ if (index < 0 || GetCount() <= index)
+ {
+ throw new ArgumentOutOfRangeException(nameof(index), index,
+ $"valid index range is 0 <= x < {nameof(GetCount)}(), but got { index }.");
+ }
+
+ IntPtr code = IntPtr.Zero;
+
+ try
+ {
+ int ret = Interop.Player.GetTrackLanguageCode(
+ _owner.GetHandle(), _streamType, index, out code);
+
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to get the selected index of the player");
+
+ string result = Marshal.PtrToStringAnsi(code);
+
+ if (result == "und")
+ {
+ return null;
+ }
+
+ return result;
+ }
+ finally
+ {
+ Interop.Libc.Free(code);
+ }
+ }
+
+ /// <summary>
+ /// Gets the selected track index.
+ /// </summary>
+ /// <returns>The currently selected track index.</returns>
+ /// <remarks>The <see cref="Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
+ public int GetSelected()
+ {
+ _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ int value = 0;
+ int ret = Interop.Player.GetCurrentTrack(_owner.GetHandle(), _streamType, out value);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to get the selected index of the player");
+
+ return value;
+ }
+
+ /// <summary>
+ /// Selects the track.
+ /// </summary>
+ /// <param name="index">The index to select.</param>
+ /// <remarks>The <see cref="Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// index is less than zero.
+ /// <para>-or-</para>
+ /// index is equal to or greater than <see cref="GetCount()"/>
+ /// </exception>
+ public void SetSelected(int index)
+ {
+ if (index < 0 || GetCount() <= index)
+ {
+ throw new ArgumentOutOfRangeException(nameof(index), index,
+ $"valid index range is 0 <= x < {nameof(GetCount)}(), but got { index }.");
+ }
+
+ _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ int ret = Interop.Player.SelectTrack(_owner.GetHandle(), _streamType, index);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to set the selected index of the player");
+ }
+
+ }
+}
+++ /dev/null
-/// This File contains ProgressiveDownloadMessageEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-namespace Tizen.Multimedia
-{
-
- /// <summary>
- /// ProgressiveDownloadMessage event arguments
- /// </summary>
- /// <remarks>
- /// ProgressiveDownloadMessage event arguments
- /// </remarks>
- public class ProgressiveDownloadMessageEventArgs : EventArgs
- {
- internal ProgressiveDownloadMessage _message;
-
- /// <summary>
- /// Constructor
- /// </summary>
- internal ProgressiveDownloadMessageEventArgs(ProgressiveDownloadMessage message)
- {
- _message = message;
- }
-
- /// <summary>
- /// Get Progressive download message.
- /// </summary>
- /// <value> 0 - 100 </value>
- public ProgressiveDownloadMessage Message
- {
- get
- {
- return _message;
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/// Progressive Download Status
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-namespace Tizen.Multimedia
-{
-
- /// <summary>
- /// DownloadProgress
- /// </summary>
- /// <remarks>
- /// Contains Progressive download status. ProgressiveDownloadStatus object is null initially.
- /// It is created only when playback starts.
- /// </remarks>
- public class ProgressiveDownloadStatus
- {
- internal ulong _current;
- internal ulong _totalSize;
-
- internal ProgressiveDownloadStatus(ulong current, ulong totalSize)
- {
- _current = current;
- _totalSize = totalSize;
- }
-
- /// <summary>
- /// Get current download position (bytes)
- /// </summary>
- /// <value> current download position </value>
- public ulong Current
- {
- get
- {
- return _current;
- }
- }
-
- /// <summary>
- /// Get total size of the file (bytes)
- /// </summary>
- /// <value> Total size of file (bytes) </value>
- public ulong TotalSize
- {
- get
- {
- return _totalSize;
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/// This File contains SeekOffsetEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-namespace Tizen.Multimedia
-{
-
- /// <summary>
- /// SeekOffset event arguments
- /// </summary>
- /// <remarks>
- /// SeekOffset event arguments
- /// </remarks>
- public class SeekOffsetEventArgs : EventArgs
- {
- internal UInt64 _offset;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- internal SeekOffsetEventArgs(UInt64 offset)
- {
- _offset = offset;
- }
-
- /// <summary>
- /// Get seek offset.
- /// </summary>
- /// <value> byte position to seek </value>
- public UInt64 Offset
- {
- get
- {
- return _offset;
- }
- }
-
- }
-}
\ No newline at end of file
--- /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 System;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// Represents properties for audio stream.
+ /// </summary>
+ public struct AudioStreamProperties
+ {
+ /// <summary>
+ /// Initialize a new instance of the AudioStreamProperties struct with the specified sample rate, channels and bit rate.
+ /// </summary>
+ public AudioStreamProperties(int sampleRate, int channels, int bitRate)
+ {
+ SampleRate = sampleRate;
+ Channels = channels;
+ BitRate = bitRate;
+ }
+
+ /// <summary>
+ /// Gets or sets the sample rate.
+ /// </summary>
+ /// <value>The audio sample rate(Hz).</value>
+ public int SampleRate
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Gets or sets the channels.
+ /// </summary>
+ public int Channels
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Gets or sets the bit rate.
+ /// </summary>
+ /// <value>The audio bit rate(Hz).</value>
+ public int BitRate
+ {
+ get;
+ set;
+ }
+
+ public override string ToString()
+ {
+ return $"SampleRate : { SampleRate }, Channels : { Channels }, BitRate : { BitRate }";
+ }
+ }
+
+ /// <summary>
+ /// Represents properties for video stream.
+ /// </summary>
+ public struct VideoStreamProperties
+ {
+ /// <summary>
+ /// Initialize a new instance of the VideoStreamProperties struct with the specified fps, bit rate and size.
+ /// </summary>
+ public VideoStreamProperties(int fps, int bitRate, Size size)
+ {
+ Fps = fps;
+ BitRate = bitRate;
+ Size = size;
+ }
+ /// <summary>
+ /// Initialize a new instance of the VideoStreamProperties struct with the specified fps, bit rate, width and height.
+ /// </summary>
+ public VideoStreamProperties(int fps, int bitRate, int width, int height)
+ {
+ Fps = fps;
+ BitRate = bitRate;
+ Size = new Size(width, height);
+ }
+
+ /// <summary>
+ /// Gets or sets the fps.
+ /// </summary>
+ public int Fps
+ {
+ get;
+ set;
+ }
+ /// <summary>
+ /// Gets or sets the bit rate.
+ /// </summary>
+ public int BitRate
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Gets or sets the size.
+ /// </summary>
+ public Size Size
+ {
+ get;
+ set;
+ }
+
+ public override string ToString()
+ {
+ return $"Fps : { Fps }, BitRate : { BitRate }, Size : [{ Size }]";
+ }
+ }
+
+
+ /// <summary>
+ /// Provides means to retrieve stream information
+ /// </summary>
+ public class StreamInfo
+ {
+ internal StreamInfo(Player owner)
+ {
+ Player = owner;
+ }
+
+ /// <summary>
+ /// Retrieves the album art of the stream or null if there is no album art data.
+ /// </summary>
+ /// <remarks>The <see cref="Multimedia.Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="Multimedia.Player"/> that this instance belongs to has been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.</exception>
+ public byte[] GetAlbumArt()
+ {
+ Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ int size;
+ IntPtr art;
+ int ret = Interop.Player.GetAlbumArt(Player.GetHandle(), out art, out size);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to get the album art");
+
+ if (art == IntPtr.Zero || size == 0)
+ {
+ return null;
+ }
+
+ byte[] albumArt = new byte[size];
+ Marshal.Copy(art, albumArt, 0, size);
+ return albumArt;
+ }
+
+ private string GetCodecInfo(bool audioInfo)
+ {
+ Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ IntPtr audioPtr = IntPtr.Zero;
+ IntPtr videoPtr = IntPtr.Zero;
+ try
+ {
+ int ret = Interop.Player.GetCodecInfo(Player.GetHandle(), out audioPtr, out videoPtr);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to get codec info");
+
+ if (audioInfo)
+ {
+ return Marshal.PtrToStringAnsi(audioPtr);
+ }
+ else
+ {
+ return Marshal.PtrToStringAnsi(videoPtr);
+ }
+ }
+ finally
+ {
+ Interop.Libc.Free(audioPtr);
+ Interop.Libc.Free(videoPtr);
+ }
+ }
+
+ /// <summary>
+ /// Retrieves the codec name of audio or null if there is no audio.
+ /// </summary>
+ public string GetAudioCodec()
+ {
+ return GetCodecInfo(true);
+ }
+
+ /// <summary>
+ /// Retrieves the codec name of video or null if there is no video.
+ /// </summary>
+ public string GetVideoCodec()
+ {
+ return GetCodecInfo(false);
+ }
+
+
+ /// <summary>
+ /// Gets the duration.
+ /// </summary>
+ /// <remarks>The <see cref="Multimedia.Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="Multimedia.Player"/> that this instance belongs to has been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.</exception>
+ public int GetDuration()
+ {
+ Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ int duration = 0;
+ PlayerErrorConverter.ThrowIfError(Interop.Player.GetDuration(Player.GetHandle(), out duration),
+ "Failed to get the duration");
+ return duration;
+ }
+
+ /// <summary>
+ /// Gets the properties of audio.
+ /// </summary>
+ /// <remarks>The <see cref="Multimedia.Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="Multimedia.Player"/> that this instance belongs to has been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.</exception>
+ public AudioStreamProperties GetAudioProperies()
+ {
+ Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ int sampleRate = 0;
+ int channels = 0;
+ int bitRate = 0;
+
+ int ret = Interop.Player.GetAudioStreamInfo(Player.GetHandle(),
+ out sampleRate, out channels, out bitRate);
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to get audio stream info");
+
+ // TODO should we check value is zero and return null?
+
+ return new AudioStreamProperties(sampleRate, channels, bitRate);
+ }
+
+ /// <summary>
+ /// Gets the properties of video.
+ /// </summary>
+ /// <remarks>The <see cref="Multimedia.Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="Multimedia.Player"/> that this instance belongs to has been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.</exception>
+ public VideoStreamProperties GetVideoProperties()
+ {
+ Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ int fps = 0;
+ int bitRate = 0;
+ int ret = Interop.Player.GetVideoStreamInfo(Player.GetHandle(), out fps, out bitRate);
+
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to get the video info");
+
+ // TODO should we check value is zero and return null?
+
+ return new VideoStreamProperties(fps, bitRate, GetVideoSize());
+ }
+
+ private Size GetVideoSize()
+ {
+ Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ int height = 0;
+ int width = 0;
+ int ret = Interop.Player.GetVideoSize(Player.GetHandle(), out width, out height);
+
+ PlayerErrorConverter.ThrowIfError(ret, "Failed to get the video size");
+
+ return new Size(width, height);
+ }
+
+ /// <summary>
+ /// Gets the metadata with the specified key.
+ /// </summary>
+ /// <param name="key">The key to query.</param>
+ /// <remarks>The <see cref="Multimedia.Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="Multimedia.Player"/> that this instance belongs to has been disposed.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.</exception>
+ public string GetMetadata(StreamMetadataKey key)
+ {
+ Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ ValidationUtil.ValidateEnum(typeof(StreamMetadataKey), key);
+
+ IntPtr ptr = IntPtr.Zero;
+
+ try
+ {
+ int ret = Interop.Player.GetContentInfo(Player.GetHandle(), (int)key, out ptr);
+ PlayerErrorConverter.ThrowIfError(ret, $"Failed to get the meta data with the key '{ key }'");
+
+
+ return Marshal.PtrToStringAnsi(ptr);
+ }
+ finally
+ {
+ Interop.Libc.Free(ptr);
+ }
+ }
+
+ /// <summary>
+ /// Gets the <see cref="Multimedia.Player"/> that owns this instance.
+ /// </summary>
+ public Player Player { get; }
+ }
+}
+++ /dev/null
-/// Audio Stream Information
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-using System.Runtime.InteropServices;
-
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// Stream information
- /// </summary>
- /// <remarks>
- /// This class provides properties and API that are required for fetching
- /// metadata of a media stream.
- /// </remarks>
- public class StreamInformation
- {
- internal IntPtr _playerHandle;
- internal PlayerContentInfo _contentInfo;
-
- internal StreamInformation()
- {
- }
-
- /// <summary>
- /// Get album art.
- /// </summary>
- /// <value> byte[] </value>
- public byte[] AlbumArt
- {
- get
- {
- int ret, size;
- IntPtr art;
- ret = Interop.Player.GetAlbumArt(_playerHandle, out art, out size);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get album art" + (PlayerError)ret);
- Console.WriteLine("GetAlbumArt() failed " + ret);
- }
- else
- {
- byte[] albumArt;
- albumArt = new byte[size];
- Marshal.Copy(art, albumArt, 0, size);
- return albumArt;
- }
- return null;
- }
- }
-
- /// <summary>
- /// Get AudioCodec.
- /// </summary>
- /// <value> AudioCodec string </value>
- public string AudioCodec
- {
- get
- {
- IntPtr audioCodec = IntPtr.Zero, videoCodec = IntPtr.Zero;
- try
- {
- int ret = Interop.Player.GetCodecInfo(_playerHandle, out audioCodec, out videoCodec);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get codec info" + (PlayerError)ret);
- }
-
- return Marshal.PtrToStringAnsi(audioCodec);
- }
- finally
- {
- Interop.Libc.Free(audioCodec);
- Interop.Libc.Free(videoCodec);
- }
- }
- }
-
- /// <summary>
- /// Get Duration.
- /// </summary>
- /// <value> duration in milliseconds </value>
- public int Duration
- {
- get
- {
- int duration;
- int ret = Interop.Player.GetDuration(_playerHandle, out duration);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get duration info" + (PlayerError)ret);
- }
- return duration;
- }
- }
-
- /// <summary>
- /// Get Sample rate.
- /// </summary>
- /// <value> The audio sample rate [Hz] </value>
- public int AudioSampleRate
- {
- get
- {
- int sampleRate, channels, bitRate;
- int ret = Interop.Player.GetAudioStreamInfo(_playerHandle, out sampleRate, out channels, out bitRate);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get audio stream info" + (PlayerError)ret);
- }
- return sampleRate;
- }
- }
-
- /// <summary>
- /// Channels
- /// </summary>
- /// <value> The audio channels </value>
- public int AudioChannels
- {
- get
- {
- int sampleRate, channels, bitRate;
- int ret = Interop.Player.GetAudioStreamInfo(_playerHandle, out sampleRate, out channels, out bitRate);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get audio channels info" + (PlayerError)ret);
- }
- return channels;
- }
- }
-
- /// <summary>
- /// Audio bit rate.
- /// </summary>
- /// <value> bit rate [Hz] </value>
- public int AudioBitRate
- {
- get
- {
- int sampleRate, channels, bitRate;
- int ret = Interop.Player.GetAudioStreamInfo(_playerHandle, out sampleRate, out channels, out bitRate);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get audio bitrate info" + (PlayerError)ret);
- }
- return bitRate;
- }
- }
-
-
- /// <summary>
- /// VideoCodec
- /// </summary>
- /// <value> video codec string </value>
- public string VideoCodec
- {
- get
- {
- IntPtr audioCodec = IntPtr.Zero, videoCodec = IntPtr.Zero;
- try
- {
- int ret = Interop.Player.GetCodecInfo(_playerHandle, out audioCodec, out videoCodec);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get codec info" + (PlayerError)ret);
- }
- return Marshal.PtrToStringAnsi(videoCodec);
- }
- finally
- {
- Interop.Libc.Free(audioCodec);
- Interop.Libc.Free(videoCodec);
- }
- }
- }
-
- /// <summary>
- /// FPS
- /// </summary>
- /// <value> int Frames per second</value>
- public int VideoFps
- {
- get
- {
- int fps, bitRate;
- int ret = Interop.Player.GetVideoStreamInfo(_playerHandle, out fps, out bitRate);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get video fps info" + (PlayerError)ret);
- }
- return fps;
- }
- }
-
- /// <summary>
- /// Video bit rate.
- /// </summary>
- /// <value> bit rate [Hz] </value>
- public int VideoBitRate
- {
- get
- {
- int fps, bitRate;
- int ret = Interop.Player.GetVideoStreamInfo(_playerHandle, out fps, out bitRate);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get video bitrate info" + (PlayerError)ret);
- }
- return bitRate;
- }
- }
-
- /// <summary>
- /// Get Video Height.
- /// </summary>
- /// <value> video height </value>
- public int VideoHeight
- {
- get
- {
- int height, width;
- int ret = Interop.Player.GetVideoSize(_playerHandle, out width, out height);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get video height" + (PlayerError)ret);
- }
- return height;
- }
- }
-
- /// <summary>
- /// Get Video Width.
- /// </summary>
- /// <value> video width </value>
- public int VideoWidth
- {
- get
- {
- int height, width;
- int ret = Interop.Player.GetVideoSize(_playerHandle, out width, out height);
- if (ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Failed to get video width" + (PlayerError)ret);
- }
- return width;
- }
- }
-
- /// <summary>
- /// Get Player content info.
- /// </summary>
- /// <value> metadata </value>
- public PlayerContentInfo ContentInfo
- {
- get
- {
- return _contentInfo;
- }
- }
-
- }
-}
+++ /dev/null
-/// Streaming configuration
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// Streaming configuration
- /// </summary>
- /// <remarks>
- /// This class provides properties and API that are required for streaming
- /// playback operations.
- /// </remarks>
- public class StreamingConfiguration
- {
- internal IntPtr _playerHandle;
- internal string _cookie;
- internal string _userAgent;
- internal string _progressiveDownloadPath;
- private EventHandler<BufferingProgressEventArgs> _bufferingProgress;
- private Interop.Player.BufferingProgressCallback _bufferingProgressCallback;
- private EventHandler<ProgressiveDownloadMessageEventArgs> _pdMessage;
- private Interop.Player.ProgressiveDownloadMessageCallback _pdMessageCallback;
- private EventHandler<VideoStreamEventArgs> _videoStreamChanged;
- private Interop.Player.VideoStreamChangedCallback _videoStreamChangedCallback;
-
-
- internal StreamingConfiguration(IntPtr handle)
- {
- _playerHandle = handle;
- }
-
-
- /// <summary>
- /// BufferingProgressChanged event is raised when there is a change in the buffering status of a media stream
- /// </summary>
- public event EventHandler<BufferingProgressEventArgs> BufferingProgressChanged
- {
- add
- {
- if(_bufferingProgress == null) {
- RegisterBufferingProgressEvent();
- }
- _bufferingProgress += value;
- }
- remove
- {
- _bufferingProgress -= value;
- if(_bufferingProgress == null) {
- UnregisterBufferingProgressEvent();
- }
- }
- }
-
- /// <summary>
- /// ProgressiveDownloadMessageChanged event is raised when progressive download is started or completed.
- /// </summary>
- public event EventHandler<ProgressiveDownloadMessageEventArgs> ProgressiveDownloadMessageChanged
- {
- add
- {
- if(_pdMessage == null) {
- RegisterProgressiveDownloadMessageEvent();
- }
- _pdMessage += value;
- }
- remove
- {
- _pdMessage -= value;
- if(_pdMessage == null) {
- UnregisterProgressiveDownloadMessageEvent();
- }
- }
- }
-
- /// <summary>
- /// Video stream changed event is raised to notify the video stream changed.
- /// </summary>
- public event EventHandler<VideoStreamEventArgs> VideoStreamChanged
- {
- add
- {
- if(_videoStreamChanged == null) {
- RegisterVideoStreamChangedEvent();
- }
- _videoStreamChanged += value;
- }
- remove
- {
- _videoStreamChanged -= value;
- if(_videoStreamChanged == null) {
- UnregisterVideoStreamChanged();
- }
- }
- }
-
- /// <summary>
- /// Set/Get Progressive download path.
- /// </summary>
- /// <value> path string </value>
- public string ProgressiveDownloadPath
- {
- set
- {
- int ret = Interop.Player.SetProgressiveDownloadPath(_playerHandle, value);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Setting progressive download path failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting progressive download path failed");
- }
- _progressiveDownloadPath = value;
- }
- get
- {
- return _progressiveDownloadPath;
- }
- }
-
- /// <summary>
- /// Get Streaming download Progress.
- /// </summary>
- /// <value> download progress int start and current [0 to 100] </value>
- public DownloadProgress DownloadProgress
- {
- get
- {
- DownloadProgress progress = null;
- int start, current;
- int ret = Interop.Player.GetStreamingDownloadProgress(_playerHandle, out start, out current);
- if(ret == (int)PlayerError.None)
- {
- progress = new DownloadProgress(start, current);
- }
- else
- {
- Log.Error(PlayerLog.LogTag, "Getting download progress failed" + (PlayerError)ret);
- }
- return progress;
- }
- }
-
- /// <summary>
- /// Get progressive download status.
- /// </summary>
- /// <value> progressive download status ulong current and total size </value>
- public ProgressiveDownloadStatus ProgressiveDownloadStatus
- {
- get
- {
- ProgressiveDownloadStatus status = null;
- ulong current, totalSize;
- int ret = Interop.Player.GetProgressiveDownloadStatus(_playerHandle, out current, out totalSize);
- if(ret == (int)PlayerError.None)
- {
- status = new ProgressiveDownloadStatus(current, totalSize);
- }
- else
- {
- Log.Error(PlayerLog.LogTag, "Getting progressive download status failed" + (PlayerError)ret);
- }
-
- return status;
- }
- }
-
- /// <summary>
- /// Set/Get cookie.
- /// </summary>
- /// <value> cookie string </value>
- public string Cookie
- {
- set
- {
- int ret = Interop.Player.SetStreamingCookie(_playerHandle, value, value.Length + 1);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Setting cookie failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting cookie failed");
- }
- _cookie = value;
- }
- get
- {
- return _cookie;
- }
- }
-
- /// <summary>
- /// Set/Get User agent.
- /// </summary>
- /// <value> user agent string </value>
- public string UserAgent
- {
- set
- {
- int ret = Interop.Player.SetStreamingUserAgent(_playerHandle, value, value.Length + 1);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Setting user agent failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting user agent failed");
- }
- _userAgent = value;
- }
- get
- {
- return _userAgent;
- }
- }
-
-
- private void RegisterBufferingProgressEvent()
- {
- _bufferingProgressCallback = (int percent, IntPtr userData) =>
- {
- BufferingProgressEventArgs eventArgs = new BufferingProgressEventArgs(percent);
- _bufferingProgress?.Invoke(this, eventArgs);
- };
-
- int ret = Interop.Player.SetBufferingCb(_playerHandle, _bufferingProgressCallback, IntPtr.Zero);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Setting Buffering callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting Buffering callback failed");
- }
-
- }
-
- private void UnregisterBufferingProgressEvent()
- {
- int ret = Interop.Player.UnsetBufferingCb(_playerHandle);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Unsetting Buffering callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Unsetting Buffering callback failed");
- }
-
- }
- private void RegisterProgressiveDownloadMessageEvent()
- {
- _pdMessageCallback = (int type, IntPtr userData) =>
- {
- ProgressiveDownloadMessageEventArgs eventArgs = new ProgressiveDownloadMessageEventArgs((ProgressiveDownloadMessage)type);
- _pdMessage?.Invoke(this, eventArgs);
- };
- int ret = Interop.Player.SetProgressiveDownloadMessageCb(_playerHandle, _pdMessageCallback, IntPtr.Zero);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Setting progressive download callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting progressive download callback failed");
- }
- }
-
- private void UnregisterProgressiveDownloadMessageEvent()
- {
- int ret = Interop.Player.UnsetProgressiveDownloadMessageCb(_playerHandle);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Unsetting progressive download callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Unsetting progressive download callback failed");
- }
-
- }
-
- private void RegisterVideoStreamChangedEvent()
- {
- _videoStreamChangedCallback = (int width, int height, int fps, int bitrate, IntPtr userData) =>
- {
- VideoStreamEventArgs eventArgs = new VideoStreamEventArgs(height, width, fps, bitrate);
- _videoStreamChanged?.Invoke(this, eventArgs);
- };
- int ret = Interop.Player.SetVideoStreamChangedCb(_playerHandle, _videoStreamChangedCallback, IntPtr.Zero);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Setting video stream changed callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting video stream changed callback failed");
- }
- }
-
- private void UnregisterVideoStreamChanged()
- {
- int ret = Interop.Player.UnsetVideoStreamChangedCb(_playerHandle);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Unsetting video stream changed callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Unsetting video stream changed callback failed");
- }
- }
- }
-}
+++ /dev/null
-/// Subtitle
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-using System.Collections.Generic;
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// Subtitle
- /// </summary>
- /// <remarks>
- /// This class provides properties and events that are required for subtitle
- /// during playback.
- ///
- /// Note: Newly created subtitle has to be set to the 'Subtitle' property of the player object.
- /// Else, operations on subtitle object do not work.
- /// </remarks>
- public class Subtitle
- {
- internal IntPtr _playerHandle;
- internal string _path;
-
- internal string _subPath
- {
- set
- {
- int ret = Interop.Player.SetSubtitlePath(_playerHandle, value);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Setting subtitle path failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting subtitle path failed");
- }
- }
- }
-
-
-
- private EventHandler<SubtitleUpdatedEventArgs> _subtitleUpdated;
- private Interop.Player.SubtitleUpdatedCallback _subtitleUpdatedCallback;
-
- /// <summary>
- /// Subtitle Constructor.
- /// Note: Newly created subtitle has to be set to the 'Subtitle' property of the player object.
- /// Else, operations on subtitle object do not work. </summary>
- /// <param name="path"> subtitle path </param>
- public Subtitle(string path)
- {
- _path = path;
- }
-
- /// <summary>
- /// Subtitle event is raised when the subtitle is updated
- /// </summary>
- public event EventHandler<SubtitleUpdatedEventArgs> Updated
- {
- add
- {
- if(_subtitleUpdated == null)
- {
- RegisterSubtitleUpdatedEvent();
- }
- _subtitleUpdated += value;
- }
- remove
- {
- _subtitleUpdated -= value;
- if(_subtitleUpdated == null)
- {
- UnregisterSubtitleUpdatedEvent();
- }
- }
- }
-
- /// <summary>
- /// Set position offset.
- /// </summary>
- /// <value> position in milli seconds </value>
- public int Position
- {
- set
- {
- int ret = Interop.Player.SetSubtitlePositionOffset(_playerHandle, value);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Setting position offset failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting position offset failed");
- }
- }
- }
-
-
- /// <summary>
- /// Get Text track.
- /// </summary>
- /// <value> Text track list </value>
- public IEnumerable<SubtitleTrack> TextTrack
- {
- get
- {
- string langCode;
- int curTrack;
- int ret;
- int tracks = 0;
- List<SubtitleTrack> textTrack = new List<SubtitleTrack>();
-
- ret = Interop.Player.GetTrackCount(_playerHandle, (int)StreamType.Text, out tracks);
- if(ret == (int)PlayerError.None)
- {
- ret = Interop.Player.GetCurrentTrack(_playerHandle, (int)StreamType.Text, out curTrack);
- if(ret == (int)PlayerError.None && tracks > 0)
- {
- for(int idx = 0; idx < tracks; idx++)
- {
- bool activated = (curTrack == idx ? true : false);
- ret = Interop.Player.GetTrackLanguageCode(_playerHandle, (int)StreamType.Text, idx, out langCode);
- if(ret == (int)PlayerError.None)
- {
- SubtitleTrack st = new SubtitleTrack(langCode, activated);
- textTrack.Add(st);
- } else
- {
- Log.Error(PlayerLog.LogTag, "Getting text track language code failed" + (PlayerError)ret);
- }
- }
- } else
- {
- Log.Error(PlayerLog.LogTag, "Getting current track index failed" + (PlayerError)ret);
- }
- } else
- {
- Log.Error(PlayerLog.LogTag, "Getting track count failed" + (PlayerError)ret);
- }
-
- return textTrack;
- }
- }
-
- /// <summary>
- /// Get Audio track.
- /// </summary>
- /// <value> Audio track list </value>
- public IEnumerable<SubtitleTrack> AudioTrack
- {
- get
- {
- string langCode;
- int curTrack;
- int ret;
- int tracks = 0;
- List<SubtitleTrack> audioTrack = new List<SubtitleTrack>();
-
- ret = Interop.Player.GetTrackCount(_playerHandle, (int)StreamType.Audio, out tracks);
- if(ret == (int)PlayerError.None)
- {
- ret = Interop.Player.GetCurrentTrack(_playerHandle, (int)StreamType.Audio, out curTrack);
- if(ret == (int)PlayerError.None && tracks > 0)
- {
- for(int idx = 0; idx < tracks; idx++)
- {
- bool activated = (curTrack == idx ? true : false);
- ret = Interop.Player.GetTrackLanguageCode(_playerHandle, (int)StreamType.Audio, idx, out langCode);
- if(ret == (int)PlayerError.None)
- {
- SubtitleTrack st = new SubtitleTrack(langCode, activated);
- audioTrack.Add(st);
- } else
- {
- Log.Error(PlayerLog.LogTag, "Getting audio track language code failed" + (PlayerError)ret);
- }
- }
- } else
- {
- Log.Error(PlayerLog.LogTag, "Getting audio track index failed" + (PlayerError)ret);
- }
- } else
- {
- Log.Error(PlayerLog.LogTag, "Getting audio track count failed" + (PlayerError)ret);
- }
-
- return audioTrack;
- }
- }
-
- /// <summary>
- /// Get video track.
- /// </summary>
- /// <value> video track list </value>
- public IEnumerable<SubtitleTrack> VideoTrack
- {
- get
- {
- string langCode;
- int curTrack;
- int ret;
- int tracks = 0;
- List<SubtitleTrack> videoTrack = new List<SubtitleTrack>();
-
- ret = Interop.Player.GetTrackCount(_playerHandle, (int)StreamType.Video, out tracks);
- if(ret == (int)PlayerError.None)
- {
- ret = Interop.Player.GetCurrentTrack(_playerHandle, (int)StreamType.Video, out curTrack);
- if(ret == (int)PlayerError.None && tracks > 0)
- {
- for(int idx = 0; idx < tracks; idx++)
- {
- bool activated = (curTrack == idx ? true : false);
- ret = Interop.Player.GetTrackLanguageCode(_playerHandle, (int)StreamType.Video, idx, out langCode);
- if(ret == (int)PlayerError.None)
- {
- SubtitleTrack st = new SubtitleTrack(langCode, activated);
- videoTrack.Add(st);
- } else
- {
- Log.Error(PlayerLog.LogTag, "Getting video track language code failed" + (PlayerError)ret);
- }
- }
- } else
- {
- Log.Error(PlayerLog.LogTag, "Getting video track index failed" + (PlayerError)ret);
- }
- } else
- {
- Log.Error(PlayerLog.LogTag, "Getting video track count failed" + (PlayerError)ret);
- }
-
- return videoTrack;
- }
- }
-
- private void RegisterSubtitleUpdatedEvent()
- {
- _subtitleUpdatedCallback = (uint duration, string text, IntPtr userData) =>
- {
- SubtitleUpdatedEventArgs eventArgs = new SubtitleUpdatedEventArgs(duration, text);
- _subtitleUpdated?.Invoke(this, eventArgs);
- };
- int ret = Interop.Player.SetSubtitleUpdatedCb(_playerHandle, _subtitleUpdatedCallback, IntPtr.Zero);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Setting subtitle updated callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Setting subtitle updated callback failed");
- }
-
- }
-
- private void UnregisterSubtitleUpdatedEvent()
- {
- int ret = Interop.Player.UnsetSubtitleUpdatedCb(_playerHandle);
- if(ret != (int)PlayerError.None)
- {
- Log.Error(PlayerLog.LogTag, "Unsetting subtitle updated callback failed" + (PlayerError)ret);
- PlayerErrorFactory.ThrowException(ret, "Unsetting subtitle updated callback failed");
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/// Subtitle track
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-using System;
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// SubtitleTrack
- /// </summary>
- /// <remarks>
- /// This class provides properties for subtitle tracks.
- /// </remarks>
-
- public class SubtitleTrack
- {
- internal string _languageCode;
- internal bool _activated;
-
- /// <summary>
- /// SubtitleTrack Constructor.
- /// </summary>
- /// <param name="code"> Language code string </param>
- /// <param name="activated"> subtitle activated true/false </param>
- public SubtitleTrack(string code, bool activated)
- {
- _languageCode = code;
- _activated = activated;
- }
-
- /// <summary>
- /// Get/Set Language code.
- /// </summary>
- /// <value> language code string </value>
- public string LanguageCode
- {
- set
- {
- _languageCode = value;
- }
- get
- {
- return _languageCode;
- }
- }
-
- /// <summary>
- /// Get/Set activation status.
- /// </summary>
- /// <value> true, false </value>
- public bool Activated
- {
- set
- {
- _activated = value;
- }
- get
- {
- return _activated;
- }
- }
-
- }
-}
-/// This File contains SubtitleUpdatedEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
+/*
+ * 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 System;
namespace Tizen.Multimedia
{
-
/// <summary>
- /// SubtitleUpdated event arguments
+ /// Provides data for the <see cref="Player.SubtitleUpdated"/> event.
/// </summary>
- /// <remarks>
- /// SubtitleUpdated event arguments
- /// </remarks>
public class SubtitleUpdatedEventArgs : EventArgs
{
- internal uint _duration;
- internal string _text;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- internal SubtitleUpdatedEventArgs(uint duration, string text)
- {
- _duration = duration;
- _text = text;
- }
+ internal SubtitleUpdatedEventArgs(uint duration, string text)
+ {
+ Duration = duration;
+ Text = text;
+ }
/// <summary>
- /// The duration of the updated subtitle .
+ /// Gets the he duration of the updated subtitl .
/// </summary>
- /// <value> ulong duration</value>
- public uint Duration
- {
- get
- {
- return _duration;
- }
- }
+ public uint Duration { get; }
/// <summary>
- /// The text of the updated subtitle .
+ /// Gets the text of the updated subtitle.
/// </summary>
/// <value> string </value>
- public string Text
+ public string Text { get; }
+
+ public override string ToString()
{
- get
- {
- return _text;
- }
+ return $"Duration : { Duration }, Text : { Text }";
}
-
}
-}
\ No newline at end of file
+}
+++ /dev/null
-/// VideoFrameCapture
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-using System;
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// VideoFrameCapture
- /// </summary>
- /// <remarks>
- /// VideoSize class provides properties of a captured video frame
- /// </remarks>
- public class VideoFrameCapture
- {
- internal byte[] _imageBuffer;
- internal int _width;
- internal int _height;
- internal uint _size;
-
- /// <summary>
- /// Constructor
- /// </summary>
- internal VideoFrameCapture(byte[] imageBuffer, int width, int height, uint size)
- {
- _imageBuffer = imageBuffer;
- _width = width;
- _height = height;
- _size = size;
- }
-
-
- /// <summary>
- /// Get ImageBuffer.
- /// </summary>
- /// <value> Image buffer </value>
- public byte[] ImageBuffer
- {
- get
- {
- return _imageBuffer;
- }
- }
-
- /// <summary>
- /// Get width.
- /// </summary>
- /// <value> Image width </value>
- public int Width
- {
- get
- {
- return _width;
- }
- }
-
- /// <summary>
- /// Get height.
- /// </summary>
- /// <value> Image Height </value>
- public int Height
- {
- get
- {
- return _height;
- }
- }
-
- /// <summary>
- /// Get Size.
- /// </summary>
- /// <value> Size of the image </value>
- public uint Size
- {
- get
- {
- return _size;
- }
- }
- }
-}
-/// This File contains VideoFrameDecodedEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
+/*
+ * 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 System;
namespace Tizen.Multimedia
{
-
/// <summary>
- /// VideoFrameDecoded event arguments
+ /// Provides data for the <see cref="Player.VideoFrameDecoded"/> event.
/// </summary>
- /// <remarks>
- /// VideoFrameDecoded event arguments
- /// </remarks>
public class VideoFrameDecodedEventArgs : EventArgs
{
- // TODO: uncomment when MediaPacket is implemented.
- //internal MediaPacket _packet;
+ /// <summary>
+ /// Initialize a new instance of the VideoFrameDecodedEventArgs class.
+ /// </summary>
+ internal VideoFrameDecodedEventArgs(MediaPacket packet)
+ {
+ Packet = packet;
+ }
- internal VideoFrameDecodedEventArgs()
- {
- }
- /// <summary>
- /// Get the Image buffer.
+ /// <summary>
+ /// Gets the packet containing the decoded frame.
/// </summary>
- /// <value> integer error code</value>
- //public MediaPacket Packet
- //{
- // get
- // {
- // return _packet;
- // }
- //}
+ public MediaPacket Packet { get; }
}
-}
\ No newline at end of file
+}
--- /dev/null
+/// This File contains VideoStreamEventArgs class
+///
+/// Copyright 2016 by Samsung Electronics, Inc.,
+/*
+ * 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 System;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// Provides data for the <see cref="Player.VideoStreamChanged"/> event.
+ /// </summary>
+ public class VideoStreamChangedEventArgs : EventArgs
+ {
+
+ /// <summary>
+ /// Initialize a new instance of the VideoStreamChangedEventArgs class.
+ /// </summary>
+ internal VideoStreamChangedEventArgs(int height, int width, int fps, int bitrate)
+ {
+ Size = new Size(width, height);
+ Fps = fps;
+ BitRate = bitrate;
+ }
+
+ /// <summary>
+ /// Gets the <see cref="Size"/> of new video.
+ /// </summary>
+ public Size Size { get; }
+
+ /// <summary>
+ /// Gets the fps of new video
+ /// </summary>
+ public int Fps { get; }
+
+ /// <summary>
+ /// Gets the bit rate of new video.
+ /// </summary>
+ public int BitRate { get; }
+
+ public override string ToString()
+ {
+ return $"Size : ({ Size }), Fps : { Fps }, BitRate : { BitRate }";
+ }
+ }
+}
+++ /dev/null
-/// This File contains VideoStreamEventArgs class
-///
-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-
-namespace Tizen.Multimedia
-{
-
- /// <summary>
- /// VideoStreamEventArgs event arguments
- /// </summary>
- /// <remarks>
- /// VideoStreamEventArgs event arguments
- /// </remarks>
- public class VideoStreamEventArgs : EventArgs
- {
- internal int _height;
- internal int _width;
- internal int _fps;
- internal int _bitrate;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- internal VideoStreamEventArgs(int height, int width, int fps, int bitrate)
- {
- _height = height;
- _width = width;
- _fps = fps;
- _bitrate = bitrate;
- }
-
- /// <summary>
- /// Get Video Height.
- /// </summary>
- /// <value> video height </value>
- public int Height
- {
- get
- {
- return _height;
- }
- }
-
- /// <summary>
- /// Get Video Width.
- /// </summary>
- /// <value> video width </value>
- public int Width
- {
- get
- {
- return _width;
- }
- }
-
- /// <summary>
- /// FPS
- /// </summary>
- /// <value> int Frames per second</value>
- public int Fps
- {
- get
- {
- return _fps;
- }
- }
-
- /// <summary>
- /// Bit rate.
- /// </summary>
- /// <value> bit rate [Hz] </value>
- public int BitRate
- {
- get
- {
- return _bitrate;
- }
- }
-
- }
-}
\ No newline at end of file
/// <summary>
/// Successful
/// </summary>
- None,
+ None = SCMirroringErrorCode.None,
/// <summary>
/// Invalid parameter
/// </summary>
- InvalidParameter,
- /// <summary>
- /// Out of memory
- /// </summary>
- OutOfMemory,
+ InvalidParameter = SCMirroringErrorCode.InvalidParameter,
/// <summary>
/// Invalid operation
/// </summary>
- InvalidOperation,
- /// <summary>
- /// Connection timeout
- /// </summary>
- ConnectionTimeOut,
- /// <summary>
- /// Permission denied
- /// </summary>
- PermissionDenied,
- /// <summary>
- /// Not supported
- /// </summary>
- NotSupported,
- /// <summary>
- /// Unknown error
- /// </summary>
- Unknown
+ InvalidOperation = SCMirroringErrorCode.InvalidOperation
}
-}
\ No newline at end of file
+}
* limitations under the License.
*/
-using System;
-
+using System;
+using Tizen.Internals.Errors;
namespace Tizen.Multimedia
{
+ internal enum SCMirroringErrorCode
+ {
+ None = ErrorCode.None,
+ InvalidParameter = ErrorCode.InvalidParameter,
+ OutOfMemory = ErrorCode.OutOfMemory,
+ InvalidOperation = ErrorCode.InvalidOperation,
+ ConnectionTimeOut = ErrorCode.ConnectionTimeout,
+ PermissionDenied = ErrorCode.PermissionDenied,
+ NotSupported = ErrorCode.NotSupported,
+ Unknown = ErrorCode.Unknown
+ };
public class ScreenMirroringErrorFactory
{
internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null)
{
- SCMirroringError err = (SCMirroringError)errorCode;
+ SCMirroringErrorCode err = (SCMirroringErrorCode)errorCode;
if (string.IsNullOrEmpty(errorMessage))
{
errorMessage = err.ToString();
}
- switch ((SCMirroringError)errorCode)
+ switch ((SCMirroringErrorCode)errorCode)
{
- case SCMirroringError.InvalidParameter:
+ case SCMirroringErrorCode.InvalidParameter:
throw new ArgumentException(errorMessage, paramName);
- case SCMirroringError.OutOfMemory:
- case SCMirroringError.InvalidOperation:
- case SCMirroringError.ConnectionTimeOut:
- case SCMirroringError.PermissionDenied:
- case SCMirroringError.NotSupported:
- case SCMirroringError.Unknown:
+ case SCMirroringErrorCode.OutOfMemory:
+ case SCMirroringErrorCode.InvalidOperation:
+ case SCMirroringErrorCode.ConnectionTimeOut:
+ case SCMirroringErrorCode.PermissionDenied:
+ case SCMirroringErrorCode.NotSupported:
+ case SCMirroringErrorCode.Unknown:
throw new InvalidOperationException(errorMessage);
}
}
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="AudioIO\AudioErrorHelper.cs" />
- <Compile Include="AudioIO\AudioInput.cs" />
- <Compile Include="AudioIO\AudioIOEnumerations.cs" />
- <Compile Include="AudioIO\AudioOutput.cs" />
- <Compile Include="AudioIO\AudioStateChangedEventArgs.cs" />
- <Compile Include="AudioIO\AudioStreamLengthChangedEventArgs.cs" />
- <Compile Include="AudioIO\BaseAudio.cs" />
+ <Compile Include="AudioIO\AudioCapture.cs" />\r
+ <Compile Include="AudioIO\AudioDataAvailableEvetnArgs.cs" />\r
+ <Compile Include="AudioIO\AudioIOEnums.cs" />\r
+ <Compile Include="AudioIO\AudioIOStateChangedEventArgs.cs" />\r
+ <Compile Include="AudioIO\AudioIOUtil.cs" />\r
+ <Compile Include="AudioIO\AudioPlaybackBufferAvailableEventArgs.cs" />\r
+ <Compile Include="AudioIO\AudioPlyaback.cs" />
<Compile Include="Camera\Area.cs" />
<Compile Include="Camera\Camera.cs" />
<Compile Include="Camera\CameraDisplay.cs" />
<Compile Include="Camera\Range.cs" />
<Compile Include="Camera\SinglePlaneData.cs" />
<Compile Include="Camera\TriplePlaneData.cs" />
+ <Compile Include="Common\MultimediaDebug.cs" />\r
+ <Compile Include="Common\Size.cs" />
+ <Compile Include="Common\ValdiationUtil.cs" />\r
<Compile Include="Interop\Interop.AudioIO.cs" />
<Compile Include="Interop\Interop.Camera.cs" />
<Compile Include="Interop\Interop.CameraDisplay.cs" />
<Compile Include="Interop\Interop.CameraSetting.cs" />
<Compile Include="Interop\Interop.MediaCodec.cs" />
<Compile Include="Interop\Interop.MediaTool.cs" />
- <Compile Include="Interop\Interop.EvasObject.cs" />
<Compile Include="Interop\Interop.MediaVision.BarCode.cs" />
<Compile Include="Interop\Interop.MediaVision.Common.cs" />
<Compile Include="Interop\Interop.MediaVision.Face.cs" />
<Compile Include="Interop\Interop.MediaVision.Image.cs" />
<Compile Include="Interop\Interop.MediaVision.Surveillance.cs" />
<Compile Include="Interop\Interop.Player.cs" />
- <Compile Include="MediaCodec\BufferStatusChangedEventArgs.cs" />
- <Compile Include="MediaCodec\EosReachedEventArgs.cs" />
- <Compile Include="MediaCodec\ErrorOccurredEventArgs.cs" />
+ <Compile Include="Interop\Interop.MetadataExtractor.cs" />
+ <Compile Include="MediaCodec\BufferStatusChangedEventArgs.cs" />
<Compile Include="MediaCodec\InputProcessedEventArgs.cs" />
<Compile Include="MediaCodec\MediaCodec.cs" />
- <Compile Include="MediaCodec\MediaCodecDebug.cs" />
<Compile Include="MediaCodec\MediaCodecError.cs" />
+ <Compile Include="MediaCodec\MediaCodecErrorOccurredEventArgs.cs" />\r
<Compile Include="MediaCodec\MediaCodecStatus.cs" />
<Compile Include="MediaCodec\MediaCodecType.cs" />
<Compile Include="MediaCodec\OutputAvailableEventArgs.cs" />
<Compile Include="MediaTool\MediaPacketBuffer.cs" />
<Compile Include="MediaTool\MediaPacketBufferFlags.cs" />
<Compile Include="MediaTool\MediaPacketVideoPlane.cs" />
- <Compile Include="MediaTool\MediaToolDebug.cs" />
- <Compile Include="MediaTool\NotEnoughMemoryException.cs" />
- <Compile Include="MediaView\MediaView.cs" />
<Compile Include="MediaVision\Barcode.cs" />
<Compile Include="MediaVision\BarcodeDetector.cs" />
<Compile Include="MediaVision\BarcodeDetectorEngineConfiguration.cs" />
<Compile Include="MediaVision\SurveillanceEventTrigger.cs" />
<Compile Include="MediaVision\TargetAttribute.cs" />
<Compile Include="MediaVision\TextAttribute.cs" />
- <Compile Include="Player\PlayerEnums.cs" />
- <Compile Include="Player\MediaStreamConfiguration.cs" />
- <Compile Include="Player\SubtitleTrack.cs" />
- <Compile Include="Player\AudioEffect.cs" />
- <Compile Include="Player\BufferingProgressChangedEventArgs.cs" />
- <Compile Include="Player\BufferStatusEventArgs.cs" />
- <Compile Include="Player\DownloadProgress.cs" />
- <Compile Include="Player\EqualizerBand.cs" />
- <Compile Include="Player\ProgressiveDownloadMessageEventArgs.cs" />
- <Compile Include="Player\ProgressiveDownloadStatus.cs" />
- <Compile Include="Player\SeekOffsetEventArgs.cs" />
- <Compile Include="Player\SubtitleUpdatedEventArgs.cs" />
- <Compile Include="Player\Display.cs" />
- <Compile Include="Player\PlaybackCompletedEventArgs.cs" />
- <Compile Include="Player\PlaybackErrorEventArgs.cs" />
- <Compile Include="Player\PlaybackInterruptedEventArgs.cs" />
- <Compile Include="Player\Player.cs" />
- <Compile Include="Player\PlayerContentInfo.cs" />
- <Compile Include="Player\StreamInformation.cs" />
- <Compile Include="Player\StreamingConfiguration.cs" />
- <Compile Include="Player\Subtitle.cs" />
- <Compile Include="Player\VideoFrameDecodedEventArgs.cs" />
- <Compile Include="Player\VideoFrameCapture.cs" />
- <Compile Include="Player\VideoStreamEventArgs.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Player\MediaSource.cs" />
- <Compile Include="Player\MediaUriSource.cs" />
- <Compile Include="Player\MediaBufferSource.cs" />
+ <Compile Include="MetadataExtractor\MetadataEnums.cs" />
+ <Compile Include="MetadataExtractor\MetadataExtractorErrorFactory.cs" />
+ <Compile Include="MetadataExtractor\Synclyrics.cs" />
+ <Compile Include="MetadataExtractor\Frame.cs" />
+ <Compile Include="MetadataExtractor\Artwork.cs" />
+ <Compile Include="MetadataExtractor\Metadata.cs" />
+ <Compile Include="MetadataExtractor\MetadataExtractor.cs" />
+ <Compile Include="Interop\Interop.EvasObject.cs" />\r
+ <Compile Include="MediaView\MediaView.cs" />\r
+ <Compile Include="Player\CapturedFrame.cs" />\r
+ <Compile Include="Player\MediaStreamBufferStatusChangedEventArgs.cs" />\r
+ <Compile Include="Player\MediaStreamSeekingOccurredEventArgs.cs" />\r
+ <Compile Include="Player\PlayerDisplay.cs" />\r
+ <Compile Include="Player\PlayerEnums.cs" />\r
+ <Compile Include="Player\MediaStreamConfiguration.cs" />\r
+ <Compile Include="Player\PlayerError.cs" />\r
+ <Compile Include="Player\PlayerErrorOccurredEventArgs.cs" />\r
+ <Compile Include="Player\PlayerTrackInfo.cs" />\r
+ <Compile Include="Player\StreamInfo.cs" />\r
+ <Compile Include="Player\AudioEffect.cs" />\r
+ <Compile Include="Player\BufferingProgressChangedEventArgs.cs" />\r
+ <Compile Include="Player\DownloadProgress.cs" />\r
+ <Compile Include="Player\EqualizerBand.cs" />\r
+ <Compile Include="Player\SubtitleUpdatedEventArgs.cs" />\r
+ <Compile Include="Player\PlaybackInterruptedEventArgs.cs" />\r
+ <Compile Include="Player\Player.cs" />\r
+ <Compile Include="Player\VideoFrameDecodedEventArgs.cs" />\r
+ <Compile Include="Player\VideoStreamChangedEventArgs.cs" />\r
+ <Compile Include="Properties\AssemblyInfo.cs" />\r
+ <Compile Include="Player\MediaSource.cs" />\r
+ <Compile Include="Player\MediaUriSource.cs" />\r
+ <Compile Include="Player\MediaBufferSource.cs" />\r
<Compile Include="Player\MediaStreamSource.cs" />
<Compile Include="Interop\Interop.Libraries.cs" />
- <Compile Include="Player\PlayerErrorFactory.cs" />
<Compile Include="Recorder\AudioStreamDeliveredEventArgs.cs" />
<Compile Include="Recorder\Recorder.cs" />
<Compile Include="Recorder\RecorderEnums.cs" />
<Compile Include="Interop\Interop.Device.cs" />
<Compile Include="Interop\Interop.StreamPolicy.cs" />
<Compile Include="Interop\Interop.Volume.cs" />
+ <Compile Include="Interop\Interop.MediaController.cs" />
+ <Compile Include="MediaController\MediaControllerPlayback.cs" />
+ <Compile Include="MediaController\MediaControllerMetadata.cs" />
+ <Compile Include="MediaController\ServerInformation.cs" />
+ <Compile Include="MediaController\CustomCommandEventArgs.cs" />
+ <Compile Include="MediaController\PlaybackStateCommandEventArgs.cs" />
+ <Compile Include="MediaController\ServerUpdatedEventArgs.cs" />
+ <Compile Include="MediaController\PlaybackUpdatedEventArgs.cs" />
+ <Compile Include="MediaController\MetadataUpdatedEventArgs.cs" />
+ <Compile Include="MediaController\ShuffleModeUpdatedEventArgs.cs" />
+ <Compile Include="MediaController\RepeatModeUpdatedEventArgs.cs" />
+ <Compile Include="MediaController\MediaControllerErrorFactory.cs" />
+ <Compile Include="MediaController\MediaControllerEnums.cs" />
+ <Compile Include="MediaController\MediaControllerLog.cs" />
+ <Compile Include="MediaController\MediaControllerClient.cs" />
+ <Compile Include="MediaController\MediaControllerServer.cs" />
+ <Compile Include="MediaController\CustomCommandReplyEventArgs.cs" />
<Compile Include="ScreenMirroring\AudioInformation.cs" />
<Compile Include="ScreenMirroring\ErrorOccurredEventArgs.cs" />
<Compile Include="ScreenMirroring\ScreenMirroring.cs" />
<Compile Include="ScreenMirroring\ScreenMirroringEnumerations.cs" />
<Compile Include="ScreenMirroring\StateChangedEventArgs.cs" />
- <Compile Include="Interop\Interop.ScreenMirroring.cs" />
<Compile Include="ScreenMirroring\ScreenMirroringErrorFactory.cs" />
<Compile Include="ScreenMirroring\VideoInformation.cs" />
+ <Compile Include="Interop\Interop.ScreenMirroring.cs" />\r
</ItemGroup>
<ItemGroup>
<None Include="Tizen.Multimedia.nuspec" />
{
"dependencies": {
- "ElmSharp": "1.0.7",
- "Tizen": "1.0.1"
+ "ElmSharp": "1.1.0-*",
+ "Tizen": "1.0.2",
+ "Tizen.Applications": "1.0.2"
},
"frameworks": {
"net45": {}
"runtimes": {
"win": {}
}
-}
\ No newline at end of file
+}
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{0CE698B0-4849-4096-9D7F-30E611F50DAD}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Tizen.Multimedia</RootNamespace>
- <AssemblyName>Tizen.Multimedia</AssemblyName>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup>
- <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
- <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
- <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
- <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
- <NoStdLib>true</NoStdLib>
- <NoWarn>$(NoWarn);1701;1702</NoWarn>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup>
- <SignAssembly>true</SignAssembly>
- </PropertyGroup>
- <PropertyGroup>
- <AssemblyOriginatorKeyFile>Tizen.Multimedia.snk</AssemblyOriginatorKeyFile>
- </PropertyGroup>
- <ItemGroup>
- <Compile Include="AudioIO\AudioErrorHelper.cs" />
- <Compile Include="AudioIO\AudioInput.cs" />
- <Compile Include="AudioIO\AudioIOEnumerations.cs" />
- <Compile Include="AudioIO\AudioOutput.cs" />
- <Compile Include="AudioIO\AudioStateChangedEventArgs.cs" />
- <Compile Include="AudioIO\AudioStreamLengthChangedEventArgs.cs" />
- <Compile Include="AudioIO\BaseAudio.cs" />
- <Compile Include="Camera\Area.cs" />
- <Compile Include="Camera\Camera.cs" />
- <Compile Include="Camera\CameraDisplay.cs" />
- <Compile Include="Camera\CameraEnums.cs" />
- <Compile Include="Camera\CameraErrorFactory.cs" />
- <Compile Include="Camera\CameraErrorOccurredEventArgs.cs" />
- <Compile Include="Camera\CameraFeature.cs" />
- <Compile Include="Camera\CameraFocusChangedEventArgs.cs" />
- <Compile Include="Camera\CameraInterruptedEventArgs.cs" />
- <Compile Include="Camera\CameraResolution.cs" />
- <Compile Include="Camera\CameraSetting.cs" />
- <Compile Include="Camera\CameraStateChangedEventArgs.cs" />
- <Compile Include="Camera\CapturingEventArgs.cs" />
- <Compile Include="Camera\DoublePlaneData.cs" />
- <Compile Include="Camera\EncodedPlaneData.cs" />
- <Compile Include="Camera\FaceDetectedData.cs" />
- <Compile Include="Camera\FaceDetectedEventArgs.cs" />
- <Compile Include="Camera\HdrCaptureProgressEventArgs.cs" />
- <Compile Include="Camera\ImageData.cs" />
- <Compile Include="Camera\Location.cs" />
- <Compile Include="Camera\MediaPacketPreviewEventArgs.cs" />
- <Compile Include="Camera\PreviewData.cs" />
- <Compile Include="Camera\PreviewEventArgs.cs" />
- <Compile Include="Camera\Range.cs" />
- <Compile Include="Camera\SinglePlaneData.cs" />
- <Compile Include="Camera\TriplePlaneData.cs" />
- <Compile Include="Interop\Interop.AudioIO.cs" />
- <Compile Include="Interop\Interop.Camera.cs" />
- <Compile Include="Interop\Interop.CameraDisplay.cs" />
- <Compile Include="Interop\Interop.CameraFeature.cs" />
- <Compile Include="Interop\Interop.CameraSetting.cs" />
- <Compile Include="Interop\Interop.MediaCodec.cs" />
- <Compile Include="Interop\Interop.MediaTool.cs" />
- <Compile Include="Interop\Interop.MediaVision.BarCode.cs" />
- <Compile Include="Interop\Interop.MediaVision.Common.cs" />
- <Compile Include="Interop\Interop.MediaVision.Face.cs" />
- <Compile Include="Interop\Interop.MediaVision.Image.cs" />
- <Compile Include="Interop\Interop.MediaVision.Surveillance.cs" />
- <Compile Include="Interop\Interop.Player.cs" />
- <Compile Include="Interop\Interop.MetadataExtractor.cs" />
- <Compile Include="MediaCodec\BufferStatusChangedEventArgs.cs" />
- <Compile Include="MediaCodec\EosReachedEventArgs.cs" />
- <Compile Include="MediaCodec\ErrorOccurredEventArgs.cs" />
- <Compile Include="MediaCodec\InputProcessedEventArgs.cs" />
- <Compile Include="MediaCodec\MediaCodec.cs" />
- <Compile Include="MediaCodec\MediaCodecDebug.cs" />
- <Compile Include="MediaCodec\MediaCodecError.cs" />
- <Compile Include="MediaCodec\MediaCodecStatus.cs" />
- <Compile Include="MediaCodec\MediaCodecType.cs" />
- <Compile Include="MediaCodec\OutputAvailableEventArgs.cs" />
- <Compile Include="MediaCodec\SupportedCodecType.cs" />
- <Compile Include="MediaTool\MediaFormat.cs" />
- <Compile Include="MediaTool\MediaFormatAacType.cs" />
- <Compile Include="MediaTool\MediaFormatMimeType.cs" />
- <Compile Include="MediaTool\MediaFormatTextType.cs" />
- <Compile Include="MediaTool\MediaPacket.cs" />
- <Compile Include="MediaTool\MediaPacketBuffer.cs" />
- <Compile Include="MediaTool\MediaPacketBufferFlags.cs" />
- <Compile Include="MediaTool\MediaPacketVideoPlane.cs" />
- <Compile Include="MediaTool\MediaToolDebug.cs" />
- <Compile Include="MediaTool\NotEnoughMemoryException.cs" />
- <Compile Include="MediaVision\Barcode.cs" />
- <Compile Include="MediaVision\BarcodeDetector.cs" />
- <Compile Include="MediaVision\BarcodeDetectorEngineConfiguration.cs" />
- <Compile Include="MediaVision\BarcodeGenerator.cs" />
- <Compile Include="MediaVision\BarcodeGeneratorEngineConfiguration.cs" />
- <Compile Include="MediaVision\BarcodeImageConfiguration.cs" />
- <Compile Include="MediaVision\BarcodeImageFormat.cs" />
- <Compile Include="MediaVision\BarcodeType.cs" />
- <Compile Include="MediaVision\Colorspace.cs" />
- <Compile Include="MediaVision\EngineConfiguration.cs" />
- <Compile Include="MediaVision\ErrorCorrectionLevel.cs" />
- <Compile Include="MediaVision\EyeCondition.cs" />
- <Compile Include="MediaVision\FaceDetectionResult.cs" />
- <Compile Include="MediaVision\FaceDetector.cs" />
- <Compile Include="MediaVision\FaceEngineConfiguration.cs" />
- <Compile Include="MediaVision\FaceRecognitionModel.cs" />
- <Compile Include="MediaVision\FaceRecognitionModelType.cs" />
- <Compile Include="MediaVision\FaceRecognitionResult.cs" />
- <Compile Include="MediaVision\FaceRecognizer.cs" />
- <Compile Include="MediaVision\FaceTracker.cs" />
- <Compile Include="MediaVision\FaceTrackingModel.cs" />
- <Compile Include="MediaVision\FaceTrackingResult.cs" />
- <Compile Include="MediaVision\FacialExpression.cs" />
- <Compile Include="MediaVision\Image.cs" />
- <Compile Include="MediaVision\ImageEngineConfiguration.cs" />
- <Compile Include="MediaVision\ImageRecognitionResult.cs" />
- <Compile Include="MediaVision\ImageRecognizer.cs" />
- <Compile Include="MediaVision\ImageTracker.cs" />
- <Compile Include="MediaVision\ImageTrackingModel.cs" />
- <Compile Include="MediaVision\MediaVisionErrorFactory.cs" />
- <Compile Include="MediaVision\MediaVisionSource.cs" />
- <Compile Include="MediaVision\MovementDetectedEventArgs.cs" />
- <Compile Include="MediaVision\MovementDetectionEventTrigger.cs" />
- <Compile Include="MediaVision\PersonAppearanceChangedEventArgs.cs" />
- <Compile Include="MediaVision\PersonAppearanceEventTrigger.cs" />
- <Compile Include="MediaVision\PersonRecognitionEventTrigger.cs" />
- <Compile Include="MediaVision\PersonRecognitionResult.cs" />
- <Compile Include="MediaVision\PersonRecognizedEventArgs.cs" />
- <Compile Include="MediaVision\Point.cs" />
- <Compile Include="MediaVision\QrConfiguration.cs" />
- <Compile Include="MediaVision\QrMode.cs" />
- <Compile Include="MediaVision\Quadrangle.cs" />
- <Compile Include="MediaVision\Rectangle.cs" />
- <Compile Include="MediaVision\SurveillanceEngineConfiguration.cs" />
- <Compile Include="MediaVision\SurveillanceEventTrigger.cs" />
- <Compile Include="MediaVision\TargetAttribute.cs" />
- <Compile Include="MediaVision\TextAttribute.cs" />
- <Compile Include="MetadataExtractor\MetadataEnums.cs" />
- <Compile Include="MetadataExtractor\MetadataExtractorErrorFactory.cs" />
- <Compile Include="MetadataExtractor\Synclyrics.cs" />
- <Compile Include="MetadataExtractor\Frame.cs" />
- <Compile Include="MetadataExtractor\Artwork.cs" />
- <Compile Include="MetadataExtractor\Metadata.cs" />
- <Compile Include="MetadataExtractor\MetadataExtractor.cs" />
- <Compile Include="Interop\Interop.EvasObject.cs" />
- <Compile Include="MediaView\MediaView.cs" />
- <Compile Include="Player\PlayerEnums.cs" />
- <Compile Include="Player\MediaStreamConfiguration.cs" />
- <Compile Include="Player\SubtitleTrack.cs" />
- <Compile Include="Player\AudioEffect.cs" />
- <Compile Include="Player\BufferingProgressChangedEventArgs.cs" />
- <Compile Include="Player\BufferStatusEventArgs.cs" />
- <Compile Include="Player\DownloadProgress.cs" />
- <Compile Include="Player\EqualizerBand.cs" />
- <Compile Include="Player\ProgressiveDownloadMessageEventArgs.cs" />
- <Compile Include="Player\ProgressiveDownloadStatus.cs" />
- <Compile Include="Player\SeekOffsetEventArgs.cs" />
- <Compile Include="Player\SubtitleUpdatedEventArgs.cs" />
- <Compile Include="Player\Display.cs" />
- <Compile Include="Player\PlaybackCompletedEventArgs.cs" />
- <Compile Include="Player\PlaybackErrorEventArgs.cs" />
- <Compile Include="Player\PlaybackInterruptedEventArgs.cs" />
- <Compile Include="Player\Player.cs" />
- <Compile Include="Player\PlayerContentInfo.cs" />
- <Compile Include="Player\StreamInformation.cs" />
- <Compile Include="Player\StreamingConfiguration.cs" />
- <Compile Include="Player\Subtitle.cs" />
- <Compile Include="Player\VideoFrameDecodedEventArgs.cs" />
- <Compile Include="Player\VideoFrameCapture.cs" />
- <Compile Include="Player\VideoStreamEventArgs.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Player\MediaSource.cs" />
- <Compile Include="Player\MediaUriSource.cs" />
- <Compile Include="Player\MediaBufferSource.cs" />
- <Compile Include="Player\MediaStreamSource.cs" />
- <Compile Include="Interop\Interop.Libraries.cs" />
- <Compile Include="Player\PlayerErrorFactory.cs" />
- <Compile Include="Recorder\AudioStreamDeliveredEventArgs.cs" />
- <Compile Include="Recorder\Recorder.cs" />
- <Compile Include="Recorder\RecorderEnums.cs" />
- <Compile Include="Recorder\RecorderErrorFactory.cs" />
- <Compile Include="Recorder\RecorderInterruptedEventArgs.cs" />
- <Compile Include="Recorder\RecorderStateChangedEventArgs.cs" />
- <Compile Include="Recorder\RecordingErrorOccurredEventArgs.cs" />
- <Compile Include="Recorder\RecordingLimitReachedEventArgs.cs" />
- <Compile Include="Recorder\RecordingStatusChangedEventArgs.cs" />
- <Compile Include="Recorder\VideoResolution.cs" />
- <Compile Include="Interop\Interop.Recorder.cs" />
- <Compile Include="Interop\Interop.RecorderAttribute.cs" />
- <Compile Include="Interop\Interop.RecorderCapability.cs" />
- <Compile Include="AudioManager\AudioDevice.cs" />
- <Compile Include="AudioManager\AudioDeviceConnectionChangedEventArgs.cs" />
- <Compile Include="AudioManager\AudioDevicePropertyChangedEventArgs.cs" />
- <Compile Include="AudioManager\AudioManager.cs" />
- <Compile Include="AudioManager\AudioManagerEnumerations.cs" />
- <Compile Include="AudioManager\AudioManagerErrorFactory.cs" />
- <Compile Include="AudioManager\AudioStreamPolicy.cs" />
- <Compile Include="AudioManager\AudioVolume.cs" />
- <Compile Include="AudioManager\FocusStateChangedEventArgs.cs" />
- <Compile Include="AudioManager\MaxVolumeLevel.cs" />
- <Compile Include="AudioManager\StreamFocusStateChangedEventArgs.cs" />
- <Compile Include="AudioManager\VolumeChangedEventArgs.cs" />
- <Compile Include="AudioManager\VolumeLevel.cs" />
- <Compile Include="Interop\Interop.Device.cs" />
- <Compile Include="Interop\Interop.StreamPolicy.cs" />
- <Compile Include="Interop\Interop.Volume.cs" />
- <Compile Include="Interop\Interop.MediaController.cs" />
- <Compile Include="MediaController\Playback.cs" />
- <Compile Include="MediaController\Metadata.cs" />
- <Compile Include="MediaController\ServerInformation.cs" />
- <Compile Include="MediaController\CustomCommandEventArgs.cs" />
- <Compile Include="MediaController\PlaybackStateCommandEventArgs.cs" />
- <Compile Include="MediaController\ServerUpdatedEventArgs.cs" />
- <Compile Include="MediaController\PlaybackUpdatedEventArgs.cs" />
- <Compile Include="MediaController\MetadataUpdatedEventArgs.cs" />
- <Compile Include="MediaController\ShuffleModeUpdatedEventArgs.cs" />
- <Compile Include="MediaController\RepeatModeUpdatedEventArgs.cs" />
- <Compile Include="MediaController\MediaControllerErrorFactory.cs" />
- <Compile Include="MediaController\MediaControllerEnums.cs" />
- <Compile Include="MediaController\MediaControllerLog.cs" />
- <Compile Include="MediaController\Client.cs" />
- <Compile Include="MediaController\Server.cs" />
- <Compile Include="MediaController\CommandReplyEventArgs.cs" />
- <Compile Include="ScreenMirroring\AudioInformation.cs" />
- <Compile Include="ScreenMirroring\ErrorOccurredEventArgs.cs" />
- <Compile Include="ScreenMirroring\ScreenMirroring.cs" />
- <Compile Include="ScreenMirroring\ScreenMirroringEnumerations.cs" />
- <Compile Include="ScreenMirroring\StateChangedEventArgs.cs" />
- <Compile Include="ScreenMirroring\ScreenMirroringErrorFactory.cs" />
- <Compile Include="ScreenMirroring\VideoInformation.cs" />
- <Compile Include="Interop\Interop.ScreenMirroring.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="Tizen.Multimedia.nuspec" />
- <None Include="Tizen.Multimedia.project.json" />
- <None Include="Tizen.Multimedia.snk" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProjectGuid>{0CE698B0-4849-4096-9D7F-30E611F50DAD}</ProjectGuid>\r
+ <OutputType>Library</OutputType>\r
+ <AppDesignerFolder>Properties</AppDesignerFolder>\r
+ <RootNamespace>Tizen.Multimedia</RootNamespace>\r
+ <AssemblyName>Tizen.Multimedia</AssemblyName>\r
+ <FileAlignment>512</FileAlignment>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>\r
+ <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>\r
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>\r
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
+ <NoStdLib>true</NoStdLib>\r
+ <NoWarn>$(NoWarn);1701;1702</NoWarn>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>false</Optimize>\r
+ <OutputPath>bin\Debug\</OutputPath>\r
+ <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DebugType>pdbonly</DebugType>\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Release\</OutputPath>\r
+ <DefineConstants>TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <SignAssembly>true</SignAssembly>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <AssemblyOriginatorKeyFile>Tizen.Multimedia.snk</AssemblyOriginatorKeyFile>\r
+ </PropertyGroup>\r
+ <ItemGroup>\r
+ <Compile Include="AudioIO\AudioCapture.cs" />\r
+ <Compile Include="AudioIO\AudioDataAvailableEvetnArgs.cs" />\r
+ <Compile Include="AudioIO\AudioIOEnums.cs" />\r
+ <Compile Include="AudioIO\AudioIOStateChangedEventArgs.cs" />\r
+ <Compile Include="AudioIO\AudioIOUtil.cs" />\r
+ <Compile Include="AudioIO\AudioPlaybackBufferAvailableEventArgs.cs" />\r
+ <Compile Include="AudioIO\AudioPlyaback.cs" />\r
+ <Compile Include="Camera\Area.cs" />\r
+ <Compile Include="Camera\Camera.cs" />\r
+ <Compile Include="Camera\CameraDisplay.cs" />\r
+ <Compile Include="Camera\CameraEnums.cs" />\r
+ <Compile Include="Camera\CameraErrorFactory.cs" />\r
+ <Compile Include="Camera\CameraErrorOccurredEventArgs.cs" />\r
+ <Compile Include="Camera\CameraFeature.cs" />\r
+ <Compile Include="Camera\CameraFocusChangedEventArgs.cs" />\r
+ <Compile Include="Camera\CameraInterruptedEventArgs.cs" />\r
+ <Compile Include="Camera\CameraResolution.cs" />\r
+ <Compile Include="Camera\CameraSetting.cs" />\r
+ <Compile Include="Camera\CameraStateChangedEventArgs.cs" />\r
+ <Compile Include="Camera\CapturingEventArgs.cs" />\r
+ <Compile Include="Camera\DoublePlaneData.cs" />\r
+ <Compile Include="Camera\EncodedPlaneData.cs" />\r
+ <Compile Include="Camera\FaceDetectedData.cs" />\r
+ <Compile Include="Camera\FaceDetectedEventArgs.cs" />\r
+ <Compile Include="Camera\HdrCaptureProgressEventArgs.cs" />\r
+ <Compile Include="Camera\ImageData.cs" />\r
+ <Compile Include="Camera\Location.cs" />\r
+ <Compile Include="Camera\MediaPacketPreviewEventArgs.cs" />\r
+ <Compile Include="Camera\PreviewData.cs" />\r
+ <Compile Include="Camera\PreviewEventArgs.cs" />\r
+ <Compile Include="Camera\Range.cs" />\r
+ <Compile Include="Camera\SinglePlaneData.cs" />\r
+ <Compile Include="Camera\TriplePlaneData.cs" />\r
+ <Compile Include="Common\MultimediaDebug.cs" />\r
+ <Compile Include="Common\Size.cs" />\r
+ <Compile Include="Common\ValdiationUtil.cs" />\r
+ <Compile Include="Interop\Interop.AudioIO.cs" />\r
+ <Compile Include="Interop\Interop.Camera.cs" />\r
+ <Compile Include="Interop\Interop.CameraDisplay.cs" />\r
+ <Compile Include="Interop\Interop.CameraFeature.cs" />\r
+ <Compile Include="Interop\Interop.CameraSetting.cs" />\r
+ <Compile Include="Interop\Interop.MediaCodec.cs" />\r
+ <Compile Include="Interop\Interop.MediaTool.cs" />\r
+ <Compile Include="Interop\Interop.MediaVision.BarCode.cs" />\r
+ <Compile Include="Interop\Interop.MediaVision.Common.cs" />\r
+ <Compile Include="Interop\Interop.MediaVision.Face.cs" />\r
+ <Compile Include="Interop\Interop.MediaVision.Image.cs" />\r
+ <Compile Include="Interop\Interop.MediaVision.Surveillance.cs" />\r
+ <Compile Include="Interop\Interop.Player.cs" />\r
+ <Compile Include="Interop\Interop.MetadataExtractor.cs" />\r
+ <Compile Include="MediaCodec\BufferStatusChangedEventArgs.cs" />\r
+ <Compile Include="MediaCodec\InputProcessedEventArgs.cs" />\r
+ <Compile Include="MediaCodec\MediaCodec.cs" />\r
+ <Compile Include="MediaCodec\MediaCodecError.cs" />\r
+ <Compile Include="MediaCodec\MediaCodecErrorOccurredEventArgs.cs" />\r
+ <Compile Include="MediaCodec\MediaCodecStatus.cs" />\r
+ <Compile Include="MediaCodec\MediaCodecType.cs" />\r
+ <Compile Include="MediaCodec\OutputAvailableEventArgs.cs" />\r
+ <Compile Include="MediaCodec\SupportedCodecType.cs" />\r
+ <Compile Include="MediaTool\MediaFormat.cs" />\r
+ <Compile Include="MediaTool\MediaFormatAacType.cs" />\r
+ <Compile Include="MediaTool\MediaFormatMimeType.cs" />\r
+ <Compile Include="MediaTool\MediaFormatTextType.cs" />\r
+ <Compile Include="MediaTool\MediaPacket.cs" />\r
+ <Compile Include="MediaTool\MediaPacketBuffer.cs" />\r
+ <Compile Include="MediaTool\MediaPacketBufferFlags.cs" />\r
+ <Compile Include="MediaTool\MediaPacketVideoPlane.cs" />\r
+ <Compile Include="MediaVision\Barcode.cs" />\r
+ <Compile Include="MediaVision\BarcodeDetector.cs" />\r
+ <Compile Include="MediaVision\BarcodeDetectorEngineConfiguration.cs" />\r
+ <Compile Include="MediaVision\BarcodeGenerator.cs" />\r
+ <Compile Include="MediaVision\BarcodeGeneratorEngineConfiguration.cs" />\r
+ <Compile Include="MediaVision\BarcodeImageConfiguration.cs" />\r
+ <Compile Include="MediaVision\BarcodeImageFormat.cs" />\r
+ <Compile Include="MediaVision\BarcodeType.cs" />\r
+ <Compile Include="MediaVision\Colorspace.cs" />\r
+ <Compile Include="MediaVision\EngineConfiguration.cs" />\r
+ <Compile Include="MediaVision\ErrorCorrectionLevel.cs" />\r
+ <Compile Include="MediaVision\EyeCondition.cs" />\r
+ <Compile Include="MediaVision\FaceDetectionResult.cs" />\r
+ <Compile Include="MediaVision\FaceDetector.cs" />\r
+ <Compile Include="MediaVision\FaceEngineConfiguration.cs" />\r
+ <Compile Include="MediaVision\FaceRecognitionModel.cs" />\r
+ <Compile Include="MediaVision\FaceRecognitionModelType.cs" />\r
+ <Compile Include="MediaVision\FaceRecognitionResult.cs" />\r
+ <Compile Include="MediaVision\FaceRecognizer.cs" />\r
+ <Compile Include="MediaVision\FaceTracker.cs" />\r
+ <Compile Include="MediaVision\FaceTrackingModel.cs" />\r
+ <Compile Include="MediaVision\FaceTrackingResult.cs" />\r
+ <Compile Include="MediaVision\FacialExpression.cs" />\r
+ <Compile Include="MediaVision\Image.cs" />\r
+ <Compile Include="MediaVision\ImageEngineConfiguration.cs" />\r
+ <Compile Include="MediaVision\ImageRecognitionResult.cs" />\r
+ <Compile Include="MediaVision\ImageRecognizer.cs" />\r
+ <Compile Include="MediaVision\ImageTracker.cs" />\r
+ <Compile Include="MediaVision\ImageTrackingModel.cs" />\r
+ <Compile Include="MediaVision\MediaVisionErrorFactory.cs" />\r
+ <Compile Include="MediaVision\MediaVisionSource.cs" />\r
+ <Compile Include="MediaVision\MovementDetectedEventArgs.cs" />\r
+ <Compile Include="MediaVision\MovementDetectionEventTrigger.cs" />\r
+ <Compile Include="MediaVision\PersonAppearanceChangedEventArgs.cs" />\r
+ <Compile Include="MediaVision\PersonAppearanceEventTrigger.cs" />\r
+ <Compile Include="MediaVision\PersonRecognitionEventTrigger.cs" />\r
+ <Compile Include="MediaVision\PersonRecognitionResult.cs" />\r
+ <Compile Include="MediaVision\PersonRecognizedEventArgs.cs" />\r
+ <Compile Include="MediaVision\Point.cs" />\r
+ <Compile Include="MediaVision\QrConfiguration.cs" />\r
+ <Compile Include="MediaVision\QrMode.cs" />\r
+ <Compile Include="MediaVision\Quadrangle.cs" />\r
+ <Compile Include="MediaVision\Rectangle.cs" />\r
+ <Compile Include="MediaVision\SurveillanceEngineConfiguration.cs" />\r
+ <Compile Include="MediaVision\SurveillanceEventTrigger.cs" />\r
+ <Compile Include="MediaVision\TargetAttribute.cs" />\r
+ <Compile Include="MediaVision\TextAttribute.cs" />\r
+ <Compile Include="MetadataExtractor\MetadataEnums.cs" />\r
+ <Compile Include="MetadataExtractor\MetadataExtractorErrorFactory.cs" />\r
+ <Compile Include="MetadataExtractor\Synclyrics.cs" />\r
+ <Compile Include="MetadataExtractor\Frame.cs" />\r
+ <Compile Include="MetadataExtractor\Artwork.cs" />\r
+ <Compile Include="MetadataExtractor\Metadata.cs" />\r
+ <Compile Include="MetadataExtractor\MetadataExtractor.cs" />\r
+ <Compile Include="Interop\Interop.EvasObject.cs" />\r
+ <Compile Include="MediaView\MediaView.cs" />\r
+ <Compile Include="Player\CapturedFrame.cs" />\r
+ <Compile Include="Player\MediaStreamBufferStatusChangedEventArgs.cs" />\r
+ <Compile Include="Player\MediaStreamSeekingOccurredEventArgs.cs" />\r
+ <Compile Include="Player\PlayerDisplay.cs" />\r
+ <Compile Include="Player\PlayerEnums.cs" />\r
+ <Compile Include="Player\MediaStreamConfiguration.cs" />\r
+ <Compile Include="Player\PlayerError.cs" />\r
+ <Compile Include="Player\PlayerErrorOccurredEventArgs.cs" />\r
+ <Compile Include="Player\PlayerTrackInfo.cs" />\r
+ <Compile Include="Player\StreamInfo.cs" />\r
+ <Compile Include="Player\AudioEffect.cs" />\r
+ <Compile Include="Player\BufferingProgressChangedEventArgs.cs" />\r
+ <Compile Include="Player\DownloadProgress.cs" />\r
+ <Compile Include="Player\EqualizerBand.cs" />\r
+ <Compile Include="Player\SubtitleUpdatedEventArgs.cs" />\r
+ <Compile Include="Player\PlaybackInterruptedEventArgs.cs" />\r
+ <Compile Include="Player\Player.cs" />\r
+ <Compile Include="Player\VideoFrameDecodedEventArgs.cs" />\r
+ <Compile Include="Player\VideoStreamChangedEventArgs.cs" />\r
+ <Compile Include="Properties\AssemblyInfo.cs" />\r
+ <Compile Include="Player\MediaSource.cs" />\r
+ <Compile Include="Player\MediaUriSource.cs" />\r
+ <Compile Include="Player\MediaBufferSource.cs" />\r
+ <Compile Include="Player\MediaStreamSource.cs" />\r
+ <Compile Include="Interop\Interop.Libraries.cs" />\r
+ <Compile Include="Recorder\AudioStreamDeliveredEventArgs.cs" />\r
+ <Compile Include="Recorder\Recorder.cs" />\r
+ <Compile Include="Recorder\RecorderEnums.cs" />\r
+ <Compile Include="Recorder\RecorderErrorFactory.cs" />\r
+ <Compile Include="Recorder\RecorderInterruptedEventArgs.cs" />\r
+ <Compile Include="Recorder\RecorderStateChangedEventArgs.cs" />\r
+ <Compile Include="Recorder\RecordingErrorOccurredEventArgs.cs" />\r
+ <Compile Include="Recorder\RecordingLimitReachedEventArgs.cs" />\r
+ <Compile Include="Recorder\RecordingStatusChangedEventArgs.cs" />\r
+ <Compile Include="Recorder\VideoResolution.cs" />\r
+ <Compile Include="Interop\Interop.Recorder.cs" />\r
+ <Compile Include="Interop\Interop.RecorderAttribute.cs" />\r
+ <Compile Include="Interop\Interop.RecorderCapability.cs" />\r
+ <Compile Include="AudioManager\AudioDevice.cs" />\r
+ <Compile Include="AudioManager\AudioDeviceConnectionChangedEventArgs.cs" />\r
+ <Compile Include="AudioManager\AudioDevicePropertyChangedEventArgs.cs" />\r
+ <Compile Include="AudioManager\AudioManager.cs" />\r
+ <Compile Include="AudioManager\AudioManagerEnumerations.cs" />\r
+ <Compile Include="AudioManager\AudioManagerErrorFactory.cs" />\r
+ <Compile Include="AudioManager\AudioStreamPolicy.cs" />\r
+ <Compile Include="AudioManager\AudioVolume.cs" />\r
+ <Compile Include="AudioManager\FocusStateChangedEventArgs.cs" />\r
+ <Compile Include="AudioManager\MaxVolumeLevel.cs" />\r
+ <Compile Include="AudioManager\StreamFocusStateChangedEventArgs.cs" />\r
+ <Compile Include="AudioManager\VolumeChangedEventArgs.cs" />\r
+ <Compile Include="AudioManager\VolumeLevel.cs" />\r
+ <Compile Include="Interop\Interop.Device.cs" />\r
+ <Compile Include="Interop\Interop.StreamPolicy.cs" />\r
+ <Compile Include="Interop\Interop.Volume.cs" />\r
+ <Compile Include="Interop\Interop.MediaController.cs" />\r
+ <Compile Include="MediaController\MediaControllerPlayback.cs" />\r
+ <Compile Include="MediaController\MediaControllerMetadata.cs" />\r
+ <Compile Include="MediaController\ServerInformation.cs" />\r
+ <Compile Include="MediaController\CustomCommandEventArgs.cs" />\r
+ <Compile Include="MediaController\PlaybackStateCommandEventArgs.cs" />\r
+ <Compile Include="MediaController\ServerUpdatedEventArgs.cs" />\r
+ <Compile Include="MediaController\PlaybackUpdatedEventArgs.cs" />\r
+ <Compile Include="MediaController\MetadataUpdatedEventArgs.cs" />\r
+ <Compile Include="MediaController\ShuffleModeUpdatedEventArgs.cs" />\r
+ <Compile Include="MediaController\RepeatModeUpdatedEventArgs.cs" />\r
+ <Compile Include="MediaController\MediaControllerErrorFactory.cs" />\r
+ <Compile Include="MediaController\MediaControllerEnums.cs" />\r
+ <Compile Include="MediaController\MediaControllerLog.cs" />\r
+ <Compile Include="MediaController\MediaControllerClient.cs" />\r
+ <Compile Include="MediaController\MediaControllerServer.cs" />\r
+ <Compile Include="MediaController\CustomCommandReplyEventArgs.cs" />\r
+ <Compile Include="ScreenMirroring\AudioInformation.cs" />\r
+ <Compile Include="ScreenMirroring\ErrorOccurredEventArgs.cs" />\r
+ <Compile Include="ScreenMirroring\ScreenMirroring.cs" />\r
+ <Compile Include="ScreenMirroring\ScreenMirroringEnumerations.cs" />\r
+ <Compile Include="ScreenMirroring\StateChangedEventArgs.cs" />\r
+ <Compile Include="ScreenMirroring\ScreenMirroringErrorFactory.cs" />\r
+ <Compile Include="ScreenMirroring\VideoInformation.cs" />\r
+ <Compile Include="Interop\Interop.ScreenMirroring.cs" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <None Include="Tizen.Multimedia.nuspec" />\r
+ <None Include="Tizen.Multimedia.project.json" />\r
+ <None Include="Tizen.Multimedia.snk" />\r
+ </ItemGroup>\r
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
- -->
- <PropertyGroup>
+ -->\r
+ <PropertyGroup>\r
<!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
- -->
+ -->\r
<!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
to prevent it from outputting a warning (MSB3644).
- -->
- <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
- <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
- <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
- </PropertyGroup>
-</Project>
+ -->\r
+ <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>\r
+ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>\r
+ <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>\r
+ </PropertyGroup>\r
+</Project>
\ No newline at end of file
<metadata>
<id>Tizen.Multimedia</id>
<version>$version$</version>
- <authors>Tizen Developers</authors>
- <description>Multimedia API for Tizen.Net</description>
+ <authors>Samsung Electronics</authors>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
+ <projectUrl>https://www.tizen.org/</projectUrl>
+ <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
+ <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
+ <description>Provides the Multimedia API for Tizen.Net</description>
<dependencies>
- <dependency id="Tizen" version="1.0.1" />
+ <dependency id="Tizen" version="1.0.2" />
+ <dependency id="ElmSharp" version="1.0.14" />
+ <dependency id="Tizen.Applications" version="1.0.2" />
</dependencies>
</metadata>
<files>
-{
- "dependencies": {
- "ElmSharp": "1.0.7",
- "NETStandard.Library": "1.6.0",
- "Tizen": "1.0.1"
- },
- "frameworks": {
- "netstandard1.3": {}
- }
-}
\ No newline at end of file
+{\r
+ "dependencies": {\r
+ "ElmSharp": "1.1.0-*",\r
+ "NETStandard.Library": "1.6.0",\r
+ "Tizen": "1.0.2",\r
+ "Tizen.Applications": "1.0.2"\r
+ },\r
+ "frameworks": {\r
+ "netstandard1.3": {}\r
+ }\r
+}\r