2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file FCnt_ContentUtility.cpp
18 * @brief This is the implementation file for the %_ContentUtility class.
20 * This file contains implementation of the %_ContentUtility class.
23 #include <unique_ptr.h>
24 #include <FBaseSysLog.h>
25 #include <FBaseInteger.h>
26 #include <FBaseLongLong.h>
27 #include <FBaseFloat.h>
28 #include <FCnt_ContentUtility.h>
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
33 namespace Tizen { namespace Content
36 static const double DEFAULT_COORDINATE = -200.0;
38 // Default constructor
39 _ContentUtility::_ContentUtility(void)
42 SysLog(NID_CNT, "Enter\n");
47 _ContentUtility::~_ContentUtility(void)
49 SysLog(NID_CNT, "Enter\n");
53 _ContentUtility::DoSafeFree(char* pSrc)
63 _ContentUtility::DoSafeDelete(String* pSrc)
72 // fills contentinfo information in the content data object.
74 _ContentUtility::FillContentData(media_info_h mediaHandle, ContentInfo::_ContentData* pContentData)
77 SysTryReturnResult(NID_CNT, mediaHandle != null && pContentData != null, E_INVALID_ARG, "mediaHandle or pContentData is null.");
79 int ret = MEDIA_CONTENT_ERROR_NONE;
82 std::unique_ptr<char, UtilCharDeleter> pMediaId;
83 std::unique_ptr<char, UtilCharDeleter> pContentName;
84 std::unique_ptr<char, UtilCharDeleter> pMediaPath;
85 std::unique_ptr<char, UtilCharDeleter> pThumbnailPath;
86 std::unique_ptr<char, UtilCharDeleter> pAuthor;
87 std::unique_ptr<char, UtilCharDeleter> pCategory;
88 std::unique_ptr<char, UtilCharDeleter> pDescription;
89 std::unique_ptr<char, UtilCharDeleter> pLocationTag;
90 std::unique_ptr<char, UtilCharDeleter> pProvider;
91 std::unique_ptr<char, UtilCharDeleter> pKeyword;
92 std::unique_ptr<char, UtilCharDeleter> pContentRating;
93 std::unique_ptr<char, UtilCharDeleter> pMimeType;
95 media_content_type_e mediaType;
96 media_content_storage_e storageType;
98 unsigned long long contentSize = 0;
101 double longitude = 0;
106 char* pGetMediaValue = null;
107 ret = media_info_get_media_id(mediaHandle, &pGetMediaValue);
108 if (pGetMediaValue != null)
110 pMediaId.reset(pGetMediaValue);
114 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_id operation.");
117 ret = media_info_get_content_name(mediaHandle, &pGetMediaValue);
118 if (pGetMediaValue != null)
120 pContentName.reset(pGetMediaValue);
124 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_content_name operation.");
127 ret = media_info_get_file_path(mediaHandle, &pGetMediaValue);
128 if (pGetMediaValue != null)
130 pMediaPath.reset(pGetMediaValue);
134 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_file_path operation.");
137 ret = media_info_get_thumbnail_path(mediaHandle, &pGetMediaValue);
138 if (pGetMediaValue != null)
140 pThumbnailPath.reset(pGetMediaValue);
144 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_thumbnail_path operation.");
147 ret = media_info_get_author(mediaHandle, &pGetMediaValue);
148 if (pGetMediaValue != null)
150 pAuthor.reset(pGetMediaValue);
154 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_author operation.");
157 ret = media_info_get_category(mediaHandle, &pGetMediaValue);
158 if (pGetMediaValue != null)
160 pCategory.reset(pGetMediaValue);
164 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_category operation.");
167 ret = media_info_get_description(mediaHandle, &pGetMediaValue);
168 if (pGetMediaValue != null)
170 pDescription.reset(pGetMediaValue);
174 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_description operation.");
177 ret = media_info_get_location_tag(mediaHandle, &pGetMediaValue);
178 if (pGetMediaValue != null)
180 pLocationTag.reset(pGetMediaValue);
184 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_location_tag operation.");
187 ret = media_info_get_provider(mediaHandle, &pGetMediaValue);
188 if (pGetMediaValue != null)
190 pProvider.reset(pGetMediaValue);
194 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_provider operation.");
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.");
201 ret = media_info_get_latitude(mediaHandle, &latitude);
202 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_latitude operation.");
204 ret = media_info_get_longitude(mediaHandle, &longitude);
205 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_longitude operation.");
207 ret = media_info_get_altitude(mediaHandle, &altitude);
208 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_altitude operation.");
210 ret = media_info_get_age_rating(mediaHandle, &pGetMediaValue);
211 if (pGetMediaValue != null)
213 pContentRating.reset(pGetMediaValue);
217 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_age_rating operation.");
220 ret = media_info_is_drm(mediaHandle, &isDrm);
221 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_is_drm operation.");
223 ret = media_info_get_added_time(mediaHandle, &addedTime);
224 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_added_time operation.");
226 ret = media_info_get_storage_type(mediaHandle, &storageType);
227 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_storage_type operation.");
229 ret = media_info_get_media_type(mediaHandle, &mediaType);
230 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_type operation.");
232 ret = media_info_get_mime_type(mediaHandle, &pGetMediaValue);
233 if (pGetMediaValue != null)
235 pMimeType.reset(pGetMediaValue);
239 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_mime_type operation.");
242 ret = media_info_get_keyword(mediaHandle, &pGetMediaValue);
243 if (pGetMediaValue != null)
245 pKeyword.reset(pGetMediaValue);
249 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_keyword operation.");
252 if (pMediaId.get() != null)
254 r = UuId::Parse(String(pMediaId.get()), pContentData->contentId);
255 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform UuId::Parse operation.");
258 pContentData->isDrm = isDrm;
259 SysLog(NID_CNT, "pContentData->isDrm = %d", pContentData->isDrm);
261 pContentData->contentSize = contentSize;
262 SysLog(NID_CNT, "pContentData->contentSize = %lu", pContentData->contentSize);
264 if (Double::Compare(latitude, DEFAULT_COORDINATE) != 0)
266 pContentData->latitude = latitude;
268 if (Double::Compare(longitude, DEFAULT_COORDINATE) != 0)
270 pContentData->longitude = longitude;
272 if (Double::Compare(altitude, DEFAULT_COORDINATE) != 0)
274 pContentData->altitude = altitude;
277 if (pMediaPath.get() != NULL)
279 pContentData->contentPath = String(pMediaPath.get());
280 SysSecureLog(NID_CNT, "pContentData->contentPath = %ls", pContentData->contentPath.GetPointer());
283 if (pThumbnailPath.get() != NULL)
285 pContentData->pThumbnailPath = new (std::nothrow) String(pThumbnailPath.get());
286 SysTryReturnResult(NID_CNT, pContentData->pThumbnailPath != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
287 SysSecureLog(NID_CNT, "pContentData->pThumbnailPath = %ls", pContentData->pThumbnailPath->GetPointer());
290 if (pAuthor.get() != NULL)
292 pContentData->pAuthor = new (std::nothrow) String(pAuthor.get());
293 SysTryReturnResult(NID_CNT, pContentData->pAuthor != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
294 SysLog(NID_CNT, "pContentData->pAuthor = %ls", pContentData->pAuthor->GetPointer());
297 if (pCategory.get() != NULL)
299 pContentData->pCategory = new (std::nothrow) String(pCategory.get());
300 SysTryReturnResult(NID_CNT, pContentData->pCategory != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
301 SysLog(NID_CNT, "pContentData->pCategory = %ls", pContentData->pCategory->GetPointer());
304 if (pContentName.get() != NULL)
306 pContentData->pContentName = new (std::nothrow) String(pContentName.get());
307 SysTryReturnResult(NID_CNT, pContentData->pContentName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
308 SysLog(NID_CNT, "pContentData->pContentName = %ls", pContentData->pContentName->GetPointer());
311 if (pDescription.get() != NULL)
313 pContentData->pDescription = new (std::nothrow) String(pDescription.get());
314 SysTryReturnResult(NID_CNT, pContentData->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
315 SysLog(NID_CNT, "pContentData->pDescription = %ls", pContentData->pDescription->GetPointer());
318 if (pLocationTag.get() != NULL)
320 pContentData->pLocationTag = new (std::nothrow) String(pLocationTag.get());
321 SysTryReturnResult(NID_CNT, pContentData->pLocationTag != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
322 SysLog(NID_CNT, "pContentData->pLocationTag = %ls", pContentData->pLocationTag->GetPointer());
325 if (pProvider.get() != NULL)
327 pContentData->pProvider = new (std::nothrow) String(pProvider.get());
328 SysTryReturnResult(NID_CNT, pContentData->pProvider != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
329 SysLog(NID_CNT, "pContentData->pProvider = %ls", pContentData->pProvider->GetPointer());
332 if (pContentRating.get() != NULL)
334 pContentData->pRating = new (std::nothrow) String(pContentRating.get());
335 SysTryReturnResult(NID_CNT, pContentData->pRating != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
336 SysLog(NID_CNT, "pContentData->pRating = %ls", pContentData->pRating->GetPointer());
339 if (pKeyword.get() != NULL)
341 pContentData->pKeyword = new (std::nothrow) String(pKeyword.get());
342 SysTryReturnResult(NID_CNT, pContentData->pKeyword != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
343 SysLog(NID_CNT, "pContentData->pKeyword = %ls", pContentData->pKeyword->GetPointer());
346 if (pMimeType.get() != NULL)
348 pContentData->mimeType = String(pMimeType.get());
349 SysLog(NID_CNT, "pContentData->mimeType = %ls", (pContentData->mimeType).GetPointer());
354 case MEDIA_CONTENT_STORAGE_INTERNAL:
355 pContentData->storageType = 0;
357 case MEDIA_CONTENT_STORAGE_EXTERNAL:
358 pContentData->storageType = 1;
365 case MEDIA_CONTENT_TYPE_OTHERS:
366 pContentData->contentType = CONTENT_TYPE_OTHER;
368 case MEDIA_CONTENT_TYPE_IMAGE:
369 pContentData->contentType = CONTENT_TYPE_IMAGE;
371 case MEDIA_CONTENT_TYPE_SOUND:
373 case MEDIA_CONTENT_TYPE_MUSIC:
374 pContentData->contentType = CONTENT_TYPE_AUDIO;
376 case MEDIA_CONTENT_TYPE_VIDEO:
377 pContentData->contentType = CONTENT_TYPE_VIDEO;
383 r = (pContentData->dateTime).SetValue(1970, 1, 1);
384 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.SetValue operation.");
386 r = (pContentData->dateTime).AddSeconds(addedTime);// need to check addedTime is secs/millisec
387 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.AddSeconds operation.");
389 SysLog(NID_CNT, "addedTime = %ld", addedTime);
390 SysLog(NID_CNT, "pContentData->dateTime : %ls", pContentData->dateTime.ToString().GetPointer());
395 // fills Imagecontentinfo information in the image content data object .
397 _ContentUtility::FillImageContentData(media_info_h mediaHandle, ImageContentInfo::_ImageContentData* pImageContentData)
399 SysTryReturnResult(NID_CNT, mediaHandle != null && pImageContentData != null, E_INVALID_ARG, "mediaHandle or pImageContentData is null.");
401 int ret = MEDIA_CONTENT_ERROR_NONE;
402 result r = E_SUCCESS;
405 media_content_orientation_e orientation;
406 std::unique_ptr<char, UtilCharDeleter> pDisplayName;
408 char* pDisplayValue = null;
409 ret = media_info_get_display_name(mediaHandle, &pDisplayValue);
410 if (pDisplayValue != null)
412 pDisplayName.reset(pDisplayValue);
416 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_display_name operation.");
419 image_meta_h tempMeta = NULL;
421 ret = media_info_get_image(mediaHandle, &tempMeta);
422 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_image operation.");
424 std::unique_ptr<image_meta_s, ImageMetaHandleDeleter> pImageHandle(tempMeta);
425 SysTryReturnResult(NID_CNT, pImageHandle != null, E_OUT_OF_MEMORY, "pImageHandle is null.");
427 ret = image_meta_get_width(pImageHandle.get(), &width);
428 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_width operation.");
430 ret = image_meta_get_orientation(pImageHandle.get(), &orientation);
431 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_orientation operation.");
433 ret = image_meta_get_height(pImageHandle.get(), &height);
434 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_height operation.");
436 pImageContentData->width = width;
437 pImageContentData->height = height;
438 pImageContentData->orientationType = static_cast<ImageOrientationType>(orientation);
440 if (pDisplayName != NULL)
443 String fileName = L"";
444 String strTitle(pDisplayName.get());
446 r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
449 r = strTitle.SubString(0, pos, fileName);
450 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform string.SubString operation.");
458 pImageContentData->title = fileName;
459 SysLog(NID_CNT, "pImageContentData->title = %ls", pImageContentData->title.GetPointer());
465 // fills audio contentinfo information in the audio content data object.
467 _ContentUtility::FillAudioContentData(media_info_h mediaHandle, AudioContentInfo::_AudioContentData* pAudioContentData)
469 SysTryReturnResult(NID_CNT, mediaHandle != null && pAudioContentData != null, E_INVALID_ARG, "mediaHandle or pAudioContentData is null.");
471 int ret = MEDIA_CONTENT_ERROR_NONE;
472 result r = E_SUCCESS;
476 std::unique_ptr<char, UtilCharDeleter> pTitle;
477 std::unique_ptr<char, UtilCharDeleter> pAlbumName;
478 std::unique_ptr<char, UtilCharDeleter> pArtistName;
479 std::unique_ptr<char, UtilCharDeleter> pGenreName;
480 std::unique_ptr<char, UtilCharDeleter> pComposerName;
481 std::unique_ptr<char, UtilCharDeleter> pYear;
482 std::unique_ptr<char, UtilCharDeleter> pCopyRight;
483 std::unique_ptr<char, UtilCharDeleter> pTrackNum;
485 audio_meta_h tempMeta = NULL;
487 ret = media_info_get_audio(mediaHandle, &tempMeta);
488 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_audio operation.");
490 std::unique_ptr<audio_meta_s, AudioMetaHandleDeleter> pAudioHandle(tempMeta);
491 SysTryReturnResult(NID_CNT, pAudioHandle != null, E_OUT_OF_MEMORY, "pAudioHandle is null.");
493 ret = audio_meta_get_bit_rate(pAudioHandle.get(), &bitrate);
494 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_bit_rate operation.");
496 char* pAudioMetaValue = null;
497 ret = audio_meta_get_title(pAudioHandle.get(), &pAudioMetaValue);
498 if (pAudioMetaValue != null)
500 pTitle.reset(pAudioMetaValue);
504 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_title operation.");
507 ret = audio_meta_get_album(pAudioHandle.get(), &pAudioMetaValue);
508 if (pAudioMetaValue != null)
510 pAlbumName.reset(pAudioMetaValue);
514 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_album operation.");
517 ret = audio_meta_get_artist(pAudioHandle.get(), &pAudioMetaValue);
518 if (pAudioMetaValue != null)
520 pArtistName.reset(pAudioMetaValue);
524 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_artist operation.");
527 ret = audio_meta_get_genre(pAudioHandle.get(), &pAudioMetaValue);
528 if (pAudioMetaValue != null)
530 pGenreName.reset(pAudioMetaValue);
534 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_genre operation.");
537 ret = audio_meta_get_composer(pAudioHandle.get(), &pAudioMetaValue);
538 if (pAudioMetaValue != null)
540 pComposerName.reset(pAudioMetaValue);
544 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_composer operation.");
547 ret = audio_meta_get_year(pAudioHandle.get(), &pAudioMetaValue);
548 if (pAudioMetaValue != null)
550 pYear.reset(pAudioMetaValue);
554 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_year operation.");
557 ret = audio_meta_get_copyright(pAudioHandle.get(), &pAudioMetaValue);
558 if (pAudioMetaValue != null)
560 pCopyRight.reset(pAudioMetaValue);
564 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_copyright operation.");
567 ret = audio_meta_get_track_num(pAudioHandle.get(), &pAudioMetaValue);
568 if (pAudioMetaValue != null)
570 pTrackNum.reset(pAudioMetaValue);
574 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_track_num operation.");
577 ret = audio_meta_get_duration(pAudioHandle.get(), &duration);
578 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_duration operation.");
580 pAudioContentData->bitrate = bitrate;
582 if (pYear.get() != null)
584 SysLog(NID_CNT, "pAudioContentData->pYear = %s", pYear.get());
586 String strYear(pYear.get());
587 if (strYear.CompareTo(L"Unknown") != 0)
589 r = Integer::Parse(strYear, pAudioContentData->releaseYear);
592 // It is one of the metadata. If error occurs, skip it for other metadata.
593 pAudioContentData->releaseYear = 0;
595 SysLog(NID_CNT, "pAudioContentData->pYear(invalid data) = %ls", strYear.GetPointer());
600 if (pTitle.get() != NULL)
602 pAudioContentData->pTitle = new (std::nothrow) String(pTitle.get());
603 SysTryReturnResult(NID_CNT, pAudioContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
604 SysLog(NID_CNT, "pAudioContentData->pTitle = %ls", pAudioContentData->pTitle->GetPointer());
607 if (pArtistName.get() != NULL)
609 pAudioContentData->pArtist = new (std::nothrow) String(pArtistName.get());
610 SysTryReturnResult(NID_CNT, pAudioContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
611 SysLog(NID_CNT, "pAudioContentData->pArtist = %ls", pAudioContentData->pArtist->GetPointer());
614 if (pGenreName.get() != NULL)
616 pAudioContentData->pGenre = new (std::nothrow) String(pGenreName.get());
617 SysTryReturnResult(NID_CNT, pAudioContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
618 SysLog(NID_CNT, "pAudioContentData->pGenre = %ls", pAudioContentData->pGenre->GetPointer());
621 if (pComposerName.get() != NULL)
623 pAudioContentData->pComposer = new (std::nothrow) String(pComposerName.get());
624 SysTryReturnResult(NID_CNT, pAudioContentData->pComposer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
625 SysLog(NID_CNT, "pAudioContentData->pComposer = %ls", pAudioContentData->pComposer->GetPointer());
628 if (pAlbumName.get() != NULL)
630 pAudioContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
631 SysTryReturnResult(NID_CNT, pAudioContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
632 SysLog(NID_CNT, "pAudioContentData->pAlbumName = %ls", pAudioContentData->pAlbumName->GetPointer());
635 if (pCopyRight.get() != NULL)
637 pAudioContentData->pCopyright = new (std::nothrow) String(pCopyRight.get());
638 SysTryReturnResult(NID_CNT, pAudioContentData->pCopyright != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
639 SysLog(NID_CNT, "pAudioContentData->pCopyright = %ls", pAudioContentData->pCopyright->GetPointer());
642 if (pTrackNum.get() != NULL)
644 pAudioContentData->pTrackInfo = new (std::nothrow) String(pTrackNum.get());
645 SysTryReturnResult(NID_CNT, pAudioContentData->pTrackInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
646 SysLog(NID_CNT, "pAudioContentData->pTrackInfo = %ls", pAudioContentData->pTrackInfo->GetPointer());
649 pAudioContentData->duration = duration;
650 SysLog(NID_CNT,"pAudioContentData->duration = %d", pAudioContentData->duration);
655 // fills video contentinfo information in the video content data object.
657 _ContentUtility::FillVideoContentData(media_info_h mediaHandle, VideoContentInfo::_VideoContentData* pVideoContentData)
659 SysTryReturnResult(NID_CNT, mediaHandle != null && pVideoContentData != null, E_INVALID_ARG, "mediaHandle or pVideoContentData is null.");
661 int ret = MEDIA_CONTENT_ERROR_NONE;
662 result r = E_SUCCESS;
665 std::unique_ptr<char, UtilCharDeleter> pArtistName;
666 std::unique_ptr<char, UtilCharDeleter> pGenreName;
667 std::unique_ptr<char, UtilCharDeleter> pTitle;
668 std::unique_ptr<char, UtilCharDeleter> pAlbumName;
671 video_meta_h tempMeta = NULL;
673 ret = media_info_get_video(mediaHandle, &tempMeta);
674 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_video operation.");
676 std::unique_ptr<video_meta_s, VideoMetaHandleDeleter> pVideoHandle(tempMeta);
677 SysTryReturnResult(NID_CNT, pVideoHandle != null, E_OUT_OF_MEMORY, "pVideoHandle is null.");
679 ret = video_meta_get_width(pVideoHandle.get(), &width);
680 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_width operation.");
682 ret = video_meta_get_height(pVideoHandle.get(), &height);
683 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_height operation.");
685 char* pVideoMetaValue = null;
686 ret = video_meta_get_artist(pVideoHandle.get(), &pVideoMetaValue);
687 if (pVideoMetaValue != null)
689 pArtistName.reset(pVideoMetaValue);
693 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_artist operation.");
696 ret = video_meta_get_genre(pVideoHandle.get(), &pVideoMetaValue);
697 if (pVideoMetaValue != null)
699 pGenreName.reset(pVideoMetaValue);
703 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_genre operation.");
706 ret = video_meta_get_title(pVideoHandle.get(), &pVideoMetaValue);
707 if (pVideoMetaValue != null)
709 pTitle.reset(pVideoMetaValue);
713 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_title operation.");
716 ret = video_meta_get_album(pVideoHandle.get(), &pVideoMetaValue);
717 if (pVideoMetaValue != null)
719 pAlbumName.reset(pVideoMetaValue);
723 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_album operation.");
726 ret = video_meta_get_duration(pVideoHandle.get(), &duration);
727 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_duration operation.");
729 pVideoContentData->width = width;
730 pVideoContentData->height = height;
732 if (pTitle.get() != NULL)
734 pVideoContentData->pTitle = new (std::nothrow) String(pTitle.get());
735 SysTryReturnResult(NID_CNT, pVideoContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
736 SysLog(NID_CNT, "pVideoContentData->pTitle = %ls", pVideoContentData->pTitle->GetPointer());
739 if (pArtistName.get() != NULL)
741 pVideoContentData->pArtist = new (std::nothrow) String(pArtistName.get());
742 SysTryReturnResult(NID_CNT, pVideoContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
743 SysLog(NID_CNT, "pVideoContentData->pArtist = %ls", pVideoContentData->pArtist->GetPointer());
746 if (pGenreName.get() != NULL)
748 pVideoContentData->pGenre = new (std::nothrow) String(pGenreName.get());
749 SysTryReturnResult(NID_CNT, pVideoContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
750 SysLog(NID_CNT, "pVideoContentData->pGenre = %ls", pVideoContentData->pGenre->GetPointer());
753 if (pAlbumName.get() != NULL)
755 pVideoContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
756 SysTryReturnResult(NID_CNT, pVideoContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
757 SysLog(NID_CNT, "pVideoContentData->pAlbumName = %ls", pVideoContentData->pAlbumName->GetPointer());
760 pVideoContentData->duration = duration;
761 SysLog(NID_CNT,"pVideoContentData->duration = %d", pVideoContentData->duration);
766 // Convertion of system errors to osp errors
768 _ContentUtility::MapCoreErrorToNativeResult(int reason)
770 result r = E_SUCCESS;
773 case MEDIA_CONTENT_ERROR_NONE:
776 case MEDIA_CONTENT_ERROR_DB_BUSY:
778 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
780 case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
782 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_INVALID_PARAMETER");
784 case MEDIA_CONTENT_ERROR_DB_FAILED:
786 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
788 case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:
790 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_OUT_OF_MEMORY");
793 SysLog(NID_CNT, "default");