Fix : Remove exception handling codes at the sample code
[platform/framework/native/content.git] / src / FCnt_ContentUtility.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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  * @file                FCnt_ContentUtility.cpp
18  * @brief               This is the implementation file for the %_ContentUtility class.
19  *
20  * This file contains implementation of the %_ContentUtility class.
21  */
22
23 #include <unique_ptr.h>
24 #include <FBaseSysLog.h>
25 #include <FBaseDateTime.h>
26 #include <FBaseInteger.h>
27 #include <FBaseLongLong.h>
28 #include <FBaseFloat.h>
29 #include <FBaseUtilStringTokenizer.h>
30 #include <FCntContentManagerUtil.h>
31 #include <FCntVideoMetadata.h>
32 #include "FCnt_ContentUtility.h"
33 #include "FCnt_ContentInfoImpl.h"
34 #include "FCnt_ImageContentInfoImpl.h"
35 #include "FCnt_AudioContentInfoImpl.h"
36 #include "FCnt_VideoContentInfoImpl.h"
37
38 using namespace Tizen::Base;
39 using namespace Tizen::Base::Collection;
40 using namespace Tizen::Base::Utility;
41 using namespace Tizen::Locations;
42
43 namespace Tizen { namespace Content
44 {
45
46 static const int DATE_TIME_TOKEN_COUNT = 6;
47 static const double DEFAULT_COORDINATE = -200.0;
48
49 // Default constructor
50 _ContentUtility::_ContentUtility(void)
51 {
52
53 }
54
55
56 // Default destructor
57 _ContentUtility::~_ContentUtility(void)
58 {
59
60 }
61
62 void
63 _ContentUtility::DoSafeFree(char* pSrc)
64 {
65         if (pSrc != NULL)
66         {
67                 free(pSrc);
68         }
69 }
70
71 // Fills ContentInfo information in the content data object.
72 result
73 _ContentUtility::FillContentData(media_info_h mediaHandle, _ContentInfoImpl* pInfoImpl)
74 {
75         SysTryReturnResult(NID_CNT, mediaHandle != null && pInfoImpl != null, E_INVALID_ARG, "mediaHandle or pInfoImpl is null.");
76
77         int ret  = MEDIA_CONTENT_ERROR_NONE;
78         result r = E_SUCCESS;
79
80         std::unique_ptr<char, UtilCharDeleter> pMediaId;
81         std::unique_ptr<char, UtilCharDeleter> pContentName;
82         std::unique_ptr<char, UtilCharDeleter> pMediaPath;
83         std::unique_ptr<char, UtilCharDeleter> pThumbnailPath;
84         std::unique_ptr<char, UtilCharDeleter> pAuthor;
85         std::unique_ptr<char, UtilCharDeleter> pCategory;
86         std::unique_ptr<char, UtilCharDeleter> pDescription;
87         std::unique_ptr<char, UtilCharDeleter> pLocationTag;
88         std::unique_ptr<char, UtilCharDeleter> pProvider;
89         std::unique_ptr<char, UtilCharDeleter> pKeyword;
90         std::unique_ptr<char, UtilCharDeleter> pContentRating;
91         std::unique_ptr<char, UtilCharDeleter> pMimeType;
92
93         media_content_type_e mediaType;
94         media_content_storage_e storageType;
95
96         unsigned long long contentSize = 0;
97         time_t addedTime        = 0;
98         time_t modifiedTime     = 0;
99         double latitude         = 0;
100         double longitude        = 0;
101         double altitude         = 0;
102         Coordinates coordinates;
103
104         bool isDrm = 0;
105
106         char* pGetMediaValue = null;
107         ret = media_info_get_media_id(mediaHandle, &pGetMediaValue);
108         if (pGetMediaValue != null)
109         {
110                 pMediaId.reset(pGetMediaValue);
111         }
112         else
113         {
114                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_id operation.");
115         }
116
117         ret = media_info_get_content_name(mediaHandle, &pGetMediaValue);
118         if (pGetMediaValue != null)
119         {
120                 pContentName.reset(pGetMediaValue);
121         }
122         else
123         {
124                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_content_name operation.");
125         }
126
127         ret = media_info_get_file_path(mediaHandle, &pGetMediaValue);
128         if (pGetMediaValue != null)
129         {
130                 pMediaPath.reset(pGetMediaValue);
131         }
132         else
133         {
134                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_file_path operation.");
135         }
136
137         ret = media_info_get_thumbnail_path(mediaHandle, &pGetMediaValue);
138         if (pGetMediaValue != null)
139         {
140                 pThumbnailPath.reset(pGetMediaValue);
141         }
142         else
143         {
144                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_thumbnail_path operation.");
145         }
146
147         ret = media_info_get_author(mediaHandle, &pGetMediaValue);
148         if (pGetMediaValue != null)
149         {
150                 pAuthor.reset(pGetMediaValue);
151         }
152         else
153         {
154                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_author operation.");
155         }
156
157         ret = media_info_get_category(mediaHandle, &pGetMediaValue);
158         if (pGetMediaValue != null)
159         {
160                 pCategory.reset(pGetMediaValue);
161         }
162         else
163         {
164                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_category operation.");
165         }
166
167         ret = media_info_get_description(mediaHandle, &pGetMediaValue);
168         if (pGetMediaValue != null)
169         {
170                 pDescription.reset(pGetMediaValue);
171         }
172         else
173         {
174                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_description operation.");
175         }
176
177         ret = media_info_get_location_tag(mediaHandle, &pGetMediaValue);
178         if (pGetMediaValue != null)
179         {
180                 pLocationTag.reset(pGetMediaValue);
181         }
182         else
183         {
184                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_location_tag operation.");
185         }
186
187         ret = media_info_get_provider(mediaHandle, &pGetMediaValue);
188         if (pGetMediaValue != null)
189         {
190                 pProvider.reset(pGetMediaValue);
191         }
192         else
193         {
194                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_provider operation.");
195         }
196
197         ret = media_info_get_size(mediaHandle, &contentSize);
198         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_size operation.");
199
200         ret = media_info_get_latitude(mediaHandle, &latitude);
201         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_latitude operation.");
202
203         ret = media_info_get_longitude(mediaHandle, &longitude);
204         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_longitude operation.");
205
206         ret = media_info_get_altitude(mediaHandle, &altitude);
207         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_altitude operation.");
208
209         ret = media_info_get_age_rating(mediaHandle, &pGetMediaValue);
210         if (pGetMediaValue != null)
211         {
212                 pContentRating.reset(pGetMediaValue);
213         }
214         else
215         {
216                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_age_rating operation.");
217         }
218
219         ret = media_info_is_drm(mediaHandle, &isDrm);
220         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_is_drm operation.");
221
222         ret = media_info_get_added_time(mediaHandle, &addedTime);
223         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_added_time operation.");
224
225         ret = media_info_get_modified_time(mediaHandle, &modifiedTime);
226         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_modified_time operation.");
227
228         ret = media_info_get_storage_type(mediaHandle, &storageType);
229         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_storage_type operation.");
230
231         ret = media_info_get_media_type(mediaHandle, &mediaType);
232         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_type operation.");
233
234         ret = media_info_get_mime_type(mediaHandle, &pGetMediaValue);
235         if (pGetMediaValue != null)
236         {
237                 pMimeType.reset(pGetMediaValue);
238         }
239         else
240         {
241                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_mime_type operation.");
242         }
243
244         ret = media_info_get_keyword(mediaHandle, &pGetMediaValue);
245         if (pGetMediaValue != null)
246         {
247                 pKeyword.reset(pGetMediaValue);
248         }
249         else
250         {
251                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_keyword operation.");
252         }
253
254         if (pMediaId.get() != null)
255         {
256                 ContentId contentId;
257
258                 r = UuId::Parse(String(pMediaId.get()), contentId);
259                 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform UuId::Parse operation.");
260
261                 pInfoImpl->SetContentId(contentId);
262         }
263
264         pInfoImpl->SetDrmProtected(isDrm);
265         SysLog(NID_CNT, "pContentInfoImpl->isDrm = %d", pInfoImpl->IsDrmProtected());
266
267         pInfoImpl->SetContentSize(contentSize);
268         SysLog(NID_CNT, "pContentInfoImpl->contentSize = %lu", pInfoImpl->GetContentSize());
269
270         if (Double::Compare(latitude, DEFAULT_COORDINATE) != 0)
271         {
272                 pInfoImpl->SetLatitude(latitude);
273                 coordinates.SetLatitude(latitude);
274         }
275         if (Double::Compare(longitude, DEFAULT_COORDINATE) != 0)
276         {
277                 pInfoImpl->SetLongitude(longitude);
278                 coordinates.SetLongitude(longitude);
279         }
280         if (Double::Compare(altitude, DEFAULT_COORDINATE) != 0)
281         {
282                 pInfoImpl->SetAltitude(altitude);
283                 coordinates.SetAltitude(altitude);
284         }
285
286         pInfoImpl->SetCoordinates(coordinates);
287
288         if (pMediaPath.get() != NULL)
289         {
290                 String contentPath(pMediaPath.get());
291
292                 pInfoImpl->SetContentPath(contentPath);
293                 SysSecureLog(NID_CNT, "pContentInfoImpl->contentPath = %ls", (pInfoImpl->GetContentPath()).GetPointer());
294         }
295
296         if (pThumbnailPath.get() != NULL)
297         {
298                 String thumbnailPath(pThumbnailPath.get());
299
300                 pInfoImpl->SetThumbnailPath(thumbnailPath);
301                 SysSecureLog(NID_CNT, "pContentInfoImpl->pThumbnailPath = %ls", (pInfoImpl->GetThumbnailPath()).GetPointer());
302         }
303
304         if (pAuthor.get() != NULL)
305         {
306                 String author(pAuthor.get());
307
308                 pInfoImpl->SetAuthor(author);
309                 SysLog(NID_CNT, "pContentInfoImpl->pAuthor = %ls", (pInfoImpl->GetAuthor()).GetPointer());
310         }
311
312         if (pCategory.get() != NULL)
313         {
314                 String category(pCategory.get());
315
316                 pInfoImpl->SetCategory(category);
317                 SysLog(NID_CNT, "pContentInfoImpl->pCategory = %ls", (pInfoImpl->GetCategory()).GetPointer());
318         }
319
320         if (pContentName.get() != NULL)
321         {
322                 String contentName(pContentName.get());
323
324                 pInfoImpl->SetContentName(contentName);
325                 SysLog(NID_CNT, "pContentInfoImpl->pContentName = %ls", (pInfoImpl->GetContentName()).GetPointer());
326         }
327
328         if (pDescription.get() != NULL)
329         {
330                 String description(pDescription.get());
331
332                 pInfoImpl->SetDescription(description);
333                 SysLog(NID_CNT, "pContentInfoImpl->pDescription = %ls", (pInfoImpl->GetDescription()).GetPointer());
334         }
335
336         if (pLocationTag.get() != NULL)
337         {
338                 String locationTag(pLocationTag.get());
339
340                 pInfoImpl->SetLocationTag(locationTag);
341                 SysLog(NID_CNT, "pContentInfoImpl->pLocationTag = %ls", (pInfoImpl->GetLocationTag()).GetPointer());
342         }
343
344         if (pProvider.get() != NULL)
345         {
346                 String provider(pProvider.get());
347
348                 pInfoImpl->SetProvider(provider);
349                 SysLog(NID_CNT, "pContentInfoImpl->pProvider = %ls", (pInfoImpl->GetProvider()).GetPointer());
350         }
351
352         if (pContentRating.get() != NULL)
353         {
354                 String rating(pContentRating.get());
355
356                 pInfoImpl->SetRating(rating);
357                 SysLog(NID_CNT, "pContentInfoImpl->pRating = %ls", (pInfoImpl->GetRating()).GetPointer());
358         }
359
360         if (pKeyword.get() != NULL)
361         {
362                 String keyword(pKeyword.get());
363
364                 pInfoImpl->SetKeyword(keyword);
365                 SysLog(NID_CNT, "pContentInfoImpl->pKeyword = %ls", (pInfoImpl->GetKeyword()).GetPointer());
366         }
367
368         if (pMimeType.get() != NULL)
369         {
370                 String mimeType(pMimeType.get());
371
372                 pInfoImpl->SetMimeType(mimeType);
373                 SysLog(NID_CNT, "pContentInfoImpl->mimeType = %ls", (pInfoImpl->GetMimeType()).GetPointer());
374         }
375
376         switch (storageType)
377         {
378         case MEDIA_CONTENT_STORAGE_INTERNAL:
379                 pInfoImpl->SetStorageType(0);
380                 break;
381         case MEDIA_CONTENT_STORAGE_EXTERNAL:
382                 pInfoImpl->SetStorageType(1);
383                 break;
384         default:
385                 break;
386         }
387         switch (mediaType)
388         {
389         case MEDIA_CONTENT_TYPE_OTHERS:
390                 pInfoImpl->SetContentType(CONTENT_TYPE_OTHER);
391                 break;
392         case MEDIA_CONTENT_TYPE_IMAGE:
393                 pInfoImpl->SetContentType(CONTENT_TYPE_IMAGE);
394                 break;
395         case MEDIA_CONTENT_TYPE_SOUND:
396                 //fall through
397         case MEDIA_CONTENT_TYPE_MUSIC:
398                 pInfoImpl->SetContentType(CONTENT_TYPE_AUDIO);
399                 break;
400         case MEDIA_CONTENT_TYPE_VIDEO:
401                 pInfoImpl->SetContentType(CONTENT_TYPE_VIDEO);
402                 break;
403         default:
404                 break;
405         }
406
407         // addedTime
408         DateTime dt;
409
410         r = dt.SetValue(1970, 1, 1);
411         SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.SetValue operation.");
412
413         r = dt.AddSeconds(addedTime);// need to check addedTime is secs/millisec
414         SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.AddSeconds operation.");
415
416         pInfoImpl->SetDateTime(dt);
417
418         SysLog(NID_CNT, "addedTime = %ld", addedTime);
419         SysLog(NID_CNT, "pContentInfoImpl->dateTime : %ls", (pInfoImpl->GetDateTime()).ToString().GetPointer());
420
421         // modifiedTime
422         r = dt.SetValue(1970, 1, 1);
423         SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.SetValue operation.");
424
425         r = dt.AddSeconds(modifiedTime);// need to check addedTime is secs/millisec
426         SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.AddSeconds operation.");
427
428         pInfoImpl->SetModifiedTime(dt);
429
430         SysLog(NID_CNT, "modifiedTime = %ld", modifiedTime);
431         SysLog(NID_CNT, "pContentInfoImpl->modifiedTime : %ls", (pInfoImpl->GetModifiedTime()).ToString().GetPointer());
432
433         return r;
434 }
435
436 // Fills ImageContentInfo information in the image content data object .
437 result
438 _ContentUtility::FillImageContentData(media_info_h mediaHandle, _ImageContentInfoImpl* pImageContentInfoImpl)
439 {
440         SysTryReturnResult(NID_CNT, mediaHandle != null && pImageContentInfoImpl != null, E_INVALID_ARG, "mediaHandle or pImageContentInfoImpl is null.");
441
442         int ret  = MEDIA_CONTENT_ERROR_NONE;
443         result r = E_SUCCESS;
444         int width  = 0;
445         int height = 0;
446         bool isBurst = false;
447         media_content_orientation_e orientation;
448         std::unique_ptr<char, UtilCharDeleter> pStrValue;
449
450         image_meta_h tempMeta = NULL;
451
452         ret = media_info_get_image(mediaHandle, &tempMeta);
453         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_image operation.");
454
455         std::unique_ptr<image_meta_s, ImageMetaHandleDeleter> pImageHandle(tempMeta);
456         SysTryReturnResult(NID_CNT, pImageHandle != null, E_OUT_OF_MEMORY, "pImageHandle is null.");
457
458         ret = image_meta_get_width(pImageHandle.get(), &width);
459         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_width operation.");
460
461         ret = image_meta_get_orientation(pImageHandle.get(), &orientation);
462         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_orientation operation.");
463
464         ret = image_meta_get_height(pImageHandle.get(), &height);
465         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_height operation.");
466
467         ret = image_meta_is_burst_shot(pImageHandle.get(), &isBurst);
468         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_is_burst_shot operation.");
469
470         pImageContentInfoImpl->SetWidth(width);
471         pImageContentInfoImpl->SetHeight(height);
472         pImageContentInfoImpl->SetOrientation(static_cast< ImageOrientationType >(orientation));
473         pImageContentInfoImpl->SetBurstShot(isBurst);
474
475         // title
476         char* pTempValue = null;
477         ret = media_info_get_display_name(mediaHandle, &pTempValue);
478         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_display_name operation.");
479
480         if (pTempValue != NULL)
481         {
482                 pStrValue.reset(pTempValue);
483
484                 int pos = 0;
485                 String fileName = L"";
486                 String strTitle(pStrValue.get());
487
488                 r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
489                 if (r == E_SUCCESS)
490                 {
491                         r = strTitle.SubString(0, pos, fileName);
492                         SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform string.SubString operation.");
493                 }
494                 else
495                 {
496                         // Without extension
497                         r = E_SUCCESS;
498                         fileName = strTitle;
499                 }
500                 pImageContentInfoImpl->SetTitle(fileName);
501                 SysLog(NID_CNT, "pImageContentInfoImpl->title = %ls", (pImageContentInfoImpl->GetTitle()).GetPointer());
502         }
503
504         // dateTaken
505         ret = image_meta_get_date_taken(pImageHandle.get(), &pTempValue);
506         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret),
507                         "Failed to perform image_meta_get_date_taken operation.");
508
509         DateTime dt;
510
511         if (pTempValue != NULL)
512         {
513                 pStrValue.reset(pTempValue);
514                 String dateTaken(pStrValue.get());
515                 String newDateTaken(L"");
516
517                 // detour the unexpected datetaken format
518                 String tempDelim(L"+-Z");
519                 String token;
520
521                 StringTokenizer tempStrTok(dateTaken, tempDelim);
522
523                 r = tempStrTok.GetNextToken(token);
524                 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
525
526                 dateTaken = token;
527
528                 String delim(L": ");
529                 String year(L"");
530
531                 StringTokenizer strTok(dateTaken, delim);
532
533                 r = strTok.SetDelimiters(delim);
534                 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation.");
535
536                 int tokenCount = strTok.GetTokenCount();
537                 if (tokenCount == DATE_TIME_TOKEN_COUNT)
538                 {
539                         r = strTok.GetNextToken(token);
540                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
541
542                         year = token;
543
544                         // Append month
545                         r = strTok.GetNextToken(token);
546                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
547
548                         r = newDateTaken.Append(token);
549                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
550
551                         r = newDateTaken.Append(L"/");
552                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
553
554                         // Append day
555                         r = strTok.GetNextToken(token);
556                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
557
558                         r = newDateTaken.Append(token);
559                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
560
561                         r = newDateTaken.Append(L"/");
562                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
563
564                         // Append year
565                         r = newDateTaken.Append(year);
566                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
567
568                         r = newDateTaken.Append(L" ");
569                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
570
571                         String newDelim(L" ");
572
573                         r = strTok.SetDelimiters(newDelim);
574                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation.");
575
576                         r = strTok.GetNextToken(token);
577                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
578
579                         r = newDateTaken.Append(token);
580                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
581
582                         r = DateTime::Parse(newDateTaken, dt);
583                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime.");
584                 }
585                 else
586                 {
587                         dt = DateTime::GetMinValue();
588                 }
589         }
590         else
591         {
592                 dt = DateTime::GetMinValue();
593         }
594
595         pImageContentInfoImpl->SetImageTakenDate(dt);
596         SysLog(NID_CNT, "pImageContentInfoImpl->takenDate = %ls", dt.ToString().GetPointer());
597
598         // burstShotId
599         ret = image_meta_get_burst_id(pImageHandle.get(), &pTempValue);
600         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret),
601                         "Failed to perform image_meta_get_burst_id operation.");
602
603         if (pTempValue != NULL)
604         {
605                 pStrValue.reset(pTempValue);
606                 String burstShotId(pStrValue.get());
607
608                 pImageContentInfoImpl->SetBurstShotId(burstShotId);
609                 SysLog(NID_CNT, "pImageContentInfoImpl->burstShotId = %ls", burstShotId.GetPointer());
610         }
611
612         return r;
613 }
614
615 // Fills AudioContentInfo information in the audio content data object.
616 result
617 _ContentUtility::FillAudioContentData(media_info_h mediaHandle, _AudioContentInfoImpl* pAudioContentInfoImpl)
618 {
619         SysTryReturnResult(NID_CNT, mediaHandle != null && pAudioContentInfoImpl != null, E_INVALID_ARG, "mediaHandle or pAudioContentInfoImpl is null.");
620
621         int ret  = MEDIA_CONTENT_ERROR_NONE;
622         result r = E_SUCCESS;
623         int bitrate = 0;
624         int duration = 0;
625
626         std::unique_ptr<char, UtilCharDeleter> pTitle;
627         std::unique_ptr<char, UtilCharDeleter> pAlbumName;
628         std::unique_ptr<char, UtilCharDeleter> pArtistName;
629         std::unique_ptr<char, UtilCharDeleter> pAlbumArtistName;
630         std::unique_ptr<char, UtilCharDeleter> pGenreName;
631         std::unique_ptr<char, UtilCharDeleter> pComposerName;
632         std::unique_ptr<char, UtilCharDeleter> pYear;
633         std::unique_ptr<char, UtilCharDeleter> pCopyRight;
634         std::unique_ptr<char, UtilCharDeleter> pTrackNum;
635
636         audio_meta_h tempMeta = NULL;
637
638         ret = media_info_get_audio(mediaHandle, &tempMeta);
639         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_audio operation.");
640
641         std::unique_ptr<audio_meta_s, AudioMetaHandleDeleter> pAudioHandle(tempMeta);
642         SysTryReturnResult(NID_CNT, pAudioHandle != null, E_OUT_OF_MEMORY, "pAudioHandle is null.");
643
644         ret = audio_meta_get_bit_rate(pAudioHandle.get(), &bitrate);
645         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_bit_rate operation.");
646
647         char* pAudioMetaValue = null;
648         ret = audio_meta_get_title(pAudioHandle.get(), &pAudioMetaValue);
649         if (pAudioMetaValue != null)
650         {
651                 pTitle.reset(pAudioMetaValue);
652         }
653         else
654         {
655                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_title operation.");
656         }
657
658         ret = audio_meta_get_album(pAudioHandle.get(), &pAudioMetaValue);
659         if (pAudioMetaValue != null)
660         {
661                 pAlbumName.reset(pAudioMetaValue);
662         }
663         else
664         {
665                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_album operation.");
666         }
667
668         ret = audio_meta_get_artist(pAudioHandle.get(), &pAudioMetaValue);
669         if (pAudioMetaValue != null)
670         {
671                 pArtistName.reset(pAudioMetaValue);
672         }
673         else
674         {
675                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_artist operation.");
676         }
677
678         // Add to private for extension api
679 //      ret = audio_meta_get_album_artist(pAudioHandle.get(), &pAudioMetaValue);
680 //      if (pAudioMetaValue != null)
681 //      {
682 //              pAlbumArtistName.reset(pAudioMetaValue);
683 //      }
684 //      else
685 //      {
686 //              SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_album_artist operation.");
687 //      }
688
689         ret = audio_meta_get_genre(pAudioHandle.get(), &pAudioMetaValue);
690         if (pAudioMetaValue != null)
691         {
692                 pGenreName.reset(pAudioMetaValue);
693         }
694         else
695         {
696                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_genre operation.");
697         }
698
699         ret = audio_meta_get_composer(pAudioHandle.get(), &pAudioMetaValue);
700         if (pAudioMetaValue != null)
701         {
702                 pComposerName.reset(pAudioMetaValue);
703         }
704         else
705         {
706                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_composer operation.");
707         }
708
709         ret = audio_meta_get_year(pAudioHandle.get(), &pAudioMetaValue);
710         if (pAudioMetaValue != null)
711         {
712                 pYear.reset(pAudioMetaValue);
713         }
714         else
715         {
716                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_year operation.");
717         }
718
719         ret = audio_meta_get_copyright(pAudioHandle.get(), &pAudioMetaValue);
720         if (pAudioMetaValue != null)
721         {
722                 pCopyRight.reset(pAudioMetaValue);
723         }
724         else
725         {
726                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_copyright operation.");
727         }
728
729         ret = audio_meta_get_track_num(pAudioHandle.get(), &pAudioMetaValue);
730         if (pAudioMetaValue != null)
731         {
732                 pTrackNum.reset(pAudioMetaValue);
733         }
734         else
735         {
736                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_track_num operation.");
737         }
738
739         ret = audio_meta_get_duration(pAudioHandle.get(), &duration);
740         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_duration operation.");
741
742         pAudioContentInfoImpl->SetBitrate(bitrate);
743
744         if (pYear.get() != null)
745         {
746                 SysLog(NID_CNT, "pAudioContentInfoImpl->pYear  = %s", pYear.get());
747
748                 String strYear(pYear.get());
749                 if (strYear.CompareTo(L"Unknown") != 0)
750                 {
751                         int releaseYear = 0;
752
753                         r = Integer::Parse(strYear, releaseYear);
754                         if (IsFailed(r))
755                         {
756                                 // It is one of the metadata. If error occurs, skip it for other metadata.
757                                 pAudioContentInfoImpl->SetReleaseYear(0);
758                                 r = E_SUCCESS;
759                                 SysLog(NID_CNT, "pAudioContentInfoImpl->pYear(invalid data) = %ls", strYear.GetPointer());
760                         }
761
762                         pAudioContentInfoImpl->SetReleaseYear(releaseYear);
763                 }
764         }
765
766         if (pTitle.get() != NULL)
767         {
768                 pAudioContentInfoImpl->SetTitle(String(pTitle.get()));
769                 SysLog(NID_CNT, "pAudioContentInfoImpl->pTitle  = %ls", (pAudioContentInfoImpl->GetTitle()).GetPointer());
770         }
771
772         if (pArtistName.get() != NULL)
773         {
774                 pAudioContentInfoImpl->SetArtist(String(pArtistName.get()));
775                 SysLog(NID_CNT, "pAudioContentInfoImpl->pArtist = %ls", (pAudioContentInfoImpl->GetArtist()).GetPointer());
776         }
777
778         // Add to private for extension api
779 //      if (pAlbumArtistName.get() != NULL)
780 //      {
781 //              pAudioContentInfoImpl->SetAlbumArtist(String(pAlbumArtistName.get()));
782 //              SysLog(NID_CNT, "pAudioContentInfoImpl->pAlbumArtist = %ls", (pAudioContentInfoImpl->GetAlbumArtist()).GetPointer());
783 //      }
784
785         if (pGenreName.get() != NULL)
786         {
787                 pAudioContentInfoImpl->SetGenre(String(pGenreName.get()));
788                 SysLog(NID_CNT, "pAudioContentInfoImpl->pGenre = %ls", (pAudioContentInfoImpl->GetGenre()).GetPointer());
789         }
790
791         if (pComposerName.get() != NULL)
792         {
793                 pAudioContentInfoImpl->SetComposer(String(pComposerName.get()));
794                 SysLog(NID_CNT, "pAudioContentInfoImpl->pComposer = %ls", (pAudioContentInfoImpl->GetComposer()).GetPointer());
795         }
796
797         if (pAlbumName.get() != NULL)
798         {
799                 pAudioContentInfoImpl->SetAlbumName(String(pAlbumName.get()));
800                 SysLog(NID_CNT, "pAudioContentInfoImpl->pAlbumName  = %ls", (pAudioContentInfoImpl->GetAlbumName()).GetPointer());
801         }
802
803         if (pCopyRight.get() != NULL)
804         {
805                 pAudioContentInfoImpl->SetCopyright(String(pCopyRight.get()));
806                 SysLog(NID_CNT, "pAudioContentInfoImpl->pCopyright  = %ls", (pAudioContentInfoImpl->GetCopyright()).GetPointer());
807         }
808
809         if (pTrackNum.get() != NULL)
810         {
811                 pAudioContentInfoImpl->SetTrackInfo(String(pTrackNum.get()));
812                 SysLog(NID_CNT, "pAudioContentInfoImpl->pTrackInfo  = %ls", (pAudioContentInfoImpl->GetTrackInfo()).GetPointer());
813         }
814
815         pAudioContentInfoImpl->SetDuration(duration);
816         SysLog(NID_CNT,"pAudioContentInfoImpl->duration = %d", pAudioContentInfoImpl->GetDuration());
817
818         return r;
819 }
820
821 // Fills VideoContentInfo information in the video content data object.
822 result
823 _ContentUtility::FillVideoContentData(media_info_h mediaHandle, _VideoContentInfoImpl* pVideoContentInfoImpl)
824 {
825         SysTryReturnResult(NID_CNT, mediaHandle != null && pVideoContentInfoImpl != null, E_INVALID_ARG, "mediaHandle or pVideoContentInfoImpl is null.");
826
827         int ret  = MEDIA_CONTENT_ERROR_NONE;
828         result r = E_SUCCESS;
829         int width  = 0;
830         int height = 0;
831         std::unique_ptr<char, UtilCharDeleter> pArtistName;
832         std::unique_ptr<char, UtilCharDeleter> pGenreName;
833         std::unique_ptr<char, UtilCharDeleter> pTitle;
834         std::unique_ptr<char, UtilCharDeleter> pAlbumName;
835         std::unique_ptr<char, UtilCharDeleter> pRecordedDate;
836         int duration = 0;
837
838         video_meta_h tempMeta = NULL;
839
840         ret = media_info_get_video(mediaHandle, &tempMeta);
841         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_video operation.");
842
843         std::unique_ptr<video_meta_s, VideoMetaHandleDeleter> pVideoHandle(tempMeta);
844         SysTryReturnResult(NID_CNT, pVideoHandle != null, E_OUT_OF_MEMORY, "pVideoHandle is null.");
845
846         ret = video_meta_get_width(pVideoHandle.get(), &width);
847         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_width operation.");
848
849         ret = video_meta_get_height(pVideoHandle.get(), &height);
850         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_height operation.");
851
852         char* pVideoMetaValue = null;
853         ret = video_meta_get_artist(pVideoHandle.get(), &pVideoMetaValue);
854         if (pVideoMetaValue != null)
855         {
856                 pArtistName.reset(pVideoMetaValue);
857         }
858         else
859         {
860                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_artist operation.");
861         }
862
863         ret = video_meta_get_genre(pVideoHandle.get(), &pVideoMetaValue);
864         if (pVideoMetaValue != null)
865         {
866                 pGenreName.reset(pVideoMetaValue);
867         }
868         else
869         {
870                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_genre operation.");
871         }
872
873         ret = video_meta_get_title(pVideoHandle.get(), &pVideoMetaValue);
874         if (pVideoMetaValue != null)
875         {
876                 pTitle.reset(pVideoMetaValue);
877         }
878         else
879         {
880                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_title operation.");
881         }
882
883         ret = video_meta_get_album(pVideoHandle.get(), &pVideoMetaValue);
884         if (pVideoMetaValue != null)
885         {
886                 pAlbumName.reset(pVideoMetaValue);
887         }
888         else
889         {
890                 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_album operation.");
891         }
892
893         ret = video_meta_get_duration(pVideoHandle.get(), &duration);
894         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_duration operation.");
895
896         pVideoContentInfoImpl->SetWidth(width);
897         pVideoContentInfoImpl->SetHeight(height);
898
899         if (pTitle.get() != NULL)
900         {
901                 pVideoContentInfoImpl->SetTitle(String(pTitle.get()));
902                 SysLog(NID_CNT, "pVideoContentInfoImpl->pTitle = %ls", (pVideoContentInfoImpl->GetTitle()).GetPointer());
903         }
904
905         if (pArtistName.get() != NULL)
906         {
907                 pVideoContentInfoImpl->SetArtist(String(pArtistName.get()));
908                 SysLog(NID_CNT, "pVideoContentInfoImpl->pArtist = %ls", (pVideoContentInfoImpl->GetArtist()).GetPointer());
909         }
910
911         if (pGenreName.get() != NULL)
912         {
913                 pVideoContentInfoImpl->SetGenre(String(pGenreName.get()));
914                 SysLog(NID_CNT, "pVideoContentInfoImpl->pGenre = %ls", (pVideoContentInfoImpl->GetGenre()).GetPointer());
915         }
916
917         if (pAlbumName.get() != NULL)
918         {
919                 pVideoContentInfoImpl->SetAlbumName(String(pAlbumName.get()));
920                 SysLog(NID_CNT, "pVideoContentInfoImpl->pAlbumName = %ls", (pVideoContentInfoImpl->GetAlbumName()).GetPointer());
921         }
922
923         pVideoContentInfoImpl->SetDuration(duration);
924         SysLog(NID_CNT,"pVideoContentInfoImpl->duration = %d", pVideoContentInfoImpl->GetDuration());
925
926         // recorded date
927         ret = video_meta_get_recorded_date(pVideoHandle.get(), &pVideoMetaValue);
928         SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret),
929                         "Failed to perform video_meta_get_recorded_date operation.");
930
931         DateTime dt;
932
933         if (pVideoMetaValue != NULL)
934         {
935                 pRecordedDate.reset(pVideoMetaValue);
936                 String recordedDate(pRecordedDate.get());
937                 String newRecordedDate(L"");
938
939                 // detour the unexpected recorded date format
940                 String tempDelim(L"+-Z");
941                 String token;
942
943                 StringTokenizer tempStrTok(recordedDate, tempDelim);
944
945                 r = tempStrTok.GetNextToken(token);
946                 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
947
948                 recordedDate = token;
949
950                 String delim(L": ");
951                 String year(L"");
952
953                 StringTokenizer strTok(recordedDate, delim);
954
955                 r = strTok.SetDelimiters(delim);
956                 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation.");
957
958                 int tokenCount = strTok.GetTokenCount();
959                 if (tokenCount == DATE_TIME_TOKEN_COUNT)
960                 {
961                         r = strTok.GetNextToken(token);
962                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
963
964                         year = token;
965
966                         // Append month
967                         r = strTok.GetNextToken(token);
968                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
969
970                         r = newRecordedDate.Append(token);
971                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
972
973                         r = newRecordedDate.Append(L"/");
974                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
975
976                         // Append day
977                         r = strTok.GetNextToken(token);
978                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
979
980                         r = newRecordedDate.Append(token);
981                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
982
983                         r = newRecordedDate.Append(L"/");
984                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
985
986                         // Append year
987                         r = newRecordedDate.Append(year);
988                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
989
990                         r = newRecordedDate.Append(L" ");
991                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
992
993                         String newDelim(L" ");
994
995                         r = strTok.SetDelimiters(newDelim);
996                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation.");
997
998                         r = strTok.GetNextToken(token);
999                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
1000
1001                         r = newRecordedDate.Append(token);
1002                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
1003
1004                         r = DateTime::Parse(newRecordedDate, dt);
1005                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime.");
1006                 }
1007                 else
1008                 {
1009                         dt = DateTime::GetMinValue();
1010                 }
1011         }
1012         else
1013         {
1014                 dt = DateTime::GetMinValue();
1015         }
1016
1017         pVideoContentInfoImpl->SetVideoRecordedDate(dt);
1018         SysLog(NID_CNT, "pVideoContentInfoImpl->recordedDate = %ls", dt.ToString().GetPointer());
1019
1020         return r;
1021 }
1022
1023 // Conversion of system errors to native errors
1024 result
1025 _ContentUtility::MapCoreErrorToNativeResult(int reason)
1026 {
1027         result r = E_SUCCESS;
1028         switch (reason)
1029         {
1030         case MEDIA_CONTENT_ERROR_NONE:
1031                 r = E_SUCCESS;
1032                 break;
1033         case MEDIA_CONTENT_ERROR_DB_BUSY:
1034                 r = E_SERVICE_BUSY;
1035                 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
1036                 break;
1037         case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
1038                 r = E_INVALID_ARG;
1039                 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_INVALID_PARAMETER");
1040                 break;
1041         case MEDIA_CONTENT_ERROR_DB_FAILED:
1042                 r = E_DATABASE;
1043                 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
1044                 break;
1045         case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:
1046                 r = E_OUT_OF_MEMORY;
1047                 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_OUT_OF_MEMORY");
1048                 break;
1049         default:
1050                 SysLog(NID_CNT, "default");
1051                 r = E_SYSTEM;
1052                 break;
1053         }
1054         return r;
1055 }
1056
1057 }}