merge with master
[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                 , pDescription(null)
50                 , pComposer(null)
51                 , pCopyright(null)
52                 , pGenre(null)
53                 , pRecordingDate(null)
54                 , pTitle(null)
55                 , pTrackInfo(null)
56                 , pThumbnail(null)
57                 , pAlbumArt(null)  {}
58
59         int bitrate;
60         int channelCount;
61         long duration;
62         int frequency;
63         int trackNum;
64         int year;
65         Tizen::Base::String contentPath;
66         Tizen::Base::String* pAlbumName;
67         Tizen::Base::String* pArtist;
68         Tizen::Base::String* pComment;
69         Tizen::Base::String* pDescription;
70         Tizen::Base::String* pComposer;
71         Tizen::Base::String* pCopyright;
72         Tizen::Base::String* pGenre;
73         Tizen::Base::String* pRecordingDate;
74         Tizen::Base::String* pTitle;
75         Tizen::Base::String* pTrackInfo;
76         Tizen::Graphics::Bitmap* pThumbnail;
77         Tizen::Graphics::Bitmap* pAlbumArt;
78 };
79
80 struct AudioMetaDeleter
81 {
82         void operator()(AudioMeta* pAudioMeta)
83         {
84                 if (pAudioMeta != null)
85                 {
86                         if (pAudioMeta->pAlbumName)
87                         {
88                                 delete pAudioMeta->pAlbumName;
89                                 pAudioMeta->pAlbumName = null;
90                         }
91                         if (pAudioMeta->pArtist)
92                         {
93                                 delete pAudioMeta->pArtist;
94                                 pAudioMeta->pArtist = null;
95                         }
96                         if (pAudioMeta->pComment)
97                         {
98                                 delete pAudioMeta->pComment;
99                                 pAudioMeta->pComment = null;
100                         }
101                         if (pAudioMeta->pDescription)
102                         {
103                                 delete pAudioMeta->pDescription;
104                                 pAudioMeta->pDescription = null;
105                         }
106                         if (pAudioMeta->pComposer)
107                         {
108                                 delete pAudioMeta->pComposer;
109                                 pAudioMeta->pComposer = null;
110                         }
111                         if (pAudioMeta->pCopyright)
112                         {
113                                 delete pAudioMeta->pCopyright;
114                                 pAudioMeta->pCopyright = null;
115                         }
116                         if (pAudioMeta->pGenre)
117                         {
118                                 delete pAudioMeta->pGenre;
119                                 pAudioMeta->pGenre = null;
120                         }
121                         if (pAudioMeta->pRecordingDate)
122                         {
123                                 delete pAudioMeta->pRecordingDate;
124                                 pAudioMeta->pRecordingDate = null;
125                         }
126                         if (pAudioMeta->pTitle)
127                         {
128                                 delete pAudioMeta->pTitle;
129                                 pAudioMeta->pTitle = null;
130                         }
131                         if (pAudioMeta->pTrackInfo)
132                         {
133                                 delete pAudioMeta->pTrackInfo;
134                                 pAudioMeta->pTrackInfo = null;
135                         }
136                         if (pAudioMeta->pThumbnail)
137                         {
138                                 delete pAudioMeta->pThumbnail;
139                                 pAudioMeta->pThumbnail = null;
140                         }
141                         if (pAudioMeta->pAlbumArt)
142                         {
143                                 delete pAudioMeta->pAlbumArt;
144                                 pAudioMeta->pAlbumArt = null;
145                         }
146
147                         delete pAudioMeta;
148                         pAudioMeta = null;
149                 }
150         }
151 };
152
153 class _AudioMetadataImpl
154         : public Tizen::Base::Object
155 {
156 public:
157         /**
158          * This is the default constructor for this class.
159          *
160          * @since 2.1
161          */
162         _AudioMetadataImpl(void);
163
164         /**
165          * This is the copy constructor for this class.
166          *
167          * @since 2.1
168          */
169         _AudioMetadataImpl(const _AudioMetadataImpl& rhs);
170
171         /**
172          * This is the destructor for this class.
173          *
174          * @since 2.1
175          */
176         virtual ~_AudioMetadataImpl(void);
177
178         /**
179          * @see @ref Tizen::Content::AudioMetadata::GetTitle()
180          */
181         Tizen::Base::String GetTitle(void) const;
182
183         /**
184          * @see @ref Tizen::Content::AudioMetadata::GetBitrate()
185          */
186         int GetBitrate(void) const;
187
188         /**
189          * @see @ref Tizen::Content::AudioMetadata::GetFrequency()
190          */
191         int GetFrequency(void) const;
192
193         /**
194          * @see @ref Tizen::Content::AudioMetadata::GetArtist()
195          */
196         Tizen::Base::String GetArtist(void) const;
197
198         /**
199          * @see @ref Tizen::Content::AudioMetadata::GetAlbumName()
200          */
201         Tizen::Base::String GetAlbumName(void) const;
202
203         /**
204          * @see @ref Tizen::Content::AudioMetadata::GetComment()
205          */
206         Tizen::Base::String GetComment(void) const;
207
208         /**
209          * @see @ref Tizen::Content::AudioMetadata::GetDescription()
210          */
211         Tizen::Base::String GetDescription(void) const;
212
213         /**
214          * @see @ref Tizen::Content::AudioMetadata::GetTrack()
215          */
216         int GetTrack(void) const;
217
218         /**
219          * @see @ref Tizen::Content::AudioMetadata::GetGenre()
220          */
221         Tizen::Base::String GetGenre(void) const;
222
223         /**
224          * @see @ref Tizen::Content::AudioMetadata::GetComposer()
225          */
226         Tizen::Base::String GetComposer(void) const;
227
228         /**
229          * @see @ref Tizen::Content::AudioMetadata::GetCopyright()
230          */
231         Tizen::Base::String GetCopyright(void) const;
232
233         /**
234          * @see @ref Tizen::Content::AudioMetadata::GetDuration()
235          */
236         long GetDuration(void) const;
237
238         /**
239          * @see @ref Tizen::Content::AudioMetadata::GetYear()
240          */
241         int GetYear(void) const;
242
243         /**
244          * @see @ref Tizen::Content::AudioMetadata::GetTrackInfo()
245          */
246         Tizen::Base::String GetTrackInfo(void) const;
247
248         /**
249          * @see @ref Tizen::Content::AudioMetadata::GetRecordingDate()
250          */
251         Tizen::Base::String GetRecordingDate(void) const;
252
253         /**
254          * @see @ref Tizen::Content::AudioMetadata::GetChannelCount()
255          */
256         int GetChannelCount(void) const;
257
258         /**
259          * @see @ref Tizen::Content::AudioMetadata::GetThumbnailN()
260          */
261         Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
262
263         /**
264          * @see @ref Tizen::Content::AudioMetadata::GetAlbumArtN()
265          */
266         Tizen::Graphics::Bitmap* GetAlbumArtN(void) const;
267
268         /**
269          * Gets the Impl instance.
270          *
271          * @since 2.1
272          * @return      The pointer to _AudioMetadataImpl
273          * @param[in] audioMetadata             An instance of AudioMetadata
274          */
275         static _AudioMetadataImpl* GetInstance(AudioMetadata& audioMetadata);
276
277         /**
278          * Gets the Impl instance.
279          *
280          * @since 2.1
281          * @return      The pointer to _AudioMetadataImpl
282          * @param[in] audioMetadata             An instance of AudioMetadata
283          */
284         static const _AudioMetadataImpl* GetInstance(const AudioMetadata& audioMetadata);
285
286         /**
287          * @see @ref Tizen::Content::AudioMetadata::Equals()
288          */
289         virtual bool Equals(const Tizen::Base::Object& rhs) const;
290
291         /**
292          * @see @ref Tizen::Content::AudioMetadata::GetHashCode()
293          */
294         virtual int GetHashCode(void) const;
295
296         /**
297          * @see @ref Tizen::Content::AudioMetadata::operator =()
298          */
299         _AudioMetadataImpl& operator =(const _AudioMetadataImpl& rhs);
300
301 private:
302         result SetAudioMetadata(const AudioMeta* pAudioMeta);
303         AudioMeta* GetAudioMetadata(void) const;
304
305 private:
306         std::unique_ptr<AudioMeta, AudioMetaDeleter> __pAudioMeta;
307
308         friend class _ContentManagerUtilImpl;
309
310 };  // class _AudioMetadataImpl
311
312 }}  // Tizen::Content
313
314 #endif  // _FCNT_INTERNAL_AUDIO_METADATA_IMPL_H_