CATCH:
// There are two steps(insert and update) for content registration.
// If the update failed after inserting, the inserted data SHOULD be deleted from here.
- val = media_info_delete_from_db(pStr.get());
+ char* pTempMediaId = null;
+ unique_ptr<char, CharDeleter> pMediaId(null);
+ val = media_info_get_media_id(pMediaInfo.get(), &pTempMediaId);
+ if (pTempMediaId != null)
+ {
+ pMediaId.reset(pTempMediaId);
+ }
+ else
+ {
+ SysLog(NID_CNT, "Failed to perform media_info_get_media_id operation.");
+ return UuId::GetInvalidUuId();
+ }
+
+ val = media_info_delete_from_db(pMediaId.get());
SysLog(NID_CNT, "The result of deletion from database[%d].", val);
return UuId::GetInvalidUuId();
if (pMediaInfo != null)
{
- val = media_info_delete_from_db(pStr.get());
+ char* pTempMediaId = null;
+ unique_ptr<char, CharDeleter> pMediaId(null);
+ val = media_info_get_media_id(pMediaInfo.get(), &pTempMediaId);
+ if (pTempMediaId != null)
+ {
+ pMediaId.reset(pTempMediaId);
+ }
+ else
+ {
+ SysLog(NID_CNT, "Failed to perform media_info_get_media_id operation.");
+ return UuId::GetInvalidUuId();
+ }
+
+ val = media_info_delete_from_db(pMediaId.get());
SysLog(NID_CNT, "The result of deletion from database[%d].", val);
}
SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath), UuId::GetInvalidUuId(),
E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
- result r = E_SUCCESS;
- bool isCopy = false;
-
- if (deleteSource) // move
- {
- r = _FileImpl::Move(sourcePath, destinationPath);
- SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Moving the file failed.", GetErrorMessage(r));
- }
- else // copy
- {
- r = _FileImpl::Copy(sourcePath, destinationPath, true);
- SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
-
- isCopy = true;
- }
+ result r = _FileImpl::Copy(sourcePath, destinationPath, true);
+ SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
int val = 0;
ContentId contentId;
SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
"[%s] SaveDataToDatabase failed.", GetErrorMessage(r));
+ if (deleteSource)
+ {
+ unique_ptr<char[]> pContentPath(_StringConverter::CopyToCharArrayN(sourcePath));
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY, "[%s] pContentPath is null.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ r = _FileImpl::Remove(sourcePath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , r, "[%s] Failed to perform Remove operation.", GetErrorMessage(r));
+
+ val = media_content_scan_file(pContentPath.get());
+ SysTryLog(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, "Failed to perform media_content_scan_file[%d].", val);
+ }
+
return contentId;
CATCH:
result saveResult = GetLastResult();
- if (isCopy)
- {
- r = _FileImpl::Remove(destinationPath);
- SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
- }
- else
- {
- r = _FileImpl::Move(destinationPath, sourcePath);
- SysLog(NID_CNT, "Move[%s].", GetErrorMessage(r));
- }
+ r = _FileImpl::Remove(destinationPath);
+ SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
if (pMediaInfo != null)
{
- val = media_info_delete_from_db(pStr.get());
+ char* pTempMediaId = null;
+ unique_ptr<char, CharDeleter> pMediaId(null);
+ val = media_info_get_media_id(pMediaInfo.get(), &pTempMediaId);
+ if (pTempMediaId != null)
+ {
+ pMediaId.reset(pTempMediaId);
+ }
+ else
+ {
+ SysLog(NID_CNT, "Failed to perform media_info_get_media_id operation.");
+ return UuId::GetInvalidUuId();
+ }
+
+ val = media_info_delete_from_db(pMediaId.get());
SysLog(NID_CNT, "The result of deletion from database[%d].", val);
}
pVideoContentInfoImpl->SetDuration(intValue);
SysLog(NID_CNT, "META: duration[%d]", intValue);
- // Get from metadata extractor (framerate, audio bitrate, video bitrate)
- VideoMetadata* pVideoMetadata = ContentManagerUtil::GetVideoMetaN(pVideoContentInfoImpl->GetContentPath());
- result r = GetLastResult();
- SysTryReturnResult(NID_CNT, pVideoMetadata != null, r, "GetVideoMetadata() failed.");
-
- pVideoContentInfoImpl->SetFramerate(pVideoMetadata->GetFramerate());
- pVideoContentInfoImpl->SetAudioBitrate(pVideoMetadata->GetAudioBitrate());
- pVideoContentInfoImpl->SetVideoBitrate(pVideoMetadata->GetVideoBitrate());
+ // Get some information from metadata extractor when calling VideoContentInfo (framerate, audio bitrate, video bitrate)
return E_SUCCESS;
}