#include <unique_ptr.h>
#include <FBaseSysLog.h>
+#include <FBaseDateTime.h>
#include <FBaseInteger.h>
#include <FBaseLongLong.h>
#include <FBaseFloat.h>
-#include <FCnt_ContentUtility.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FCntContentManagerUtil.h>
+#include <FCntVideoMetadata.h>
+#include "FCnt_ContentUtility.h"
+#include "FCnt_ContentInfoImpl.h"
+#include "FCnt_ImageContentInfoImpl.h"
+#include "FCnt_AudioContentInfoImpl.h"
+#include "FCnt_VideoContentInfoImpl.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Locations;
namespace Tizen { namespace Content
{
// Default constructor
_ContentUtility::_ContentUtility(void)
- : Object()
{
- SysLog(NID_CNT, "Enter\n");
+
}
// Default destructor
_ContentUtility::~_ContentUtility(void)
{
- SysLog(NID_CNT, "Enter\n");
+
}
void
if (pSrc != NULL)
{
free(pSrc);
- pSrc = NULL;
}
}
-void
-_ContentUtility::DoSafeDelete(String* pSrc)
-{
- if (pSrc != NULL)
- {
- delete pSrc;
- pSrc = NULL;
- }
-}
-
-// fills contentinfo information in the content data object.
+// Fills ContentInfo information in the content data object.
result
-_ContentUtility::FillContentData(media_info_h mediaHandle, ContentInfo::_ContentData* pContentData)
+_ContentUtility::FillContentData(media_info_h mediaHandle, _ContentInfoImpl* pInfoImpl)
{
-
- SysTryReturnResult(NID_CNT, mediaHandle != null && pContentData != null, E_INVALID_ARG, "mediaHandle or pContentData is null.");
+ SysTryReturnResult(NID_CNT, mediaHandle != null && pInfoImpl != null, E_INVALID_ARG, "mediaHandle or pInfoImpl is null.");
int ret = MEDIA_CONTENT_ERROR_NONE;
result r = E_SUCCESS;
unsigned long long contentSize = 0;
time_t addedTime = 0;
+ time_t modifiedTime = 0;
double latitude = 0;
double longitude = 0;
double altitude = 0;
+ Coordinates coordinates;
bool isDrm = 0;
ret = media_info_get_added_time(mediaHandle, &addedTime);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_added_time operation.");
+ ret = media_info_get_modified_time(mediaHandle, &modifiedTime);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_modified_time operation.");
+
ret = media_info_get_storage_type(mediaHandle, &storageType);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_storage_type operation.");
if (pMediaId.get() != null)
{
- r = UuId::Parse(String(pMediaId.get()), pContentData->contentId);
+ ContentId contentId;
+
+ r = UuId::Parse(String(pMediaId.get()), contentId);
SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform UuId::Parse operation.");
+
+ pInfoImpl->SetContentId(contentId);
}
- pContentData->isDrm = isDrm;
- SysLog(NID_CNT, "pContentData->isDrm = %d", pContentData->isDrm);
+ pInfoImpl->SetDrmProtected(isDrm);
+ SysLog(NID_CNT, "pContentInfoImpl->isDrm = %d", pInfoImpl->IsDrmProtected());
- pContentData->contentSize = contentSize;
- SysLog(NID_CNT, "pContentData->contentSize = %lu", pContentData->contentSize);
+ pInfoImpl->SetContentSize(contentSize);
+ SysLog(NID_CNT, "pContentInfoImpl->contentSize = %lu", pInfoImpl->GetContentSize());
if (Double::Compare(latitude, DEFAULT_COORDINATE) != 0)
{
- pContentData->latitude = latitude;
+ pInfoImpl->SetLatitude(latitude);
+ coordinates.SetLatitude(latitude);
}
if (Double::Compare(longitude, DEFAULT_COORDINATE) != 0)
{
- pContentData->longitude = longitude;
+ pInfoImpl->SetLongitude(longitude);
+ coordinates.SetLongitude(longitude);
}
if (Double::Compare(altitude, DEFAULT_COORDINATE) != 0)
{
- pContentData->altitude = altitude;
+ pInfoImpl->SetAltitude(altitude);
+ coordinates.SetAltitude(altitude);
}
+ pInfoImpl->SetCoordinates(coordinates);
+
if (pMediaPath.get() != NULL)
{
- pContentData->contentPath = String(pMediaPath.get());
- SysSecureLog(NID_CNT, "pContentData->contentPath = %ls", pContentData->contentPath.GetPointer());
+ String contentPath(pMediaPath.get());
+
+ pInfoImpl->SetContentPath(contentPath);
+ SysSecureLog(NID_CNT, "pContentInfoImpl->contentPath = %ls", (pInfoImpl->GetContentPath()).GetPointer());
}
if (pThumbnailPath.get() != NULL)
{
- pContentData->pThumbnailPath = new (std::nothrow) String(pThumbnailPath.get());
- SysTryReturnResult(NID_CNT, pContentData->pThumbnailPath != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysSecureLog(NID_CNT, "pContentData->pThumbnailPath = %ls", pContentData->pThumbnailPath->GetPointer());
+ String thumbnailPath(pThumbnailPath.get());
+
+ pInfoImpl->SetThumbnailPath(thumbnailPath);
+ SysSecureLog(NID_CNT, "pContentInfoImpl->pThumbnailPath = %ls", (pInfoImpl->GetThumbnailPath()).GetPointer());
}
if (pAuthor.get() != NULL)
{
- pContentData->pAuthor = new (std::nothrow) String(pAuthor.get());
- SysTryReturnResult(NID_CNT, pContentData->pAuthor != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pContentData->pAuthor = %ls", pContentData->pAuthor->GetPointer());
+ String author(pAuthor.get());
+
+ pInfoImpl->SetAuthor(author);
+ SysLog(NID_CNT, "pContentInfoImpl->pAuthor = %ls", (pInfoImpl->GetAuthor()).GetPointer());
}
if (pCategory.get() != NULL)
{
- pContentData->pCategory = new (std::nothrow) String(pCategory.get());
- SysTryReturnResult(NID_CNT, pContentData->pCategory != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pContentData->pCategory = %ls", pContentData->pCategory->GetPointer());
+ String category(pCategory.get());
+
+ pInfoImpl->SetCategory(category);
+ SysLog(NID_CNT, "pContentInfoImpl->pCategory = %ls", (pInfoImpl->GetCategory()).GetPointer());
}
if (pContentName.get() != NULL)
{
- pContentData->pContentName = new (std::nothrow) String(pContentName.get());
- SysTryReturnResult(NID_CNT, pContentData->pContentName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pContentData->pContentName = %ls", pContentData->pContentName->GetPointer());
+ String contentName(pContentName.get());
+
+ pInfoImpl->SetContentName(contentName);
+ SysLog(NID_CNT, "pContentInfoImpl->pContentName = %ls", (pInfoImpl->GetContentName()).GetPointer());
}
if (pDescription.get() != NULL)
{
- pContentData->pDescription = new (std::nothrow) String(pDescription.get());
- SysTryReturnResult(NID_CNT, pContentData->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pContentData->pDescription = %ls", pContentData->pDescription->GetPointer());
+ String description(pDescription.get());
+
+ pInfoImpl->SetDescription(description);
+ SysLog(NID_CNT, "pContentInfoImpl->pDescription = %ls", (pInfoImpl->GetDescription()).GetPointer());
}
if (pLocationTag.get() != NULL)
{
- pContentData->pLocationTag = new (std::nothrow) String(pLocationTag.get());
- SysTryReturnResult(NID_CNT, pContentData->pLocationTag != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pContentData->pLocationTag = %ls", pContentData->pLocationTag->GetPointer());
+ String locationTag(pLocationTag.get());
+
+ pInfoImpl->SetLocationTag(locationTag);
+ SysLog(NID_CNT, "pContentInfoImpl->pLocationTag = %ls", (pInfoImpl->GetLocationTag()).GetPointer());
}
if (pProvider.get() != NULL)
{
- pContentData->pProvider = new (std::nothrow) String(pProvider.get());
- SysTryReturnResult(NID_CNT, pContentData->pProvider != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pContentData->pProvider = %ls", pContentData->pProvider->GetPointer());
+ String provider(pProvider.get());
+
+ pInfoImpl->SetProvider(provider);
+ SysLog(NID_CNT, "pContentInfoImpl->pProvider = %ls", (pInfoImpl->GetProvider()).GetPointer());
}
if (pContentRating.get() != NULL)
{
- pContentData->pRating = new (std::nothrow) String(pContentRating.get());
- SysTryReturnResult(NID_CNT, pContentData->pRating != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pContentData->pRating = %ls", pContentData->pRating->GetPointer());
+ String rating(pContentRating.get());
+
+ pInfoImpl->SetRating(rating);
+ SysLog(NID_CNT, "pContentInfoImpl->pRating = %ls", (pInfoImpl->GetRating()).GetPointer());
}
if (pKeyword.get() != NULL)
{
- pContentData->pKeyword = new (std::nothrow) String(pKeyword.get());
- SysTryReturnResult(NID_CNT, pContentData->pKeyword != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pContentData->pKeyword = %ls", pContentData->pKeyword->GetPointer());
+ String keyword(pKeyword.get());
+
+ pInfoImpl->SetKeyword(keyword);
+ SysLog(NID_CNT, "pContentInfoImpl->pKeyword = %ls", (pInfoImpl->GetKeyword()).GetPointer());
}
if (pMimeType.get() != NULL)
{
- pContentData->mimeType = String(pMimeType.get());
- SysLog(NID_CNT, "pContentData->mimeType = %ls", (pContentData->mimeType).GetPointer());
+ String mimeType(pMimeType.get());
+
+ pInfoImpl->SetMimeType(mimeType);
+ SysLog(NID_CNT, "pContentInfoImpl->mimeType = %ls", (pInfoImpl->GetMimeType()).GetPointer());
}
switch (storageType)
{
case MEDIA_CONTENT_STORAGE_INTERNAL:
- pContentData->storageType = 0;
+ pInfoImpl->SetStorageType(0);
break;
case MEDIA_CONTENT_STORAGE_EXTERNAL:
- pContentData->storageType = 1;
+ pInfoImpl->SetStorageType(1);
break;
default:
break;
switch (mediaType)
{
case MEDIA_CONTENT_TYPE_OTHERS:
- pContentData->contentType = CONTENT_TYPE_OTHER;
+ pInfoImpl->SetContentType(CONTENT_TYPE_OTHER);
break;
case MEDIA_CONTENT_TYPE_IMAGE:
- pContentData->contentType = CONTENT_TYPE_IMAGE;
+ pInfoImpl->SetContentType(CONTENT_TYPE_IMAGE);
break;
case MEDIA_CONTENT_TYPE_SOUND:
//fall through
case MEDIA_CONTENT_TYPE_MUSIC:
- pContentData->contentType = CONTENT_TYPE_AUDIO;
+ pInfoImpl->SetContentType(CONTENT_TYPE_AUDIO);
break;
case MEDIA_CONTENT_TYPE_VIDEO:
- pContentData->contentType = CONTENT_TYPE_VIDEO;
+ pInfoImpl->SetContentType(CONTENT_TYPE_VIDEO);
break;
default:
break;
}
- r = (pContentData->dateTime).SetValue(1970, 1, 1);
+ // addedTime
+ DateTime dt;
+
+ r = dt.SetValue(1970, 1, 1);
SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.SetValue operation.");
- r = (pContentData->dateTime).AddSeconds(addedTime);// need to check addedTime is secs/millisec
+ r = dt.AddSeconds(addedTime);// need to check addedTime is secs/millisec
SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.AddSeconds operation.");
+ pInfoImpl->SetDateTime(dt);
+
SysLog(NID_CNT, "addedTime = %ld", addedTime);
- SysLog(NID_CNT, "pContentData->dateTime : %ls", pContentData->dateTime.ToString().GetPointer());
+ SysLog(NID_CNT, "pContentInfoImpl->dateTime : %ls", (pInfoImpl->GetDateTime()).ToString().GetPointer());
+
+ // modifiedTime
+ r = dt.SetValue(1970, 1, 1);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.SetValue operation.");
+
+ r = dt.AddSeconds(modifiedTime);// need to check addedTime is secs/millisec
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.AddSeconds operation.");
+
+ pInfoImpl->SetModifiedTime(dt);
+
+ SysLog(NID_CNT, "modifiedTime = %ld", modifiedTime);
+ SysLog(NID_CNT, "pContentInfoImpl->modifiedTime : %ls", (pInfoImpl->GetModifiedTime()).ToString().GetPointer());
return r;
}
-// fills Imagecontentinfo information in the image content data object .
+// Fills ImageContentInfo information in the image content data object .
result
-_ContentUtility::FillImageContentData(media_info_h mediaHandle, ImageContentInfo::_ImageContentData* pImageContentData)
+_ContentUtility::FillImageContentData(media_info_h mediaHandle, _ImageContentInfoImpl* pImageContentInfoImpl)
{
- SysTryReturnResult(NID_CNT, mediaHandle != null && pImageContentData != null, E_INVALID_ARG, "mediaHandle or pImageContentData is null.");
+ SysTryReturnResult(NID_CNT, mediaHandle != null && pImageContentInfoImpl != null, E_INVALID_ARG, "mediaHandle or pImageContentInfoImpl is null.");
int ret = MEDIA_CONTENT_ERROR_NONE;
result r = E_SUCCESS;
int width = 0;
int height = 0;
+ bool isBurst = false;
media_content_orientation_e orientation;
- std::unique_ptr<char, UtilCharDeleter> pDisplayName;
+ std::unique_ptr<char, UtilCharDeleter> pStrValue;
- char* pDisplayValue = null;
- ret = media_info_get_display_name(mediaHandle, &pDisplayValue);
- if (pDisplayValue != null)
- {
- pDisplayName.reset(pDisplayValue);
- }
- else
- {
- SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_display_name operation.");
- }
-
- std::unique_ptr<image_meta_h, ImageMetaHandleDeleter> pImageHandle(new (std::nothrow) image_meta_h);
- ret = media_info_get_image(mediaHandle, pImageHandle.get());
+ image_meta_h tempMeta = NULL;
+ ret = media_info_get_image(mediaHandle, &tempMeta);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_image operation.");
-
- ret = image_meta_get_width(*(pImageHandle.get()), &width);
+ std::unique_ptr<image_meta_s, ImageMetaHandleDeleter> pImageHandle(tempMeta);
+ SysTryReturnResult(NID_CNT, pImageHandle != null, E_OUT_OF_MEMORY, "pImageHandle is null.");
+
+ ret = image_meta_get_width(pImageHandle.get(), &width);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_width operation.");
- ret = image_meta_get_orientation(*(pImageHandle.get()), &orientation);
+ ret = image_meta_get_orientation(pImageHandle.get(), &orientation);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_orientation operation.");
- ret = image_meta_get_height(*(pImageHandle.get()), &height);
+ ret = image_meta_get_height(pImageHandle.get(), &height);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_height operation.");
- pImageContentData->width = width;
- pImageContentData->height = height;
- pImageContentData->orientationType = static_cast<ImageOrientationType>(orientation);
+ ret = image_meta_is_burst_shot(pImageHandle.get(), &isBurst);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_is_burst_shot operation.");
+
+ pImageContentInfoImpl->SetWidth(width);
+ pImageContentInfoImpl->SetHeight(height);
+ pImageContentInfoImpl->SetOrientation(static_cast< ImageOrientationType >(orientation));
+ pImageContentInfoImpl->SetBurstShot(isBurst);
- if (pDisplayName != NULL)
+ // title
+ char* pTempValue = null;
+ ret = media_info_get_display_name(mediaHandle, &pTempValue);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_display_name operation.");
+
+ if (pTempValue != NULL)
{
+ pStrValue.reset(pTempValue);
+
int pos = 0;
String fileName = L"";
- String strTitle(pDisplayName.get());
+ String strTitle(pStrValue.get());
r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
if (r == E_SUCCESS)
r = E_SUCCESS;
fileName = strTitle;
}
- pImageContentData->title = fileName;
- SysLog(NID_CNT, "pImageContentData->title = %ls", pImageContentData->title.GetPointer());
+ pImageContentInfoImpl->SetTitle(fileName);
+ SysLog(NID_CNT, "pImageContentInfoImpl->title = %ls", (pImageContentInfoImpl->GetTitle()).GetPointer());
+ }
+
+ // dateTaken
+ ret = image_meta_get_date_taken(pImageHandle.get(), &pTempValue);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret),
+ "Failed to perform image_meta_get_date_taken operation.");
+
+ DateTime dt;
+
+ if (pTempValue != NULL)
+ {
+ pStrValue.reset(pTempValue);
+ String dateTaken(pStrValue.get());
+ String newDateTaken(L"");
+
+ // detour the unexpected datetaken format
+ String tempDelim(L"+-Z");
+ String token;
+
+ StringTokenizer tempStrTok(dateTaken, tempDelim);
+
+ r = tempStrTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
+
+ dateTaken = token;
+
+ String delim(L": ");
+ String year(L"");
+
+ StringTokenizer strTok(dateTaken, delim);
+
+ r = strTok.SetDelimiters(delim);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation.");
+
+ r = strTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
+
+ year = token;
+
+ // Append month
+ r = strTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
+
+ r = newDateTaken.Append(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
+
+ r = newDateTaken.Append(L"/");
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
+
+ // Append day
+ r = strTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
+
+ r = newDateTaken.Append(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
+
+ r = newDateTaken.Append(L"/");
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
+
+ // Append year
+ r = newDateTaken.Append(year);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
+
+ r = newDateTaken.Append(L" ");
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
+
+ String newDelim(L" ");
+
+ r = strTok.SetDelimiters(newDelim);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation.");
+
+ r = strTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
+
+ r = newDateTaken.Append(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
+
+ r = DateTime::Parse(newDateTaken, dt);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime.");
+ }
+ else
+ {
+ dt = DateTime::GetMinValue();
+ }
+
+ pImageContentInfoImpl->SetImageTakenDate(dt);
+ SysLog(NID_CNT, "pImageContentInfoImpl->takenDate = %ls", dt.ToString().GetPointer());
+
+ // burstShotId
+ ret = image_meta_get_burst_id(pImageHandle.get(), &pTempValue);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret),
+ "Failed to perform image_meta_get_burst_id operation.");
+
+ if (pTempValue != NULL)
+ {
+ pStrValue.reset(pTempValue);
+ String burstShotId(pStrValue.get());
+
+ pImageContentInfoImpl->SetBurstShotId(burstShotId);
+ SysLog(NID_CNT, "pImageContentInfoImpl->burstShotId = %ls", burstShotId.GetPointer());
}
return r;
}
-// fills audio contentinfo information in the audio content data object.
+// Fills AudioContentInfo information in the audio content data object.
result
-_ContentUtility::FillAudioContentData(media_info_h mediaHandle, AudioContentInfo::_AudioContentData* pAudioContentData)
+_ContentUtility::FillAudioContentData(media_info_h mediaHandle, _AudioContentInfoImpl* pAudioContentInfoImpl)
{
- SysTryReturnResult(NID_CNT, mediaHandle != null && pAudioContentData != null, E_INVALID_ARG, "mediaHandle or pAudioContentData is null.");
+ SysTryReturnResult(NID_CNT, mediaHandle != null && pAudioContentInfoImpl != null, E_INVALID_ARG, "mediaHandle or pAudioContentInfoImpl is null.");
int ret = MEDIA_CONTENT_ERROR_NONE;
result r = E_SUCCESS;
std::unique_ptr<char, UtilCharDeleter> pCopyRight;
std::unique_ptr<char, UtilCharDeleter> pTrackNum;
+ audio_meta_h tempMeta = NULL;
- std::unique_ptr<audio_meta_h, AudioMetaHandleDeleter> pAudioHandle(new (std::nothrow) audio_meta_h);
- ret = media_info_get_audio(mediaHandle, pAudioHandle.get());
+ ret = media_info_get_audio(mediaHandle, &tempMeta);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_audio operation.");
- ret = audio_meta_get_bit_rate(*(pAudioHandle.get()), &bitrate);
+ std::unique_ptr<audio_meta_s, AudioMetaHandleDeleter> pAudioHandle(tempMeta);
+ SysTryReturnResult(NID_CNT, pAudioHandle != null, E_OUT_OF_MEMORY, "pAudioHandle is null.");
+
+ ret = audio_meta_get_bit_rate(pAudioHandle.get(), &bitrate);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_bit_rate operation.");
char* pAudioMetaValue = null;
- ret = audio_meta_get_title(*(pAudioHandle.get()), &pAudioMetaValue);
+ ret = audio_meta_get_title(pAudioHandle.get(), &pAudioMetaValue);
if (pAudioMetaValue != null)
{
pTitle.reset(pAudioMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_title operation.");
}
- ret = audio_meta_get_album(*(pAudioHandle.get()), &pAudioMetaValue);
+ ret = audio_meta_get_album(pAudioHandle.get(), &pAudioMetaValue);
if (pAudioMetaValue != null)
{
pAlbumName.reset(pAudioMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_album operation.");
}
- ret = audio_meta_get_artist(*(pAudioHandle.get()), &pAudioMetaValue);
+ ret = audio_meta_get_artist(pAudioHandle.get(), &pAudioMetaValue);
if (pAudioMetaValue != null)
{
pArtistName.reset(pAudioMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_artist operation.");
}
- ret = audio_meta_get_genre(*(pAudioHandle.get()), &pAudioMetaValue);
+ ret = audio_meta_get_genre(pAudioHandle.get(), &pAudioMetaValue);
if (pAudioMetaValue != null)
{
pGenreName.reset(pAudioMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_genre operation.");
}
- ret = audio_meta_get_composer(*(pAudioHandle.get()), &pAudioMetaValue);
+ ret = audio_meta_get_composer(pAudioHandle.get(), &pAudioMetaValue);
if (pAudioMetaValue != null)
{
pComposerName.reset(pAudioMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_composer operation.");
}
- ret = audio_meta_get_year(*(pAudioHandle.get()), &pAudioMetaValue);
+ ret = audio_meta_get_year(pAudioHandle.get(), &pAudioMetaValue);
if (pAudioMetaValue != null)
{
pYear.reset(pAudioMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_year operation.");
}
- ret = audio_meta_get_copyright(*(pAudioHandle.get()), &pAudioMetaValue);
+ ret = audio_meta_get_copyright(pAudioHandle.get(), &pAudioMetaValue);
if (pAudioMetaValue != null)
{
pCopyRight.reset(pAudioMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_copyright operation.");
}
- ret = audio_meta_get_track_num(*(pAudioHandle.get()), &pAudioMetaValue);
+ ret = audio_meta_get_track_num(pAudioHandle.get(), &pAudioMetaValue);
if (pAudioMetaValue != null)
{
pTrackNum.reset(pAudioMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_track_num operation.");
}
- ret = audio_meta_get_duration(*(pAudioHandle.get()), &duration);
+ ret = audio_meta_get_duration(pAudioHandle.get(), &duration);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_duration operation.");
- pAudioContentData->bitrate = bitrate;
+ pAudioContentInfoImpl->SetBitrate(bitrate);
if (pYear.get() != null)
{
- SysLog(NID_CNT, "pAudioContentData->pYear = %s", pYear.get());
+ SysLog(NID_CNT, "pAudioContentInfoImpl->pYear = %s", pYear.get());
String strYear(pYear.get());
if (strYear.CompareTo(L"Unknown") != 0)
{
- r = Integer::Parse(strYear, pAudioContentData->releaseYear);
+ int releaseYear = 0;
+
+ r = Integer::Parse(strYear, releaseYear);
if (IsFailed(r))
{
// It is one of the metadata. If error occurs, skip it for other metadata.
- pAudioContentData->releaseYear = 0;
+ pAudioContentInfoImpl->SetReleaseYear(0);
r = E_SUCCESS;
- SysLog(NID_CNT, "pAudioContentData->pYear(invalid data) = %ls", strYear.GetPointer());
+ SysLog(NID_CNT, "pAudioContentInfoImpl->pYear(invalid data) = %ls", strYear.GetPointer());
}
+
+ pAudioContentInfoImpl->SetReleaseYear(releaseYear);
}
}
if (pTitle.get() != NULL)
{
- pAudioContentData->pTitle = new (std::nothrow) String(pTitle.get());
- SysTryReturnResult(NID_CNT, pAudioContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pAudioContentData->pTitle = %ls", pAudioContentData->pTitle->GetPointer());
+ pAudioContentInfoImpl->SetTitle(String(pTitle.get()));
+ SysLog(NID_CNT, "pAudioContentInfoImpl->pTitle = %ls", (pAudioContentInfoImpl->GetTitle()).GetPointer());
}
if (pArtistName.get() != NULL)
{
- pAudioContentData->pArtist = new (std::nothrow) String(pArtistName.get());
- SysTryReturnResult(NID_CNT, pAudioContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pAudioContentData->pArtist = %ls", pAudioContentData->pArtist->GetPointer());
+ pAudioContentInfoImpl->SetArtist(String(pArtistName.get()));
+ SysLog(NID_CNT, "pAudioContentInfoImpl->pArtist = %ls", (pAudioContentInfoImpl->GetArtist()).GetPointer());
}
if (pGenreName.get() != NULL)
{
- pAudioContentData->pGenre = new (std::nothrow) String(pGenreName.get());
- SysTryReturnResult(NID_CNT, pAudioContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pAudioContentData->pGenre = %ls", pAudioContentData->pGenre->GetPointer());
+ pAudioContentInfoImpl->SetGenre(String(pGenreName.get()));
+ SysLog(NID_CNT, "pAudioContentInfoImpl->pGenre = %ls", (pAudioContentInfoImpl->GetGenre()).GetPointer());
}
if (pComposerName.get() != NULL)
{
- pAudioContentData->pComposer = new (std::nothrow) String(pComposerName.get());
- SysTryReturnResult(NID_CNT, pAudioContentData->pComposer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pAudioContentData->pComposer = %ls", pAudioContentData->pComposer->GetPointer());
+ pAudioContentInfoImpl->SetComposer(String(pComposerName.get()));
+ SysLog(NID_CNT, "pAudioContentInfoImpl->pComposer = %ls", (pAudioContentInfoImpl->GetComposer()).GetPointer());
}
if (pAlbumName.get() != NULL)
{
- pAudioContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
- SysTryReturnResult(NID_CNT, pAudioContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pAudioContentData->pAlbumName = %ls", pAudioContentData->pAlbumName->GetPointer());
+ pAudioContentInfoImpl->SetAlbumName(String(pAlbumName.get()));
+ SysLog(NID_CNT, "pAudioContentInfoImpl->pAlbumName = %ls", (pAudioContentInfoImpl->GetAlbumName()).GetPointer());
}
if (pCopyRight.get() != NULL)
{
- pAudioContentData->pCopyright = new (std::nothrow) String(pCopyRight.get());
- SysTryReturnResult(NID_CNT, pAudioContentData->pCopyright != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pAudioContentData->pCopyright = %ls", pAudioContentData->pCopyright->GetPointer());
+ pAudioContentInfoImpl->SetCopyright(String(pCopyRight.get()));
+ SysLog(NID_CNT, "pAudioContentInfoImpl->pCopyright = %ls", (pAudioContentInfoImpl->GetCopyright()).GetPointer());
}
if (pTrackNum.get() != NULL)
{
- pAudioContentData->pTrackInfo = new (std::nothrow) String(pTrackNum.get());
- SysTryReturnResult(NID_CNT, pAudioContentData->pTrackInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pAudioContentData->pTrackInfo = %ls", pAudioContentData->pTrackInfo->GetPointer());
+ pAudioContentInfoImpl->SetTrackInfo(String(pTrackNum.get()));
+ SysLog(NID_CNT, "pAudioContentInfoImpl->pTrackInfo = %ls", (pAudioContentInfoImpl->GetTrackInfo()).GetPointer());
}
- pAudioContentData->duration = duration;
- SysLog(NID_CNT,"pAudioContentData->duration = %d", pAudioContentData->duration);
+ pAudioContentInfoImpl->SetDuration(duration);
+ SysLog(NID_CNT,"pAudioContentInfoImpl->duration = %d", pAudioContentInfoImpl->GetDuration());
return r;
}
-// fills video contentinfo information in the video content data object.
+// Fills VideoContentInfo information in the video content data object.
result
-_ContentUtility::FillVideoContentData(media_info_h mediaHandle, VideoContentInfo::_VideoContentData* pVideoContentData)
+_ContentUtility::FillVideoContentData(media_info_h mediaHandle, _VideoContentInfoImpl* pVideoContentInfoImpl)
{
- SysTryReturnResult(NID_CNT, mediaHandle != null && pVideoContentData != null, E_INVALID_ARG, "mediaHandle or pVideoContentData is null.");
+ SysTryReturnResult(NID_CNT, mediaHandle != null && pVideoContentInfoImpl != null, E_INVALID_ARG, "mediaHandle or pVideoContentInfoImpl is null.");
int ret = MEDIA_CONTENT_ERROR_NONE;
result r = E_SUCCESS;
std::unique_ptr<char, UtilCharDeleter> pAlbumName;
int duration = 0;
- std::unique_ptr<video_meta_h, VideoMetaHandleDeleter> pVideoHandle(new (std::nothrow) video_meta_h);
- ret = media_info_get_video(mediaHandle, pVideoHandle.get());
+ video_meta_h tempMeta = NULL;
+
+ ret = media_info_get_video(mediaHandle, &tempMeta);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_video operation.");
- ret = video_meta_get_width(*(pVideoHandle.get()), &width);
+ std::unique_ptr<video_meta_s, VideoMetaHandleDeleter> pVideoHandle(tempMeta);
+ SysTryReturnResult(NID_CNT, pVideoHandle != null, E_OUT_OF_MEMORY, "pVideoHandle is null.");
+
+ ret = video_meta_get_width(pVideoHandle.get(), &width);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_width operation.");
- ret = video_meta_get_height(*(pVideoHandle.get()), &height);
+ ret = video_meta_get_height(pVideoHandle.get(), &height);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_height operation.");
char* pVideoMetaValue = null;
- ret = video_meta_get_artist(*(pVideoHandle.get()), &pVideoMetaValue);
+ ret = video_meta_get_artist(pVideoHandle.get(), &pVideoMetaValue);
if (pVideoMetaValue != null)
{
pArtistName.reset(pVideoMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_artist operation.");
}
- ret = video_meta_get_genre(*(pVideoHandle.get()), &pVideoMetaValue);
+ ret = video_meta_get_genre(pVideoHandle.get(), &pVideoMetaValue);
if (pVideoMetaValue != null)
{
pGenreName.reset(pVideoMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_genre operation.");
}
- ret = video_meta_get_title(*(pVideoHandle.get()), &pVideoMetaValue);
+ ret = video_meta_get_title(pVideoHandle.get(), &pVideoMetaValue);
if (pVideoMetaValue != null)
{
pTitle.reset(pVideoMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_title operation.");
}
- ret = video_meta_get_album(*(pVideoHandle.get()), &pVideoMetaValue);
+ ret = video_meta_get_album(pVideoHandle.get(), &pVideoMetaValue);
if (pVideoMetaValue != null)
{
pAlbumName.reset(pVideoMetaValue);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_album operation.");
}
- ret = video_meta_get_duration(*(pVideoHandle.get()), &duration);
+ ret = video_meta_get_duration(pVideoHandle.get(), &duration);
SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_duration operation.");
- pVideoContentData->width = width;
- pVideoContentData->height = height;
+ pVideoContentInfoImpl->SetWidth(width);
+ pVideoContentInfoImpl->SetHeight(height);
if (pTitle.get() != NULL)
{
- pVideoContentData->pTitle = new (std::nothrow) String(pTitle.get());
- SysTryReturnResult(NID_CNT, pVideoContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pVideoContentData->pTitle = %ls", pVideoContentData->pTitle->GetPointer());
+ pVideoContentInfoImpl->SetTitle(String(pTitle.get()));
+ SysLog(NID_CNT, "pVideoContentInfoImpl->pTitle = %ls", (pVideoContentInfoImpl->GetTitle()).GetPointer());
}
if (pArtistName.get() != NULL)
{
- pVideoContentData->pArtist = new (std::nothrow) String(pArtistName.get());
- SysTryReturnResult(NID_CNT, pVideoContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pVideoContentData->pArtist = %ls", pVideoContentData->pArtist->GetPointer());
+ pVideoContentInfoImpl->SetArtist(String(pArtistName.get()));
+ SysLog(NID_CNT, "pVideoContentInfoImpl->pArtist = %ls", (pVideoContentInfoImpl->GetArtist()).GetPointer());
}
if (pGenreName.get() != NULL)
{
- pVideoContentData->pGenre = new (std::nothrow) String(pGenreName.get());
- SysTryReturnResult(NID_CNT, pVideoContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pVideoContentData->pGenre = %ls", pVideoContentData->pGenre->GetPointer());
+ pVideoContentInfoImpl->SetGenre(String(pGenreName.get()));
+ SysLog(NID_CNT, "pVideoContentInfoImpl->pGenre = %ls", (pVideoContentInfoImpl->GetGenre()).GetPointer());
}
if (pAlbumName.get() != NULL)
{
- pVideoContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
- SysTryReturnResult(NID_CNT, pVideoContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- SysLog(NID_CNT, "pVideoContentData->pAlbumName = %ls", pVideoContentData->pAlbumName->GetPointer());
+ pVideoContentInfoImpl->SetAlbumName(String(pAlbumName.get()));
+ SysLog(NID_CNT, "pVideoContentInfoImpl->pAlbumName = %ls", (pVideoContentInfoImpl->GetAlbumName()).GetPointer());
}
- pVideoContentData->duration = duration;
- SysLog(NID_CNT,"pVideoContentData->duration = %d", pVideoContentData->duration);
+ pVideoContentInfoImpl->SetDuration(duration);
+ SysLog(NID_CNT,"pVideoContentInfoImpl->duration = %d", pVideoContentInfoImpl->GetDuration());
return r;
}
-// Convertion of system errors to osp errors
+// Conversion of system errors to native errors
result
_ContentUtility::MapCoreErrorToNativeResult(int reason)
{