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 std::unique_ptr<image_meta_h, ImageMetaHandleDeleter> pImageHandle(new (std::nothrow) image_meta_h);
420 ret = media_info_get_image(mediaHandle, pImageHandle.get());
422 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_image operation.");
425 ret = image_meta_get_width(*(pImageHandle.get()), &width);
426 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_width operation.");
428 ret = image_meta_get_orientation(*(pImageHandle.get()), &orientation);
429 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_orientation operation.");
431 ret = image_meta_get_height(*(pImageHandle.get()), &height);
432 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_height operation.");
434 pImageContentData->width = width;
435 pImageContentData->height = height;
436 pImageContentData->orientationType = static_cast<ImageOrientationType>(orientation);
438 if (pDisplayName != NULL)
441 String fileName = L"";
442 String strTitle(pDisplayName.get());
444 r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
447 r = strTitle.SubString(0, pos, fileName);
448 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform string.SubString operation.");
456 pImageContentData->title = fileName;
457 SysLog(NID_CNT, "pImageContentData->title = %ls", pImageContentData->title.GetPointer());
463 // fills audio contentinfo information in the audio content data object.
465 _ContentUtility::FillAudioContentData(media_info_h mediaHandle, AudioContentInfo::_AudioContentData* pAudioContentData)
467 SysTryReturnResult(NID_CNT, mediaHandle != null && pAudioContentData != null, E_INVALID_ARG, "mediaHandle or pAudioContentData is null.");
469 int ret = MEDIA_CONTENT_ERROR_NONE;
470 result r = E_SUCCESS;
474 std::unique_ptr<char, UtilCharDeleter> pTitle;
475 std::unique_ptr<char, UtilCharDeleter> pAlbumName;
476 std::unique_ptr<char, UtilCharDeleter> pArtistName;
477 std::unique_ptr<char, UtilCharDeleter> pGenreName;
478 std::unique_ptr<char, UtilCharDeleter> pComposerName;
479 std::unique_ptr<char, UtilCharDeleter> pYear;
480 std::unique_ptr<char, UtilCharDeleter> pCopyRight;
481 std::unique_ptr<char, UtilCharDeleter> pTrackNum;
484 std::unique_ptr<audio_meta_h, AudioMetaHandleDeleter> pAudioHandle(new (std::nothrow) audio_meta_h);
485 ret = media_info_get_audio(mediaHandle, pAudioHandle.get());
486 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_audio operation.");
488 ret = audio_meta_get_bit_rate(*(pAudioHandle.get()), &bitrate);
489 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_bit_rate operation.");
491 char* pAudioMetaValue = null;
492 ret = audio_meta_get_title(*(pAudioHandle.get()), &pAudioMetaValue);
493 if (pAudioMetaValue != null)
495 pTitle.reset(pAudioMetaValue);
499 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_title operation.");
502 ret = audio_meta_get_album(*(pAudioHandle.get()), &pAudioMetaValue);
503 if (pAudioMetaValue != null)
505 pAlbumName.reset(pAudioMetaValue);
509 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_album operation.");
512 ret = audio_meta_get_artist(*(pAudioHandle.get()), &pAudioMetaValue);
513 if (pAudioMetaValue != null)
515 pArtistName.reset(pAudioMetaValue);
519 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_artist operation.");
522 ret = audio_meta_get_genre(*(pAudioHandle.get()), &pAudioMetaValue);
523 if (pAudioMetaValue != null)
525 pGenreName.reset(pAudioMetaValue);
529 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_genre operation.");
532 ret = audio_meta_get_composer(*(pAudioHandle.get()), &pAudioMetaValue);
533 if (pAudioMetaValue != null)
535 pComposerName.reset(pAudioMetaValue);
539 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_composer operation.");
542 ret = audio_meta_get_year(*(pAudioHandle.get()), &pAudioMetaValue);
543 if (pAudioMetaValue != null)
545 pYear.reset(pAudioMetaValue);
549 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_year operation.");
552 ret = audio_meta_get_copyright(*(pAudioHandle.get()), &pAudioMetaValue);
553 if (pAudioMetaValue != null)
555 pCopyRight.reset(pAudioMetaValue);
559 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_copyright operation.");
562 ret = audio_meta_get_track_num(*(pAudioHandle.get()), &pAudioMetaValue);
563 if (pAudioMetaValue != null)
565 pTrackNum.reset(pAudioMetaValue);
569 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_track_num operation.");
572 ret = audio_meta_get_duration(*(pAudioHandle.get()), &duration);
573 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_duration operation.");
575 pAudioContentData->bitrate = bitrate;
577 if (pYear.get() != null)
579 SysLog(NID_CNT, "pAudioContentData->pYear = %s", pYear.get());
581 String strYear(pYear.get());
582 if (strYear.CompareTo(L"Unknown") != 0)
584 r = Integer::Parse(strYear, pAudioContentData->releaseYear);
587 // It is one of the metadata. If error occurs, skip it for other metadata.
588 pAudioContentData->releaseYear = 0;
590 SysLog(NID_CNT, "pAudioContentData->pYear(invalid data) = %ls", strYear.GetPointer());
595 if (pTitle.get() != NULL)
597 pAudioContentData->pTitle = new (std::nothrow) String(pTitle.get());
598 SysTryReturnResult(NID_CNT, pAudioContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
599 SysLog(NID_CNT, "pAudioContentData->pTitle = %ls", pAudioContentData->pTitle->GetPointer());
602 if (pArtistName.get() != NULL)
604 pAudioContentData->pArtist = new (std::nothrow) String(pArtistName.get());
605 SysTryReturnResult(NID_CNT, pAudioContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
606 SysLog(NID_CNT, "pAudioContentData->pArtist = %ls", pAudioContentData->pArtist->GetPointer());
609 if (pGenreName.get() != NULL)
611 pAudioContentData->pGenre = new (std::nothrow) String(pGenreName.get());
612 SysTryReturnResult(NID_CNT, pAudioContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
613 SysLog(NID_CNT, "pAudioContentData->pGenre = %ls", pAudioContentData->pGenre->GetPointer());
616 if (pComposerName.get() != NULL)
618 pAudioContentData->pComposer = new (std::nothrow) String(pComposerName.get());
619 SysTryReturnResult(NID_CNT, pAudioContentData->pComposer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
620 SysLog(NID_CNT, "pAudioContentData->pComposer = %ls", pAudioContentData->pComposer->GetPointer());
623 if (pAlbumName.get() != NULL)
625 pAudioContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
626 SysTryReturnResult(NID_CNT, pAudioContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
627 SysLog(NID_CNT, "pAudioContentData->pAlbumName = %ls", pAudioContentData->pAlbumName->GetPointer());
630 if (pCopyRight.get() != NULL)
632 pAudioContentData->pCopyright = new (std::nothrow) String(pCopyRight.get());
633 SysTryReturnResult(NID_CNT, pAudioContentData->pCopyright != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
634 SysLog(NID_CNT, "pAudioContentData->pCopyright = %ls", pAudioContentData->pCopyright->GetPointer());
637 if (pTrackNum.get() != NULL)
639 pAudioContentData->pTrackInfo = new (std::nothrow) String(pTrackNum.get());
640 SysTryReturnResult(NID_CNT, pAudioContentData->pTrackInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
641 SysLog(NID_CNT, "pAudioContentData->pTrackInfo = %ls", pAudioContentData->pTrackInfo->GetPointer());
644 pAudioContentData->duration = duration;
645 SysLog(NID_CNT,"pAudioContentData->duration = %d", pAudioContentData->duration);
650 // fills video contentinfo information in the video content data object.
652 _ContentUtility::FillVideoContentData(media_info_h mediaHandle, VideoContentInfo::_VideoContentData* pVideoContentData)
654 SysTryReturnResult(NID_CNT, mediaHandle != null && pVideoContentData != null, E_INVALID_ARG, "mediaHandle or pVideoContentData is null.");
656 int ret = MEDIA_CONTENT_ERROR_NONE;
657 result r = E_SUCCESS;
660 std::unique_ptr<char, UtilCharDeleter> pArtistName;
661 std::unique_ptr<char, UtilCharDeleter> pGenreName;
662 std::unique_ptr<char, UtilCharDeleter> pTitle;
663 std::unique_ptr<char, UtilCharDeleter> pAlbumName;
666 std::unique_ptr<video_meta_h, VideoMetaHandleDeleter> pVideoHandle(new (std::nothrow) video_meta_h);
667 ret = media_info_get_video(mediaHandle, pVideoHandle.get());
668 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_video operation.");
670 ret = video_meta_get_width(*(pVideoHandle.get()), &width);
671 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_width operation.");
673 ret = video_meta_get_height(*(pVideoHandle.get()), &height);
674 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_height operation.");
676 char* pVideoMetaValue = null;
677 ret = video_meta_get_artist(*(pVideoHandle.get()), &pVideoMetaValue);
678 if (pVideoMetaValue != null)
680 pArtistName.reset(pVideoMetaValue);
684 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_artist operation.");
687 ret = video_meta_get_genre(*(pVideoHandle.get()), &pVideoMetaValue);
688 if (pVideoMetaValue != null)
690 pGenreName.reset(pVideoMetaValue);
694 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_genre operation.");
697 ret = video_meta_get_title(*(pVideoHandle.get()), &pVideoMetaValue);
698 if (pVideoMetaValue != null)
700 pTitle.reset(pVideoMetaValue);
704 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_title operation.");
707 ret = video_meta_get_album(*(pVideoHandle.get()), &pVideoMetaValue);
708 if (pVideoMetaValue != null)
710 pAlbumName.reset(pVideoMetaValue);
714 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_album operation.");
717 ret = video_meta_get_duration(*(pVideoHandle.get()), &duration);
718 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_duration operation.");
720 pVideoContentData->width = width;
721 pVideoContentData->height = height;
723 if (pTitle.get() != NULL)
725 pVideoContentData->pTitle = new (std::nothrow) String(pTitle.get());
726 SysTryReturnResult(NID_CNT, pVideoContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
727 SysLog(NID_CNT, "pVideoContentData->pTitle = %ls", pVideoContentData->pTitle->GetPointer());
730 if (pArtistName.get() != NULL)
732 pVideoContentData->pArtist = new (std::nothrow) String(pArtistName.get());
733 SysTryReturnResult(NID_CNT, pVideoContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
734 SysLog(NID_CNT, "pVideoContentData->pArtist = %ls", pVideoContentData->pArtist->GetPointer());
737 if (pGenreName.get() != NULL)
739 pVideoContentData->pGenre = new (std::nothrow) String(pGenreName.get());
740 SysTryReturnResult(NID_CNT, pVideoContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
741 SysLog(NID_CNT, "pVideoContentData->pGenre = %ls", pVideoContentData->pGenre->GetPointer());
744 if (pAlbumName.get() != NULL)
746 pVideoContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
747 SysTryReturnResult(NID_CNT, pVideoContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
748 SysLog(NID_CNT, "pVideoContentData->pAlbumName = %ls", pVideoContentData->pAlbumName->GetPointer());
751 pVideoContentData->duration = duration;
752 SysLog(NID_CNT,"pVideoContentData->duration = %d", pVideoContentData->duration);
757 // Convertion of system errors to osp errors
759 _ContentUtility::MapCoreErrorToNativeResult(int reason)
761 result r = E_SUCCESS;
764 case MEDIA_CONTENT_ERROR_NONE:
767 case MEDIA_CONTENT_ERROR_DB_BUSY:
769 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
771 case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
773 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_INVALID_PARAMETER");
775 case MEDIA_CONTENT_ERROR_DB_FAILED:
777 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
779 case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:
781 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_OUT_OF_MEMORY");
784 SysLog(NID_CNT, "default");