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;
105 char* pGetMediaValue = null;
106 ret = media_info_get_media_id(mediaHandle, &pGetMediaValue);
107 if (pGetMediaValue != null)
109 pMediaId.reset(pGetMediaValue);
113 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_id operation.");
116 ret = media_info_get_content_name(mediaHandle, &pGetMediaValue);
117 if (pGetMediaValue != null)
119 pContentName.reset(pGetMediaValue);
123 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_content_name operation.");
126 ret = media_info_get_file_path(mediaHandle, &pGetMediaValue);
127 if (pGetMediaValue != null)
129 pMediaPath.reset(pGetMediaValue);
133 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_file_path operation.");
136 ret = media_info_get_thumbnail_path(mediaHandle, &pGetMediaValue);
137 if (pGetMediaValue != null)
139 pThumbnailPath.reset(pGetMediaValue);
143 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_thumbnail_path operation.");
146 ret = media_info_get_author(mediaHandle, &pGetMediaValue);
147 if (pGetMediaValue != null)
149 pAuthor.reset(pGetMediaValue);
153 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_author operation.");
156 ret = media_info_get_category(mediaHandle, &pGetMediaValue);
157 if (pGetMediaValue != null)
159 pCategory.reset(pGetMediaValue);
163 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_category operation.");
166 ret = media_info_get_description(mediaHandle, &pGetMediaValue);
167 if (pGetMediaValue != null)
169 pDescription.reset(pGetMediaValue);
173 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_description operation.");
176 ret = media_info_get_location_tag(mediaHandle, &pGetMediaValue);
177 if (pGetMediaValue != null)
179 pLocationTag.reset(pGetMediaValue);
183 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_location_tag operation.");
186 ret = media_info_get_provider(mediaHandle, &pGetMediaValue);
187 if (pGetMediaValue != null)
189 pProvider.reset(pGetMediaValue);
193 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_provider operation.");
196 ret = media_info_get_size(mediaHandle, &contentSize);
197 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_size operation.");
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.");
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.");
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.");
209 ret = media_info_get_age_rating(mediaHandle, &pGetMediaValue);
210 if (pGetMediaValue != null)
212 pContentRating.reset(pGetMediaValue);
216 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_age_rating operation.");
219 ret = media_info_get_added_time(mediaHandle, &addedTime);
220 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_added_time operation.");
222 ret = media_info_get_storage_type(mediaHandle, &storageType);
223 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_storage_type operation.");
225 ret = media_info_get_media_type(mediaHandle, &mediaType);
226 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_type operation.");
228 ret = media_info_get_mime_type(mediaHandle, &pGetMediaValue);
229 if (pGetMediaValue != null)
231 pMimeType.reset(pGetMediaValue);
235 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_mime_type operation.");
238 ret = media_info_get_keyword(mediaHandle, &pGetMediaValue);
239 if (pGetMediaValue != null)
241 pKeyword.reset(pGetMediaValue);
245 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_keyword operation.");
248 if (pMediaId.get() != null)
250 r = UuId::Parse(String(pMediaId.get()), pContentData->contentId);
251 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform UuId::Parse operation.");
254 pContentData->contentSize = contentSize;
255 SysLog(NID_CNT, "pContentData->contentSize = %lu", pContentData->contentSize);
257 if (Double::Compare(latitude, DEFAULT_COORDINATE) != 0)
259 pContentData->latitude = latitude;
261 if (Double::Compare(longitude, DEFAULT_COORDINATE) != 0)
263 pContentData->longitude = longitude;
265 if (Double::Compare(altitude, DEFAULT_COORDINATE) != 0)
267 pContentData->altitude = altitude;
270 if (pMediaPath.get() != NULL)
272 pContentData->contentPath = String(pMediaPath.get());
273 SysLog(NID_CNT, "pContentData->contentPath = %ls", pContentData->contentPath.GetPointer());
276 if (pThumbnailPath.get() != NULL)
278 pContentData->pThumbnailPath = new (std::nothrow) String(pThumbnailPath.get());
279 SysTryReturnResult(NID_CNT, pContentData->pThumbnailPath != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
280 SysLog(NID_CNT, "pContentData->pThumbnailPath = %ls", pContentData->pThumbnailPath->GetPointer());
283 if (pAuthor.get() != NULL)
285 pContentData->pAuthor = new (std::nothrow) String(pAuthor.get());
286 SysTryReturnResult(NID_CNT, pContentData->pAuthor != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
287 SysLog(NID_CNT, "pContentData->pAuthor = %ls", pContentData->pAuthor->GetPointer());
290 if (pCategory.get() != NULL)
292 pContentData->pCategory = new (std::nothrow) String(pCategory.get());
293 SysTryReturnResult(NID_CNT, pContentData->pCategory != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
294 SysLog(NID_CNT, "pContentData->pCategory = %ls", pContentData->pCategory->GetPointer());
297 if (pContentName.get() != NULL)
299 pContentData->pContentName = new (std::nothrow) String(pContentName.get());
300 SysTryReturnResult(NID_CNT, pContentData->pContentName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
301 SysLog(NID_CNT, "pContentData->pContentName = %ls", pContentData->pContentName->GetPointer());
304 if (pDescription.get() != NULL)
306 pContentData->pDescription = new (std::nothrow) String(pDescription.get());
307 SysTryReturnResult(NID_CNT, pContentData->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
308 SysLog(NID_CNT, "pContentData->pDescription = %ls", pContentData->pDescription->GetPointer());
311 if (pLocationTag.get() != NULL)
313 pContentData->pLocationTag = new (std::nothrow) String(pLocationTag.get());
314 SysTryReturnResult(NID_CNT, pContentData->pLocationTag != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
315 SysLog(NID_CNT, "pContentData->pLocationTag = %ls", pContentData->pLocationTag->GetPointer());
318 if (pProvider.get() != NULL)
320 pContentData->pProvider = new (std::nothrow) String(pProvider.get());
321 SysTryReturnResult(NID_CNT, pContentData->pProvider != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
322 SysLog(NID_CNT, "pContentData->pProvider = %ls", pContentData->pProvider->GetPointer());
325 if (pContentRating.get() != NULL)
327 pContentData->pRating = new (std::nothrow) String(pContentRating.get());
328 SysTryReturnResult(NID_CNT, pContentData->pRating != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
329 SysLog(NID_CNT, "pContentData->pRating = %ls", pContentData->pRating->GetPointer());
332 if (pKeyword.get() != NULL)
334 pContentData->pKeyword = new (std::nothrow) String(pKeyword.get());
335 SysTryReturnResult(NID_CNT, pContentData->pKeyword != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
336 SysLog(NID_CNT, "pContentData->pKeyword = %ls", pContentData->pKeyword->GetPointer());
339 if (pMimeType.get() != NULL)
341 pContentData->mimeType = String(pMimeType.get());
342 SysLog(NID_CNT, "pContentData->mimeType = %ls", (pContentData->mimeType).GetPointer());
347 case MEDIA_CONTENT_STORAGE_INTERNAL:
348 pContentData->storageType = 0;
350 case MEDIA_CONTENT_STORAGE_EXTERNAL:
351 pContentData->storageType = 1;
358 case MEDIA_CONTENT_TYPE_OTHERS:
359 pContentData->contentType = CONTENT_TYPE_OTHER;
361 case MEDIA_CONTENT_TYPE_IMAGE:
362 pContentData->contentType = CONTENT_TYPE_IMAGE;
364 case MEDIA_CONTENT_TYPE_SOUND:
366 case MEDIA_CONTENT_TYPE_MUSIC:
367 pContentData->contentType = CONTENT_TYPE_AUDIO;
369 case MEDIA_CONTENT_TYPE_VIDEO:
370 pContentData->contentType = CONTENT_TYPE_VIDEO;
376 r = (pContentData->dateTime).SetValue(1970, 1, 1);
377 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.SetValue operation.");
379 r = (pContentData->dateTime).AddSeconds(addedTime);// need to check addedTime is secs/millisec
380 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.AddSeconds operation.");
382 SysLog(NID_CNT, "addedTime = %ld", addedTime);
383 SysLog(NID_CNT, "pContentData->dateTime : %ls", pContentData->dateTime.ToString().GetPointer());
388 // fills Imagecontentinfo information in the image content data object .
390 _ContentUtility::FillImageContentData(media_info_h mediaHandle, ImageContentInfo::_ImageContentData* pImageContentData)
392 SysTryReturnResult(NID_CNT, mediaHandle != null && pImageContentData != null, E_INVALID_ARG, "mediaHandle or pImageContentData is null.");
394 int ret = MEDIA_CONTENT_ERROR_NONE;
395 result r = E_SUCCESS;
398 media_content_orientation_e orientation;
399 std::unique_ptr<char, UtilCharDeleter> pDisplayName;
401 char* pDisplayValue = null;
402 ret = media_info_get_display_name(mediaHandle, &pDisplayValue);
403 if (pDisplayValue != null)
405 pDisplayName.reset(pDisplayValue);
409 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_display_name operation.");
412 std::unique_ptr<image_meta_h, ImageMetaHandleDeleter> pImageHandle(new (std::nothrow) image_meta_h);
413 ret = media_info_get_image(mediaHandle, pImageHandle.get());
415 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_image operation.");
418 ret = image_meta_get_width(*(pImageHandle.get()), &width);
419 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_width operation.");
421 ret = image_meta_get_orientation(*(pImageHandle.get()), &orientation);
422 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_orientation operation.");
424 ret = image_meta_get_height(*(pImageHandle.get()), &height);
425 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_height operation.");
427 pImageContentData->width = width;
428 pImageContentData->height = height;
429 pImageContentData->orientationType = static_cast<ImageOrientationType>(orientation);
431 if (pDisplayName != NULL)
434 String fileName = L"";
435 String strTitle(pDisplayName.get());
437 r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
440 r = strTitle.SubString(0, pos, fileName);
441 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform string.SubString operation.");
449 pImageContentData->title = fileName;
450 SysLog(NID_CNT, "pImageContentData->title = %ls", pImageContentData->title.GetPointer());
456 // fills audio contentinfo information in the audio content data object.
458 _ContentUtility::FillAudioContentData(media_info_h mediaHandle, AudioContentInfo::_AudioContentData* pAudioContentData)
460 SysTryReturnResult(NID_CNT, mediaHandle != null && pAudioContentData != null, E_INVALID_ARG, "mediaHandle or pAudioContentData is null.");
462 int ret = MEDIA_CONTENT_ERROR_NONE;
463 result r = E_SUCCESS;
467 std::unique_ptr<char, UtilCharDeleter> pTitle;
468 std::unique_ptr<char, UtilCharDeleter> pAlbumName;
469 std::unique_ptr<char, UtilCharDeleter> pArtistName;
470 std::unique_ptr<char, UtilCharDeleter> pGenreName;
471 std::unique_ptr<char, UtilCharDeleter> pComposerName;
472 std::unique_ptr<char, UtilCharDeleter> pYear;
473 std::unique_ptr<char, UtilCharDeleter> pCopyRight;
474 std::unique_ptr<char, UtilCharDeleter> pTrackNum;
477 std::unique_ptr<audio_meta_h, AudioMetaHandleDeleter> pAudioHandle(new (std::nothrow) audio_meta_h);
478 ret = media_info_get_audio(mediaHandle, pAudioHandle.get());
479 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_audio operation.");
481 ret = audio_meta_get_bit_rate(*(pAudioHandle.get()), &bitrate);
482 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_bit_rate operation.");
484 char* pAudioMetaValue = null;
485 ret = audio_meta_get_title(*(pAudioHandle.get()), &pAudioMetaValue);
486 if (pAudioMetaValue != null)
488 pTitle.reset(pAudioMetaValue);
492 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_title operation.");
495 ret = audio_meta_get_album(*(pAudioHandle.get()), &pAudioMetaValue);
496 if (pAudioMetaValue != null)
498 pAlbumName.reset(pAudioMetaValue);
502 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_album operation.");
505 ret = audio_meta_get_artist(*(pAudioHandle.get()), &pAudioMetaValue);
506 if (pAudioMetaValue != null)
508 pArtistName.reset(pAudioMetaValue);
512 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_artist operation.");
515 ret = audio_meta_get_genre(*(pAudioHandle.get()), &pAudioMetaValue);
516 if (pAudioMetaValue != null)
518 pGenreName.reset(pAudioMetaValue);
522 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_genre operation.");
525 ret = audio_meta_get_composer(*(pAudioHandle.get()), &pAudioMetaValue);
526 if (pAudioMetaValue != null)
528 pComposerName.reset(pAudioMetaValue);
532 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_composer operation.");
535 ret = audio_meta_get_year(*(pAudioHandle.get()), &pAudioMetaValue);
536 if (pAudioMetaValue != null)
538 pYear.reset(pAudioMetaValue);
542 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_year operation.");
545 ret = audio_meta_get_copyright(*(pAudioHandle.get()), &pAudioMetaValue);
546 if (pAudioMetaValue != null)
548 pCopyRight.reset(pAudioMetaValue);
552 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_copyright operation.");
555 ret = audio_meta_get_track_num(*(pAudioHandle.get()), &pAudioMetaValue);
556 if (pAudioMetaValue != null)
558 pTrackNum.reset(pAudioMetaValue);
562 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_track_num operation.");
565 ret = audio_meta_get_duration(*(pAudioHandle.get()), &duration);
566 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_duration operation.");
568 pAudioContentData->bitrate = bitrate;
570 if (pYear.get() != null)
572 SysLog(NID_CNT, "pAudioContentData->pYear = %s", pYear.get());
574 String strYear(pYear.get());
575 if (strYear.CompareTo(L"Unknown") != 0)
577 r = Integer::Parse(strYear, pAudioContentData->releaseYear);
580 // It is one of the metadata. If error occurs, skip it for other metadata.
581 pAudioContentData->releaseYear = 0;
583 SysLog(NID_CNT, "pAudioContentData->pYear(invalid data) = %ls", strYear.GetPointer());
588 if (pTitle.get() != NULL)
590 pAudioContentData->pTitle = new (std::nothrow) String(pTitle.get());
591 SysTryReturnResult(NID_CNT, pAudioContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
592 SysLog(NID_CNT, "pAudioContentData->pTitle = %ls", pAudioContentData->pTitle->GetPointer());
595 if (pArtistName.get() != NULL)
597 pAudioContentData->pArtist = new (std::nothrow) String(pArtistName.get());
598 SysTryReturnResult(NID_CNT, pAudioContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
599 SysLog(NID_CNT, "pAudioContentData->pArtist = %ls", pAudioContentData->pArtist->GetPointer());
602 if (pGenreName.get() != NULL)
604 pAudioContentData->pGenre = new (std::nothrow) String(pGenreName.get());
605 SysTryReturnResult(NID_CNT, pAudioContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
606 SysLog(NID_CNT, "pAudioContentData->pGenre = %ls", pAudioContentData->pGenre->GetPointer());
609 if (pComposerName.get() != NULL)
611 pAudioContentData->pComposer = new (std::nothrow) String(pComposerName.get());
612 SysTryReturnResult(NID_CNT, pAudioContentData->pComposer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
613 SysLog(NID_CNT, "pAudioContentData->pComposer = %ls", pAudioContentData->pComposer->GetPointer());
616 if (pAlbumName.get() != NULL)
618 pAudioContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
619 SysTryReturnResult(NID_CNT, pAudioContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
620 SysLog(NID_CNT, "pAudioContentData->pAlbumName = %ls", pAudioContentData->pAlbumName->GetPointer());
623 if (pCopyRight.get() != NULL)
625 pAudioContentData->pCopyright = new (std::nothrow) String(pCopyRight.get());
626 SysTryReturnResult(NID_CNT, pAudioContentData->pCopyright != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
627 SysLog(NID_CNT, "pAudioContentData->pCopyright = %ls", pAudioContentData->pCopyright->GetPointer());
630 if (pTrackNum.get() != NULL)
632 pAudioContentData->pTrackInfo = new (std::nothrow) String(pTrackNum.get());
633 SysTryReturnResult(NID_CNT, pAudioContentData->pTrackInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
634 SysLog(NID_CNT, "pAudioContentData->pTrackInfo = %ls", pAudioContentData->pTrackInfo->GetPointer());
637 pAudioContentData->duration = duration;
638 SysLog(NID_CNT,"pAudioContentData->duration = %d", pAudioContentData->duration);
643 // fills video contentinfo information in the video content data object.
645 _ContentUtility::FillVideoContentData(media_info_h mediaHandle, VideoContentInfo::_VideoContentData* pVideoContentData)
647 SysTryReturnResult(NID_CNT, mediaHandle != null && pVideoContentData != null, E_INVALID_ARG, "mediaHandle or pVideoContentData is null.");
649 int ret = MEDIA_CONTENT_ERROR_NONE;
650 result r = E_SUCCESS;
653 std::unique_ptr<char, UtilCharDeleter> pArtistName;
654 std::unique_ptr<char, UtilCharDeleter> pGenreName;
655 std::unique_ptr<char, UtilCharDeleter> pTitle;
656 std::unique_ptr<char, UtilCharDeleter> pAlbumName;
659 std::unique_ptr<video_meta_h, VideoMetaHandleDeleter> pVideoHandle(new (std::nothrow) video_meta_h);
660 ret = media_info_get_video(mediaHandle, pVideoHandle.get());
661 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_video operation.");
663 ret = video_meta_get_width(*(pVideoHandle.get()), &width);
664 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_width operation.");
666 ret = video_meta_get_height(*(pVideoHandle.get()), &height);
667 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_height operation.");
669 char* pVideoMetaValue = null;
670 ret = video_meta_get_artist(*(pVideoHandle.get()), &pVideoMetaValue);
671 if (pVideoMetaValue != null)
673 pArtistName.reset(pVideoMetaValue);
677 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_artist operation.");
680 ret = video_meta_get_genre(*(pVideoHandle.get()), &pVideoMetaValue);
681 if (pVideoMetaValue != null)
683 pGenreName.reset(pVideoMetaValue);
687 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_genre operation.");
690 ret = video_meta_get_title(*(pVideoHandle.get()), &pVideoMetaValue);
691 if (pVideoMetaValue != null)
693 pTitle.reset(pVideoMetaValue);
697 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_title operation.");
700 ret = video_meta_get_album(*(pVideoHandle.get()), &pVideoMetaValue);
701 if (pVideoMetaValue != null)
703 pAlbumName.reset(pVideoMetaValue);
707 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_album operation.");
710 ret = video_meta_get_duration(*(pVideoHandle.get()), &duration);
711 SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_duration operation.");
713 pVideoContentData->width = width;
714 pVideoContentData->height = height;
716 if (pTitle.get() != NULL)
718 pVideoContentData->pTitle = new (std::nothrow) String(pTitle.get());
719 SysTryReturnResult(NID_CNT, pVideoContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
720 SysLog(NID_CNT, "pVideoContentData->pTitle = %ls", pVideoContentData->pTitle->GetPointer());
723 if (pArtistName.get() != NULL)
725 pVideoContentData->pArtist = new (std::nothrow) String(pArtistName.get());
726 SysTryReturnResult(NID_CNT, pVideoContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
727 SysLog(NID_CNT, "pVideoContentData->pArtist = %ls", pVideoContentData->pArtist->GetPointer());
730 if (pGenreName.get() != NULL)
732 pVideoContentData->pGenre = new (std::nothrow) String(pGenreName.get());
733 SysTryReturnResult(NID_CNT, pVideoContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
734 SysLog(NID_CNT, "pVideoContentData->pGenre = %ls", pVideoContentData->pGenre->GetPointer());
737 if (pAlbumName.get() != NULL)
739 pVideoContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
740 SysTryReturnResult(NID_CNT, pVideoContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
741 SysLog(NID_CNT, "pVideoContentData->pAlbumName = %ls", pVideoContentData->pAlbumName->GetPointer());
744 pVideoContentData->duration = duration;
745 SysLog(NID_CNT,"pVideoContentData->duration = %d", pVideoContentData->duration);
750 // Convertion of system errors to osp errors
752 _ContentUtility::MapCoreErrorToNativeResult(int reason)
754 result r = E_SUCCESS;
757 case MEDIA_CONTENT_ERROR_NONE:
760 case MEDIA_CONTENT_ERROR_DB_BUSY:
762 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
764 case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
766 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_INVALID_PARAMETER");
768 case MEDIA_CONTENT_ERROR_DB_FAILED:
770 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
772 case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:
774 SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_OUT_OF_MEMORY");
777 SysLog(NID_CNT, "default");