2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FCnt_ContentUtility.cpp
19 * @brief This is the implementation file for the %_ContentUtility class.
21 * This file contains implementation of the %_ContentUtility class.
24 #include <unique_ptr.h>
25 #include <FBaseSysLog.h>
26 #include <FBaseInteger.h>
27 #include <FBaseLongLong.h>
28 #include <FBaseFloat.h>
29 #include <FCnt_ContentUtility.h>
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
34 namespace Tizen { namespace Content
37 static const double DEFAULT_COORDINATE = -200.0;
39 // Default constructor
40 _ContentUtility::_ContentUtility(void)
43 SysLog(NID_CNT, "Enter\n");
48 _ContentUtility::~_ContentUtility(void)
50 SysLog(NID_CNT, "Enter\n");
54 _ContentUtility::DoSafeFree(char* pSrc)
64 _ContentUtility::DoSafeDelete(String* pSrc)
73 // fills contentinfo information in the content data object.
75 _ContentUtility::FillContentData(media_info_h mediaHandle, ContentInfo::_ContentData* pContentData)
78 SysTryReturnResult(NID_CNT, mediaHandle != null && pContentData != null, E_INVALID_ARG, "mediaHandle or pContentData is null.");
80 int ret = MEDIA_CONTENT_ERROR_NONE;
83 std::unique_ptr<char, UtilCharDeleter> pMediaId;
84 std::unique_ptr<char, UtilCharDeleter> pContentName;
85 std::unique_ptr<char, UtilCharDeleter> pMediaPath;
86 std::unique_ptr<char, UtilCharDeleter> pThumbnailPath;
87 std::unique_ptr<char, UtilCharDeleter> pAuthor;
88 std::unique_ptr<char, UtilCharDeleter> pCategory;
89 std::unique_ptr<char, UtilCharDeleter> pDescription;
90 std::unique_ptr<char, UtilCharDeleter> pLocationTag;
91 std::unique_ptr<char, UtilCharDeleter> pProvider;
92 std::unique_ptr<char, UtilCharDeleter> pKeyword;
93 std::unique_ptr<char, UtilCharDeleter> pContentRating;
94 std::unique_ptr<char, UtilCharDeleter> pMimeType;
96 media_content_type_e mediaType;
97 media_content_storage_e storageType;
99 unsigned long long contentSize = 0;
100 time_t addedTime = 0;
102 double longitude = 0;
107 char* pGetMediaValue = null;
108 ret = media_info_get_media_id(mediaHandle, &pGetMediaValue);
109 if (pGetMediaValue != null)
111 pMediaId.reset(pGetMediaValue);
115 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_id operation.");
118 ret = media_info_get_content_name(mediaHandle, &pGetMediaValue);
119 if (pGetMediaValue != null)
121 pContentName.reset(pGetMediaValue);
125 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_content_name operation.");
128 ret = media_info_get_file_path(mediaHandle, &pGetMediaValue);
129 if (pGetMediaValue != null)
131 pMediaPath.reset(pGetMediaValue);
135 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_file_path operation.");
138 ret = media_info_get_thumbnail_path(mediaHandle, &pGetMediaValue);
139 if (pGetMediaValue != null)
141 pThumbnailPath.reset(pGetMediaValue);
145 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_thumbnail_path operation.");
148 ret = media_info_get_author(mediaHandle, &pGetMediaValue);
149 if (pGetMediaValue != null)
151 pAuthor.reset(pGetMediaValue);
155 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_author operation.");
158 ret = media_info_get_category(mediaHandle, &pGetMediaValue);
159 if (pGetMediaValue != null)
161 pCategory.reset(pGetMediaValue);
165 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_category operation.");
168 ret = media_info_get_description(mediaHandle, &pGetMediaValue);
169 if (pGetMediaValue != null)
171 pDescription.reset(pGetMediaValue);
175 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_description operation.");
178 ret = media_info_get_location_tag(mediaHandle, &pGetMediaValue);
179 if (pGetMediaValue != null)
181 pLocationTag.reset(pGetMediaValue);
185 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_location_tag operation.");
188 ret = media_info_get_provider(mediaHandle, &pGetMediaValue);
189 if (pGetMediaValue != null)
191 pProvider.reset(pGetMediaValue);
195 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_provider operation.");
198 ret = media_info_get_size(mediaHandle, &contentSize);
199 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_size operation.");
202 ret = media_info_get_latitude(mediaHandle, &latitude);
203 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_latitude operation.");
205 ret = media_info_get_longitude(mediaHandle, &longitude);
206 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_longitude operation.");
208 ret = media_info_get_altitude(mediaHandle, &altitude);
209 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_altitude operation.");
211 ret = media_info_get_age_rating(mediaHandle, &pGetMediaValue);
212 if (pGetMediaValue != null)
214 pContentRating.reset(pGetMediaValue);
218 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_age_rating operation.");
221 ret = media_info_is_drm(mediaHandle, &isDrm);
222 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_is_drm operation.");
224 ret = media_info_get_added_time(mediaHandle, &addedTime);
225 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_added_time operation.");
227 ret = media_info_get_storage_type(mediaHandle, &storageType);
228 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_storage_type operation.");
230 ret = media_info_get_media_type(mediaHandle, &mediaType);
231 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_type operation.");
233 ret = media_info_get_mime_type(mediaHandle, &pGetMediaValue);
234 if (pGetMediaValue != null)
236 pMimeType.reset(pGetMediaValue);
240 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_mime_type operation.");
243 ret = media_info_get_keyword(mediaHandle, &pGetMediaValue);
244 if (pGetMediaValue != null)
246 pKeyword.reset(pGetMediaValue);
250 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_keyword operation.");
253 if (pMediaId.get() != null)
255 r = UuId::Parse(String(pMediaId.get()), pContentData->contentId);
256 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform UuId::Parse operation.");
259 pContentData->isDrm = isDrm;
260 SysLog(NID_CNT, "pContentData->isDrm = %d", pContentData->isDrm);
262 pContentData->contentSize = contentSize;
263 SysLog(NID_CNT, "pContentData->contentSize = %lu", pContentData->contentSize);
265 if (Double::Compare(latitude, DEFAULT_COORDINATE) != 0)
267 pContentData->latitude = latitude;
269 if (Double::Compare(longitude, DEFAULT_COORDINATE) != 0)
271 pContentData->longitude = longitude;
273 if (Double::Compare(altitude, DEFAULT_COORDINATE) != 0)
275 pContentData->altitude = altitude;
278 if (pMediaPath.get() != NULL)
280 pContentData->contentPath = String(pMediaPath.get());
281 SysLog(NID_CNT, "pContentData->contentPath = %ls", pContentData->contentPath.GetPointer());
284 if (pThumbnailPath.get() != NULL)
286 pContentData->pThumbnailPath = new (std::nothrow) String(pThumbnailPath.get());
287 SysTryReturnResult(NID_CNT, pContentData->pThumbnailPath != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
288 SysLog(NID_CNT, "pContentData->pThumbnailPath = %ls", pContentData->pThumbnailPath->GetPointer());
291 if (pAuthor.get() != NULL)
293 pContentData->pAuthor = new (std::nothrow) String(pAuthor.get());
294 SysTryReturnResult(NID_CNT, pContentData->pAuthor != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
295 SysLog(NID_CNT, "pContentData->pAuthor = %ls", pContentData->pAuthor->GetPointer());
298 if (pCategory.get() != NULL)
300 pContentData->pCategory = new (std::nothrow) String(pCategory.get());
301 SysTryReturnResult(NID_CNT, pContentData->pCategory != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
302 SysLog(NID_CNT, "pContentData->pCategory = %ls", pContentData->pCategory->GetPointer());
305 if (pContentName.get() != NULL)
307 pContentData->pContentName = new (std::nothrow) String(pContentName.get());
308 SysTryReturnResult(NID_CNT, pContentData->pContentName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
309 SysLog(NID_CNT, "pContentData->pContentName = %ls", pContentData->pContentName->GetPointer());
312 if (pDescription.get() != NULL)
314 pContentData->pDescription = new (std::nothrow) String(pDescription.get());
315 SysTryReturnResult(NID_CNT, pContentData->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
316 SysLog(NID_CNT, "pContentData->pDescription = %ls", pContentData->pDescription->GetPointer());
319 if (pLocationTag.get() != NULL)
321 pContentData->pLocationTag = new (std::nothrow) String(pLocationTag.get());
322 SysTryReturnResult(NID_CNT, pContentData->pLocationTag != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
323 SysLog(NID_CNT, "pContentData->pLocationTag = %ls", pContentData->pLocationTag->GetPointer());
326 if (pProvider.get() != NULL)
328 pContentData->pProvider = new (std::nothrow) String(pProvider.get());
329 SysTryReturnResult(NID_CNT, pContentData->pProvider != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
330 SysLog(NID_CNT, "pContentData->pProvider = %ls", pContentData->pProvider->GetPointer());
333 if (pContentRating.get() != NULL)
335 pContentData->pRating = new (std::nothrow) String(pContentRating.get());
336 SysTryReturnResult(NID_CNT, pContentData->pRating != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
337 SysLog(NID_CNT, "pContentData->pRating = %ls", pContentData->pRating->GetPointer());
340 if (pKeyword.get() != NULL)
342 pContentData->pKeyword = new (std::nothrow) String(pKeyword.get());
343 SysTryReturnResult(NID_CNT, pContentData->pKeyword != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
344 SysLog(NID_CNT, "pContentData->pKeyword = %ls", pContentData->pKeyword->GetPointer());
347 if (pMimeType.get() != NULL)
349 pContentData->mimeType = String(pMimeType.get());
350 SysLog(NID_CNT, "pContentData->mimeType = %ls", (pContentData->mimeType).GetPointer());
355 case MEDIA_CONTENT_STORAGE_INTERNAL:
356 pContentData->storageType = 0;
358 case MEDIA_CONTENT_STORAGE_EXTERNAL:
359 pContentData->storageType = 1;
366 case MEDIA_CONTENT_TYPE_OTHERS:
367 pContentData->contentType = CONTENT_TYPE_OTHER;
369 case MEDIA_CONTENT_TYPE_IMAGE:
370 pContentData->contentType = CONTENT_TYPE_IMAGE;
372 case MEDIA_CONTENT_TYPE_SOUND:
374 case MEDIA_CONTENT_TYPE_MUSIC:
375 pContentData->contentType = CONTENT_TYPE_AUDIO;
377 case MEDIA_CONTENT_TYPE_VIDEO:
378 pContentData->contentType = CONTENT_TYPE_VIDEO;
384 r = (pContentData->dateTime).SetValue(1970, 1, 1);
385 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.SetValue operation.");
387 r = (pContentData->dateTime).AddSeconds(addedTime);// need to check addedTime is secs/millisec
388 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.AddSeconds operation.");
390 SysLog(NID_CNT, "addedTime = %ld", addedTime);
391 SysLog(NID_CNT, "pContentData->dateTime : %ls", pContentData->dateTime.ToString().GetPointer());
396 // fills Imagecontentinfo information in the image content data object .
398 _ContentUtility::FillImageContentData(media_info_h mediaHandle, ImageContentInfo::_ImageContentData* pImageContentData)
400 SysTryReturnResult(NID_CNT, mediaHandle != null && pImageContentData != null, E_INVALID_ARG, "mediaHandle or pImageContentData is null.");
402 int ret = MEDIA_CONTENT_ERROR_NONE;
403 result r = E_SUCCESS;
406 media_content_orientation_e orientation;
407 std::unique_ptr<char, UtilCharDeleter> pDisplayName;
409 char* pDisplayValue = null;
410 ret = media_info_get_display_name(mediaHandle, &pDisplayValue);
411 if (pDisplayValue != null)
413 pDisplayName.reset(pDisplayValue);
417 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_display_name operation.");
420 std::unique_ptr<image_meta_h, ImageMetaHandleDeleter> pImageHandle(new (std::nothrow) image_meta_h);
421 ret = media_info_get_image(mediaHandle, pImageHandle.get());
423 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_image operation.");
426 ret = image_meta_get_width(*(pImageHandle.get()), &width);
427 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_width operation.");
429 ret = image_meta_get_orientation(*(pImageHandle.get()), &orientation);
430 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_orientation operation.");
432 ret = image_meta_get_height(*(pImageHandle.get()), &height);
433 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_height operation.");
435 pImageContentData->width = width;
436 pImageContentData->height = height;
437 pImageContentData->orientationType = static_cast<ImageOrientationType>(orientation);
439 if (pDisplayName != NULL)
442 String fileName = L"";
443 String strTitle(pDisplayName.get());
445 r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
448 r = strTitle.SubString(0, pos, fileName);
449 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform string.SubString operation.");
457 pImageContentData->title = fileName;
458 SysLog(NID_CNT, "pImageContentData->title = %ls", pImageContentData->title.GetPointer());
464 // fills audio contentinfo information in the audio content data object.
466 _ContentUtility::FillAudioContentData(media_info_h mediaHandle, AudioContentInfo::_AudioContentData* pAudioContentData)
468 SysTryReturnResult(NID_CNT, mediaHandle != null && pAudioContentData != null, E_INVALID_ARG, "mediaHandle or pAudioContentData is null.");
470 int ret = MEDIA_CONTENT_ERROR_NONE;
471 result r = E_SUCCESS;
475 std::unique_ptr<char, UtilCharDeleter> pTitle;
476 std::unique_ptr<char, UtilCharDeleter> pAlbumName;
477 std::unique_ptr<char, UtilCharDeleter> pArtistName;
478 std::unique_ptr<char, UtilCharDeleter> pGenreName;
479 std::unique_ptr<char, UtilCharDeleter> pComposerName;
480 std::unique_ptr<char, UtilCharDeleter> pYear;
481 std::unique_ptr<char, UtilCharDeleter> pCopyRight;
482 std::unique_ptr<char, UtilCharDeleter> pTrackNum;
485 std::unique_ptr<audio_meta_h, AudioMetaHandleDeleter> pAudioHandle(new (std::nothrow) audio_meta_h);
486 ret = media_info_get_audio(mediaHandle, pAudioHandle.get());
487 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_audio operation.");
489 ret = audio_meta_get_bit_rate(*(pAudioHandle.get()), &bitrate);
490 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_bit_rate operation.");
492 char* pAudioMetaValue = null;
493 ret = audio_meta_get_title(*(pAudioHandle.get()), &pAudioMetaValue);
494 if (pAudioMetaValue != null)
496 pTitle.reset(pAudioMetaValue);
500 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_title operation.");
503 ret = audio_meta_get_album(*(pAudioHandle.get()), &pAudioMetaValue);
504 if (pAudioMetaValue != null)
506 pAlbumName.reset(pAudioMetaValue);
510 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_album operation.");
513 ret = audio_meta_get_artist(*(pAudioHandle.get()), &pAudioMetaValue);
514 if (pAudioMetaValue != null)
516 pArtistName.reset(pAudioMetaValue);
520 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_artist operation.");
523 ret = audio_meta_get_genre(*(pAudioHandle.get()), &pAudioMetaValue);
524 if (pAudioMetaValue != null)
526 pGenreName.reset(pAudioMetaValue);
530 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_genre operation.");
533 ret = audio_meta_get_composer(*(pAudioHandle.get()), &pAudioMetaValue);
534 if (pAudioMetaValue != null)
536 pComposerName.reset(pAudioMetaValue);
540 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_composer operation.");
543 ret = audio_meta_get_year(*(pAudioHandle.get()), &pAudioMetaValue);
544 if (pAudioMetaValue != null)
546 pYear.reset(pAudioMetaValue);
550 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_year operation.");
553 ret = audio_meta_get_copyright(*(pAudioHandle.get()), &pAudioMetaValue);
554 if (pAudioMetaValue != null)
556 pCopyRight.reset(pAudioMetaValue);
560 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_copyright operation.");
563 ret = audio_meta_get_track_num(*(pAudioHandle.get()), &pAudioMetaValue);
564 if (pAudioMetaValue != null)
566 pTrackNum.reset(pAudioMetaValue);
570 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_track_num operation.");
573 ret = audio_meta_get_duration(*(pAudioHandle.get()), &duration);
574 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_duration operation.");
576 pAudioContentData->bitrate = bitrate;
578 if (pYear.get() != null)
580 SysLog(NID_CNT, "pAudioContentData->pYear = %s", pYear.get());
582 String strYear(pYear.get());
583 if (strYear.CompareTo(L"Unknown") != 0)
585 r = Integer::Parse(strYear, pAudioContentData->releaseYear);
588 // It is one of the metadata. If error occurs, skip it for other metadata.
589 pAudioContentData->releaseYear = 0;
591 SysLog(NID_CNT, "pAudioContentData->pYear(invalid data) = %ls", strYear.GetPointer());
596 if (pTitle.get() != NULL)
598 pAudioContentData->pTitle = new (std::nothrow) String(pTitle.get());
599 SysTryReturnResult(NID_CNT, pAudioContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
600 SysLog(NID_CNT, "pAudioContentData->pTitle = %ls", pAudioContentData->pTitle->GetPointer());
603 if (pArtistName.get() != NULL)
605 pAudioContentData->pArtist = new (std::nothrow) String(pArtistName.get());
606 SysTryReturnResult(NID_CNT, pAudioContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
607 SysLog(NID_CNT, "pAudioContentData->pArtist = %ls", pAudioContentData->pArtist->GetPointer());
610 if (pGenreName.get() != NULL)
612 pAudioContentData->pGenre = new (std::nothrow) String(pGenreName.get());
613 SysTryReturnResult(NID_CNT, pAudioContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
614 SysLog(NID_CNT, "pAudioContentData->pGenre = %ls", pAudioContentData->pGenre->GetPointer());
617 if (pComposerName.get() != NULL)
619 pAudioContentData->pComposer = new (std::nothrow) String(pComposerName.get());
620 SysTryReturnResult(NID_CNT, pAudioContentData->pComposer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
621 SysLog(NID_CNT, "pAudioContentData->pComposer = %ls", pAudioContentData->pComposer->GetPointer());
624 if (pAlbumName.get() != NULL)
626 pAudioContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
627 SysTryReturnResult(NID_CNT, pAudioContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
628 SysLog(NID_CNT, "pAudioContentData->pAlbumName = %ls", pAudioContentData->pAlbumName->GetPointer());
631 if (pCopyRight.get() != NULL)
633 pAudioContentData->pCopyright = new (std::nothrow) String(pCopyRight.get());
634 SysTryReturnResult(NID_CNT, pAudioContentData->pCopyright != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
635 SysLog(NID_CNT, "pAudioContentData->pCopyright = %ls", pAudioContentData->pCopyright->GetPointer());
638 if (pTrackNum.get() != NULL)
640 pAudioContentData->pTrackInfo = new (std::nothrow) String(pTrackNum.get());
641 SysTryReturnResult(NID_CNT, pAudioContentData->pTrackInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
642 SysLog(NID_CNT, "pAudioContentData->pTrackInfo = %ls", pAudioContentData->pTrackInfo->GetPointer());
645 pAudioContentData->duration = duration;
646 SysLog(NID_CNT,"pAudioContentData->duration = %d", pAudioContentData->duration);
651 // fills video contentinfo information in the video content data object.
653 _ContentUtility::FillVideoContentData(media_info_h mediaHandle, VideoContentInfo::_VideoContentData* pVideoContentData)
655 SysTryReturnResult(NID_CNT, mediaHandle != null && pVideoContentData != null, E_INVALID_ARG, "mediaHandle or pVideoContentData is null.");
657 int ret = MEDIA_CONTENT_ERROR_NONE;
658 result r = E_SUCCESS;
661 std::unique_ptr<char, UtilCharDeleter> pArtistName;
662 std::unique_ptr<char, UtilCharDeleter> pGenreName;
663 std::unique_ptr<char, UtilCharDeleter> pTitle;
664 std::unique_ptr<char, UtilCharDeleter> pAlbumName;
667 std::unique_ptr<video_meta_h, VideoMetaHandleDeleter> pVideoHandle(new (std::nothrow) video_meta_h);
668 ret = media_info_get_video(mediaHandle, pVideoHandle.get());
669 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_video operation.");
671 ret = video_meta_get_width(*(pVideoHandle.get()), &width);
672 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_width operation.");
674 ret = video_meta_get_height(*(pVideoHandle.get()), &height);
675 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_height operation.");
677 char* pVideoMetaValue = null;
678 ret = video_meta_get_artist(*(pVideoHandle.get()), &pVideoMetaValue);
679 if (pVideoMetaValue != null)
681 pArtistName.reset(pVideoMetaValue);
685 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_artist operation.");
688 ret = video_meta_get_genre(*(pVideoHandle.get()), &pVideoMetaValue);
689 if (pVideoMetaValue != null)
691 pGenreName.reset(pVideoMetaValue);
695 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_genre operation.");
698 ret = video_meta_get_title(*(pVideoHandle.get()), &pVideoMetaValue);
699 if (pVideoMetaValue != null)
701 pTitle.reset(pVideoMetaValue);
705 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_title operation.");
708 ret = video_meta_get_album(*(pVideoHandle.get()), &pVideoMetaValue);
709 if (pVideoMetaValue != null)
711 pAlbumName.reset(pVideoMetaValue);
715 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_album operation.");
718 ret = video_meta_get_duration(*(pVideoHandle.get()), &duration);
719 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_duration operation.");
721 pVideoContentData->width = width;
722 pVideoContentData->height = height;
724 if (pTitle.get() != NULL)
726 pVideoContentData->pTitle = new (std::nothrow) String(pTitle.get());
727 SysTryReturnResult(NID_CNT, pVideoContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
728 SysLog(NID_CNT, "pVideoContentData->pTitle = %ls", pVideoContentData->pTitle->GetPointer());
731 if (pArtistName.get() != NULL)
733 pVideoContentData->pArtist = new (std::nothrow) String(pArtistName.get());
734 SysTryReturnResult(NID_CNT, pVideoContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
735 SysLog(NID_CNT, "pVideoContentData->pArtist = %ls", pVideoContentData->pArtist->GetPointer());
738 if (pGenreName.get() != NULL)
740 pVideoContentData->pGenre = new (std::nothrow) String(pGenreName.get());
741 SysTryReturnResult(NID_CNT, pVideoContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
742 SysLog(NID_CNT, "pVideoContentData->pGenre = %ls", pVideoContentData->pGenre->GetPointer());
745 if (pAlbumName.get() != NULL)
747 pVideoContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
748 SysTryReturnResult(NID_CNT, pVideoContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
749 SysLog(NID_CNT, "pVideoContentData->pAlbumName = %ls", pVideoContentData->pAlbumName->GetPointer());
752 pVideoContentData->duration = duration;
753 SysLog(NID_CNT,"pVideoContentData->duration = %d", pVideoContentData->duration);
758 // Convertion of system errors to osp errors
760 _ContentUtility::MapCoreErrorToNativeResult(int reason)
762 result r = E_SUCCESS;
765 case MEDIA_CONTENT_ERROR_NONE:
768 case MEDIA_CONTENT_ERROR_DB_BUSY:
770 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
772 case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
774 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_INVALID_PARAMETER");
776 case MEDIA_CONTENT_ERROR_DB_FAILED:
778 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
780 case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:
782 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_OUT_OF_MEMORY");
785 SysLog(NID_CNT, "default");