2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
20 * @brief This is the header file for the %Tone class.
22 * This header file contains the declarations of the %Tone class.
25 #ifndef _FMEDIA_TONE_H_
26 #define _FMEDIA_TONE_H_
28 #include <FBaseObject.h>
29 #include <FMediaToneTypes.h>
31 namespace Tizen { namespace Media
36 * @brief This class generates a tone.
41 * The instance of the %Tone class can be played using TonePlayer.
43 * The %Tone class generates a tone and provides methods for:
44 * - Generating a single tone.
45 * - Generating dual tones with two different values of frequencies.
46 * - Generating a silent tone for a specified period of interval.
49 class _OSP_EXPORT_ Tone
50 : public Tizen::Base::Object
54 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
58 * @remarks After creating an instance of this class, one of the Construct() methods must be called explicitly to initialize this instance.
63 * This destructor overrides Tizen::Base::Object::~Object(). @n
64 * The resources are deallocated by this method.
65 * This method must be called in the same thread as the Construct() method.
76 * Initializes this instance of %Tone with the values of the specified tone.
78 * @brief <i> [Deprecated] </i>
79 * @deprecated This method is deprecated because this method is not used as 2-phase constructor.
82 * @return An error code
83 * @param[in] firstFrequency The first frequency of the dual tone in Hertz (Hz) @n
84 * The range of this parameter is @c 0 Hz to @c 15000 Hz.
85 * @param[in] secondFrequency The second frequency of the dual tone in Hertz (Hz) @n
86 * The range of this parameter is @c 0 Hz to @c 15000 Hz.
87 * @param[in] duration The duration of the tone in milliseconds @n
88 * The value of this parameter must be greater than @c 0.
89 * @exception E_SUCCESS The method is successful.
90 * @exception E_OUT_OF_RANGE A specified input parameter is out of range.
91 * @remarks If both the input frequencies are @c 0 Hz, the tone is set as a silent tone.
94 result Construct(int firstFrequency, int secondFrequency, long duration);
99 * Initializes this instance of %Tone with the values of the specified DTMF preset tone.
101 * @brief <i> [Deprecated] </i>
102 * @deprecated This method is deprecated because this method is not used as 2-phase constructor.
105 * @return An error code
106 * @param[in] preset The preset of the DTMF tone
107 * @param[in] duration The duration of the tone in milliseconds @n
108 * The value of this parameter must be greater than @c 0.
109 * @exception E_SUCCESS The method is successful.
110 * @exception E_OUT_OF_RANGE A specified input parameter is out of range.
113 result Construct(DtmfPreset preset, long duration);
117 * Gets the current frequency.
121 * @return An error code
122 * @param[out] firstFrequency The first frequency of the dual tone in Hertz (Hz)
123 * @param[out] secondFrequency The second frequency of the dual tone in Hertz (Hz)
124 * @exception E_SUCCESS The method is successful.
125 * @remarks The specified input parameters of this method are @c -1 when an exception occurs.
127 result GetFrequency(int& firstFrequency, int& secondFrequency) const;
130 * Gets the current duration.
134 * @return The duration of the tone
135 * @remarks This method returns @c 0 before the Construct() method is called.
137 long GetDuration(void) const;
140 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. @n
142 * Initializes this instance of %Tone with the values of the specified tone.
146 * @param[in] firstFrequency The first frequency of the dual tone in Hertz (Hz) @n
147 * The range of this parameter is @c 0 Hz to @c 15000 Hz.
148 * @param[in] secondFrequency The second frequency of the dual tone in Hertz (Hz) @n
149 * The range of this parameter is @c 0 Hz to @c 15000 Hz.
150 * @param[in] duration The duration of the tone in milliseconds @n
151 * The value of this parameter must be greater than @c 0.
152 * @remarks If both the input frequencies are @c 0 Hz, the tone is set as a silent tone.
154 Tone(int firstFrequency, int secondFrequency, long duration);
157 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. @n
158 * Initializes this instance of %Tone with the values of the specified DTMF preset tone.
162 * @param[in] preset The preset of the DTMF tone
163 * @param[in] duration The duration of the tone in milliseconds @n
164 * The value of this parameter must be greater than @c 0.
166 Tone(DtmfPreset preset, long duration);
169 * Compares the specified instance of %Tone with the calling instance.
173 * @return @c true if the values match, @n
175 * @param[in] rhs The other Tizen::Base::Object to compare
176 * @see Tizen::Base::Object::Equals()
178 virtual bool Equals(const Object& rhs) const;
181 * Gets the hash value of the current instance.
185 * @return The hash value of the current instance
187 virtual int GetHashCode(void) const;
190 * Copying of objects using this copy constructor is allowed.
194 * @return The copy of this instance
195 * @param[in] rhs An instance of %Tone
197 Tone(const Tone& rhs);
200 * Copying of objects using this copy assignment operator is allowed.
204 * @return The reference of this instance
205 * @param[in] rhs An instance of %Tone
207 Tone& operator =(const Tone& rhs);
210 int __firstFrequency;
211 int __secondFrequency;
213 bool __isConstructed;