Fix : Extract the gps information according to a locale
[platform/framework/native/content.git] / src / FCnt_ContentManagerUtilImpl.cpp
index d73ed3d..3393c15 100755 (executable)
@@ -105,9 +105,14 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
        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(contentPath));
+               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.");
 
@@ -123,6 +128,9 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
                        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++)
                        {
@@ -162,11 +170,13 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
                                                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)
                                        {
@@ -178,11 +188,25 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
                                        {
                                                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)
                                        {
                                                String tempLatitude(buf);
-                                               String delim(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"", };
 
@@ -192,15 +216,15 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
                                                        strTok.GetNextToken(token[count++]);
                                                }
 
-                                               double ddVal = _LocalizedNumParser::ToDouble(token[0], "C"); // degree value
+                                               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], "C"); // minutes value
+                                               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], "C"); // seconds value
+                                               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.");
 
@@ -211,16 +235,31 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
                                                {
                                                        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)
                                        {
                                                String tempLongitude(buf);
-                                               String delim(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"", };
 
@@ -230,15 +269,15 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
                                                        strTok.GetNextToken(token[count++]);
                                                }
 
-                                               double ddVal = _LocalizedNumParser::ToDouble(token[0], "C"); // degree value
+                                               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], "C"); // minutes value
+                                               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], "C"); // seconds value
+                                               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.");
 
@@ -249,6 +288,7 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
                                                {
                                                        pMetadata->longitude = (pMetadata->longitude * (double)(-1));
                                                }
+                                               isLongitude = true;
                                        }
                                        else if (tag == EXIF_TAG_WHITE_BALANCE)
                                        {
@@ -289,11 +329,16 @@ _ContentManagerUtilImpl::GetAudioMetaN(const String& contentPath)
 
        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);
-       result r = ErrorMapToRetVal(retVal);
+       r = ErrorMapToRetVal(retVal);
        SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
                        "[%s] metadata_extractor_create failed.", GetErrorMessage(r));
 
@@ -302,7 +347,7 @@ _ContentManagerUtilImpl::GetAudioMetaN(const String& contentPath)
                        "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        // Set file path of content to extract the metadata
-       unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(contentPath));
+       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.");
 
@@ -631,11 +676,16 @@ _ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath)
 
        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);
-       result r = ErrorMapToRetVal(retVal);
+       r = ErrorMapToRetVal(retVal);
        SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
                        "[%s] metadata_extractor_create failed.", GetErrorMessage(r));
 
@@ -644,7 +694,7 @@ _ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath)
                                "[E_OUT_OF_MEMORY] The memory insufficient.");
 
        // Set file path of content to extract the metadata
-       unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(contentPath));
+       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.");
 
@@ -861,6 +911,9 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer)
        ImageFormat imgType = IMG_FORMAT_NONE;
        int imageWidth = 0;
        int imageHeight = 0;
+       bool isOrientation = false;
+       bool isLatitude = false;
+       bool isLongitude = false;
 
        result r = ImageBuffer::GetImageInfo(byteBuffer, imgType, imageWidth, imageHeight);
        SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_INVALID_ARG,
@@ -924,11 +977,13 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer)
                                                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)
                                        {
@@ -940,11 +995,25 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer)
                                        {
                                                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)
                                        {
                                                String tempLatitude(buf);
-                                               String delim(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"", };
 
@@ -954,15 +1023,15 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer)
                                                        strTok.GetNextToken(token[count++]);
                                                }
 
-                                               double ddVal = _LocalizedNumParser::ToDouble(token[0], "C"); // degree value
+                                               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], "C"); // minutes value
+                                               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], "C"); // seconds value
+                                               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.");
 
@@ -973,16 +1042,31 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer)
                                                {
                                                        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)
                                        {
                                                String tempLongitude(buf);
-                                               String delim(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"", };
 
@@ -992,15 +1076,15 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer)
                                                        strTok.GetNextToken(token[count++]);
                                                }
 
-                                               double ddVal = _LocalizedNumParser::ToDouble(token[0], "C"); // degree value
+                                               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], "C"); // minutes value
+                                               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], "C"); // seconds value
+                                               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.");
 
@@ -1011,6 +1095,7 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer)
                                                {
                                                        pMetadata->longitude = (pMetadata->longitude * (double)(-1));
                                                }
+                                               isLongitude = true;
                                        }
                                        else if (tag == EXIF_TAG_WHITE_BALANCE)
                                        {
@@ -1597,13 +1682,19 @@ _ContentManagerUtilImpl::CheckContentType(const String& contentPath, bool intern
                SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), contentType, E_INVALID_ARG,
                                "[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);
-       result r = GetLastResult();
+       String fileExt = _FileImpl::GetFileExtension(changedPath);
+       r = GetLastResult();
 
        if (!IsFailed(r))
        {
@@ -1629,9 +1720,11 @@ _ContentManagerUtilImpl::CheckContentType(const String& contentPath, bool intern
        }
        else
        {
+               ClearLastResult();
+
                SysLog(NID_CNT, "[%s] Failed to perform GetFileExtension operation.", GetErrorMessage(r));
 
-               unique_ptr<char[]> pTempPath(_StringConverter::CopyToCharArrayN(contentPath));
+               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.");
 
@@ -1662,7 +1755,7 @@ _ContentManagerUtilImpl::CheckContentType(const String& contentPath, bool intern
        {
                if (mimeType == L"video/3gpp" || mimeType == L"video/mp4")
                {
-                       return CheckStream(contentPath);
+                       return CheckStream(tizenPath);
                }
                return CONTENT_TYPE_VIDEO;
        }
@@ -1720,8 +1813,9 @@ _ContentManagerUtilImpl::CheckStream(const String& contentPath)
        }
        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, contentType, r,
+               SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, CONTENT_TYPE_VIDEO, r,
                                "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r));
        }
 
@@ -1732,8 +1826,9 @@ _ContentManagerUtilImpl::CheckStream(const String& contentPath)
        }
        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, contentType, r,
+               SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, CONTENT_TYPE_VIDEO, r,
                                "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r));
        }
 
@@ -1861,4 +1956,41 @@ _ContentManagerUtilImpl::MoveToMediaDirectory(const String& srcContentPath, cons
        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;
+}
+
 }}