#include <new>
#include <stdlib.h>
+#include <aul/aul.h>
#include <mime_type.h>
#include <FAppApp.h>
#include <FBaseByteBuffer.h>
#include "FCnt_ImageMetadataImpl.h"
#include "FCnt_VideoMetadataImpl.h"
-
using namespace std;
using namespace Tizen::App;
using namespace Tizen::Base;
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;
ClearLastResult();
ContentType contentType = CONTENT_TYPE_UNKNOWN;
+ String mimeType(L"");
if (!internal)
{
String fileExt = _FileImpl::GetFileExtension(contentPath);
result r = GetLastResult();
- SysTryReturn(NID_CNT, !IsFailed(r), contentType, r, "[%s] GetFileExtension 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.");
+ if (!IsFailed(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.");
- 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.");
+ 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.");
- unique_ptr<char, CharDeleter> pMimeType;
- pMimeType.reset(pTempMimeType);
+ unique_ptr<char, CharDeleter> pMimeType;
+ pMimeType.reset(pTempMimeType);
- SysLog(NID_CNT, "The MIME type for %ls is %s", fileExt.GetPointer(), pTempMimeType);
+ SysLog(NID_CNT, "The MIME type for %ls is %s", fileExt.GetPointer(), pTempMimeType);
- String mimeType(pMimeType.get());
+ 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
+ {
+ SysLog(NID_CNT, "[%s] Failed to perform GetFileExtension operation.", GetErrorMessage(r));
+
+ unique_ptr<char[]> pTempPath(_StringConverter::CopyToCharArrayN(contentPath));
+ SysTryReturn(NID_CNT, pTempPath != null, contentType, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ 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.");
+
+ r = mimeType.Append(tempType);
+ SysTryReturn(NID_CNT, !IsFailed(r), contentType, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Append operation.");
+ }
if (mimeType.Contains(L"image"))
{
}
else if (mimeType.Contains(L"video"))
{
- String format;
- fileExt.ToLowerCase(format);
-
- if (format == L"3gp" || format == L"mp4")
+ if (mimeType == L"video/3gpp" || mimeType == L"video/mp4")
{
return CheckStream(contentPath);
}
return r;
}
+
}}