[Multimedia] Modified a constructor of the Display class not to check the raw video...
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.MediaPlayer / Player / EqualizerBand.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Diagnostics;
19 using Native = Interop.AudioEffect;
20
21 namespace Tizen.Multimedia
22 {
23
24     /// <summary>
25     /// Represents an equalizer band of <see cref="AudioEffect"/>.
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     public class EqualizerBand
29     {
30         private readonly AudioEffect _owner;
31         private readonly int _index;
32
33         internal EqualizerBand(AudioEffect owner, int index)
34         {
35             Debug.Assert(owner != null);
36
37             _owner = owner;
38             _index = index;
39
40             int frequency = 0;
41             int range = 0;
42
43             Native.GetEqualizerBandFrequency(_owner.Player.Handle, _index, out frequency).
44                 ThrowIfFailed("Failed to initialize equalizer band");
45
46             Native.GetEqualizerBandFrequencyRange(_owner.Player.Handle, _index, out range).
47                 ThrowIfFailed("Failed to initialize equalizer band");
48
49             Frequency = frequency;
50             FrequencyRange = range;
51             Log.Debug(PlayerLog.Tag, "frequency : " + frequency + ", range : " + range);
52         }
53
54         /// <summary>
55         /// Sets or gets the gain for the equalizer band.
56         /// </summary>
57         /// <param name="value">The value indicating new gain in decibel(dB).</param>
58         /// <exception cref="ObjectDisposedException">The player that this EqualizerBand belongs to has already been disposed of.</exception>
59         /// <exception cref="ArgumentOutOfRangeException">
60         ///     <paramref name="value"/> is not inside of <see cref="AudioEffect.BandLevelRange"/>.
61         /// </exception>
62         /// <since_tizen> 3 </since_tizen>
63         public int Level
64         {
65             get
66             {
67                 _owner.Player.ValidateNotDisposed();
68
69                 int value = 0;
70                 Native.GetEqualizerBandLevel(_owner.Player.Handle, _index, out value).
71                     ThrowIfFailed("Failed to get the level of the equalizer band");
72                 Log.Info(PlayerLog.Tag, "get level : " + value);
73                 return value;
74             }
75             set
76             {
77                 _owner.Player.ValidateNotDisposed();
78
79                 if (value < _owner.BandLevelRange.Min || _owner.BandLevelRange.Max < value)
80                 {
81                     Log.Error(PlayerLog.Tag, "invalid level : " + value);
82                     throw new ArgumentOutOfRangeException(nameof(value), value,
83                         $"valid value range is { nameof(AudioEffect.BandLevelRange) }." +
84                         $"but got {value}.");
85                 }
86
87                 Native.SetEqualizerBandLevel(_owner.Player.Handle, _index, value).
88                     ThrowIfFailed("Failed to set the level of the equalizer band");
89             }
90         }
91
92
93         /// <summary>
94         /// Gets the frequency in the dB.
95         /// </summary>
96         /// <since_tizen> 3 </since_tizen>
97         public int Frequency { get; }
98
99         /// <summary>
100         /// Gets the frequency range in the dB.
101         /// </summary>
102         /// <since_tizen> 3 </since_tizen>
103         public int FrequencyRange { get; }
104
105     }
106 }