25cf2dde5ad4a15acfba7272fae3b6c91000d3bb
[platform/framework/native/content.git] / src / inc / FCnt_AudioMetadataImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 /**
18  * @file                FCnt_AudioMetadataImpl.h
19  * @brief               This is the header file for the %_AudioMetadataImpl class.
20  *
21  * This header file contains the declarations of the %_AudioMetadataImpl class.
22  */
23
24 #ifndef _FCNT_INTERNAL_AUDIO_METADATA_IMPL_H_
25 #define _FCNT_INTERNAL_AUDIO_METADATA_IMPL_H_
26
27 #include <unique_ptr.h>
28 #include <FBaseString.h>
29 #include <FGrpBitmap.h>
30
31 namespace Tizen { namespace Content
32 {
33
34 class AudioMetadata;
35
36 struct AudioMeta
37 {
38         AudioMeta()
39                 : bitrate(0)
40                 , channelCount(0)
41                 , duration(0)
42                 , frequency(0)
43                 , trackNum(0)
44                 , year(0)
45                 , contentPath(L"")
46                 , pAlbumName(null)
47                 , pArtist(null)
48                 , pComment(null)
49                 , pComposer(null)
50                 , pCopyright(null)
51                 , pGenre(null)
52                 , pRecordingDate(null)
53                 , pTitle(null)
54                 , pTrackInfo(null)
55                 , pThumbnail(null)
56                 , pAlbumArt(null)  {}
57
58         int bitrate;
59         int channelCount;
60         long duration;
61         int frequency;
62         int trackNum;
63         int year;
64         Tizen::Base::String contentPath;
65         Tizen::Base::String* pAlbumName;
66         Tizen::Base::String* pArtist;
67         Tizen::Base::String* pComment;
68         Tizen::Base::String* pComposer;
69         Tizen::Base::String* pCopyright;
70         Tizen::Base::String* pGenre;
71         Tizen::Base::String* pRecordingDate;
72         Tizen::Base::String* pTitle;
73         Tizen::Base::String* pTrackInfo;
74         Tizen::Graphics::Bitmap* pThumbnail;
75         Tizen::Graphics::Bitmap* pAlbumArt;
76 };
77
78 struct AudioMetaDeleter
79 {
80         void operator()(AudioMeta* pAudioMeta)
81         {
82                 if (pAudioMeta != null)
83                 {
84                         if (pAudioMeta->pAlbumName)
85                         {
86                                 delete pAudioMeta->pAlbumName;
87                                 pAudioMeta->pAlbumName = null;
88                         }
89                         if (pAudioMeta->pArtist)
90                         {
91                                 delete pAudioMeta->pArtist;
92                                 pAudioMeta->pArtist = null;
93                         }
94                         if (pAudioMeta->pComment)
95                         {
96                                 delete pAudioMeta->pComment;
97                                 pAudioMeta->pComment = null;
98                         }
99                         if (pAudioMeta->pComposer)
100                         {
101                                 delete pAudioMeta->pComposer;
102                                 pAudioMeta->pComposer = null;
103                         }
104                         if (pAudioMeta->pCopyright)
105                         {
106                                 delete pAudioMeta->pCopyright;
107                                 pAudioMeta->pCopyright = null;
108                         }
109                         if (pAudioMeta->pGenre)
110                         {
111                                 delete pAudioMeta->pGenre;
112                                 pAudioMeta->pGenre = null;
113                         }
114                         if (pAudioMeta->pRecordingDate)
115                         {
116                                 delete pAudioMeta->pRecordingDate;
117                                 pAudioMeta->pRecordingDate = null;
118                         }
119                         if (pAudioMeta->pTitle)
120                         {
121                                 delete pAudioMeta->pTitle;
122                                 pAudioMeta->pTitle = null;
123                         }
124                         if (pAudioMeta->pTrackInfo)
125                         {
126                                 delete pAudioMeta->pTrackInfo;
127                                 pAudioMeta->pTrackInfo = null;
128                         }
129                         if (pAudioMeta->pThumbnail)
130                         {
131                                 delete pAudioMeta->pThumbnail;
132                                 pAudioMeta->pThumbnail = null;
133                         }
134                         if (pAudioMeta->pAlbumArt)
135                         {
136                                 delete pAudioMeta->pAlbumArt;
137                                 pAudioMeta->pAlbumArt = null;
138                         }
139
140                         delete pAudioMeta;
141                         pAudioMeta = null;
142                 }
143         }
144 };
145
146 class _AudioMetadataImpl
147         : public Tizen::Base::Object
148 {
149 public:
150         /**
151          * This is the default constructor for this class.
152          *
153          * @since 2.1
154          */
155         _AudioMetadataImpl(void);
156
157         /**
158          * This is the copy constructor for this class.
159          *
160          * @since 2.1
161          */
162         _AudioMetadataImpl(const _AudioMetadataImpl& rhs);
163
164         /**
165          * This is the destructor for this class.
166          *
167          * @since 2.1
168          */
169         virtual ~_AudioMetadataImpl(void);
170
171         /**
172          * @see @ref Tizen::Content::AudioMetadata::GetTitle()
173          */
174         Tizen::Base::String GetTitle(void) const;
175
176         /**
177          * @see @ref Tizen::Content::AudioMetadata::GetBitrate()
178          */
179         int GetBitrate(void) const;
180
181         /**
182          * @see @ref Tizen::Content::AudioMetadata::GetFrequency()
183          */
184         int GetFrequency(void) const;
185
186         /**
187          * @see @ref Tizen::Content::AudioMetadata::GetArtist()
188          */
189         Tizen::Base::String GetArtist(void) const;
190
191         /**
192          * @see @ref Tizen::Content::AudioMetadata::GetAlbumName()
193          */
194         Tizen::Base::String GetAlbumName(void) const;
195
196         /**
197          * @see @ref Tizen::Content::AudioMetadata::GetComment()
198          */
199         Tizen::Base::String GetComment(void) const;
200
201         /**
202          * @see @ref Tizen::Content::AudioMetadata::GetTrack()
203          */
204         int GetTrack(void) const;
205
206         /**
207          * @see @ref Tizen::Content::AudioMetadata::GetGenre()
208          */
209         Tizen::Base::String GetGenre(void) const;
210
211         /**
212          * @see @ref Tizen::Content::AudioMetadata::GetComposer()
213          */
214         Tizen::Base::String GetComposer(void) const;
215
216         /**
217          * @see @ref Tizen::Content::AudioMetadata::GetCopyright()
218          */
219         Tizen::Base::String GetCopyright(void) const;
220
221         /**
222          * @see @ref Tizen::Content::AudioMetadata::GetDuration()
223          */
224         long GetDuration(void) const;
225
226         /**
227          * @see @ref Tizen::Content::AudioMetadata::GetYear()
228          */
229         int GetYear(void) const;
230
231         /**
232          * @see @ref Tizen::Content::AudioMetadata::GetTrackInfo()
233          */
234         Tizen::Base::String GetTrackInfo(void) const;
235
236         /**
237          * @see @ref Tizen::Content::AudioMetadata::GetRecordingDate()
238          */
239         Tizen::Base::String GetRecordingDate(void) const;
240
241         /**
242          * @see @ref Tizen::Content::AudioMetadata::GetChannelCount()
243          */
244         int GetChannelCount(void) const;
245
246         /**
247          * @see @ref Tizen::Content::AudioMetadata::GetThumbnailN()
248          */
249         Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
250
251         /**
252          * @see @ref Tizen::Content::AudioMetadata::GetAlbumArtN()
253          */
254         Tizen::Graphics::Bitmap* GetAlbumArtN(void) const;
255
256         /**
257          * Gets the Impl instance.
258          *
259          * @since 2.1
260          * @return      The pointer to _AudioMetadataImpl
261          * @param[in] audioMetadata             An instance of AudioMetadata
262          */
263         static _AudioMetadataImpl* GetInstance(AudioMetadata& audioMetadata);
264
265         /**
266          * Gets the Impl instance.
267          *
268          * @since 2.1
269          * @return      The pointer to _AudioMetadataImpl
270          * @param[in] audioMetadata             An instance of AudioMetadata
271          */
272         static const _AudioMetadataImpl* GetInstance(const AudioMetadata& audioMetadata);
273
274         /**
275          * @see @ref Tizen::Content::AudioMetadata::Equals()
276          */
277         virtual bool Equals(const Tizen::Base::Object& rhs) const;
278
279         /**
280          * @see @ref Tizen::Content::AudioMetadata::GetHashCode()
281          */
282         virtual int GetHashCode(void) const;
283
284         /**
285          * @see @ref Tizen::Content::AudioMetadata::operator =()
286          */
287         _AudioMetadataImpl& operator =(const _AudioMetadataImpl& rhs);
288
289 private:
290         result SetAudioMetadata(const AudioMeta* pAudioMeta);
291         AudioMeta* GetAudioMetadata(void) const;
292
293 private:
294         std::unique_ptr<AudioMeta, AudioMetaDeleter> __pAudioMeta;
295
296         friend class _ContentManagerUtilImpl;
297
298 };  // class _AudioMetadataImpl
299
300 }}  // Tizen::Content
301
302 #endif  // _FCNT_INTERNAL_AUDIO_METADATA_IMPL_H_