/// <summary>
/// Enumeration for audio device options.
/// </summary>
- public enum AudioDeviceOptions{
- /// <summary>
+ public enum AudioDeviceOptions
+ {
+ /// <summary>
/// Mask for input devices
- /// </summary>
- Input = 0x0001,
- /// <summary>
- /// Mask for output devices
- /// </summary>
- Output = 0x0002,
- /// <summary>
- /// Mask for input/output devices (both directions are available)
- /// </summary>
- InputAndOutput = 0x0004,
- /// <summary>
- /// Mask for built-in devices
- /// </summary>
- Internal = 0x00010,
- /// <summary>
- /// Mask for external devices
- /// </summary>
- External = 0x0020,
- /// <summary>
- /// Mask for deactivated devices
- /// </summary>
- Deactivated = 0x1000,
- /// <summary>
- /// Mask for activated devices
- /// </summary>
- Activated = 0x2000,
- /// <summary>
- /// Mask for all devices
- /// </summary>
- All = 0xFFFF
+ /// </summary>
+ Input = 0x0001,
+ /// <summary>
+ /// Mask for output devices
+ /// </summary>
+ Output = 0x0002,
+ /// <summary>
+ /// Mask for input/output devices (both directions are available)
+ /// </summary>
+ InputAndOutput = 0x0004,
+ /// <summary>
+ /// Mask for built-in devices
+ /// </summary>
+ Internal = 0x00010,
+ /// <summary>
+ /// Mask for external devices
+ /// </summary>
+ External = 0x0020,
+ /// <summary>
+ /// Mask for deactivated devices
+ /// </summary>
+ Deactivated = 0x1000,
+ /// <summary>
+ /// Mask for activated devices
+ /// </summary>
+ Activated = 0x2000,
+ /// <summary>
+ /// Mask for all devices
+ /// </summary>
+ All = 0xFFFF
}
+
/// <summary>
/// Enumeration for audio device type.
/// </summary>
- public enum AudioDeviceType{
- /// <summary>
- /// Built-in speaker
- /// </summary>
- BuiltinSpeaker,
- /// <summary>
- /// Built-in receiver
- /// </summary>
- BuiltinReceiver,
- /// <summary>
- /// Built-in mic
- /// </summary>
- BuiltinMic,
- /// <summary>
- /// Audio jack that can be connected to wired accessory such as headphones and headsets
- /// </summary>
- AudioJack,
- /// <summary>
- /// Bluetooth
- /// </summary>
- Bluetooth,
- /// <summary>
- /// HDMI
- /// </summary>
- Hdmi,
- /// <summary>
- /// Device for forwarding
- /// </summary>
- Forwarding,
- /// <summary>
- /// USB Audio
- /// </summary>
- UsbAudio
+ public enum AudioDeviceType
+ {
+ /// <summary>
+ /// Built-in speaker
+ /// </summary>
+ BuiltinSpeaker,
+ /// <summary>
+ /// Built-in receiver
+ /// </summary>
+ BuiltinReceiver,
+ /// <summary>
+ /// Built-in mic
+ /// </summary>
+ BuiltinMic,
+ /// <summary>
+ /// Audio jack that can be connected to wired accessory such as headphones and headsets
+ /// </summary>
+ AudioJack,
+ /// <summary>
+ /// Bluetooth
+ /// </summary>
+ Bluetooth,
+ /// <summary>
+ /// HDMI
+ /// </summary>
+ Hdmi,
+ /// <summary>
+ /// Device for forwarding
+ /// </summary>
+ Forwarding,
+ /// <summary>
+ /// USB Audio
+ /// </summary>
+ UsbAudio
}
+
/// <summary>
/// Enumeration for audio device direction.
/// </summary>
- public enum AudioDeviceIoDirection{
- /// <summary>
- /// Input device
- /// </summary>
- Input,
- /// <summary>
- /// Output device
- /// </summary>
- Output,
- /// <summary>
- /// Input/output device (both directions are available)
- /// </summary>
- InputAndOutput
+ public enum AudioDeviceIoDirection
+ {
+ /// <summary>
+ /// Input device
+ /// </summary>
+ Input,
+ /// <summary>
+ /// Output device
+ /// </summary>
+ Output,
+ /// <summary>
+ /// Input/output device (both directions are available)
+ /// </summary>
+ InputAndOutput
}
/// <summary>
/// Enumeration for audio device state.
/// </summary>
- public enum AudioDeviceState{
- /// <summary>
+ public enum AudioDeviceState
+ {
+ /// <summary>
/// Deactivated state
- /// </summary>
- Deactivated,
- /// <summary>
- /// Activated state
- /// </summary>
- Activated
+ /// </summary>
+ Deactivated,
+ /// <summary>
+ /// Activated state
+ /// </summary>
+ Activated
}
/// <summary>
/// Enumeration for changed property of audio device.
/// </summary>
- public enum AudioDeviceProperty{
- /// <summary>
- /// State of the device was changed
- /// </summary>
- State,
- /// <summary>
- /// IO direction of the device was changed
- /// </summary>
- IoDirection
+ public enum AudioDeviceProperty
+ {
+ /// <summary>
+ /// State of the device was changed
+ /// </summary>
+ State,
+ /// <summary>
+ /// IO direction of the device was changed
+ /// </summary>
+ IoDirection
}
/// <summary>
/// Enumeration for audio type.
/// </summary>
- public enum AudioVolumeType{
- /// <summary>
- /// Audio type for system
- /// </summary>
- System,
- /// <summary>
- /// Audio type for notifications
- /// </summary>
- Notification,
- /// <summary>
- /// Audio type for alarm
- /// </summary>
- Alarm,
- /// <summary>
- /// Audio type for ringtones
- /// </summary>
- Ringtone,
- /// <summary>
- /// Audio type for media
- /// </summary>
- Media,
- /// <summary>
- /// Audio type for call
- /// </summary>
- Call,
- /// <summary>
- /// Audio type for voip
- /// </summary>
- Voip,
- /// <summary>
- /// Audio type for voice
- /// </summary>
- Voice,
- /// <summary>
- /// Audio Type None
- /// </summary>
- None
+ public enum AudioVolumeType
+ {
+ /// <summary>
+ /// Audio type for system
+ /// </summary>
+ System,
+ /// <summary>
+ /// Audio type for notifications
+ /// </summary>
+ Notification,
+ /// <summary>
+ /// Audio type for alarm
+ /// </summary>
+ Alarm,
+ /// <summary>
+ /// Audio type for ringtones
+ /// </summary>
+ Ringtone,
+ /// <summary>
+ /// Audio type for media
+ /// </summary>
+ Media,
+ Call,
+ /// <summary>
+ /// Audio type for voip
+ /// </summary>
+ Voip,
+ /// <summary>
+ /// Audio type for voice
+ /// </summary>
+ Voice
}
+
/// <summary>
/// Enumeration for audio stream type.
/// </summary>
- public enum AudioStreamType{
- /// <summary>
- /// Audio stream type for media
- /// </summary>
- Media,
- /// <summary>
- /// Audio stream type for system
- /// </summary>
- System,
- /// <summary>
- /// Audio stream type for alarm
- /// </summary>
- Alarm,
- /// <summary>
- /// Audio stream type for notification
- /// </summary>
- Notification,
- /// <summary>
- /// Audio stream type for emergency
- /// </summary>
- Emergency,
- /// <summary>
- /// Audio stream type for voice information
- /// </summary>
- VoiceInformation,
- /// <summary>
- /// Audio stream type for voice recognition
- /// </summary>
- VoiceRecognition,
- /// <summary>
- /// Audio stream type for ringtone for VoIP
- /// </summary>
- RingtoneVoip,
- /// <summary>
- /// Audio stream type for VoIP
- /// </summary>
- Voip,
- /// <summary>
- /// Audio stream type for media only for external devices
- /// </summary>
- MediaExternalOnly
+ public enum AudioStreamType
+ {
+ /// <summary>
+ /// Audio stream type for media
+ /// </summary>
+ Media,
+ /// <summary>
+ /// Audio stream type for system
+ /// </summary>
+ System,
+ /// <summary>
+ /// Audio stream type for alarm
+ /// </summary>
+ Alarm,
+ /// <summary>
+ /// Audio stream type for notification
+ /// </summary>
+ Notification,
+ /// <summary>
+ /// Audio stream type for emergency
+ /// </summary>
+ Emergency,
+ /// <summary>
+ /// Audio stream type for voice information
+ /// </summary>
+ VoiceInformation,
+ /// <summary>
+ /// Audio stream type for voice recognition
+ /// </summary>
+ VoiceRecognition,
+ /// <summary>
+ /// Audio stream type for ringtone for VoIP
+ /// </summary>
+ RingtoneVoip,
+ /// <summary>
+ /// Audio stream type for VoIP
+ /// </summary>
+ Voip,
+ /// <summary>
+ /// Audio stream type for media only for external devices
+ /// </summary>
+ MediaExternalOnly
}
+
/// <summary>
/// Enumeration for change reason of audio stream focus state.
/// </summary>
- public enum AudioStreamFocusChangedReason{
- /// <summary>
- /// Changed by the stream type for media
- /// </summary>
- Media,
- /// <summary>
- /// Changed by the stream type for system
- /// </summary>
- System,
- /// <summary>
- /// Changed by the stream type for alarm
- /// </summary>
- Alarm,
- /// <summary>
- /// Changed by the stream type for notification
- /// </summary>
- Notification,
- /// <summary>
- /// Changed by the stream type for emergency
- /// </summary>
- Emergency,
- /// <summary>
- /// Changed by the stream type for voice information
- /// </summary>
- VoiceInformation,
- /// <summary>
- /// Changed by the stream type for voice recognition
- /// </summary>
- VoiceRecognition,
- /// <summary>
- /// Changed by the stream type for ringtone
- /// </summary>
- RingtoneVoip,
- /// <summary>
- /// Changed by the stream type for VoIP
- /// </summary>
- Voip,
- /// <summary>
- /// Changed by the stream type for voice-call or video-call
- /// </summary>
- Call,
- /// <summary>
- /// Changed by the stream type for media only for external devices
- /// </summary>
- MediaExternalOnly
+ public enum AudioStreamFocusChangedReason
+ {
+ /// <summary>
+ /// Changed by the stream type for media
+ /// </summary>
+ Media,
+ /// <summary>
+ /// Changed by the stream type for system
+ /// </summary>
+ System,
+ /// <summary>
+ /// Changed by the stream type for alarm
+ /// </summary>
+ Alarm,
+ /// <summary>
+ /// Changed by the stream type for notification
+ /// </summary>
+ Notification,
+ /// <summary>
+ /// Changed by the stream type for emergency
+ /// </summary>
+ Emergency,
+ /// <summary>
+ /// Changed by the stream type for voice information
+ /// </summary>
+ VoiceInformation,
+ /// <summary>
+ /// Changed by the stream type for voice recognition
+ /// </summary>
+ VoiceRecognition,
+ /// <summary>
+ /// Changed by the stream type for ringtone
+ /// </summary>
+ RingtoneVoip,
+ /// <summary>
+ /// Changed by the stream type for VoIP
+ /// </summary>
+ Voip,
+ /// <summary>
+ /// Changed by the stream type for voice-call or video-call
+ /// </summary>
+ Call,
+ /// <summary>
+ /// Changed by the stream type for media only for external devices
+ /// </summary>
+ MediaExternalOnly
}
/// <summary>
/// Enumeration for audio stream focus options.
/// </summary>
- public enum AudioStreamFocusOptions{
- /// <summary>
- /// Mask for playback focus
- /// </summary>
- Playback = 0x0001,
- /// <summary>
- /// Mask for recording focus
- /// </summary>
- Recording = 0x0002
+ public enum AudioStreamFocusOptions
+ {
+ /// <summary>
+ /// Mask for playback focus
+ /// </summary>
+ Playback = 0x0001,
+ /// <summary>
+ /// Mask for recording focus
+ /// </summary>
+ Recording = 0x0002
}
/// <summary>
/// Enumeration for audio stream focus state.
/// </summary>
- public enum AudioStreamFocusState{
- /// <summary>
- /// Focus state for release
- /// </summary>
- Released,
- /// <summary>
- ///Focus state for acquisition
- /// </summary>
- Acquired
+ public enum AudioStreamFocusState
+ {
+ /// <summary>
+ /// Focus state for release
+ /// </summary>
+ Released,
+ /// <summary>
+ ///Focus state for acquisition
+ /// </summary>
+ Acquired
}
}
\ No newline at end of file
-using System;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- internal static class AudioStreamPolicyLog\r
- {\r
- internal const string Tag = "Tizen.Multimedia.AudioStreamPolicy";\r
- }\r
-\r
- /// <summary>\r
- /// The Stream Policy API provides functions to control a sound stream.\r
- /// </summary>\r
- public class AudioStreamPolicy : IDisposable\r
- {\r
- private static int _focusStateWatchCounter = 0;\r
- private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForPlayback;\r
- private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForRecording;\r
- private static Interop.SoundStreamFocusStateWatchCallback _focusStateWatchCallback;\r
-\r
- private IntPtr _streamInfo;\r
- private AudioStreamType _streamType;\r
- private bool _disposed = false;\r
- private EventHandler<StreamFocusStateChangedEventArgs> _focusStateChanged;\r
- private Interop.SoundStreamFocusStateChangedCallback _focusStateChangedCallback;\r
-\r
- /// <summary>\r
- /// Creates and returns an AudioStreamPolicy object\r
- /// </summary>\r
- /// <remarks>\r
- /// To apply the stream policy according to this stream information, this object should be passed to other APIs\r
- /// related to playback or recording. (e.g., player, wav-player, audio-io, etc.)\r
- /// </remarks>\r
- /// <param name="streamType">Type of sound stream for which policy needs to be created</param>\r
- /// <returns>StreamPolicy object</returns>\r
- public AudioStreamPolicy(AudioStreamType streamType)\r
- {\r
- _streamType = streamType;\r
- _focusStateChangedCallback = (IntPtr streamInfo, int reason, string extraInfo, IntPtr userData) =>\r
- {\r
- StreamFocusStateChangedEventArgs eventArgs = new StreamFocusStateChangedEventArgs((AudioStreamFocusChangedReason)reason, extraInfo);\r
- _focusStateChanged?.Invoke(this, eventArgs);\r
- };\r
- int ret = Interop.AudioStreamPolicy.CreateStreamInformation((int)streamType, _focusStateChangedCallback, IntPtr.Zero, out _streamInfo);\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to create stream information");\r
- }\r
-\r
- ~AudioStreamPolicy()\r
- {\r
- Dispose(false);\r
- }\r
-\r
- /// <summary>\r
- /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process.\r
- /// <remarks>\r
- /// Remarks: You can set this only once per process.\r
- /// </remarks>\r
- /// </summary>\r
- public static event EventHandler<FocusStateChangedEventArgs> PlaybackFocusStateWatch\r
- {\r
- add\r
- {\r
- if (_focusStateWatchCounter == 0)\r
- {\r
- RegisterFocusStateWatchEvent();\r
- }\r
- _focusStateWatchCounter++;\r
- _focusStateWatchForPlayback += value;\r
- }\r
- remove\r
- {\r
- _focusStateWatchForPlayback -= value;\r
- _focusStateWatchCounter--;\r
- if (_focusStateWatchCounter == 0)\r
- {\r
- UnregisterFocusStateWatch();\r
- }\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process.\r
- /// <remarks>\r
- /// Remarks: You can set this only once per process.\r
- /// </remarks>\r
- /// </summary>\r
- public static event EventHandler<FocusStateChangedEventArgs> RecordingFocusStateWatch\r
- {\r
- add\r
- {\r
- if (_focusStateWatchCounter == 0)\r
- {\r
- RegisterFocusStateWatchEvent();\r
- }\r
- _focusStateWatchCounter++;\r
- _focusStateWatchForRecording += value;\r
- }\r
- remove\r
- {\r
- _focusStateWatchForRecording -= value;\r
- _focusStateWatchCounter--;\r
- if (_focusStateWatchCounter == 0)\r
- {\r
- UnregisterFocusStateWatch();\r
- }\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Registers function to be called when the state of focus that belongs to the stream_info is changed.\r
- /// </summary>\r
- /// <remarks>\r
- /// Remarks: This function is issued in the internal thread of the sound manager. Therefore it is recommended not to call UI update function in this function.\r
- /// Postcondition : FocusStateForPlayback and FokcusStateForRecording in the registered event handler to figure out how the focus state of the StreamInfo has been changed.\r
- /// </remarks>\r
- public event EventHandler<StreamFocusStateChangedEventArgs> StreamFocusStateChanged\r
- {\r
- add\r
- {\r
- _focusStateChanged += value;\r
- }\r
- remove\r
- {\r
- _focusStateChanged -= value;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// The sound type of the stream information.\r
- /// </summary>\r
- public AudioVolumeType VolumeType\r
- {\r
- get\r
- {\r
- AudioVolumeType soundType;\r
- int ret = Interop.AudioStreamPolicy.GetSoundType(_streamInfo, out soundType);\r
- if (ret != 0)\r
- {\r
- Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get sound type:" + (AudioManagerError)ret);\r
- return AudioVolumeType.None;\r
- }\r
- return soundType;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// The state of focus for playback.\r
- /// </summary>\r
- public AudioStreamFocusState PlaybackFocusState\r
- {\r
- get\r
- {\r
- AudioStreamFocusState stateForPlayback;\r
- AudioStreamFocusState stateForRecording;\r
- int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording);\r
- if (ret != 0)\r
- {\r
- Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret);\r
- return AudioStreamFocusState.Released;\r
- }\r
- return stateForPlayback;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// The state of focus for recording.\r
- /// </summary>\r
- public AudioStreamFocusState RecordingFocusState\r
- {\r
- get\r
- {\r
- AudioStreamFocusState stateForPlayback;\r
- AudioStreamFocusState stateForRecording;\r
- int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording);\r
- if (ret != 0)\r
- {\r
- Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret);\r
- return AudioStreamFocusState.Released;\r
- }\r
- return stateForRecording;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Auto focus reacquisition property\r
- /// </summary>\r
- /// <remarks>\r
- /// The focus reacquistion is set as default. If you don't want to reacquire the focus you've lost automatically, disable the focus reacqusition setting by using this API and vice versa.\r
- /// </remarks>\r
- public bool FocusReacquisitionEnabled\r
- {\r
- get\r
- {\r
- bool enabled;\r
- int ret = Interop.AudioStreamPolicy.GetFocusReacquisition(_streamInfo, out enabled);\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get focus reacquisition");\r
- if (ret != 0)\r
- {\r
- Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus reacquisition" + (AudioManagerError)ret);\r
- return true;\r
- }\r
- return enabled;\r
- }\r
- set\r
- {\r
- int ret = Interop.AudioStreamPolicy.SetFocusReacquisition(_streamInfo, value);\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus reacquisition");\r
- }\r
- }\r
-\r
- internal IntPtr Handle\r
- {\r
- get\r
- {\r
- return _streamInfo;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Acquires the stream focus.\r
- /// </summary>\r
- /// <param name="focusMask">The focus mask that user wants to acquire</param>\r
- /// <param name="extraInformation">The Extra information for this request (optional, this can be null)</param>\r
- /// <remarks>\r
- /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception\r
- /// </remarks>\r
- public void AcquireFocus(AudioStreamFocusOptions options, string extraInformation)\r
- {\r
- int ret = Interop.AudioStreamPolicy.AcquireFocus(_streamInfo, options, extraInformation);\r
- Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Acquire focus return: " + ret);\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to acquire focus");\r
- }\r
-\r
- /// <summary>\r
- /// Releases the acquired focus.\r
- /// </summary>\r
- /// <param name="options">The focus mask that user wants to release</param>\r
- /// <param name="extraInformation">he Extra information for this request (optional, this can be null)</param>\r
- /// <remarks>\r
- /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception\r
- /// </remarks>\r
- public void ReleaseFocus(AudioStreamFocusOptions options, string extraInformation)\r
- {\r
- int ret = Interop.AudioStreamPolicy.ReleaseFocus(_streamInfo, options, extraInformation);\r
- Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Release focus return: " + ret);\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to release focus");\r
- }\r
-\r
- /// <summary>\r
- /// Applies the stream routing.\r
- /// </summary>\r
- /// <remarks>\r
- /// If the stream has not been made yet, this setting will be applied when the stream starts to play.\r
- /// Precondition: Call AddDeviceForStreamRouting() before calling this function.\r
- /// </remarks>\r
- public void ApplyStreamRouting()\r
- {\r
- int ret = Interop.AudioStreamPolicy.ApplyStreamRouting(_streamInfo);\r
- Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Apply Routing: " + (AudioManagerError)ret);\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to apply stream routing");\r
- }\r
-\r
- /// <summary>\r
- /// Adds the device to the stream information for the stream routing.\r
- /// </summary>\r
- /// <remarks>\r
- /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device.\r
- /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly.\r
- /// Postcondition: You can apply this setting by calling ApplyStreamRouting().\r
- /// </remarks>\r
- /// <param name="soundDevice">The device item from the current sound devices list.</param>\r
- public void AddDeviceForStreamRouting(AudioDevice soundDevice)\r
- {\r
- int ret = Interop.AudioStreamPolicy.AddDeviceForStreamRouting(_streamInfo, soundDevice.Handle);\r
- Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Add stream routing: " + (AudioManagerError)ret);\r
-\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to add device for stream routing");\r
- }\r
-\r
- /// <summary>\r
- /// Removes the device to the stream information for the stream routing.\r
- /// </summary>\r
- /// <remarks>\r
- /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device.\r
- /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly.\r
- /// Postcondition: You can apply this setting by calling ApplyStreamRouting().\r
- /// </remarks>\r
- /// <param name="soundDevice">The device item from the current sound devices list.</param>\r
- public void RemoveDeviceForStreamRouting(AudioDevice soundDevice)\r
- {\r
- int ret = Interop.AudioStreamPolicy.RemoveDeviceForStreamRouting(_streamInfo, soundDevice.Handle);\r
- Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Remove stream routing: " + (AudioManagerError)ret);\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to remove device for stream routing");\r
- }\r
-\r
- public void Dispose()\r
- {\r
- Dispose(true);\r
- GC.SuppressFinalize(this);\r
- }\r
-\r
- protected virtual void Dispose(bool disposing)\r
- {\r
- if (!_disposed)\r
- {\r
- if (disposing)\r
- {\r
- // to be used if there are any other disposable objects\r
- }\r
- if (_streamInfo != IntPtr.Zero)\r
- {\r
- Interop.AudioStreamPolicy.DestroyStreamInformation(_streamInfo); // Destroy the handle\r
- _streamInfo = IntPtr.Zero;\r
- }\r
- _disposed = true;\r
- }\r
- }\r
-\r
- private static void RegisterFocusStateWatchEvent()\r
- {\r
- _focusStateWatchCallback = (AudioStreamFocusOptions options, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData) =>\r
- {\r
- FocusStateChangedEventArgs eventArgs = new FocusStateChangedEventArgs(focusState, reason, extraInfo);\r
- if (options == AudioStreamFocusOptions.Playback)\r
- {\r
- _focusStateWatchForPlayback?.Invoke(null, eventArgs);\r
- }\r
- else if (options == AudioStreamFocusOptions.Recording)\r
- {\r
- _focusStateWatchForRecording?.Invoke(null, eventArgs);\r
- }\r
- else if (options == (AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording))\r
- {\r
- _focusStateWatchForPlayback?.Invoke(null, eventArgs);\r
- _focusStateWatchForRecording?.Invoke(null, eventArgs);\r
- }\r
- };\r
- int ret = Interop.AudioStreamPolicy.SetFocusStateWatchCallback(AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording, _focusStateWatchCallback, IntPtr.Zero);\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus state watch callback");\r
- }\r
-\r
- private static void UnregisterFocusStateWatch()\r
- {\r
- int ret = Interop.AudioStreamPolicy.UnsetFocusStateWatchCallback();\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset focus state watch callback");\r
- }\r
- }\r
-}\r
+using System;
+
+namespace Tizen.Multimedia
+{
+ internal static class AudioStreamPolicyLog
+ {
+ internal const string Tag = "Tizen.Multimedia.AudioStreamPolicy";
+ }
+
+ /// <summary>
+ /// The Stream Policy API provides functions to control a sound stream.
+ /// </summary>
+ public class AudioStreamPolicy : IDisposable
+ {
+ private static int _focusStateWatchCounter = 0;
+ private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForPlayback;
+ private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForRecording;
+ private static Interop.SoundStreamFocusStateWatchCallback _focusStateWatchCallback;
+
+ private IntPtr _streamInfo;
+ private AudioStreamType _streamType;
+ private bool _disposed = false;
+ private EventHandler<StreamFocusStateChangedEventArgs> _focusStateChanged;
+ private Interop.SoundStreamFocusStateChangedCallback _focusStateChangedCallback;
+
+ /// <summary>
+ /// Creates and returns an AudioStreamPolicy object
+ /// </summary>
+ /// <remarks>
+ /// To apply the stream policy according to this stream information, this object should be passed to other APIs
+ /// related to playback or recording. (e.g., player, wav-player, audio-io, etc.)
+ /// </remarks>
+ /// <param name="streamType">Type of sound stream for which policy needs to be created</param>
+ /// <returns>StreamPolicy object</returns>
+ public AudioStreamPolicy(AudioStreamType streamType)
+ {
+ _streamType = streamType;
+ _focusStateChangedCallback = (IntPtr streamInfo, int reason, string extraInfo, IntPtr userData) => {
+ StreamFocusStateChangedEventArgs eventArgs = new StreamFocusStateChangedEventArgs((AudioStreamFocusChangedReason)reason, extraInfo);
+ _focusStateChanged?.Invoke(this, eventArgs);
+ };
+ int ret = Interop.AudioStreamPolicy.CreateStreamInformation((int)streamType, _focusStateChangedCallback, IntPtr.Zero, out _streamInfo);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to create stream information");
+ }
+
+ ~AudioStreamPolicy()
+ {
+ Dispose(false);
+ }
+
+ /// <summary>
+ /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process.
+ /// <remarks>
+ /// Remarks: You can set this only once per process.
+ /// </remarks>
+ /// </summary>
+ public static event EventHandler<FocusStateChangedEventArgs> PlaybackFocusStateWatch {
+ add {
+ if(_focusStateWatchCounter == 0) {
+ RegisterFocusStateWatchEvent();
+ }
+ _focusStateWatchCounter++;
+ _focusStateWatchForPlayback += value;
+ }
+ remove {
+ _focusStateWatchForPlayback -= value;
+ _focusStateWatchCounter--;
+ if(_focusStateWatchCounter == 0) {
+ UnregisterFocusStateWatch();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process.
+ /// <remarks>
+ /// Remarks: You can set this only once per process.
+ /// </remarks>
+ /// </summary>
+ public static event EventHandler<FocusStateChangedEventArgs> RecordingFocusStateWatch {
+ add {
+ if(_focusStateWatchCounter == 0) {
+ RegisterFocusStateWatchEvent();
+ }
+ _focusStateWatchCounter++;
+ _focusStateWatchForRecording += value;
+ }
+ remove {
+ _focusStateWatchForRecording -= value;
+ _focusStateWatchCounter--;
+ if(_focusStateWatchCounter == 0) {
+ UnregisterFocusStateWatch();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Registers function to be called when the state of focus that belongs to the current
+ /// streamInfo is changed.
+ /// </summary>
+ /// <remarks>
+ /// Remarks: This function is issued in the internal thread of the sound manager. Therefore it is recommended not to call UI update function in this function.
+ /// Postcondition : Check PlaybackFocusState and RecordingFocusState in the registered event handler to figure out how the focus state of the StreamInfo has been changed.
+ /// </remarks>
+ public event EventHandler<StreamFocusStateChangedEventArgs> StreamFocusStateChanged {
+ add {
+ _focusStateChanged += value;
+ }
+ remove {
+ _focusStateChanged -= value;
+ }
+ }
+
+ /// <summary>
+ /// The sound type of the stream information.
+ /// </summary>
+ public AudioVolumeType VolumeType {
+ get {
+ AudioVolumeType soundType;
+ int ret = Interop.AudioStreamPolicy.GetSoundType(_streamInfo, out soundType);
+ if(ret != 0) {
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get sound type:" + (AudioManagerError)ret);
+ return AudioVolumeType.None;
+ }
+ return soundType;
+ }
+ }
+
+ /// <summary>
+ /// The state of focus for playback.
+ /// </summary>
+ public AudioStreamFocusState PlaybackFocusState {
+ get {
+ AudioStreamFocusState stateForPlayback;
+ AudioStreamFocusState stateForRecording;
+ int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording);
+ if(ret != 0) {
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret);
+ return AudioStreamFocusState.Released;
+ }
+ return stateForPlayback;
+ }
+ }
+
+ /// <summary>
+ /// The state of focus for recording.
+ /// </summary>
+ public AudioStreamFocusState RecordingFocusState {
+ get {
+ AudioStreamFocusState stateForPlayback;
+ AudioStreamFocusState stateForRecording;
+ int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording);
+ if(ret != 0) {
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret);
+ return AudioStreamFocusState.Released;
+ }
+ return stateForRecording;
+ }
+ }
+
+ /// <summary>
+ /// Auto focus reacquisition property
+ /// </summary>
+ /// <remarks>
+ /// The focus reacquistion is set as default. If you don't want to reacquire the focus you've lost automatically, disable the focus reacqusition setting by using this API and vice versa.
+ /// </remarks>
+ public bool FocusReacquisitionEnabled {
+ get {
+ bool enabled;
+ int ret = Interop.AudioStreamPolicy.GetFocusReacquisition(_streamInfo, out enabled);
+ if(ret != 0) {
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus reacquisition" + (AudioManagerError)ret);
+ return true;
+ }
+ return enabled;
+ }
+ set {
+ int ret = Interop.AudioStreamPolicy.SetFocusReacquisition(_streamInfo, value);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus reacquisition");
+ }
+ }
+
+ internal IntPtr Handle {
+ get {
+ return _streamInfo;
+ }
+ }
+
+ /// <summary>
+ /// Acquires the stream focus.
+ /// </summary>
+ /// <param name="focusMask">The focus mask that user wants to acquire</param>
+ /// <param name="extraInformation">The Extra information for this request (optional, this can be null)</param>
+ /// <remarks>
+ /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception
+ /// </remarks>
+ public void AcquireFocus(AudioStreamFocusOptions options, string extraInformation)
+ {
+ int ret = Interop.AudioStreamPolicy.AcquireFocus(_streamInfo, options, extraInformation);
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Acquire focus return: " + ret);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to acquire focus");
+ }
+
+ /// <summary>
+ /// Releases the acquired focus.
+ /// </summary>
+ /// <param name="options">The focus mask that user wants to release</param>
+ /// <param name="extraInformation">he Extra information for this request (optional, this can be null)</param>
+ /// <remarks>
+ /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception
+ /// </remarks>
+ public void ReleaseFocus(AudioStreamFocusOptions options, string extraInformation)
+ {
+ int ret = Interop.AudioStreamPolicy.ReleaseFocus(_streamInfo, options, extraInformation);
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Release focus return: " + ret);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to release focus");
+ }
+
+ /// <summary>
+ /// Applies the stream routing.
+ /// </summary>
+ /// <remarks>
+ /// If the stream has not been made yet, this setting will be applied when the stream starts to play.
+ /// Precondition: Call AddDeviceForStreamRouting() before calling this function.
+ /// </remarks>
+ public void ApplyStreamRouting()
+ {
+ int ret = Interop.AudioStreamPolicy.ApplyStreamRouting(_streamInfo);
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Apply Routing: " + (AudioManagerError)ret);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to apply stream routing");
+ }
+
+ /// <summary>
+ /// Adds the device to the stream information for the stream routing.
+ /// </summary>
+ /// <remarks>
+ /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device.
+ /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly.
+ /// Postcondition: You can apply this setting by calling ApplyStreamRouting().
+ /// </remarks>
+ /// <param name="soundDevice">The device item from the current sound devices list.</param>
+ public void AddDeviceForStreamRouting(AudioDevice soundDevice)
+ {
+ int ret = Interop.AudioStreamPolicy.AddDeviceForStreamRouting(_streamInfo, soundDevice.Handle);
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Add stream routing: " + (AudioManagerError)ret);
+
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to add device for stream routing");
+ }
+
+ /// <summary>
+ /// Removes the device to the stream information for the stream routing.
+ /// </summary>
+ /// <remarks>
+ /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device.
+ /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly.
+ /// Postcondition: You can apply this setting by calling ApplyStreamRouting().
+ /// </remarks>
+ /// <param name="soundDevice">The device item from the current sound devices list.</param>
+ public void RemoveDeviceForStreamRouting(AudioDevice soundDevice)
+ {
+ int ret = Interop.AudioStreamPolicy.RemoveDeviceForStreamRouting(_streamInfo, soundDevice.Handle);
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Remove stream routing: " + (AudioManagerError)ret);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to remove device for stream routing");
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if(!_disposed) {
+ if(disposing) {
+ // to be used if there are any other disposable objects
+ }
+ if(_streamInfo != IntPtr.Zero) {
+ Interop.AudioStreamPolicy.DestroyStreamInformation(_streamInfo); // Destroy the handle
+ _streamInfo = IntPtr.Zero;
+ }
+ _disposed = true;
+ }
+ }
+
+ private static void RegisterFocusStateWatchEvent()
+ {
+ _focusStateWatchCallback = (AudioStreamFocusOptions options, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData) => {
+ FocusStateChangedEventArgs eventArgs = new FocusStateChangedEventArgs(focusState, reason, extraInfo);
+ if(options == AudioStreamFocusOptions.Playback) {
+ _focusStateWatchForPlayback?.Invoke(null, eventArgs);
+ } else if(options == AudioStreamFocusOptions.Recording) {
+ _focusStateWatchForRecording?.Invoke(null, eventArgs);
+ } else if(options == (AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording)) {
+ _focusStateWatchForPlayback?.Invoke(null, eventArgs);
+ _focusStateWatchForRecording?.Invoke(null, eventArgs);
+ }
+ };
+ int ret = Interop.AudioStreamPolicy.SetFocusStateWatchCallback(AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording, _focusStateWatchCallback, IntPtr.Zero);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus state watch callback");
+ }
+
+ private static void UnregisterFocusStateWatch()
+ {
+ int ret = Interop.AudioStreamPolicy.UnsetFocusStateWatchCallback();
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset focus state watch callback");
+ }
+ }
+}
/// <summary>
/// Registers a function to be invoked when the volume level is changed.
/// </summary>
- public event EventHandler<VolumeChangedEventArgs> Changed
- {
- add
- {
+ public event EventHandler<VolumeChangedEventArgs> Changed {
+ add {
Tizen.Log.Info(AudioVolumeLog.Tag, "VolumeController Changed Event added....");
- if (_volumeChanged == null)
- {
+ if(_volumeChanged == null) {
RegisterVolumeChangedEvent();
}
_volumeChanged += value;
}
- remove
- {
+ remove {
Tizen.Log.Info(AudioVolumeLog.Tag, "VolumeController Changed Event removed....");
_volumeChanged -= value;
- if (_volumeChanged == null)
- {
+ if(_volumeChanged == null) {
UnregisterVolumeChangedEvent();
}
}
/// The Sound Manager has predefined types of sounds.(system, notification, alarm, ringtone, media, call, voip, voice).
/// The type of the sound being currently played.
/// </summary>
- public AudioVolumeType CurrentType
- {
- get
- {
+ public AudioVolumeType CurrentType {
+ get {
AudioVolumeType currentType;
int ret = Interop.AudioVolume.GetCurrentSoundType(out currentType);
- if ( ret != 0)
- {
+ if(ret != 0) {
Tizen.Log.Info(AudioVolumeLog.Tag, "Unable to get current sound type" + (AudioManagerError)ret);
return AudioVolumeType.None;
}
return currentType;
}
- set
- {
+ set {
int ret = Interop.AudioVolume.SetCurrentSoundType(value);
- if (ret != 0)
- {
- if (value == AudioVolumeType.None)
- {
+ if(ret != 0) {
+ if(value == AudioVolumeType.None) {
ret = Interop.AudioVolume.UnsetCurrentType();
}
}
}
}
+ /// <summary>
+ /// The indexer class which is used to get/set volume level specified for a particular sound type.
+ /// </summary>
public VolumeLevel Level;
+ /// <summary>
+ /// The indexer class which is used to get maximum volume level supported for a particular sound type.
+ /// </summary>
public MaxVolumeLevel MaxLevel;
private void RegisterVolumeChangedEvent()
{
- _volumeChangedCallback = (AudioVolumeType type, uint volume, IntPtr userData) =>
- {
+ _volumeChangedCallback = (AudioVolumeType type, uint volume, IntPtr userData) => {
VolumeChangedEventArgs eventArgs = new VolumeChangedEventArgs(type, volume);
_volumeChanged.Invoke(this, eventArgs);
};
internal const string Tag = "Tizen.Multimedia.MaxVolume";
}
+ /// <summary>
+ /// This is a indexer class which is used to get the maximum volume level
+ /// supported for a particular sound type.
+ /// </summary>
public class MaxVolumeLevel
{
- public int this[AudioVolumeType type]
- {
- get
- {
- if (type == AudioVolumeType.None)
+ public int this [AudioVolumeType type] {
+ get {
+ if(type == AudioVolumeType.None)
throw new ArgumentException("Wrong Audio volume type. Cannot get max volume level for AudioVolumeType.None");
int maxVolume;
int ret = Interop.AudioVolume.GetMaxVolume(type, out maxVolume);
- if (ret != 0)
- {
+ if(ret != 0) {
Tizen.Log.Info(MaxVolumeLog.Tag, "Max Level Error: " + (AudioManagerError)ret);
return -1;
}
internal const string Tag = "Tizen.Multimedia.VolumeLevel";
}
+ /// <summary>
+ /// This is a indexer class which is used to get/set the volume level
+ /// specified for a particular sound type.
+ /// </summary>
public class VolumeLevel
{
- public int this[AudioVolumeType type]
- {
- get
- {
- if (type == AudioVolumeType.None)
+ public int this [AudioVolumeType type] {
+ get {
+ if(type == AudioVolumeType.None)
throw new ArgumentException("Wrong Audio volume type. Cannot get volume level for AudioVolumeType.None");
int volume;
int ret = Interop.AudioVolume.GetVolume(type, out volume);
- if (ret != 0)
- {
+ if(ret != 0) {
Tizen.Log.Info(VolumeLevelLog.Tag, "Get Level Error: " + (AudioManagerError)ret);
return -1;
}
return volume;
}
- set
- {
- if (type == AudioVolumeType.None)
+ set {
+ if(type == AudioVolumeType.None)
throw new ArgumentException("Wrong Audio volume type. Cannot set volume level for AudioVolumeType.None");
int ret = Interop.AudioVolume.SetVolume(type, value);
- if (ret != 0)
- {
+ if(ret != 0) {
Tizen.Log.Info(VolumeLevelLog.Tag, "Set Level Error: " + (AudioManagerError)ret);
AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set level");
}
/// </summary>
public class AudioStreamDeliveredEventArgs : EventArgs
{
- private byte[] _stream = null;
- private AudioSampleType _type = AudioSampleType.S16Le;
- private int _channel = 0;
- private uint _recordingTime = 0;
+ private byte[] _stream = null;
+ private AudioSampleType _type = AudioSampleType.S16Le;
+ private int _channel = 0;
+ private uint _recordingTime = 0;
- internal AudioStreamDeliveredEventArgs(byte[] stream, AudioSampleType type, int channel, uint recordingTime)
- {
- _stream = stream;
- _type = type;
- _channel = channel;
- _recordingTime = recordingTime;
- }
+ internal AudioStreamDeliveredEventArgs(byte[] stream, AudioSampleType type, int channel, uint recordingTime)
+ {
+ _stream = stream;
+ _type = type;
+ _channel = channel;
+ _recordingTime = recordingTime;
+ }
/// <summary>
/// The audio stream data.
/// </summary>
- public byte[] Stream
- {
- get
- {
- return _stream;
- }
+ public byte[] Stream {
+ get {
+ return _stream;
+ }
}
/// <summary>
/// The audio format type.
/// </summary>
- public AudioSampleType Type
- {
- get
- {
- return _type;
- }
+ public AudioSampleType Type {
+ get {
+ return _type;
+ }
}
/// <summary>
/// The number of channels.
/// </summary>
- public int Channel
- {
- get
- {
- return _channel;
- }
+ public int Channel {
+ get {
+ return _channel;
+ }
}
/// <summary>
/// The recording time of the stream buffer in milliseconds.
/// </summary>
- public uint RecordingTime
- {
- get
- {
- return _recordingTime;
- }
+ public uint RecordingTime {
+ get {
+ return _recordingTime;
+ }
}
}
}
namespace Tizen.Multimedia
{
- public class Camera
- {
- public Camera ()
- {
- }
- }
+ /// <summary>
+ /// The Camera API allows application developers to support using the camera
+ /// </summary>
+ public class Camera
+ {
+ public Camera()
+ {
+ }
+ }
}
}
/// <summary>
- /// The maximum size of a recording file in KB(kilobytes). If 0 means
+ /// The maximum size of a recording file in KB(kilobytes). If 0, means
/// unlimited recording size.
/// </summary>
/// <remarks>
}
/// <summary>
- /// The time limit of a recording file in Seconds. If 0 means unlimited recording
+ /// The time limit of a recording file in Seconds. If 0, means unlimited recording
/// time.
/// </summary>
/// <remarks>
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)
namespace Tizen.Multimedia
{
- /// <summary>
- /// Enumeration for Audio Codec.
- /// </summary>
- public enum RecorderAudioCodec
- {
- /// <summary>
- /// Disable Audio track.
- /// </summary>
- Disable = -1,
- /// <summary>
- /// AMR codec.
- /// </summary>
- Amr = 0,
- /// <summary>
- /// AAC codec.
- /// </summary>
- Aac,
- /// <summary>
- /// Vorbis codec.
- /// </summary>
- Vorbis,
- /// <summary>
- /// PCM codec.
- /// </summary>
- Pcm,
- /// <summary>
- /// The mp3 codec.
- /// </summary>
- Mp3
- }
+ /// <summary>
+ /// Enumeration for Audio Codec.
+ /// </summary>
+ public enum RecorderAudioCodec
+ {
+ /// <summary>
+ /// Disable Audio track.
+ /// </summary>
+ Disable = -1,
+ /// <summary>
+ /// AMR codec.
+ /// </summary>
+ Amr = 0,
+ /// <summary>
+ /// AAC codec.
+ /// </summary>
+ Aac,
+ /// <summary>
+ /// Vorbis codec.
+ /// </summary>
+ Vorbis,
+ /// <summary>
+ /// PCM codec.
+ /// </summary>
+ Pcm,
+ /// <summary>
+ /// The mp3 codec.
+ /// </summary>
+ Mp3
+ }
- /// <summary>
- /// Enumeration for Audio capture devices.
- /// </summary>
- public enum RecorderAudioDevice
- {
- /// <summary>
- /// Capture audio from Mic device.
- /// </summary>
- Mic,
- /// <summary>
- /// Capture audio from modem.
- /// </summary>
- Modem
- }
+ /// <summary>
+ /// Enumeration for Audio capture devices.
+ /// </summary>
+ public enum RecorderAudioDevice
+ {
+ /// <summary>
+ /// Capture audio from Mic device.
+ /// </summary>
+ Mic,
+ /// <summary>
+ /// Capture audio from modem.
+ /// </summary>
+ Modem
+ }
- /// <summary>
- /// Enumeration for the file container format.
- /// </summary>
- public enum RecorderFileFormat
- {
- /// <summary>
- /// 3GP file format.
- /// </summary>
- ThreeGp,
- /// <summary>
- /// MP4 file format.
- /// </summary>
- Mp4,
- /// <summary>
- /// AMR file format.
- /// </summary>
- Amr,
- /// <summary>
- /// ADTS file format.
- /// </summary>
- Adts,
- /// <summary>
- /// WAV file format.
- /// </summary>
- Wav,
- /// <summary>
- /// OGG file format.
- /// </summary>
- Ogg,
- /// <summary>
- /// M2TS file format.
- /// </summary>
- M2ts
- }
+ /// <summary>
+ /// Enumeration for the file container format.
+ /// </summary>
+ public enum RecorderFileFormat
+ {
+ /// <summary>
+ /// 3GP file format.
+ /// </summary>
+ ThreeGp,
+ /// <summary>
+ /// MP4 file format.
+ /// </summary>
+ Mp4,
+ /// <summary>
+ /// AMR file format.
+ /// </summary>
+ Amr,
+ /// <summary>
+ /// ADTS file format.
+ /// </summary>
+ Adts,
+ /// <summary>
+ /// WAV file format.
+ /// </summary>
+ Wav,
+ /// <summary>
+ /// OGG file format.
+ /// </summary>
+ Ogg,
+ /// <summary>
+ /// M2TS file format.
+ /// </summary>
+ M2ts
+ }
- /// <summary>
- /// Enumeration for the recorder policy.
- /// </summary>
- public enum RecorderPolicy
- {
- /// <summary>
- /// None.
- /// </summary>
- None = 0,
- /// <summary>
- /// Security policy.
- /// </summary>
- Security = 4,
- /// <summary>
- /// Resource conflict policy.
- /// </summary>
- ResourceConflict = 5
- }
+ /// <summary>
+ /// Enumeration for the recorder policy.
+ /// </summary>
+ public enum RecorderPolicy
+ {
+ /// <summary>
+ /// None.
+ /// </summary>
+ None = 0,
+ /// <summary>
+ /// Security policy.
+ /// </summary>
+ Security = 4,
+ /// <summary>
+ /// Resource conflict policy.
+ /// </summary>
+ ResourceConflict = 5
+ }
- /// <summary>
- /// Enumeration for the recording limit.
- /// </summary>
- public enum RecordingLimitType
- {
- /// <summary>
- /// Time limit in seconds of recording file
- /// </summary>
- Time,
- /// <summary>
- /// Size limit in KB(KiloBytes) of recording file.
- /// </summary>
- Size,
- /// <summary>
- /// No free space in storage.
- /// </summary>
- Space
- }
+ /// <summary>
+ /// Enumeration for the recording limit.
+ /// </summary>
+ public enum RecordingLimitType
+ {
+ /// <summary>
+ /// Time limit in seconds of recording file
+ /// </summary>
+ Time,
+ /// <summary>
+ /// Size limit in KB(KiloBytes) of recording file.
+ /// </summary>
+ Size,
+ /// <summary>
+ /// No free space in storage.
+ /// </summary>
+ Space
+ }
- /// <summary>
- /// Enumeration for the recorder rotation type.
- /// </summary>
- public enum RecorderOrientation
- {
- /// <summary>
- /// No rotation.
- /// </summary>
- RotationNone,
- /// <summary>
- /// 90 Degree rotation.
- /// </summary>
- Rotation90,
- /// <summary>
- /// 180 Degree rotation.
- /// </summary>
- Rotation180,
- /// <summary>
- /// 270 Degree rotation.
- /// </summary>
- Rotation270
- }
+ /// <summary>
+ /// Enumeration for the recorder rotation type.
+ /// </summary>
+ public enum RecorderOrientation
+ {
+ /// <summary>
+ /// No rotation.
+ /// </summary>
+ RotationNone,
+ /// <summary>
+ /// 90 Degree rotation.
+ /// </summary>
+ Rotation90,
+ /// <summary>
+ /// 180 Degree rotation.
+ /// </summary>
+ Rotation180,
+ /// <summary>
+ /// 270 Degree rotation.
+ /// </summary>
+ Rotation270
+ }
- /// <summary>
- /// Enumeration for recorder states.
- /// </summary>
- public enum RecorderState
- {
- /// <summary>
- /// Recorder is not created.
- /// </summary>
- None,
- /// <summary>
- /// Recorder is created, but not prepared.
- /// </summary>
- Created,
- /// <summary>
- /// Recorder is ready to record. In case of video recorder,
- /// preview display will be shown.
- /// </summary>
- Ready,
- /// <summary>
- /// Recorder is recording media.
- /// </summary>
- Recording,
- /// <summary>
- /// Recorder is paused while recording media.
- /// </summary>
- Paused
- }
+ /// <summary>
+ /// Enumeration for recorder states.
+ /// </summary>
+ public enum RecorderState
+ {
+ /// <summary>
+ /// Recorder is not created.
+ /// </summary>
+ None,
+ /// <summary>
+ /// Recorder is created, but not prepared.
+ /// </summary>
+ Created,
+ /// <summary>
+ /// Recorder is ready to record. In case of video recorder,
+ /// preview display will be shown.
+ /// </summary>
+ Ready,
+ /// <summary>
+ /// Recorder is recording media.
+ /// </summary>
+ Recording,
+ /// <summary>
+ /// Recorder is paused while recording media.
+ /// </summary>
+ Paused
+ }
- /// <summary>
- /// Enumeration for video codec.
- /// </summary>
- public enum RecorderVideoCodec
- {
- /// <summary>
- /// H263 codec.
- /// </summary>
- H263,
- /// <summary>
- /// H264 codec.
- /// </summary>
- H264,
- /// <summary>
- /// MPEG4 codec.
- /// </summary>
- Mpeg4,
- /// <summary>
- /// Theora codec.
- /// </summary>
- Theora
- }
+ /// <summary>
+ /// Enumeration for video codec.
+ /// </summary>
+ public enum RecorderVideoCodec
+ {
+ /// <summary>
+ /// H263 codec.
+ /// </summary>
+ H263,
+ /// <summary>
+ /// H264 codec.
+ /// </summary>
+ H264,
+ /// <summary>
+ /// MPEG4 codec.
+ /// </summary>
+ Mpeg4,
+ /// <summary>
+ /// Theora codec.
+ /// </summary>
+ Theora
+ }
/// <summary>
/// Enumeration for audio sample type.
/// </summary>
- public enum AudioSampleType {
+ public enum AudioSampleType
+ {
/// <summary>
/// Unsigned 8-bit audio samples.
/// </summary>
/// <summary>
/// Enumeration for recorder failure error.
/// </summary>
- public enum RecorderErrorCode {
+ public enum RecorderErrorCode
+ {
/// <summary>
/// Device Error.
/// </summary>
- DeviceError = RecorderError.ErrorDevice,
+ DeviceError = RecorderError.ErrorDevice,
/// <summary>
/// Internal error.
/// </summary>
- InvalidOperation = RecorderError.InvalidOperation,
+ InvalidOperation = RecorderError.InvalidOperation,
/// <summary>
/// Out of memory.
/// </summary>
- OutOfMemory = RecorderError.OutOfMemory
+ OutOfMemory = RecorderError.OutOfMemory
}
}
namespace Tizen.Multimedia
{
- internal enum RecorderError
- {
- None = ErrorCode.None,
- InvalidParameter = ErrorCode.InvalidParameter,
- TizenErrorRecorder = -0x01950000,
- RecorderErrorClass = TizenErrorRecorder | 0x10,
- InvalidState = RecorderErrorClass | 0x02,
- OutOfMemory = ErrorCode.OutOfMemory,
- ErrorDevice = RecorderErrorClass | 0x04,
- InvalidOperation = ErrorCode.InvalidOperation,
- SoundPolicy = RecorderErrorClass | 0x06,
- SecurityRestricted = RecorderErrorClass | 0x07,
- SoundPolicyByCall = RecorderErrorClass | 0x08,
- SoundPolicyByAlarm = RecorderErrorClass | 0x09,
- Esd = RecorderErrorClass | 0x0a,
- OutOfStorage = RecorderErrorClass | 0x0b,
- PermissionDenied = ErrorCode.PermissionDenied,
- NotSupported = ErrorCode.NotSupported,
- ResourceConflict = RecorderErrorClass | 0x0c
- }
+ internal enum RecorderError
+ {
+ None = ErrorCode.None,
+ InvalidParameter = ErrorCode.InvalidParameter,
+ TizenErrorRecorder = -0x01950000,
+ RecorderErrorClass = TizenErrorRecorder | 0x10,
+ InvalidState = RecorderErrorClass | 0x02,
+ OutOfMemory = ErrorCode.OutOfMemory,
+ ErrorDevice = RecorderErrorClass | 0x04,
+ InvalidOperation = ErrorCode.InvalidOperation,
+ SoundPolicy = RecorderErrorClass | 0x06,
+ SecurityRestricted = RecorderErrorClass | 0x07,
+ SoundPolicyByCall = RecorderErrorClass | 0x08,
+ SoundPolicyByAlarm = RecorderErrorClass | 0x09,
+ Esd = RecorderErrorClass | 0x0a,
+ OutOfStorage = RecorderErrorClass | 0x0b,
+ PermissionDenied = ErrorCode.PermissionDenied,
+ NotSupported = ErrorCode.NotSupported,
+ ResourceConflict = RecorderErrorClass | 0x0c
+ }
- internal static class RecorderErrorFactory
- {
- internal static void ThrowException(int errorCode, string errorMessage = null, string paramName= null)
- {
- RecorderError err = (RecorderError)errorCode;
- if (string.IsNullOrEmpty (errorMessage))
- {
- errorMessage = err.ToString ();
- }
- switch ((RecorderError)errorCode)
- {
- case RecorderError.InvalidParameter:
- throw new ArgumentException (errorMessage, paramName);
+ internal static class RecorderErrorFactory
+ {
+ internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null)
+ {
+ RecorderError err = (RecorderError)errorCode;
+ if(string.IsNullOrEmpty(errorMessage)) {
+ errorMessage = err.ToString();
+ }
+ switch((RecorderError)errorCode) {
+ case RecorderError.InvalidParameter:
+ throw new ArgumentException(errorMessage, paramName);
- case RecorderError.InvalidState:
- case RecorderError.OutOfMemory:
- case RecorderError.ErrorDevice:
- case RecorderError.InvalidOperation:
- case RecorderError.SoundPolicy:
- case RecorderError.SecurityRestricted:
- case RecorderError.SoundPolicyByCall:
- case RecorderError.SoundPolicyByAlarm:
- case RecorderError.Esd:
- case RecorderError.OutOfStorage:
- case RecorderError.PermissionDenied:
- case RecorderError.NotSupported:
- case RecorderError.ResourceConflict:
- throw new InvalidOperationException (errorMessage);
- }
- }
- }
+ case RecorderError.InvalidState:
+ case RecorderError.OutOfMemory:
+ case RecorderError.ErrorDevice:
+ case RecorderError.InvalidOperation:
+ case RecorderError.SoundPolicy:
+ case RecorderError.SecurityRestricted:
+ case RecorderError.SoundPolicyByCall:
+ case RecorderError.SoundPolicyByAlarm:
+ case RecorderError.Esd:
+ case RecorderError.OutOfStorage:
+ case RecorderError.PermissionDenied:
+ case RecorderError.NotSupported:
+ case RecorderError.ResourceConflict:
+ throw new InvalidOperationException(errorMessage);
+ }
+ }
+ }
}
/// </summary>
public class RecorderInterruptedEventArgs : EventArgs
{
- private RecorderPolicy _policy = RecorderPolicy.None;
- private RecorderState _previous = RecorderState.None;
- private RecorderState _current = RecorderState.None;
+ private RecorderPolicy _policy = RecorderPolicy.None;
+ private RecorderState _previous = RecorderState.None;
+ private RecorderState _current = RecorderState.None;
- internal RecorderInterruptedEventArgs(RecorderPolicy policy, RecorderState previous, RecorderState current)
- {
- _policy = policy;
- _previous = previous;
- _current = current;
- }
+ internal RecorderInterruptedEventArgs(RecorderPolicy policy, RecorderState previous, RecorderState current)
+ {
+ _policy = policy;
+ _previous = previous;
+ _current = current;
+ }
/// <summary>
/// The policy that interrupted the recorder.
/// </summary>
- public RecorderPolicy Policy
- {
- get
- {
- return _policy;
- }
+ public RecorderPolicy Policy {
+ get {
+ return _policy;
+ }
}
/// <summary>
/// The previous state of the recorder.
/// </summary>
- public RecorderState Previous
- {
- get
- {
- return _previous;
- }
+ public RecorderState Previous {
+ get {
+ return _previous;
+ }
}
/// <summary>
/// The current state of the recorder.
/// </summary>
- public RecorderState Current
- {
- get
- {
- return _current;
- }
+ public RecorderState Current {
+ get {
+ return _current;
+ }
}
}
}
/// </summary>
public class RecorderStateChangedEventArgs : EventArgs
{
- private RecorderState _previous = RecorderState.None;
- private RecorderState _current = RecorderState.None;
- private bool _policy = false;
+ private RecorderState _previous = RecorderState.None;
+ private RecorderState _current = RecorderState.None;
+ private bool _policy = false;
- internal RecorderStateChangedEventArgs(RecorderState previous, RecorderState current, bool policy)
- {
- _previous = previous;
- _current = current;
- _policy = policy;
- }
+ internal RecorderStateChangedEventArgs(RecorderState previous, RecorderState current, bool policy)
+ {
+ _previous = previous;
+ _current = current;
+ _policy = policy;
+ }
/// <summary>
/// Previous state of the recorder.
/// </summary>
- public RecorderState Previous
- {
- get
- {
- return _previous;
- }
+ public RecorderState Previous {
+ get {
+ return _previous;
+ }
}
/// <summary>
/// Current state of the recorder.
/// </summary>
- public RecorderState Current
- {
- get
- {
- return _current;
- }
+ public RecorderState Current {
+ get {
+ return _current;
+ }
}
/// <summary>
- /// true if the state changed by policy, otherwise false.
+ /// true if the state changed by policy such as Resource Conflict or Security, otherwise false
+ /// in normal state change.
/// </summary>
- public bool ByPolicy
- {
- get
- {
- return _policy;
- }
+ public bool ByPolicy {
+ get {
+ return _policy;
+ }
}
}
}
/// state of the recorder when it failed.
/// </summary>
public class RecordingErrorOccurredEventArgs : EventArgs
- {
- private RecorderErrorCode _error = RecorderErrorCode.DeviceError;
- private RecorderState _state = RecorderState.None;
+ {
+ private RecorderErrorCode _error = RecorderErrorCode.DeviceError;
+ private RecorderState _state = RecorderState.None;
- internal RecordingErrorOccurredEventArgs(RecorderErrorCode error, RecorderState state)
- {
- _error = error;
- _state = state;
- }
+ internal RecordingErrorOccurredEventArgs(RecorderErrorCode error, RecorderState state)
+ {
+ _error = error;
+ _state = state;
+ }
/// <summary>
/// The error code.
/// </summary>
- public RecorderErrorCode Error
- {
- get
- {
- return _error;
- }
+ public RecorderErrorCode Error {
+ get {
+ return _error;
+ }
}
/// <summary>
/// The state of the recorder.
/// </summary>
- public RecorderState State
- {
- get
- {
- return _state;
- }
+ public RecorderState State {
+ get {
+ return _state;
+ }
}
}
/// </summary>
public class RecordingLimitReachedEventArgs : EventArgs
{
- private RecordingLimitType _type = RecordingLimitType.Size;
+ private RecordingLimitType _type = RecordingLimitType.Size;
- internal RecordingLimitReachedEventArgs(RecordingLimitType type)
- {
- _type = type;
- }
+ internal RecordingLimitReachedEventArgs(RecordingLimitType type)
+ {
+ _type = type;
+ }
/// <summary>
/// The limitation type.
/// </summary>
- public RecordingLimitType Type
- {
- get
- {
- return _type;
- }
+ public RecordingLimitType Type {
+ get {
+ return _type;
+ }
}
}
}
/// </summary>
public class RecordingStatusChangedEventArgs : EventArgs
{
- private ulong _time = 0;
- private ulong _fileSize = 0;
+ private ulong _time = 0;
+ private ulong _fileSize = 0;
- internal RecordingStatusChangedEventArgs(ulong time, ulong fileSize)
- {
- _time = time;
- _fileSize = fileSize;
- }
+ internal RecordingStatusChangedEventArgs(ulong time, ulong fileSize)
+ {
+ _time = time;
+ _fileSize = fileSize;
+ }
/// <summary>
/// The time of recording in milliseconds.
/// </summary>
- public ulong ElapsedTime
- {
- get
- {
- return _time;
- }
+ public ulong ElapsedTime {
+ get {
+ return _time;
+ }
}
/// <summary>
/// The size of the recording file in Kilobyte.
/// </summary>
- public ulong FileSize
- {
- get
- {
- return _fileSize;
- }
+ public ulong FileSize {
+ get {
+ return _fileSize;
+ }
}
}
}
namespace Tizen.Multimedia
{
-
- /// <summary>
- /// Resolution for video recording.
- /// </summary>
+ /// <summary>
+ /// Resolution for video recording.
+ /// </summary>
public class RecorderVideoResolution
{
- private int _width, _height;
- private bool _interopFlag;
- internal IntPtr _videoHandle;
+ private int _width, _height;
+ private bool _interopFlag;
+ internal IntPtr _videoHandle;
- internal RecorderVideoResolution(IntPtr handle)
- {
- _videoHandle = handle;
- _interopFlag = true;
- int ret = Interop.Recorder.GetVideoResolution (_videoHandle, out _width, out _height);
- RecorderError err = (RecorderError)ret;
- Log.Info (RecorderLog.Tag, "width " + _width + " height " + _height + "return " + err.ToString());
- }
+ internal RecorderVideoResolution(IntPtr handle)
+ {
+ _videoHandle = handle;
+ _interopFlag = true;
+ int ret = Interop.Recorder.GetVideoResolution(_videoHandle, out _width, out _height);
+ RecorderError err = (RecorderError)ret;
+ Log.Info(RecorderLog.Tag, "width " + _width + " height " + _height + "return " + err.ToString());
+ }
- internal RecorderVideoResolution(int width, int height)
- {
- _interopFlag = false;
- _width = width;
- _height = height;
- }
+ internal RecorderVideoResolution(int width, int height)
+ {
+ _interopFlag = false;
+ _width = width;
+ _height = height;
+ }
- /// <summary>
- /// The video width.
- /// </summary>
- /// <value>The width.</value>
- public int Width
- {
- get
- {
- if (_interopFlag == true)
- Interop.Recorder.GetVideoResolution (_videoHandle, out _width, out _height);
- return _width;
- }
- set
- {
- _width = value;
- if (_interopFlag == true)
- {
- int ret = Interop.Recorder.SetVideoResolution (_videoHandle, _width, _height);
- RecorderError err = (RecorderError)ret;
- Log.Info (RecorderLog.Tag, " set width " + _width + " height " + _height + "set return " + err.ToString ());
- }
- }
- }
+ /// <summary>
+ /// The video width.
+ /// </summary>
+ /// <value>The width.</value>
+ public int Width {
+ get {
+ if(_interopFlag == true)
+ Interop.Recorder.GetVideoResolution(_videoHandle, out _width, out _height);
+ return _width;
+ }
+ set {
+ _width = value;
+ if(_interopFlag == true) {
+ int ret = Interop.Recorder.SetVideoResolution(_videoHandle, _width, _height);
+ RecorderError err = (RecorderError)ret;
+ Log.Info(RecorderLog.Tag, " set width " + _width + " height " + _height + "set return " + err.ToString());
+ }
+ }
+ }
- /// <summary>
- /// The video height.
- /// </summary>
- /// <value>The height.</value>
- public int Height
- {
- get
- {
- if (_interopFlag == true)
- Interop.Recorder.GetVideoResolution (_videoHandle, out _width, out _height);
- return _height;
- }
- set
- {
- _height = value;
- if (_interopFlag == true)
- {
- int ret = Interop.Recorder.SetVideoResolution (_videoHandle, _width, _height);
- RecorderError err = (RecorderError)ret;
- Log.Info (RecorderLog.Tag, " set width " + _width + " height " + _height + "set return " + err.ToString ());
- }
- }
- }
+ /// <summary>
+ /// The video height.
+ /// </summary>
+ /// <value>The height.</value>
+ public int Height {
+ get {
+ if(_interopFlag == true)
+ Interop.Recorder.GetVideoResolution(_videoHandle, out _width, out _height);
+ return _height;
+ }
+ set {
+ _height = value;
+ if(_interopFlag == true) {
+ int ret = Interop.Recorder.SetVideoResolution(_videoHandle, _width, _height);
+ RecorderError err = (RecorderError)ret;
+ Log.Info(RecorderLog.Tag, " set width " + _width + " height " + _height + "set return " + err.ToString());
+ }
+ }
+ }
}
}