//
-// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
* This file contains implementation of the %_ContentManagerUtilImpl class.
*/
+#include <new>
#include <stdlib.h>
+#include <aul/aul.h>
#include <mime_type.h>
-#include <FBaseSysLog.h>
-#include <FIoDirectory.h>
#include <FAppApp.h>
-#include <FSysEnvironment.h>
-#include <FMediaImage.h>
-#include <FMediaImageUtil.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringTokenizer.h>
#include <FCntImageMetadata.h>
#include <FCntAudioMetadata.h>
#include <FCntVideoMetadata.h>
-#include <FCnt_ContentManagerUtilImpl.h>
-#include <FCnt_AudioMetadataImpl.h>
-#include <FCnt_VideoMetadataImpl.h>
-#include <FCnt_ImageMetadataImpl.h>
+#include <FMediaImage.h>
+#include <FMediaImageBuffer.h>
+#include <FMediaImageUtil.h>
+#include <FIoDirectory.h>
+#include <FSysEnvironment.h>
+#include <FApp_AppInfo.h>
+#include <FBase_LocalizedNumParser.h>
#include <FBase_StringConverter.h>
-#include <FIo_FileImpl.h>
#include <FGrp_BitmapImpl.h>
+#include <FIo_FileImpl.h>
#include <FMedia_ImageDecoder.h>
#include <FMedia_ImageImpl.h>
-#include <FApp_AppInfo.h>
+#include "FCnt_AudioMetadataImpl.h"
+#include "FCnt_ContentManagerUtilImpl.h"
+#include "FCnt_ImageMetadataImpl.h"
+#include "FCnt_VideoMetadataImpl.h"
+
+using namespace std;
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+using namespace Tizen::Media;
+using namespace Tizen::System;
+
+namespace Tizen { namespace Content
+{
+
+// Types of content, format supported and default values
+static const int _IMAGE_BUFF_LENGTH = 100;
+static const int _THUMBNAIL_IMAGE_WIDTH = 80;
+static const int _THUMBNAIL_IMAGE_HEIGHT = 60;
+static const int _MINUTES = 60;
+static const int _SECONDS = 3600;
+static const double DEFAULT_COORDINATE = -200.0;
+
+ImageMetadata*
+_ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
+{
+ ClearLastResult();
+
+ if (!internal)
+ {
+ SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), null, E_INVALID_ARG,
+ "[E_INVALID_ARG] The path is not compatible.");
+ }
+ SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), null, E_INVALID_ARG,
+ "[E_INVALID_ARG] The file corresponding to contentPath could not be found.");
+
+ // create object here as it needs to be passed to client in any case to make sure Get APIs do not crash
+ unique_ptr<ImageMetadata> pImageMetadata(new (nothrow) ImageMetadata());
+ SysTryReturn(NID_CNT, pImageMetadata != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] pImageMetadata is null.");
+
+ _ImageMetadataImpl* pImageMetaImpl = _ImageMetadataImpl::GetInstance(*(pImageMetadata.get()));
+ SysTryReturn(NID_CNT, pImageMetaImpl != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] pImageMetaImpl is null.");
+
+ ImageMeta* pMetadata = pImageMetaImpl->GetImageMetadata();
+ SysTryReturn(NID_CNT, pMetadata != null, null, E_INVALID_ARG,
+ "[E_INVALID_ARG] pMetadata is null.");
+
+ //assign by default here and overwrite below if width and height presents in EXIF data.
+ ImageFormat imgType = IMG_FORMAT_NONE;
+ Dimension dim(0,0);
+
+ result r = _ImageImpl::GetImageInfo(contentPath, imgType, dim);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_INVALID_ARG,
+ "[E_INVALID_ARG] GetImageInfo failed.");
+
+ pMetadata->width = dim.width;
+ pMetadata->height = dim.height;
+ pMetadata->contentPath = contentPath;
+
+ String tizenPath(L"");
+ String changedPath(L"");
+ r = ChangeMediaFilePath(contentPath, tizenPath, changedPath);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, r, "[%s] Failed to perform ChangeMediaFilePath.", GetErrorMessage(r));
+
+ if (imgType == IMG_FORMAT_JPG)
+ {
+ unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(tizenPath));
+ SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ unique_ptr<ExifData, ExifDataDeleter> pExifdata(exif_data_new_from_file(pFileName.get()));
+ if (pExifdata != null)
+ {
+ ExifTag tag;
+ ExifByteOrder byteOrder;
+ ExifEntry** pEntries = null;
+ const char* pData = null;
+ char buf[_IMAGE_BUFF_LENGTH] = {0, };
+ ExifContent* pExifcont[EXIF_IFD_COUNT];
+ char latitudeRef = 0; // to store latitude reference (quadrasphere designation 'N', 'S', 'W' or 'E')
+ char longitudeRef = 0; // to store longitude reference (quadrasphere designation 'N', 'S', 'W' or 'E')
+ unsigned int entryCount = 0;
+ bool isOrientation = false;
+ bool isLatitude = false;
+ bool isLongitude = false;
+
+ for (int i = 0; i < EXIF_IFD_COUNT; i++)
+ {
+ pExifcont[i] = pExifdata->ifd[i];
+ entryCount = pExifcont[i]->count;
+ pEntries = pExifcont[i]->entries;
+ for (unsigned int j = 0; j < entryCount; j++)
+ {
+ tag = pEntries[j]->tag;
+ pData = exif_entry_get_value(pEntries[j], buf, sizeof(buf));
+ SysTryReturn(NID_CNT, pData != null, pImageMetadata.release(), E_INVALID_ARG,
+ "[E_INVALID_ARG] exif_entry_get_value failed.");
+
+ if (tag == EXIF_TAG_PIXEL_X_DIMENSION)
+ {
+ pMetadata->width = atoi(buf);
+ }
+ else if (tag == EXIF_TAG_PIXEL_Y_DIMENSION)
+ {
+ pMetadata->height = atoi(buf);
+ }
+ else if (tag == EXIF_TAG_MAKE)
+ {
+ pMetadata->pManufacturer = new (nothrow) String(buf);
+ SysTryReturn(NID_CNT, pMetadata->pManufacturer != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else if (tag == EXIF_TAG_MODEL)
+ {
+ pMetadata->pModel = new (nothrow) String(buf);
+ SysTryReturn(NID_CNT, pMetadata->pModel != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else if (tag == EXIF_TAG_DATE_TIME)
+ {
+ pMetadata->pDateTime = new (nothrow) String(buf);
+ SysTryReturn(NID_CNT, pMetadata->pDateTime != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else if (tag == EXIF_TAG_ORIENTATION && !isOrientation)
+ {
+ //get the byte order(little endian or big endian) before extracting orientation type
+ byteOrder = exif_data_get_byte_order(pEntries[j]->parent->parent);
+ pMetadata->orientation = static_cast<ImageOrientationType>(exif_get_short(pEntries[j]->data, byteOrder));
+
+ isOrientation = true;
+ }
+ else if (tag == EXIF_TAG_SOFTWARE)
+ {
+ pMetadata->pSoftware = new (nothrow) String(buf);
+ SysTryReturn(NID_CNT, pMetadata->pSoftware != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else if (tag == EXIF_TAG_GPS_LATITUDE_REF)
+ {
+ latitudeRef = buf[0]; // GPS Latitude reference value will be 'N'(NORTH) or 'S'(SOUTH)
+ }
+ else if (tag == EXIF_TAG_GPS_LATITUDE && !isLatitude)
+ {
+ String tempLatitude(buf);
+ if (!tempLatitude.Contains(L","))
+ {
+ pMetadata->latitude = DEFAULT_COORDINATE;
+ isLatitude = true;
+ continue;
+ }
+
+ int firstComma = 0;
+ int lastComma = 0;
+
+ r = tempLatitude.IndexOf(',', 0, firstComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r));
+
+ r = tempLatitude.SetCharAt('/', firstComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r));
+
+ r = tempLatitude.LastIndexOf(',', tempLatitude.GetLength() - 1, lastComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r));
+
+ r = tempLatitude.SetCharAt('/', lastComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r));
+
+ String delim(L"/");
+ StringTokenizer strTok(tempLatitude, delim);
+ String token[3] = {L"", };
+
+ int count = 0;
+ while (strTok.HasMoreTokens() && count < 3)
+ {
+ strTok.GetNextToken(token[count++]);
+ }
+
+ double ddVal = _LocalizedNumParser::ToDouble(token[0], ""); // degree value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ double mmVal = _LocalizedNumParser::ToDouble(token[1], ""); // minutes value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ double ssVal = _LocalizedNumParser::ToDouble(token[2], ""); // seconds value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ pMetadata->latitude = ddVal + (mmVal/_MINUTES) + (ssVal/_SECONDS);
+
+ // if latitude designation is Southern (SOUTH) then latitude degree will be negative DD
+ if (latitudeRef == 'S')
+ {
+ pMetadata->latitude = (pMetadata->latitude * (double)(-1));
+ }
+ isLatitude = true;
+ }
+ else if (tag == EXIF_TAG_GPS_LONGITUDE_REF)
+ {
+ longitudeRef = buf[0]; // GPS Longitude reference value will be 'W'(WEST) or 'E'(EAST)
+ }
+ else if (tag == EXIF_TAG_GPS_LONGITUDE && !isLongitude)
+ {
+ String tempLongitude(buf);
+ if (!tempLongitude.Contains(L","))
+ {
+ pMetadata->longitude = DEFAULT_COORDINATE;
+ isLongitude = true;
+ continue;
+ }
+
+ int firstComma = 0;
+ int lastComma = 0;
+
+ r = tempLongitude.IndexOf(',', 0, firstComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r));
+
+ r = tempLongitude.SetCharAt('/', firstComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r));
+
+ r = tempLongitude.LastIndexOf(',', tempLongitude.GetLength() - 1, lastComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r));
+
+ r = tempLongitude.SetCharAt('/', lastComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r));
+
+ String delim(L"/");
+ StringTokenizer strTok(tempLongitude, delim);
+ String token[3] = {L"", };
+
+ int count = 0;
+ while (strTok.HasMoreTokens() && count < 3)
+ {
+ strTok.GetNextToken(token[count++]);
+ }
+
+ double ddVal = _LocalizedNumParser::ToDouble(token[0], ""); // degree value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ double mmVal = _LocalizedNumParser::ToDouble(token[1], ""); // minutes value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ double ssVal = _LocalizedNumParser::ToDouble(token[2], ""); // seconds value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ pMetadata->longitude = ddVal + (mmVal/_MINUTES) + (ssVal/_SECONDS);
+
+ // if longitude designation is Western (WEST) then longitude degree will be negative DD
+ if (longitudeRef == 'W')
+ {
+ pMetadata->longitude = (pMetadata->longitude * (double)(-1));
+ }
+ isLongitude = true;
+ }
+ else if (tag == EXIF_TAG_WHITE_BALANCE)
+ {
+ pMetadata->pWhiteBalance = new (nothrow) String(buf);
+ SysTryReturn(NID_CNT, pMetadata->pWhiteBalance != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ }
+ }
+ }
+ }
+
+ return pImageMetadata.release();
+}
+
+AudioMetadata*
+_ContentManagerUtilImpl::GetAudioMetaN(const String& contentPath)
+{
+ ClearLastResult();
+
+ SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), null, E_INVALID_ARG,
+ "[E_INVALID_ARG] The path is not compatible.");
+ SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), null, E_INVALID_ARG,
+ "[E_INVALID_ARG] The file corresponding to contentPath could not be found.");
+
+ // create here to make sure that get apis will not crash though the below API calls fails in case of invalid file.
+ unique_ptr<AudioMetadata> pAudioMetadata(new (nothrow) AudioMetadata());
+ SysTryReturn(NID_CNT, pAudioMetadata != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ _AudioMetadataImpl* pAudioMetaImpl = _AudioMetadataImpl::GetInstance(*(pAudioMetadata.get()));
+ SysTryReturn(NID_CNT, pAudioMetaImpl != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] pAudioMetaImpl is null.");
+
+ AudioMeta* pMetadata = pAudioMetaImpl->GetAudioMetadata();
+ SysTryReturn(NID_CNT, pMetadata != null, null, E_INVALID_ARG,
+ "[E_INVALID_ARG] pMetadata is null.");
+
+ pMetadata->contentPath = contentPath;
+
+ String tizenPath(L"");
+ String changedPath(L"");
+ result r = ChangeMediaFilePath(contentPath, tizenPath, changedPath);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, r, "[%s] Failed to perform ChangeMediaFilePath.", GetErrorMessage(r));
+
+ // Create the metadata extractor handle
+ metadata_extractor_h tempExtractor = NULL;
+
+ int retVal = metadata_extractor_create(&tempExtractor);
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
+ "[%s] metadata_extractor_create failed.", GetErrorMessage(r));
+
+ unique_ptr<metadata_extractor_s, ExtractorDeleter> pExtractor(tempExtractor);
+ SysTryReturn(NID_CNT, pExtractor != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ // Set file path of content to extract the metadata
+ unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(tizenPath));
+ SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ retVal = metadata_extractor_set_path(pExtractor.get(), pFileName.get());
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
+ "[%s] metadata_extractor_set_path failed.", GetErrorMessage(r));
+
+ // Get all relavent audio metadata by passing relavent attirbutes
+ char* pTempAudioMeta = null;
+ unique_ptr<char, CharDeleter> pAudioMeta(null);
+
+ // bitrate
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUDIO_BITRATE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->bitrate = atoi(pAudioMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(bitrate) failed.", GetErrorMessage(r));
+ }
+
+ // channelcount
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUDIO_CHANNELS, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->channelCount = atoi(pAudioMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(channels) failed.", GetErrorMessage(r));
+ }
+
+ // duration
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DURATION, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->duration = atoi(pAudioMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(duration) failed.", GetErrorMessage(r));
+ }
+
+ // frequency
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUDIO_SAMPLERATE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->frequency = atoi(pAudioMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(frequency) failed.", GetErrorMessage(r));
+ }
+
+ // albumname
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_ALBUM, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pAlbumName = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pAlbumName != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(album name) failed.", GetErrorMessage(r));
+ }
+
+ // artist
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_ARTIST, &pTempAudioMeta);
+ if (pAudioMeta.get() != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pArtist = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pArtist != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(artist) failed.", GetErrorMessage(r));
+ }
+
+ // copyright
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_COPYRIGHT, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pCopyright = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pCopyright != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(copyright) failed.", GetErrorMessage(r));
+ }
+
+ // genre
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_GENRE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pGenre = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pGenre != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(genre) failed.", GetErrorMessage(r));
+ }
+
+ // title
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_TITLE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pTitle = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pTitle != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(title) failed.", GetErrorMessage(r));
+ }
+
+ // comment
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_COMMENT, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pComment = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pComment != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(comment) failed.", GetErrorMessage(r));
+ }
+
+ // description
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DESCRIPTION, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pDescription = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pDescription != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(description) failed.", GetErrorMessage(r));
+ }
+
+ // recording date
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_RECDATE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pRecordingDate = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pRecordingDate != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(recording date) failed.", GetErrorMessage(r));
+ }
+
+ // author
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUTHOR, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pComposer = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pComposer != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(author) failed.", GetErrorMessage(r));
+ }
+
+ // track info
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_TRACK_NUM, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pTrackInfo = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pTrackInfo != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ // if the string contains the track info like track num/track position,
+ // then track position will be ignored and only track num is returned
+ // no need to parse this string, since only track number is required
+ pMetadata->trackNum = atoi(pAudioMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(track info) failed.", GetErrorMessage(r));
+ }
+
+ // date
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DATE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->year = atoi(pAudioMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(date) failed.", GetErrorMessage(r));
+ }
+
+ // artwork
+ int size = 0;
+ void* pTempArtwork = null;
+ unique_ptr<void, VoidDeleter> pArtwork(null);
+
+ // Get the artwork image in media file
+ retVal = metadata_extractor_get_artwork(pExtractor.get(), &pTempArtwork, &size, &pTempAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
+
+ //Check if the albumart present and pass it to client if it is successfully processed, otherwise ignore any errors
+ //while processing albumart. This is to pass the other metadata tags to application.
+ if (pTempArtwork != null)
+ {
+ pArtwork.reset(pTempArtwork);
+
+ Image img;
+ ImageFormat format = IMG_FORMAT_NONE;
+ ByteBuffer buffer;
+
+ r = buffer.Construct(size);
+ if (!IsFailed(r)) //Ignore the error codes to send other metadata to app
+ {
+ r = buffer.SetArray((const byte*)(pArtwork.get()), 0, size);
+ if (!IsFailed(r))
+ {
+ r = img.Construct();
+ if (!IsFailed(r))
+ {
+ format = img.GetImageFormat(buffer);
+ pMetadata->pThumbnail = img.DecodeN(buffer, format, BITMAP_PIXEL_FORMAT_ARGB8888,
+ _THUMBNAIL_IMAGE_WIDTH, _THUMBNAIL_IMAGE_HEIGHT);
+ if (pMetadata->pThumbnail == null)
+ {
+ // Because Thumbnail is one of the metadata, it is not exception in this function.
+ SysLog(NID_CNT, "DecodeN failed.");
+ }
+ pMetadata->pAlbumArt = img.DecodeN(buffer, format, BITMAP_PIXEL_FORMAT_ARGB8888);
+ if (pMetadata->pAlbumArt == null)
+ {
+ // Because Album Art is one of the metadata, it is not exception in this function.
+ SysLog(NID_CNT, "DecodeN failed.");
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_artwork failed.", GetErrorMessage(r));
+ }
+
+ return pAudioMetadata.release();
+}
+
+VideoMetadata*
+_ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath)
+{
+ ClearLastResult();
+
+ SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), null, E_INVALID_ARG,
+ "[E_INVALID_ARG] The path is not compatible.");
+ SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), null, E_INVALID_ARG,
+ "[E_INVALID_ARG] The file corresponding to contentPath could not be found.");
+
+ // need to create here to make sure that all get APIs will not crash in case of corrupted file
+ unique_ptr<VideoMetadata> pVideoMetadata(new (nothrow) VideoMetadata());
+ SysTryReturn(NID_CNT, pVideoMetadata != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory insufficient.");
+
+ _VideoMetadataImpl* pVideoMetaImpl = _VideoMetadataImpl::GetInstance(*(pVideoMetadata.get()));
+ SysTryReturn(NID_CNT, pVideoMetaImpl != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] pVideoMetaImpl is null.");
+
+ VideoMeta* pMetadata = pVideoMetaImpl->GetVideoMetadata();
+ SysTryReturn(NID_CNT, pMetadata != null, null, E_INVALID_ARG,
+ "[E_INVALID_ARG] pMetadata is null.");
+
+ pMetadata->contentPath = contentPath;
+
+ String tizenPath(L"");
+ String changedPath(L"");
+ result r = ChangeMediaFilePath(contentPath, tizenPath, changedPath);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, r, "[%s] Failed to perform ChangeMediaFilePath.", GetErrorMessage(r));
+
+ // Create the metadata extractor handle
+ metadata_extractor_h tempExtractor = NULL;
+
+ int retVal = metadata_extractor_create(&tempExtractor);
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
+ "[%s] metadata_extractor_create failed.", GetErrorMessage(r));
+
+ unique_ptr<metadata_extractor_s, ExtractorDeleter> pExtractor(tempExtractor);
+ SysTryReturn(NID_CNT, pExtractor != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory insufficient.");
+
+ // Set file path of content to extract the metadata
+ unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(tizenPath));
+ SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ retVal = metadata_extractor_set_path(pExtractor.get(), pFileName.get());
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
+ "[%s] metadata_extractor_set_path failed.", GetErrorMessage(r));
+
+ // Get all relavent video metadata by passing relavent attirbutes
+ char* pTempVideoMeta = null;
+ unique_ptr<char, CharDeleter> pVideoMeta(null);
+
+ // width
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_VIDEO_WIDTH, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->width = atoi(pVideoMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(width) failed.", GetErrorMessage(r));
+ }
+
+ // height
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_VIDEO_HEIGHT, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->height = atoi(pVideoMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(height) failed.", GetErrorMessage(r));
+ }
+
+ // video bitrate
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_VIDEO_BITRATE, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->videoBitrate = atoi(pVideoMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(video bitrate) failed.", GetErrorMessage(r));
+ }
+
+ // audio bitrate
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUDIO_BITRATE, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->audioBitrate = atoi(pVideoMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(audio bitrate) failed.", GetErrorMessage(r));
+ }
+
+ // framerate
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_VIDEO_FPS, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->framerate = atoi(pVideoMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(framerate) failed.", GetErrorMessage(r));
+ }
+
+ // duration
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DURATION, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->duration = atoi(pVideoMeta.get());
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(duration) failed.", GetErrorMessage(r));
+ }
+
+ // genre
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_GENRE, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->pGenre = new (nothrow) String(pVideoMeta.get()); //allocate memory
+ SysTryReturn(NID_CNT, pMetadata->pGenre != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(genre) failed.", GetErrorMessage(r));
+ }
+
+ // comment
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_COMMENT, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->pComment = new (nothrow) String(pVideoMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pComment != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(comment) failed.", GetErrorMessage(r));
+ }
+
+ // description
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DESCRIPTION, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->pDescription = new (nothrow) String(pVideoMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pDescription != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(description) failed.", GetErrorMessage(r));
+ }
+
+ // artwork
+ int size = 0;
+ void* pTempArtwork = null;
+ unique_ptr<void, VoidDeleter> pArtwork(null);
-using namespace Tizen::Base;
-using namespace Tizen::Io;
-using namespace Tizen::Media;
-using namespace Tizen::Graphics;
-using namespace Tizen::App;
-using namespace Tizen::System;
-using namespace std;
+ // Get the artwork image in media file
+ retVal = metadata_extractor_get_artwork(pExtractor.get(), &pTempArtwork, &size, &pTempVideoMeta);
+ pVideoMeta.reset(pTempVideoMeta);
+ if (pTempArtwork != null)
+ {
+ pArtwork.reset(pTempArtwork);
-namespace Tizen { namespace Content
-{
-// Types of content, format supported and default values
-static const int IMAGE_BUFF_LENGTH = 100;
-static const int THUMBNAIL_IMAGE_WIDTH = 80;
-static const int THUMBNAIL_IMAGE_HEIGHT = 60;
-static const int MINUTES = 60;
-static const int SECONDS = 3600; // 60*60
-static const wchar_t CONTENT_FORMAT[] =
- L"jpg1 JPG1 jpeg1 JPEG1 png1 PNG1 gif1 GIF1 wbmp1 WBMP1 bmp1 BMP1 tiff1 TIFF1 tif1 TIF1 \
- mp32 MP32 aac2 AAC2 wma2 WMA2 m4a2 M4A2 3ga2 3GA2 midi2 MIDI2 mid2 MID2 mmf2 MMF2 \
- wav2 WAV2 amr2 AMR2 imy2 IMY2 mxmf2 MXMF2 xmf2 XMF2 pmd2 PMD2 sdc2 SDC2 spm2 SPM2 flac2 FLAC2 pya2 PYA2 \
- ogg2 OGG2 oga2 OGA2 \
- wmv3 WMV3 avi3 AVI3 asf3 ASF3 sdp3 SDP3 divx3 DIVX3 mkv3 MKV3 skm3 SKM3 k3g3 K3G3 pyv3 PYV3 rv3 RV3 \
- rm3 RM3 ram3 RAM3 mov3 MOV3 qt3 QT3 mpeg3 MPEG3 flv3 FLV3 ra2 RA2 \
- txt0 TXT0 fb20 FB20 smt0 SMT0 docx0 DOCX0 doc0 DOC0 pdf0 PDF0 pptx0 PPTX0 ppt0 PPT0 xlsx0 XLSX0 \
- xls0 XLS0 html0 HTML0 htm0 HTM0 jad0 JAD0 jar0 JAR0 vbm0 VBM0 vcf0 VCF0 vcs0 VCS0 vmg0 VMG0 eml0 EML0 \
- zse0 ZSE0 cer0 CER0 crt0 CRT0 der0 DER0 p120 P120 pfx0 PFX0 wgt0 WGT0 svgz0 SVGZ0 svg0 SVG0 swf0 SWF0 \
- enc0 ENC0 ics0 ICS0 oap0 OAP0 mp45 MP45 3gpp5 3GPP5 3gp5 3GP5";
+ Image img;
+ ImageFormat format = IMG_FORMAT_NONE;
+ ByteBuffer buffer;
+
+ r = buffer.Construct(size);
+ if (!IsFailed(r)) //Ignore the error codes to send other metadata to app
+ {
+ r = buffer.SetArray((const byte*)(pArtwork.get()), 0, size);
+ if (!IsFailed(r))
+ {
+ r = img.Construct();
+ if (!IsFailed(r))
+ {
+ format = img.GetImageFormat(buffer);
+
+ pMetadata->pAlbumArt = img.DecodeN(buffer, format, BITMAP_PIXEL_FORMAT_ARGB8888);
+ if (pMetadata->pAlbumArt == null)
+ {
+ // Because Album Art is one of the metadata, it is not exception in this function.
+ SysLog(NID_CNT, "DecodeN failed.");
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_artwork failed.", GetErrorMessage(r));
+ }
+
+ return pVideoMetadata.release();
+}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_OUT_OF_MEMORY
-//
ImageMetadata*
-_ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
+_ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer)
{
ClearLastResult();
- if (!internal)
- {
- SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), null, E_INVALID_ARG,
- "[E_INVALID_ARG] %ls is not compatible.", contentPath.GetPointer());
- }
- SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), null, E_INVALID_ARG,
- "[E_INVALID_ARG] The file corresponding to contentPath could not be found.(%ls)", contentPath.GetPointer());
+ int bufferLen = byteBuffer.GetRemaining();
+ SysTryReturn(NID_CNT, bufferLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The length of buffer is less than zero.");
// create object here as it needs to be passed to client in any case to make sure Get APIs do not crash
unique_ptr<ImageMetadata> pImageMetadata(new (nothrow) ImageMetadata());
//assign by default here and overwrite below if width and height presents in EXIF data.
ImageFormat imgType = IMG_FORMAT_NONE;
- Dimension dim(0,0);
+ int imageWidth = 0;
+ int imageHeight = 0;
+ bool isOrientation = false;
+ bool isLatitude = false;
+ bool isLongitude = false;
- result r = _ImageImpl::GetImageInfo(contentPath, imgType, dim);
+ result r = ImageBuffer::GetImageInfo(byteBuffer, imgType, imageWidth, imageHeight);
SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_INVALID_ARG,
"[E_INVALID_ARG] GetImageInfo failed.");
- pMetadata->width = dim.width;
- pMetadata->height = dim.height;
- pMetadata->contentPath = contentPath;
+ pMetadata->width = imageWidth;
+ pMetadata->height = imageHeight;
if (imgType == IMG_FORMAT_JPG)
{
- unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(contentPath));
- SysTryReturn(NID_CNT, pFileName != null, pImageMetadata.release(), E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ const byte* pByte = byteBuffer.GetPointer();
- unique_ptr<ExifData, ExifDataDeleter> pExifdata(exif_data_new_from_file(pFileName.get()));
+ unique_ptr<ExifData, ExifDataDeleter> pExifdata(exif_data_new_from_data(pByte, bufferLen));
if (pExifdata != null)
{
ExifTag tag;
ExifByteOrder byteOrder;
ExifEntry** pEntries = null;
const char* pData = null;
- char buf[IMAGE_BUFF_LENGTH] = {0, };
- char mmBuff[IMAGE_BUFF_LENGTH] = {0, }; // to store minutes value of GPS data
- char ssBuff[IMAGE_BUFF_LENGTH] = {0, }; // to store seconds value of GPS data
+ char buf[_IMAGE_BUFF_LENGTH] = {0, };
ExifContent* pExifcont[EXIF_IFD_COUNT];
- int index = 0;
char latitudeRef = 0; // to store latitude reference (quadrasphere designation 'N', 'S', 'W' or 'E')
char longitudeRef = 0; // to store longitude reference (quadrasphere designation 'N', 'S', 'W' or 'E')
unsigned int entryCount = 0;
SysTryReturn(NID_CNT, pMetadata->pDateTime != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
}
- else if (tag == EXIF_TAG_ORIENTATION)
+ else if (tag == EXIF_TAG_ORIENTATION && !isOrientation)
{
//get the byte order(little endian or big endian) before extracting orientation type
byteOrder = exif_data_get_byte_order(pEntries[j]->parent->parent);
pMetadata->orientation = static_cast<ImageOrientationType>(exif_get_short(pEntries[j]->data, byteOrder));
+
+ isOrientation = true;
}
else if (tag == EXIF_TAG_SOFTWARE)
{
{
latitudeRef = buf[0]; // GPS Latitude reference value will be 'N'(NORTH) or 'S'(SOUTH)
}
- else if (tag == EXIF_TAG_GPS_LATITUDE)
+ else if (tag == EXIF_TAG_GPS_LATITUDE && !isLatitude)
{
- ParseBuffer(buf, index); // to extract the minutes value of GPS data, if present
- for (int l = 0; l < IMAGE_BUFF_LENGTH-1; l++)
+ String tempLatitude(buf);
+ if (!tempLatitude.Contains(L","))
{
- mmBuff[l] = buf[l + index + 1]; //add 1 to skip the ','
+ pMetadata->latitude = DEFAULT_COORDINATE;
+ isLatitude = true;
+ continue;
}
- index = 0; //re-assign index value as this is new buffer
- ParseBuffer(mmBuff, index); // to extract the seconds value of GPS data, if present
- for (int l = 0; l < IMAGE_BUFF_LENGTH-1; l++)
+
+ int firstComma = 0;
+ int lastComma = 0;
+
+ r = tempLatitude.IndexOf(',', 0, firstComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r));
+
+ r = tempLatitude.SetCharAt('/', firstComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r));
+
+ r = tempLatitude.LastIndexOf(',', tempLatitude.GetLength() - 1, lastComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r));
+
+ r = tempLatitude.SetCharAt('/', lastComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r));
+
+ String delim(L"/");
+ StringTokenizer strTok(tempLatitude, delim);
+ String token[3] = {L"", };
+
+ int count = 0;
+ while (strTok.HasMoreTokens() && count < 3)
{
- ssBuff[l] = mmBuff[l + index + 1]; //add 1 to skip the ','
+ strTok.GetNextToken(token[count++]);
}
- double ddVal = atof(buf); // degree value
- double mmVal = atof(mmBuff); // minutesvalue
- double ssVal = atof(ssBuff); // seconds value
- pMetadata->latitude = ddVal + (mmVal/MINUTES) + (ssVal/SECONDS);
+
+ double ddVal = _LocalizedNumParser::ToDouble(token[0], ""); // degree value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ double mmVal = _LocalizedNumParser::ToDouble(token[1], ""); // minutes value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ double ssVal = _LocalizedNumParser::ToDouble(token[2], ""); // seconds value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ pMetadata->latitude = ddVal + (mmVal/_MINUTES) + (ssVal/_SECONDS);
// if latitude designation is Southern (SOUTH) then latitude degree will be negative DD
if (latitudeRef == 'S')
{
pMetadata->latitude = (pMetadata->latitude * (double)(-1));
}
+ isLatitude = true;
}
else if (tag == EXIF_TAG_GPS_LONGITUDE_REF)
{
longitudeRef = buf[0]; // GPS Longitude reference value will be 'W'(WEST) or 'E'(EAST)
}
- else if (tag == EXIF_TAG_GPS_LONGITUDE)
+ else if (tag == EXIF_TAG_GPS_LONGITUDE && !isLongitude)
{
- index = 0; //re-assign index value as this is new buffer
- ParseBuffer(buf, index); // to extract the minutes value of GPS data, if present
- for (int l = 0; l < IMAGE_BUFF_LENGTH-1; l++)
+ String tempLongitude(buf);
+ if (!tempLongitude.Contains(L","))
{
- mmBuff[l] = buf[l + index + 1]; //add 1 to skip the ','
+ pMetadata->longitude = DEFAULT_COORDINATE;
+ isLongitude = true;
+ continue;
}
- index = 0; //re-assign index value as this is new buffer
- ParseBuffer(mmBuff, index); // to extract the seconds value of GPS data, if present
- for (int l = 0; l < IMAGE_BUFF_LENGTH-1; l++)
+
+ int firstComma = 0;
+ int lastComma = 0;
+
+ r = tempLongitude.IndexOf(',', 0, firstComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r));
+
+ r = tempLongitude.SetCharAt('/', firstComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r));
+
+ r = tempLongitude.LastIndexOf(',', tempLongitude.GetLength() - 1, lastComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r));
+
+ r = tempLongitude.SetCharAt('/', lastComma);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r));
+
+ String delim(L"/");
+ StringTokenizer strTok(tempLongitude, delim);
+ String token[3] = {L"", };
+
+ int count = 0;
+ while (strTok.HasMoreTokens() && count < 3)
{
- ssBuff[l] = mmBuff[l + index + 1]; //add 1 to skip the ','
+ strTok.GetNextToken(token[count++]);
}
- double ddVal = atof(buf); // degree value
- double mmVal = atof(mmBuff); // minutesvalue
- double ssVal = atof(ssBuff); // seconds value
- pMetadata->longitude = ddVal + (mmVal/MINUTES) + (ssVal/SECONDS);
+
+ double ddVal = _LocalizedNumParser::ToDouble(token[0], ""); // degree value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ double mmVal = _LocalizedNumParser::ToDouble(token[1], ""); // minutes value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ double ssVal = _LocalizedNumParser::ToDouble(token[2], ""); // seconds value
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation.");
+
+ pMetadata->longitude = ddVal + (mmVal/_MINUTES) + (ssVal/_SECONDS);
// if longitude designation is Western (WEST) then longitude degree will be negative DD
if (longitudeRef == 'W')
{
pMetadata->longitude = (pMetadata->longitude * (double)(-1));
}
+ isLongitude = true;
}
else if (tag == EXIF_TAG_WHITE_BALANCE)
{
return pImageMetadata.release();
}
-void
-_ContentManagerUtilImpl::ParseBuffer(char* pBuffer, int& count)
-{
- if ((*pBuffer != ',') && (*pBuffer != '\0')) // parse the buffer till ',' or '\0' and return the index
- {
- ParseBuffer(++pBuffer, ++count);
- }
-}
-
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_OUT_OF_MEMORY
-//
AudioMetadata*
-_ContentManagerUtilImpl::GetAudioMetaN(const String& contentPath)
+_ContentManagerUtilImpl::GetAudioMetaN(const ByteBuffer& byteBuffer)
{
ClearLastResult();
- SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), null, E_INVALID_ARG,
- "[E_INVALID_ARG] %ls is not compatible.", contentPath.GetPointer());
- SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), null, E_INVALID_ARG,
- "[E_INVALID_ARG] The file corresponding to contentPath could not be found.");
+ int bufferLen = byteBuffer.GetRemaining();
+ SysTryReturn(NID_CNT, bufferLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The length of buffer is less than zero.");
// create here to make sure that get apis will not crash though the below API calls fails in case of invalid file.
unique_ptr<AudioMetadata> pAudioMetadata(new (nothrow) AudioMetadata());
SysTryReturn(NID_CNT, pMetadata != null, null, E_INVALID_ARG,
"[E_INVALID_ARG] pMetadata is null.");
- pMetadata->contentPath = contentPath;
-
// Create the metadata extractor handle
- unique_ptr<metadata_extractor_h, ExtractorDeleter> pExtractor(new (nothrow) metadata_extractor_h);
- SysTryReturn(NID_CNT, pExtractor != null, null, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ metadata_extractor_h tempExtractor = NULL;
- int retVal = metadata_extractor_create(pExtractor.get());
+ int retVal = metadata_extractor_create(&tempExtractor);
result r = ErrorMapToRetVal(retVal);
SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
"[%s] metadata_extractor_create failed.", GetErrorMessage(r));
- // Set file path of content to extract the metadata
- unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(contentPath));
- SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY,
+ unique_ptr<metadata_extractor_s, ExtractorDeleter> pExtractor(tempExtractor);
+ SysTryReturn(NID_CNT, pExtractor != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- retVal = metadata_extractor_set_path(*(pExtractor.get()), pFileName.get());
+ const byte* pByte = byteBuffer.GetPointer();
+
+ retVal = metadata_extractor_set_buffer(pExtractor.get(), pByte, bufferLen);
r = ErrorMapToRetVal(retVal);
SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
"[%s] metadata_extractor_set_path failed.", GetErrorMessage(r));
// Get all relavent audio metadata by passing relavent attirbutes
- char* __pAudioMeta = null;
+ char* pTempAudioMeta = null;
unique_ptr<char, CharDeleter> pAudioMeta(null);
// bitrate
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUDIO_BITRATE, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUDIO_BITRATE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->bitrate = atoi(pAudioMeta.get());
}
else
}
// channelcount
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUDIO_CHANNELS, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUDIO_CHANNELS, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->channelCount = atoi(pAudioMeta.get());
}
else
}
// duration
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DURATION, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DURATION, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->duration = atoi(pAudioMeta.get());
}
else
}
// frequency
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUDIO_SAMPLERATE, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUDIO_SAMPLERATE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->frequency = atoi(pAudioMeta.get());
}
else
}
// albumname
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_ALBUM, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_ALBUM, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->pAlbumName = new (nothrow) String(pAudioMeta.get());
SysTryReturn(NID_CNT, pMetadata->pAlbumName != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
}
// artist
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_ARTIST, &__pAudioMeta);
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_ARTIST, &pTempAudioMeta);
if (pAudioMeta.get() != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->pArtist = new (nothrow) String(pAudioMeta.get());
SysTryReturn(NID_CNT, pMetadata->pArtist != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
}
// copyright
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_COPYRIGHT, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_COPYRIGHT, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->pCopyright = new (nothrow) String(pAudioMeta.get());
SysTryReturn(NID_CNT, pMetadata->pCopyright != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
}
// genre
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_GENRE, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_GENRE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->pGenre = new (nothrow) String(pAudioMeta.get());
SysTryReturn(NID_CNT, pMetadata->pGenre != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
}
// title
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_TITLE, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_TITLE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->pTitle = new (nothrow) String(pAudioMeta.get());
SysTryReturn(NID_CNT, pMetadata->pTitle != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
"[%s] metadata_extractor_get_metadata(title) failed.", GetErrorMessage(r));
}
- // description
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DESCRIPTION, &__pAudioMeta);
- if (__pAudioMeta != null)
+ // comment
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_COMMENT, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->pComment = new (nothrow) String(pAudioMeta.get());
SysTryReturn(NID_CNT, pMetadata->pComment != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
{
r = ErrorMapToRetVal(retVal);
SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(comment) failed.", GetErrorMessage(r));
+ }
+
+ // description
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DESCRIPTION, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
+ {
+ pAudioMeta.reset(pTempAudioMeta);
+ pMetadata->pDescription = new (nothrow) String(pAudioMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pDescription != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pAudioMetadata.release(), r,
"[%s] metadata_extractor_get_metadata(description) failed.", GetErrorMessage(r));
}
// recording date
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_RECDATE, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_RECDATE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->pRecordingDate = new (nothrow) String(pAudioMeta.get());
SysTryReturn(NID_CNT, pMetadata->pRecordingDate != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
}
// author
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUTHOR, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUTHOR, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->pComposer = new (nothrow) String(pAudioMeta.get());
SysTryReturn(NID_CNT, pMetadata->pComposer != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
}
// track info
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_TRACK_NUM, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_TRACK_NUM, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->pTrackInfo = new (nothrow) String(pAudioMeta.get());
SysTryReturn(NID_CNT, pMetadata->pTrackInfo != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
}
// date
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DATE, &__pAudioMeta);
- if (__pAudioMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DATE, &pTempAudioMeta);
+ if (pTempAudioMeta != null)
{
- pAudioMeta.reset(__pAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
pMetadata->year = atoi(pAudioMeta.get());
}
else
// artwork
int size = 0;
- void* __pArtwork = null;
+ void* pTempArtwork = null;
unique_ptr<void, VoidDeleter> pArtwork(null);
// Get the artwork image in media file
- retVal = metadata_extractor_get_artwork(*(pExtractor.get()), &__pArtwork, &size, &__pAudioMeta);
+ retVal = metadata_extractor_get_artwork(pExtractor.get(), &pTempArtwork, &size, &pTempAudioMeta);
+ pAudioMeta.reset(pTempAudioMeta);
//Check if the albumart present and pass it to client if it is successfully processed, otherwise ignore any errors
//while processing albumart. This is to pass the other metadata tags to application.
- if (__pArtwork != null)
+ if (pTempArtwork != null)
{
- pArtwork.reset(__pArtwork);
+ pArtwork.reset(pTempArtwork);
Image img;
ImageFormat format = IMG_FORMAT_NONE;
{
format = img.GetImageFormat(buffer);
pMetadata->pThumbnail = img.DecodeN(buffer, format, BITMAP_PIXEL_FORMAT_ARGB8888,
- THUMBNAIL_IMAGE_WIDTH, THUMBNAIL_IMAGE_HEIGHT);
+ _THUMBNAIL_IMAGE_WIDTH, _THUMBNAIL_IMAGE_HEIGHT);
if (pMetadata->pThumbnail == null)
{
// Because Thumbnail is one of the metadata, it is not exception in this function.
return pAudioMetadata.release();
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_OUT_OF_MEMORY
-//
VideoMetadata*
-_ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath)
+_ContentManagerUtilImpl::GetVideoMetaN(const ByteBuffer& byteBuffer)
{
ClearLastResult();
- SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), null, E_INVALID_ARG,
- "[E_INVALID_ARG] %ls is not compatible.", contentPath.GetPointer());
- SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), null, E_INVALID_ARG,
- "[E_INVALID_ARG] The file corresponding to contentPath could not be found.");
+ int bufferLen = byteBuffer.GetRemaining();
+ SysTryReturn(NID_CNT, bufferLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The length of buffer is less than zero.");
// need to create here to make sure that all get APIs will not crash in case of corrupted file
unique_ptr<VideoMetadata> pVideoMetadata(new (nothrow) VideoMetadata());
SysTryReturn(NID_CNT, pMetadata != null, null, E_INVALID_ARG,
"[E_INVALID_ARG] pMetadata is null.");
- pMetadata->contentPath = contentPath;
-
// Create the metadata extractor handle
- unique_ptr<metadata_extractor_h, ExtractorDeleter> pExtractor(new (nothrow) metadata_extractor_h);
- SysTryReturn(NID_CNT, pExtractor != null, null, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory insufficient.");
+ metadata_extractor_h tempExtractor = NULL;
- int retVal = metadata_extractor_create(pExtractor.get());
+ int retVal = metadata_extractor_create(&tempExtractor);
result r = ErrorMapToRetVal(retVal);
SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
"[%s] metadata_extractor_create failed.", GetErrorMessage(r));
- // Set file path of content to extract the metadata
- unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(contentPath));
- SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ unique_ptr<metadata_extractor_s, ExtractorDeleter> pExtractor(tempExtractor);
+ SysTryReturn(NID_CNT, pExtractor != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory insufficient.");
+
+ const byte* pByte = byteBuffer.GetPointer();
- retVal = metadata_extractor_set_path(*(pExtractor.get()), pFileName.get());
+ retVal = metadata_extractor_set_buffer(pExtractor.get(), pByte, bufferLen);
r = ErrorMapToRetVal(retVal);
SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
"[%s] metadata_extractor_set_path failed.", GetErrorMessage(r));
// Get all relavent video metadata by passing relavent attirbutes
- char* __pVideoMeta = null;
+ char* pTempVideoMeta = null;
unique_ptr<char, CharDeleter> pVideoMeta(null);
// width
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_VIDEO_WIDTH, &__pVideoMeta);
- if (__pVideoMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_VIDEO_WIDTH, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
{
- pVideoMeta.reset(__pVideoMeta);
+ pVideoMeta.reset(pTempVideoMeta);
pMetadata->width = atoi(pVideoMeta.get());
}
else
}
// height
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_VIDEO_HEIGHT, &__pVideoMeta);
- if (__pVideoMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_VIDEO_HEIGHT, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
{
- pVideoMeta.reset(__pVideoMeta);
+ pVideoMeta.reset(pTempVideoMeta);
pMetadata->height = atoi(pVideoMeta.get());
}
else
}
// video bitrate
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_VIDEO_BITRATE, &__pVideoMeta);
- if (__pVideoMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_VIDEO_BITRATE, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
{
- pVideoMeta.reset(__pVideoMeta);
+ pVideoMeta.reset(pTempVideoMeta);
pMetadata->videoBitrate = atoi(pVideoMeta.get());
}
else
}
// audio bitrate
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_AUDIO_BITRATE, &__pVideoMeta);
- if (__pVideoMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_AUDIO_BITRATE, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
{
- pVideoMeta.reset(__pVideoMeta);
+ pVideoMeta.reset(pTempVideoMeta);
pMetadata->audioBitrate = atoi(pVideoMeta.get());
}
else
}
// framerate
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_VIDEO_FPS, &__pVideoMeta);
- if (__pVideoMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_VIDEO_FPS, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
{
- pVideoMeta.reset(__pVideoMeta);
+ pVideoMeta.reset(pTempVideoMeta);
pMetadata->framerate = atoi(pVideoMeta.get());
}
else
}
// duration
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DURATION, &__pVideoMeta);
- if (__pVideoMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DURATION, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
{
- pVideoMeta.reset(__pVideoMeta);
+ pVideoMeta.reset(pTempVideoMeta);
pMetadata->duration = atoi(pVideoMeta.get());
}
else
}
// genre
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_GENRE, &__pVideoMeta);
- if (__pVideoMeta != null)
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_GENRE, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
{
- pVideoMeta.reset(__pVideoMeta);
+ pVideoMeta.reset(pTempVideoMeta);
pMetadata->pGenre = new (nothrow) String(pVideoMeta.get()); //allocate memory
SysTryReturn(NID_CNT, pMetadata->pGenre != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
"[%s] metadata_extractor_get_metadata(genre) failed.", GetErrorMessage(r));
}
+ // comment
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_COMMENT, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->pComment = new (nothrow) String(pVideoMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pComment != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(comment) failed.", GetErrorMessage(r));
+ }
+
+ // description
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_DESCRIPTION, &pTempVideoMeta);
+ if (pTempVideoMeta != null)
+ {
+ pVideoMeta.reset(pTempVideoMeta);
+ pMetadata->pDescription = new (nothrow) String(pVideoMeta.get());
+ SysTryReturn(NID_CNT, pMetadata->pDescription != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ else
+ {
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, pVideoMetadata.release(), r,
+ "[%s] metadata_extractor_get_metadata(description) failed.", GetErrorMessage(r));
+ }
+
// artwork
int size = 0;
- void* __pArtwork = null;
+ void* pTempArtwork = null;
unique_ptr<void, VoidDeleter> pArtwork(null);
// Get the artwork image in media file
- retVal = metadata_extractor_get_artwork(*(pExtractor.get()), &__pArtwork, &size, &__pVideoMeta);
- if (__pArtwork != null)
+ retVal = metadata_extractor_get_artwork(pExtractor.get(), &pTempArtwork, &size, &pTempVideoMeta);
+ pVideoMeta.reset(pTempVideoMeta);
+ if (pTempArtwork != null)
{
- pArtwork.reset(__pArtwork);
+ pArtwork.reset(pTempArtwork);
Image img;
ImageFormat format = IMG_FORMAT_NONE;
return pVideoMetadata.release();
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_OUT_OF_MEMORY
-// E_FILE_NOT_FOUND
-// E_UNSUPPORTED_FORMAT
-//
ContentType
_ContentManagerUtilImpl::CheckContentType(const String& contentPath, bool internal)
{
ClearLastResult();
ContentType contentType = CONTENT_TYPE_UNKNOWN;
+ String mimeType(L"");
if (!internal)
{
SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), contentType, E_INVALID_ARG,
- "[E_INVALID_ARG] %ls is not compatible.", contentPath.GetPointer());
+ "[E_INVALID_ARG] The path is not compatible.");
}
- SysTryReturn(NID_CNT, contentPath.GetLength() != 0, contentType, E_INVALID_ARG,
+
+ String tizenPath(L"");
+ String changedPath(L"");
+ result r = ChangeMediaFilePath(contentPath, tizenPath, changedPath);
+ SysTryReturn(NID_CNT, !IsFailed(r), contentType, r, "[%s] Failed to perform ChangeMediaFilePathCompat.", GetErrorMessage(r));
+
+ SysTryReturn(NID_CNT, changedPath.GetLength() != 0, contentType, E_INVALID_ARG,
"[E_INVALID_ARG] The length of contentPath is 0.");
- SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), contentType, E_FILE_NOT_FOUND,
+ SysTryReturn(NID_CNT, _FileImpl::IsFileExist(changedPath), contentType, E_FILE_NOT_FOUND,
"[E_FILE_NOT_FOUND] The file corresponding to contentPath could not be found.");
- String fileExt = _FileImpl::GetFileExtension(contentPath);
- // The type of ISMA and ISMV can be changed from other to video.
- String format;
- fileExt.ToLowerCase(format);
+ String fileExt = _FileImpl::GetFileExtension(changedPath);
+ r = GetLastResult();
- if (format == L"isma" || format == L"ismv")
+ if (!IsFailed(r))
{
- contentType = GetDrmFileType(format);
- result r = GetLastResult();
- SysTryReturn(NID_CNT, !IsFailed(r), contentType, r, "[%s] GetDrmFileType failed.", GetErrorMessage(r));
+ unique_ptr<char[]> pFormat(_StringConverter::CopyToCharArrayN(fileExt));
+ SysTryReturn(NID_CNT, pFormat != null, contentType, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
- return contentType;
- }
+ char* pTempMimeType = null;
+ int retVal = mime_type_get_mime_type(pFormat.get(), &pTempMimeType);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, E_INVALID_ARG,
+ "[E_INVALID_ARG] mime_type_get_mime_type failed.");
+ SysTryReturn(NID_CNT, pTempMimeType != null, contentType, E_INVALID_ARG,
+ "[E_INVALID_ARG] mime_type_get_mime_type failed.");
- int index = 0;
+ unique_ptr<char, CharDeleter> pMimeType;
+ pMimeType.reset(pTempMimeType);
- result r = String(CONTENT_FORMAT).LastIndexOf(format, String(CONTENT_FORMAT).GetLength() - 1, index);
- if (IsFailed(r))
- {
- if (r == E_OBJ_NOT_FOUND)
- {
- SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT,
- "[E_UNSUPPORTED_FORMAT] The file format is not supported[%ls].", format.GetPointer());
- }
- else
- {
- SysLogException(NID_CNT, E_INVALID_ARG,
- "[E_INVALID_ARG] The contentPath is invalid[%ls].", contentPath.GetPointer());
- }
- return contentType;
+ SysLog(NID_CNT, "The MIME type for %ls is %s", fileExt.GetPointer(), pTempMimeType);
+
+ r = mimeType.Append(pMimeType.get());
+ SysTryReturn(NID_CNT, !IsFailed(r), contentType, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Append operation.");
}
+ else
+ {
+ ClearLastResult();
- String subStr;
- int length = fileExt.GetLength();
+ SysLog(NID_CNT, "[%s] Failed to perform GetFileExtension operation.", GetErrorMessage(r));
- r = String(CONTENT_FORMAT).SubString(index+length, 1, subStr);
- SysTryReturn(NID_CNT, !(IsFailed(r)), contentType, E_INVALID_ARG, "[E_INVALID_ARG] SubString failed.");
+ unique_ptr<char[]> pTempPath(_StringConverter::CopyToCharArrayN(tizenPath));
+ SysTryReturn(NID_CNT, pTempPath != null, contentType, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
- SysLog(NID_CNT, "index = %d, length = %d, subStr = %ls", index, length, subStr.GetPointer());
+ char tempType[255] = {0, };
+ int ret = aul_get_mime_from_file(pTempPath.get(), tempType, sizeof(tempType));
+ SysTryReturn(NID_CNT, ret == AUL_R_OK, contentType, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform aul_get_mime_from_file operation.");
- const String image(L"1");
- const String audio(L"2");
- const String video(L"3");
- const String other(L"0");
- const String audioOrVideo(L"5");
+ r = mimeType.Append(tempType);
+ SysTryReturn(NID_CNT, !IsFailed(r), contentType, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Append operation.");
+ }
- if (subStr.CompareTo(image) == 0)
+ if (mimeType.Contains(L"image"))
{
return CONTENT_TYPE_IMAGE;
}
- else if (subStr.CompareTo(audio) == 0)
+ else if (mimeType.Contains(L"audio"))
{
+ if (mimeType.Contains(L"x-mpegurl"))
+ {
+ SysLog(NID_CNT, "The type of x-mpegurl is other.");
+ return CONTENT_TYPE_OTHER;
+ }
return CONTENT_TYPE_AUDIO;
}
- else if (subStr.CompareTo(video) == 0)
+ else if (mimeType.Contains(L"video"))
{
+ if (mimeType == L"video/3gpp" || mimeType == L"video/mp4")
+ {
+ return CheckStream(tizenPath);
+ }
return CONTENT_TYPE_VIDEO;
}
- else if (subStr.CompareTo(other) == 0)
+ else if (mimeType.Contains(L"application"))
{
+ if (mimeType.Contains(L"x-smaf"))
+ {
+ SysLog(NID_CNT, "The type of x-smaf is audio.");
+ return CONTENT_TYPE_AUDIO;
+ }
return CONTENT_TYPE_OTHER;
}
- else if (subStr.CompareTo(audioOrVideo) == 0)
- {
- //Create metadata extractor handle
- unique_ptr<metadata_extractor_h, ExtractorDeleter> pExtractor(new (nothrow) metadata_extractor_h);
- SysTryReturn(NID_CNT, pExtractor != null, contentType, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
- int retVal = metadata_extractor_create(pExtractor.get());
- result r = ErrorMapToRetVal(retVal);
- SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r,
- "[%s] metadata_extractor_create failed.", GetErrorMessage(r));
+ return CONTENT_TYPE_OTHER;
+}
- //Set file path of content to extract metadata.
- unique_ptr<char[]> pContentPath(_StringConverter::CopyToCharArrayN(contentPath));
- SysTryReturn(NID_CNT, pContentPath != null, contentType, E_INVALID_ARG,
- "[E_INVALID_ARG] The memory is insufficient.");
+ContentType
+_ContentManagerUtilImpl::CheckStream(const String& contentPath)
+{
+ ClearLastResult();
- retVal = metadata_extractor_set_path(*(pExtractor.get()), pContentPath.get());
- r = ErrorMapToRetVal(retVal);
- SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE && pExtractor, contentType, r,
- "[%s] metadata_extractor_set_path failed.", GetErrorMessage(r));
+ ContentType contentType = CONTENT_TYPE_UNKNOWN;
+ metadata_extractor_h tempExtractor = NULL;
- //Get the metadata info, to check whether audio or video present in the file
- char* __pAudio = null;
- unique_ptr<char> pAudio(null);
+ int retVal = metadata_extractor_create(&tempExtractor);
+ result r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r,
+ "[%s] metadata_extractor_create failed.", GetErrorMessage(r));
- char* __pVideo = null;
- unique_ptr<char> pVideo(null);
+ unique_ptr<metadata_extractor_s, ExtractorDeleter> pExtractor(tempExtractor);
+ SysTryReturn(NID_CNT, pExtractor != null, contentType, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_HAS_AUDIO, &__pAudio);
- if (__pAudio != null)
- {
- pAudio.reset(__pAudio);
- }
- else
- {
- r = ErrorMapToRetVal(retVal);
- SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r,
- "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r));
- }
+ //Set the file path to extract metadata.
+ unique_ptr<char[]> pContentPath(_StringConverter::CopyToCharArrayN(contentPath));
+ SysTryReturn(NID_CNT, pContentPath != null, contentType, E_INVALID_ARG,
+ "[E_INVALID_ARG] The memory is insufficient.");
- retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_HAS_VIDEO, &__pVideo);
- if (__pVideo != null)
- {
- pVideo.reset(__pVideo);
- }
- else
- {
- r = ErrorMapToRetVal(retVal);
- SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r,
- "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r));
- }
+ retVal = metadata_extractor_set_path(pExtractor.get(), pContentPath.get());
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE && pExtractor, contentType, r,
+ "[%s] metadata_extractor_set_path failed.", GetErrorMessage(r));
- if (*(pAudio.get()) > 0 && *(pVideo.get()) == 0)
- {
- contentType = CONTENT_TYPE_AUDIO;
- }
- else if (*(pAudio.get()) == 0 && *(pVideo.get()) > 0)
- {
- contentType = CONTENT_TYPE_VIDEO;
- }
- else if (*(pAudio.get()) > 0 && *(pVideo.get()) > 0)
- {
- contentType = CONTENT_TYPE_VIDEO;
- }
- else
- {
- SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] The stream is empty.");
- }
+ //Check whether it is an audio or video file.
+ char* pTempAudio = null;
+ unique_ptr<char, CharDeleter> pAudio(null);
+
+ char* pTempVideo = null;
+ unique_ptr<char, CharDeleter> pVideo(null);
+
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_HAS_AUDIO, &pTempAudio);
+ if (pTempAudio != null)
+ {
+ pAudio.reset(pTempAudio);
}
else
{
- // The file extension is invalid(.jp, .bm, .m).
- SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT,
- "[E_UNSUPPORTED_FORMAT] The file extension is invalid[%ls].", subStr.GetPointer());
+ // The return value is CONTENT_TYPE_VIDEO because CreaetContent have to success, even if the content is invalid.
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, CONTENT_TYPE_VIDEO, r,
+ "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r));
}
- return contentType;
-}
-
-ContentType
-_ContentManagerUtilImpl::GetDrmFileType(const String& fileExt)
-{
- ClearLastResult();
-
- unique_ptr<char[]> pFormat(_StringConverter::CopyToCharArrayN(fileExt));
- SysTryReturn(NID_CNT, pFormat != null, CONTENT_TYPE_UNKNOWN, E_OUT_OF_MEMORY,
- "The memory is insufficient.");
-
- char* __pMimeType = null;
- int retVal = mime_type_get_mime_type(pFormat.get(), &__pMimeType);
- SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, CONTENT_TYPE_UNKNOWN, E_INVALID_ARG,
- "mime_type_get_mime_type failed.");
- SysTryReturn(NID_CNT, __pMimeType != null, CONTENT_TYPE_UNKNOWN, E_INVALID_ARG,
- "mime_type_get_mime_type failed.");
-
- unique_ptr<char, CharDeleter> pMimeType;
- pMimeType.reset(__pMimeType);
-
- SysLog(NID_CNT, "The MIME type for %ls is %s", fileExt.GetPointer(), __pMimeType);
-
- String mimeType(pMimeType.get());
+ retVal = metadata_extractor_get_metadata(pExtractor.get(), METADATA_HAS_VIDEO, &pTempVideo);
+ if (pTempVideo != null)
+ {
+ pVideo.reset(pTempVideo);
+ }
+ else
+ {
+ // The return value is CONTENT_TYPE_VIDEO because CreaetContent have to success, even if the content is invalid.
+ r = ErrorMapToRetVal(retVal);
+ SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, CONTENT_TYPE_VIDEO, r,
+ "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r));
+ }
- if (mimeType == L"audio/mp4")
+ if (*(pAudio.get()) > '0' && *(pVideo.get()) == '0')
{
+ SysLog(NID_CNT, "The result of CheckStream() is audio");
return CONTENT_TYPE_AUDIO;
}
- else if (mimeType == L"video/mp4")
+ else if (*(pAudio.get()) == '0' && *(pVideo.get()) > '0')
{
+ SysLog(NID_CNT, "The result of CheckStream() is video");
return CONTENT_TYPE_VIDEO;
}
- else if (mimeType == L"application/octet-stream")
+ else if (*(pAudio.get()) > '0' && *(pVideo.get()) > '0')
{
- return CONTENT_TYPE_OTHER;
+ SysLog(NID_CNT, "The result of CheckStream() is video");
+ return CONTENT_TYPE_VIDEO;
}
else
{
- SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT, "The MIME type is invalid.");
+ SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] The stream is empty.");
}
- return CONTENT_TYPE_UNKNOWN;
+ return contentType;
}
bool
return r;
}
-/**
- * deprecation
- */
result
_ContentManagerUtilImpl::CopyToMediaDirectory(const String& srcContentPath, const String& destContentPath)
{
return r;
}
-/**
- * deprecation
- */
result
_ContentManagerUtilImpl::MoveToMediaDirectory(const String& srcContentPath, const String& destContentPath)
{
return r;
}
+
+result
+_ContentManagerUtilImpl::ChangeMediaFilePath(const String& contentPath, String& tizenPath, String& changedPath)
+{
+ result r = E_SUCCESS;
+
+ tizenPath = contentPath;
+ changedPath = contentPath;
+
+ // If the api version is 2.0, the content path has to be changed.
+ if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+ {
+ if ((contentPath.StartsWith(Environment::GetMediaPath(), 0)) || (contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
+ {
+ tizenPath = contentPath;
+
+ r = _FileImpl::ConvertPhysicalToVirtualPath(contentPath, changedPath);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG,
+ "[%s] Failed to convert physical path to virtual path.", GetErrorMessage(E_INVALID_ARG));
+ }
+ else if ((contentPath.StartsWith(OSP_MEDIA_PHONE, 0)) || (contentPath.StartsWith(OSP_MEDIA_MMC, 0)) || (contentPath.StartsWith(OSP_HOME, 0)))
+ {
+ changedPath = contentPath;
+
+ r = _FileImpl::ConvertVirtualToPhysicalPath(contentPath, tizenPath);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG,
+ "[%s] Failed to convert virtual path to physical path.", GetErrorMessage(E_INVALID_ARG));
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG, "[%s] The path is not supported.", GetErrorMessage(E_INVALID_ARG));
+ return E_INVALID_ARG;
+ }
+ }
+
+ return r;
+}
+
}}