diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-02-01 13:46:18 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-02-01 13:46:18 +0900 |
commit | f79d6b73d64fb7c223211cc674c0a94da3ca4a02 (patch) | |
tree | b67fea3d86252a91dd08552950c4dd4dc1f42acb | |
parent | 113ece21d830a9101ada9151eba0182cd15d7364 (diff) | |
download | libmm-fileinfo-tizen_2.3.tar.gz libmm-fileinfo-tizen_2.3.tar.bz2 libmm-fileinfo-tizen_2.3.zip |
tizen 2.3 releasetizen_2.3_releasesubmit/tizen_2.3/20150202.062953tizen_2.3
-rwxr-xr-x | configure.ac | 23 | ||||
-rwxr-xr-x | formats/ffmpeg/Makefile.am | 8 | ||||
-rwxr-xr-x | formats/ffmpeg/include/mm_file_format_ffmpeg_drm.h | 37 | ||||
-rwxr-xr-x | formats/ffmpeg/mm_file_format_ffmpeg.c | 87 | ||||
-rwxr-xr-x | formats/ffmpeg/mm_file_format_frame.c | 14 | ||||
-rwxr-xr-x | formats/ffmpeg/mm_file_format_imelody.c | 6 | ||||
-rwxr-xr-x | formats/ffmpeg/mm_file_format_wav.c | 21 | ||||
-rwxr-xr-x | formats/ffmpeg/mm_file_formats.c | 76 | ||||
-rwxr-xr-x | include/mm_file.h | 3 | ||||
-rwxr-xr-x | include/mm_file_formats.h | 9 | ||||
-rwxr-xr-x | mm_file.c | 92 | ||||
-rwxr-xr-x | packaging/libmm-fileinfo.spec | 17 | ||||
-rwxr-xr-x | tests/mm_file_test.c | 5 | ||||
-rwxr-xr-x | utils/mm_file_util_locale.c | 23 | ||||
-rwxr-xr-x | utils/mm_file_util_tag.c | 51 | ||||
-rwxr-xr-x | utils/mm_file_util_validity.c | 18 |
16 files changed, 291 insertions, 199 deletions
diff --git a/configure.ac b/configure.ac index 9ebdc60..86b4542 100755 --- a/configure.ac +++ b/configure.ac @@ -48,16 +48,10 @@ PKG_CHECK_MODULES(MMCOMMON,mm-common) AC_SUBST(MMCOMMON_CFLAGS) AC_SUBST(MMCOMMON_LIBS) -#PKG_CHECK_MODULES(MMMHAL,mm-mhal) -#AC_SUBST(MMMHAL_CFLAGS) -#AC_SUBST(MMMHAL_LIBS) - PKG_CHECK_MODULES(MMLOG,mm-log) AC_SUBST(MMLOG_CFLAGS) AC_SUBST(MMLOG_LIBS) - - PKG_CHECK_MODULES(GLIB, glib-2.0) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) @@ -66,7 +60,6 @@ PKG_CHECK_MODULES(GTK, gtk+-2.0, [HAVE_GTK=yes], [HAVE_GTK=no]) AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) - PKG_CHECK_MODULES(AVCODEC, libavcodec) AC_SUBST(AVCODEC_CFLAGS) AC_SUBST(AVCODEC_LIBS) @@ -91,22 +84,6 @@ PKG_CHECK_MODULES(VCONF, vconf) AC_SUBST(VCONF_CFLAGS) AC_SUBST(VCONF_LIBS) -dnl use drm -------------------------------------------------------------------------- -AC_ARG_ENABLE(drm, AC_HELP_STRING([--enable-drm], [using drm]), -[ - case "${enableval}" in - yes) USE_DRM=yes ;; - no) USE_DRM=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-drm) ;; - esac -],[USE_DRM=yes]) -if test "x$USE_DRM" = "xyes"; then - PKG_CHECK_MODULES(DRMCLIENT, drm-client) - AC_SUBST(DRMCLIENT_CFLAGS) - AC_SUBST(DRMCLIENT_LIBS) -fi -AM_CONDITIONAL(USE_DRM, test "x$USE_DRM" = "xyes") - dnl use dyn -------------------------------------------------------------------------- AC_ARG_ENABLE(dyn, AC_HELP_STRING([--enable-dyn], [using dyn]), [ diff --git a/formats/ffmpeg/Makefile.am b/formats/ffmpeg/Makefile.am index 6983699..4d93a50 100755 --- a/formats/ffmpeg/Makefile.am +++ b/formats/ffmpeg/Makefile.am @@ -47,10 +47,6 @@ if USE_DUMP libmmfile_formats_la_CFLAGS += -DMMFILE_FORMAT_DEBUG_DUMP endif -if USE_DRM -libmmfile_formats_la_CFLAGS += $(DRMCLIENT_CFLAGS) -DDRM_SUPPORT -endif - if USE_IOMMAP libmmfile_formats_la_CFLAGS += -D__MMFILE_MMAP_MODE__ endif @@ -63,10 +59,6 @@ libmmfile_formats_la_LIBADD = $(MMCOMMON_LIBS) \ $(SWSCALE_LIBS) \ $(top_builddir)/utils/libmmfile_utils.la -if USE_DRM -libmmfile_formats_la_LIBADD += $(DRMCLIENT_LIBS) -endif - libmmfile_formats_la_CFLAGS += $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x040 -DMMF_DEBUG_PREFIX=\"MMF-FILE-FORMAT-FFMPEG\" libmmfile_formats_la_LIBADD += $(MMLOG_LIBS) diff --git a/formats/ffmpeg/include/mm_file_format_ffmpeg_drm.h b/formats/ffmpeg/include/mm_file_format_ffmpeg_drm.h deleted file mode 100755 index 092fd8c..0000000 --- a/formats/ffmpeg/include/mm_file_format_ffmpeg_drm.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * libmm-fileinfo - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Haejeong Kim <backto.kim@samsung.com> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef _MM_FILE_PLUGIN_FFMPEG_H_ -#define _MM_FILE_PLUGIN_FFMPEG_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <libavformat/avformat.h> - -extern URLProtocol MMFileDRMProtocol; - -#ifdef __cplusplus -} -#endif - -#endif /* _MM_FILE_PLUGIN_FFMPEG_H_ */ diff --git a/formats/ffmpeg/mm_file_format_ffmpeg.c b/formats/ffmpeg/mm_file_format_ffmpeg.c index a248e2b..bf37f36 100755 --- a/formats/ffmpeg/mm_file_format_ffmpeg.c +++ b/formats/ffmpeg/mm_file_format_ffmpeg.c @@ -24,24 +24,18 @@ #include <libavformat/avformat.h> #include <libavcodec/avcodec.h> +#include <libavutil/samplefmt.h> #ifdef __MMFILE_FFMPEG_V085__ #include <libswscale/swscale.h> #endif #include <mm_error.h> #include <mm_types.h> -#ifdef DRM_SUPPORT -#include <drm_client.h> -#endif #include "mm_debug.h" #include "mm_file_formats.h" #include "mm_file_utils.h" #include "mm_file_format_ffmpeg.h" -#ifdef DRM_SUPPORT -#include "mm_file_format_ffmpeg_drm.h" -#endif - #include "mm_file_format_ffmpeg_mem.h" #include <sys/time.h> @@ -59,7 +53,7 @@ static void _dump_av_packet (AVPacket *pkt); #endif static int _get_video_fps (int frame_cnt, int duration, AVRational r_frame_rate, int is_roundup); -static int _get_first_good_video_frame (AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, int videoStream, AVFrame **pFrame); +static int _get_first_good_video_frame (AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, int videoStream, AVFrame **pFrame, int cdis); static int ConvertVideoCodecEnum (int AVVideoCodecID); static int ConvertAudioCodecEnum (int AVAudioCodecID); @@ -80,9 +74,6 @@ int mmfile_format_open_ffmpg (MMFileFormatContext *formatContext) AVInputFormat *grab_iformat = NULL; int ret = 0; int i; -#ifdef DRM_SUPPORT - drm_content_info_s contentInfo = {0,}; -#endif char ffmpegFormatName[MMFILE_FILE_FMT_MAX_LEN] = {0,}; char mimeType[MMFILE_MIMETYPE_MAX_LEN] = {0,}; @@ -151,23 +142,16 @@ int mmfile_format_open_ffmpg (MMFileFormatContext *formatContext) } if (formatContext->filesrc->type == MM_FILE_SRC_TYPE_FILE) { - - if (formatContext->isdrm == MM_FILE_DRM_OMA) { - debug_error ("error: drm content\n"); - goto exception; - } else { -HANDLING_DRM_DIVX: #ifdef __MMFILE_FFMPEG_V085__ - ret = avformat_open_input(&pFormatCtx, formatContext->filesrc->file.path, NULL, NULL); + ret = avformat_open_input(&pFormatCtx, formatContext->filesrc->file.path, NULL, NULL); #else - ret = av_open_input_file(&pFormatCtx, formatContext->filesrc->file.path, NULL, 0, NULL); + ret = av_open_input_file(&pFormatCtx, formatContext->filesrc->file.path, NULL, 0, NULL); #endif - if (ret < 0) { - debug_error("error: cannot open %s %d\n", formatContext->filesrc->file.path, ret); - goto exception; - } - formatContext->privateFormatData = pFormatCtx; + if (ret < 0) { + debug_error("error: cannot open %s %d\n", formatContext->filesrc->file.path, ret); + goto exception; } + formatContext->privateFormatData = pFormatCtx; } if (!pFormatCtx || !(pFormatCtx->nb_streams > 0)) { @@ -237,6 +221,25 @@ exception: /* fail to get content information */ return MMFILE_FORMAT_FAIL; } +static bool __check_uhqa(int sample_rate, enum AVSampleFormat sample_fmt_info) +{ + bool ret = FALSE; + +#ifdef __MMFILE_TEST_MODE__ + debug_error("[sample rate %d, sample format %d]", sample_rate, sample_fmt_info); +#endif + + if ((sample_rate >= 44100) && (sample_fmt_info >= AV_SAMPLE_FMT_S32)) { +#ifdef __MMFILE_TEST_MODE__ + debug_msg("UHQA CONTENT"); +#endif + ret = TRUE; + } else { + ret = FALSE; + } + + return ret; +} EXPORT_API int mmfile_format_read_stream_ffmpg (MMFileFormatContext * formatContext) @@ -366,6 +369,8 @@ int mmfile_format_read_stream_ffmpg (MMFileFormatContext * formatContext) audioStream->bitRate = pAudioCodecCtx->bit_rate; audioStream->nbChannel = pAudioCodecCtx->channels; audioStream->samplePerSec = pAudioCodecCtx->sample_rate; + audioStream->bitPerSample = pAudioCodecCtx->bits_per_raw_sample; + audioStream->is_uhqa = __check_uhqa(audioStream->samplePerSec, pFormatCtx->streams[i]->codec->sample_fmt); } } } @@ -659,6 +664,11 @@ int mmfile_format_read_frame_ffmpg (MMFileFormatContext *formatContext, unsigne return MMFILE_FORMAT_FAIL; } + if (formatContext->isdrm == MM_FILE_DRM_PROTECTED) { + debug_error ("This is protected drm file\n"); + return MMFILE_FORMAT_FAIL; + } + pFormatCtx = formatContext->privateFormatData; if (formatContext->videoStreamId != -1) { @@ -693,6 +703,11 @@ int mmfile_format_read_frame_ffmpg (MMFileFormatContext *formatContext, unsigne /*set workaround bug flag*/ pVideoCodecCtx->workaround_bugs = FF_BUG_AUTODETECT; #ifdef __MMFILE_FFMPEG_V100__ + /* this is solution for PLM issue P13091703323 */ + /* If using thread when decoding frame, the result of decoding is not always same. + Thumbnail of video content is different with original file when copying file. */ + pVideoCodecCtx->thread_type = 0; + pVideoCodecCtx->thread_count = 0; ret = avcodec_open2 (pVideoCodecCtx, pVideoCodec, NULL); #else ret = avcodec_open (pVideoCodecCtx, pVideoCodec); @@ -712,7 +727,7 @@ int mmfile_format_read_frame_ffmpg (MMFileFormatContext *formatContext, unsigne /* search & decode */ // seek_ts = formatContext->duration > _SHORT_MEDIA_LIMIT ? seek_ts : 0; /*if short media, seek first key frame*/ - ret = _get_first_good_video_frame (pFormatCtx, pVideoCodecCtx, formatContext->videoStreamId, &pFrame); + ret = _get_first_good_video_frame (pFormatCtx, pVideoCodecCtx, formatContext->videoStreamId, &pFrame, formatContext->cdis); if ( ret != MMFILE_FORMAT_SUCCESS ) { debug_error ("error: get key frame\n"); ret = MMFILE_FORMAT_FAIL; @@ -988,7 +1003,7 @@ static void _dump_av_packet (AVPacket *pkt) } #endif -static int _get_first_good_video_frame (AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, int videoStream, AVFrame **pFrame) +static int _get_first_good_video_frame (AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, int videoStream, AVFrame **pFrame, int cdis) { // AVStream *st = NULL; AVPacket pkt; @@ -1007,10 +1022,16 @@ static int _get_first_good_video_frame (AVFormatContext *pFormatCtx, AVCodecCont #ifdef MMFILE_FORMAT_DEBUG_DUMP char pgm_name[256] = {0,}; #endif + int key_search_limit = 0; + int frame_search_limit = 0; -#define _RETRY_SEARCH_LIMIT 150 +#define _RETRY_SEARCH_LIMIT 75 #define _KEY_SEARCH_LIMIT (_RETRY_SEARCH_LIMIT*2) /*2 = 1 read. some frame need to read one more*/ -#define _FRAME_SEARCH_LIMIT 1000 +#define _FRAME_SEARCH_LIMIT 500 + +#define _RETRY_SEARCH_LIMIT_CDIS 10 +#define _KEY_SEARCH_LIMIT_CDIS (_RETRY_SEARCH_LIMIT*2) /*2 = 1 read. some frame need to read one more*/ +#define _FRAME_SEARCH_LIMIT_CDIS 10 first_frame = avcodec_alloc_frame (); tmp_frame = avcodec_alloc_frame (); @@ -1032,7 +1053,15 @@ static int _get_first_good_video_frame (AVFormatContext *pFormatCtx, AVCodecCont pCodecCtx->hurry_up = 1; #endif - for(i = 0, v = 0, key_detected = 0, frame = first_frame; i < _KEY_SEARCH_LIMIT && v < _FRAME_SEARCH_LIMIT;) { + if (cdis == 1) { + key_search_limit = _KEY_SEARCH_LIMIT_CDIS; + frame_search_limit = _FRAME_SEARCH_LIMIT_CDIS; + } else { + key_search_limit = _KEY_SEARCH_LIMIT; + frame_search_limit = _FRAME_SEARCH_LIMIT; + } + + for(i = 0, v = 0, key_detected = 0, frame = first_frame; i < key_search_limit && v < frame_search_limit;) { av_init_packet (&pkt); got_picture = 0; diff --git a/formats/ffmpeg/mm_file_format_frame.c b/formats/ffmpeg/mm_file_format_frame.c index 923888b..15f5bd1 100755 --- a/formats/ffmpeg/mm_file_format_frame.c +++ b/formats/ffmpeg/mm_file_format_frame.c @@ -30,10 +30,6 @@ #include "mm_file_format_ffmpeg_mem.h" #include "mm_file_format_frame.h" -#ifdef DRM_SUPPORT -#include <drm_client.h> -#endif - #define MILLION 1000000 #ifdef MMFILE_FORMAT_DEBUG_DUMP static void __save_frame(AVFrame *pFrame, int width, int height, int iFrame); @@ -523,19 +519,11 @@ int mmfile_format_get_frame(const char* path, double timestamp, bool is_accurate { int ret = MMFILE_FORMAT_SUCCESS; AVFormatContext *pFormatCtx = NULL; - drm_bool_type_e res = DRM_FALSE; if (!size || !width || !height) { return MMFILE_FORMAT_FAIL; } -#ifdef DRM_SUPPORT - ret = drm_is_drm_file (path, &res); - if (DRM_TRUE == res) - { - debug_error ("Not support DRM Contents\n"); - return MMFILE_FORMAT_FAIL; - } -#endif + av_register_all(); /* Open video file */ diff --git a/formats/ffmpeg/mm_file_format_imelody.c b/formats/ffmpeg/mm_file_format_imelody.c index 5baefbd..d3e7297 100755 --- a/formats/ffmpeg/mm_file_format_imelody.c +++ b/formats/ffmpeg/mm_file_format_imelody.c @@ -416,14 +416,20 @@ static int __get_imelody_tag (const char *uriname, tMMFileImelodyTagInfo *tags) { if (!strncmp (imy_key_buffer, "NAME", 4)) { + if(tags->title != NULL) + mmfile_free(tags->title); tags->title = mmfile_strdup (imy_value_buffer); } else if (!strncmp (imy_key_buffer, "COMPOSER", 8)) { + if(tags->composer != NULL) + mmfile_free(tags->composer); tags->composer = mmfile_strdup (imy_value_buffer); } else if (!strncmp (imy_key_buffer, "COPYRIGHT", 9)) { + if(tags->copyright != NULL) + mmfile_free(tags->copyright); tags->copyright = mmfile_strdup (imy_value_buffer); } diff --git a/formats/ffmpeg/mm_file_format_wav.c b/formats/ffmpeg/mm_file_format_wav.c index a035001..bbe04d2 100755 --- a/formats/ffmpeg/mm_file_format_wav.c +++ b/formats/ffmpeg/mm_file_format_wav.c @@ -222,6 +222,25 @@ int mmfile_format_open_wav (MMFileFormatContext *formatContext) return MMFILE_FORMAT_SUCCESS; } +static bool __check_uhqa(int sample_rate, short bits_per_sample) +{ + bool ret = FALSE; + +#ifdef __MMFILE_TEST_MODE__ + debug_error("[sample rate %d, sample format %d]", sample_rate, bits_per_sample); +#endif + + if ((sample_rate >= 44100) && (bits_per_sample >= 24)) { +#ifdef __MMFILE_TEST_MODE__ + debug_msg("UHQA CONTENT"); +#endif + ret = TRUE; + } else { + ret = FALSE; + } + + return ret; +} EXPORT_API int mmfile_format_read_stream_wav (MMFileFormatContext *formatContext) @@ -311,6 +330,8 @@ int mmfile_format_read_stream_wav (MMFileFormatContext *formatContext) formatContext->streams[MMFILE_AUDIO_STREAM]->nbChannel = waveinfo->channel; formatContext->streams[MMFILE_AUDIO_STREAM]->framePerSec = 0; formatContext->streams[MMFILE_AUDIO_STREAM]->samplePerSec = waveinfo->sample_rate; + formatContext->streams[MMFILE_AUDIO_STREAM]->bitPerSample = waveinfo->bits_per_sample; + formatContext->streams[MMFILE_AUDIO_STREAM]->is_uhqa = __check_uhqa(waveinfo->sample_rate, waveinfo->bits_per_sample); return MMFILE_FORMAT_SUCCESS; diff --git a/formats/ffmpeg/mm_file_formats.c b/formats/ffmpeg/mm_file_formats.c index f77c070..573d262 100755 --- a/formats/ffmpeg/mm_file_formats.c +++ b/formats/ffmpeg/mm_file_formats.c @@ -23,11 +23,6 @@ #include <string.h> #include <stdlib.h> -#ifdef DRM_SUPPORT -#include <drm_client.h> -#endif - - #include "mm_debug.h" #include "mm_file_format_private.h" #include "mm_file_utils.h" @@ -170,60 +165,32 @@ _PreprocessFile (MMFileSourceType *fileSrc, char **urifilename, int *formatEnum, return MMFILE_FORMAT_FAIL; /*invalid file name*/ } -#ifdef DRM_SUPPORT - /** - * Make URI name with file name - */ - drm_bool_type_e res = DRM_TRUE; - drm_file_type_e file_type = DRM_TYPE_UNDEFINED; - int ret = 0; - bool is_drm = FALSE; - - ret = drm_is_drm_file (fileSrc->file.path, &res); - if (ret == DRM_RETURN_SUCCESS && DRM_TRUE == res) - { - ret = drm_get_file_type(fileSrc->file.path, &file_type); - if((ret == DRM_RETURN_SUCCESS) && ((file_type == DRM_TYPE_OMA_V1) ||(file_type == DRM_TYPE_OMA_V2))) - { - is_drm = TRUE; - } - } - - if (is_drm) - { - *isdrm = MM_FILE_DRM_OMA; - debug_error ("OMA DRM detected. Not Support DRM Content\n"); - return MMFILE_FORMAT_FAIL; /*Not Support DRM Content*/ - } - else -#endif // DRM_SUPPORT - { - *isdrm = MM_FILE_DRM_NONE; + + *isdrm = MM_FILE_DRM_NONE; #ifdef __MMFILE_MMAP_MODE__ - *urifilename = mmfile_malloc (MMFILE_MMAP_URI_LEN + filename_len + 1); - if (!*urifilename) { - debug_error ("error: mmfile_malloc uriname\n"); - return MMFILE_FORMAT_FAIL; - } + *urifilename = mmfile_malloc (MMFILE_MMAP_URI_LEN + filename_len + 1); + if (!*urifilename) { + debug_error ("error: mmfile_malloc uriname\n"); + return MMFILE_FORMAT_FAIL; + } - memset (*urifilename, 0x00, MMFILE_MMAP_URI_LEN + filename_len + 1); - strncpy (*urifilename, MMFILE_MMAP_URI, MMFILE_MMAP_URI_LEN); - strncat (*urifilename, fileName, filename_len); - (*urifilename)[MMFILE_MMAP_URI_LEN + filename_len] = '\0'; + memset (*urifilename, 0x00, MMFILE_MMAP_URI_LEN + filename_len + 1); + strncpy (*urifilename, MMFILE_MMAP_URI, MMFILE_MMAP_URI_LEN); + strncat (*urifilename, fileName, filename_len); + (*urifilename)[MMFILE_MMAP_URI_LEN + filename_len] = '\0'; #else - *urifilename = mmfile_malloc (MMFILE_FILE_URI_LEN + filename_len + 1); - if (!*urifilename) { - debug_error ("error: mmfile_malloc uriname\n"); - return MMFILE_FORMAT_FAIL; - } + *urifilename = mmfile_malloc (MMFILE_FILE_URI_LEN + filename_len + 1); + if (!*urifilename) { + debug_error ("error: mmfile_malloc uriname\n"); + return MMFILE_FORMAT_FAIL; + } - memset (*urifilename, 0x00, MMFILE_FILE_URI_LEN + filename_len + 1); - strncpy (*urifilename, MMFILE_FILE_URI, MMFILE_FILE_URI_LEN+1); - strncat (*urifilename, fileName, filename_len); - (*urifilename)[MMFILE_FILE_URI_LEN + filename_len] = '\0'; + memset (*urifilename, 0x00, MMFILE_FILE_URI_LEN + filename_len + 1); + strncpy (*urifilename, MMFILE_FILE_URI, MMFILE_FILE_URI_LEN+1); + strncat (*urifilename, fileName, filename_len); + (*urifilename)[MMFILE_FILE_URI_LEN + filename_len] = '\0'; #endif - } /////////////////////////////////////////////////////////////////////// // Check File format // @@ -867,7 +834,8 @@ int mmfile_format_open (MMFileFormatContext **formatContext, MMFileSourceType *f if (MMFILE_FORMAT_FAIL == ret) { debug_error ("error: Try other formats\n"); ret = MMFILE_FORMAT_FAIL; - goto find_valid_handler; +// goto find_valid_handler; + goto exception; } *formatContext = formatObject; diff --git a/include/mm_file.h b/include/mm_file.h index 058fb25..f752690 100755 --- a/include/mm_file.h +++ b/include/mm_file.h @@ -69,6 +69,7 @@ extern "C" { #define MM_FILE_CONTENT_AUDIO_SAMPLERATE "content-audio-samplerate" /**< Sampling rate of audio stream */ #define MM_FILE_CONTENT_AUDIO_TRACK_INDEX "content-audio-track-index" /**< Current stream of audio */ #define MM_FILE_CONTENT_AUDIO_TRACK_COUNT "content-audio-track-count"/**< Number of audio streams */ +#define MM_FILE_CONTENT_AUDIO_BITPERSAMPLE "content-audio-bitpersample" /**< Bit per sample of audio stream */ /** * tag attributes. @@ -589,6 +590,8 @@ int mm_file_get_video_frame(const char* path, double timestamp, bool is_accurate int mm_file_get_video_frame_from_memory(const void *data, unsigned int datasize, double timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height); +int mm_file_check_uhqa(const char* filename, bool *is_uhqa); + /** @} */ diff --git a/include/mm_file_formats.h b/include/mm_file_formats.h index 5ebd9ba..fbf9028 100755 --- a/include/mm_file_formats.h +++ b/include/mm_file_formats.h @@ -55,9 +55,10 @@ enum { }; enum { - MM_FILE_DRM_NONE = 0, /*not drm file*/ - MM_FILE_DRM_OMA, /*oma drm*/ - MM_FILE_DRM_DIVX, /*divx drm*/ + MM_FILE_DRM_NONE = 0, /*not drm file*/ + MM_FILE_DRM_OMA, /*oma drm*/ + MM_FILE_DRM_DIVX, /*divx drm*/ + MM_FILE_DRM_PROTECTED, /*This is drm file but not oma or divx*/ }; @@ -86,6 +87,8 @@ typedef struct _mmfilesteam { int height; int nbChannel; int samplePerSec; + int bitPerSample; + bool is_uhqa; } MMFileFormatStream; typedef struct _mmfileformatframe { @@ -85,6 +85,7 @@ typedef struct { int type; int audio_track_num; int video_track_num; + bool is_uhqa; } MMFILE_PARSE_INFO; typedef struct { @@ -143,6 +144,7 @@ static mmf_attrs_construct_info_t g_content_attrs[] = { {"content-audio-samplerate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content-audio-track-index", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content-audio-track-count", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, + {"content-audio-bitpersample", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, }; #ifdef __MMFILE_DYN_LOADING__ @@ -370,6 +372,7 @@ _info_set_attr_media (mmf_attrs_t *attrs, MMFileFormatContext *formatContext) mm_attrs_set_int_by_name (hattrs, MM_FILE_CONTENT_AUDIO_CHANNELS, audioStream->nbChannel); mm_attrs_set_int_by_name (hattrs, MM_FILE_CONTENT_AUDIO_BITRATE, audioStream->bitRate); mm_attrs_set_int_by_name (hattrs, MM_FILE_CONTENT_AUDIO_SAMPLERATE, audioStream->samplePerSec); + mm_attrs_set_int_by_name (hattrs, MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, audioStream->bitPerSample); } } else @@ -420,8 +423,18 @@ _get_contents_info (mmf_attrs_t *attrs, MMFileSourceType *src, MMFILE_PARSE_INFO goto exception; } + /* check uhqa content*/ + if (parse->is_uhqa = formatContext->streams[MMFILE_AUDIO_STREAM] != NULL) + parse->is_uhqa = formatContext->streams[MMFILE_AUDIO_STREAM]->is_uhqa; + if (parse->type >= MM_FILE_PARSE_TYPE_ALL) { if (formatContext->videoTotalTrackNum > 0) { + + if (parse->type != MM_FILE_PARSE_TYPE_SAFE) { + if (formatContext->formatType == MM_FILE_FORMAT_3GP ||formatContext->formatType == MM_FILE_FORMAT_MP4) { + MMFileUtilGetMetaDataFromMP4 (formatContext); + } + } MMFileFormatStream *videoStream = formatContext->streams[MMFILE_VIDEO_STREAM]; unsigned int timestamp = _SEEK_POINT_; @@ -1161,11 +1174,14 @@ int mm_file_create_content_attrs_simple(MMHandleType *contents_attrs, const char return MM_ERROR_FILE_INTERNAL; } #endif - if (filename == NULL) { - return MM_ERROR_INVALID_ARGUMENT; + if (filename == NULL) { + ret = MM_ERROR_INVALID_ARGUMENT; + goto END; } else { - if (strlen (filename) == 0) - return MM_ERROR_INVALID_ARGUMENT; + if (strlen (filename) == 0) { + ret = MM_ERROR_INVALID_ARGUMENT; + goto END; + } } /*set source file infomation*/ @@ -1373,3 +1389,71 @@ exception: return MM_ERROR_FILE_INTERNAL; } + +EXPORT_API +int mm_file_check_uhqa(const char* filename, bool *is_uhqa) +{ + mmf_attrs_t *attrs = NULL; + MMFileSourceType src = {0,}; + MMFILE_PARSE_INFO parse = {0,}; + int ret = 0; + +#ifdef __MMFILE_DYN_LOADING__ + MMFILE_FUNC_HANDLE func_handle; + + ret = _load_dynamic_functions (&func_handle); + if (ret == 0) { + debug_error ("load library error\n"); + return MM_ERROR_FILE_INTERNAL; + } +#endif + if (filename == NULL) { + ret = MM_ERROR_INVALID_ARGUMENT; + goto END; + } else { + if (strlen (filename) == 0) { + ret = MM_ERROR_INVALID_ARGUMENT; + goto END; + } + } + + /*set source file infomation*/ + MM_FILE_SET_MEDIA_FILE_SRC (src, filename); + + ret = _is_file_exist (filename); + if (!ret) { + ret = MM_ERROR_FILE_NOT_FOUND; + goto END; + } + + /*set attrs*/ + attrs = (mmf_attrs_t *) mmf_attrs_new_from_data ("content", g_content_attrs, ARRAY_SIZE (g_content_attrs), NULL, NULL); + if (!attrs) { + debug_error ("attribute internal error.\n"); + ret = MM_ERROR_FILE_INTERNAL; + goto END; + } + + parse.type = MM_FILE_PARSE_TYPE_NORMAL; + ret = _get_contents_info (attrs, &src, &parse); + if (ret == MM_ERROR_NONE) { + *is_uhqa = parse.is_uhqa; + } else { + debug_error ("_get_contents_info failed\n"); + *is_uhqa = FALSE; + } + + mmf_attrs_free ((MMHandleType)attrs); + attrs = NULL; + +END: +#ifdef __MMFILE_DYN_LOADING__ + _unload_dynamic_functions (&func_handle); +#endif + +#ifdef __MMFILE_TEST_MODE__ + debug_fleave(); +#endif + + return ret; +}
\ No newline at end of file diff --git a/packaging/libmm-fileinfo.spec b/packaging/libmm-fileinfo.spec index 7bfb810..ef4da4b 100755 --- a/packaging/libmm-fileinfo.spec +++ b/packaging/libmm-fileinfo.spec @@ -1,6 +1,6 @@ Name: libmm-fileinfo Summary: Media Fileinfo -Version: 0.6.23 +Version: 0.6.36 Release: 1 Group: System/Libraries License: Apache License, Version 2.0 @@ -18,13 +18,6 @@ BuildRequires: pkgconfig(libavformat) BuildRequires: pkgconfig(icu-i18n) BuildRequires: pkgconfig(vconf) -%define use_drm 1 - -%if %{use_drm} -BuildRequires: libss-client-devel -BuildRequires: pkgconfig(drm-client) -%endif - %description Multimedia Framework FileInfo Library @@ -43,13 +36,9 @@ Multimedia Framework FileInfo Library (developement files) %build ./autogen.sh -%if %{use_drm} -CFLAGS="${CFLAGS} -D_MM_PROJECT_FLOATER -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" " LDFLAGS="${LDFLAGS}" ./configure --disable-testmode --disable-dump --enable-dyn --disable-iommap --prefix=/usr --enable-drm --disable-gtk -%else -CFLAGS="${CFLAGS} -D_MM_PROJECT_FLOATER -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" " LDFLAGS="${LDFLAGS}" ./configure --disable-testmode --disable-dump --enable-dyn --disable-iommap --prefix=/usr --disable-drm --disable-gtk -%endif +CFLAGS="${CFLAGS} -D_MM_PROJECT_FLOATER -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" " LDFLAGS="${LDFLAGS}" ./configure --disable-testmode --disable-dump --enable-dyn --disable-iommap --prefix=/usr --disable-gtk -make +make %{?jobs:-j%jobs} %install %make_install diff --git a/tests/mm_file_test.c b/tests/mm_file_test.c index 7a0056f..6a7d1f5 100755 --- a/tests/mm_file_test.c +++ b/tests/mm_file_test.c @@ -98,6 +98,7 @@ typedef struct _ContentContext { int audio_samplerate; int audio_track_id; int audio_track_num; + int audio_bitpersample; mmfile_value_t thumbnail; }ContentContext_t; @@ -252,6 +253,7 @@ static int mmfile_get_file_infomation (void *data, void* user_data, bool file_te MM_FILE_CONTENT_AUDIO_CHANNELS, &ccontent.audio_channel, MM_FILE_CONTENT_AUDIO_TRACK_INDEX, &ccontent.audio_track_id, MM_FILE_CONTENT_AUDIO_TRACK_COUNT, &ccontent.audio_track_num, + MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, &ccontent.audio_bitpersample, NULL); if(ret != MM_ERROR_NONE) { @@ -265,6 +267,7 @@ static int mmfile_get_file_infomation (void *data, void* user_data, bool file_te printf("# audio channel: %d\n", ccontent.audio_channel); printf("# audio track id: %d\n", ccontent.audio_track_id); printf("# audio track num: %d\n", ccontent.audio_track_num); + printf("# audio bit per sample: %d\n", ccontent.audio_bitpersample); } } @@ -354,7 +357,7 @@ static int mmfile_get_file_infomation (void *data, void* user_data, bool file_te fclose (msg_tmp_fp); msg_tmp_fp = NULL; } - + mm_file_destroy_tag_attrs(tag_attrs); return -1; } diff --git a/utils/mm_file_util_locale.c b/utils/mm_file_util_locale.c index 7556181..982a622 100755 --- a/utils/mm_file_util_locale.c +++ b/utils/mm_file_util_locale.c @@ -80,6 +80,7 @@ static int _MMFileUtilGetLocaleindex() { int index = MMFILE_LANGUAGE_ENGLISH; char *lang = NULL; + char *con_iso = NULL; char *china_prefix = "zh"; char *eng_prefix = "en"; @@ -89,6 +90,8 @@ static int _MMFileUtilGetLocaleindex() char *taiwan_lang = "zh_TW"; char *jpn_lang = "ja_JP"; + + con_iso = vconf_get_str(VCONFKEY_CSC_COUNTRY_ISO); lang = vconf_get_str(VCONFKEY_LANGSET); if (lang != NULL) { @@ -102,9 +105,24 @@ static int _MMFileUtilGetLocaleindex() index = MMFILE_LANGUAGE_TRA_CHINA; } } else if (strncmp(lang, eng_prefix, strlen(eng_prefix)) == 0) { - /* This case is selected language is engilish*/ + /* This case is selected language is engilish + In case of engilish, the character set is related with region of target binary */ debug_msg("[%s]character set is engilish", lang); - index = MMFILE_LANGUAGE_ENGLISH; + if (con_iso!=NULL) { + if (strncmp(con_iso, "CN", strlen("CN")) == 0) { + debug_msg("region of this target is China."); + index = MMFILE_LANGUAGE_SIM_CHINA; + } else if ((strncmp(con_iso, "TW", strlen("TW")) == 0) || (strncmp(con_iso, "HK", strlen("HK")) == 0)) { + debug_msg("region of this target is Hong kong or Twian."); + index = MMFILE_LANGUAGE_TRA_CHINA; + } else { + debug_msg("Use default character set."); + index = MMFILE_LANGUAGE_ENGLISH; + } + } else { + debug_error("country iso value is NULL"); + index = MMFILE_LANGUAGE_ENGLISH; + } } else if (strncmp(lang, jpn_lang, strlen(jpn_lang)) == 0) { /* This case is selected language is japanease */ debug_msg("[%s]character set is japanease", lang); @@ -118,6 +136,7 @@ static int _MMFileUtilGetLocaleindex() index = MMFILE_LANGUAGE_ENGLISH; } + if(!con_iso) free(con_iso); if(!lang) free(lang); return index; diff --git a/utils/mm_file_util_tag.c b/utils/mm_file_util_tag.c index 0fd249a..ea04ffd 100755 --- a/utils/mm_file_util_tag.c +++ b/utils/mm_file_util_tag.c @@ -942,7 +942,8 @@ static int GetTagFromMetaBox (MMFileFormatContext *formatContext, MMFileIOHandle int limit = basic_header->size - hdlrBoxHeader.size; long long cover_offset = 0, track_offset =0 , genre_offset = 0, artist_offset = 0; - for (i = 0, cover_found = 0, track_found = 0, genre_found = 0, artist_found = 0; i < limit && (cover_found == 0 || track_found == 0 || genre_found == 0 || artist_found == 0) ; i++) { +// for (i = 0, cover_found = 0, track_found = 0, genre_found = 0, artist_found = 0; i < limit && (cover_found == 0 || track_found == 0 || genre_found == 0 || artist_found == 0) ; i++) { + for (i = 0; (i < limit) && (cover_found == 0) ; i++) { readed = mmfile_read (fp, read_buf, _ITUNES_READ_BUF_SZ); if (readed != _ITUNES_READ_BUF_SZ) goto exception; @@ -1519,8 +1520,7 @@ static bool make_characterset_array(char ***charset_array) { char *locale = MMFileUtilGetLocale (NULL); - *charset_array = malloc(sizeof(char*) * AV_ID3V2_MAX); - memset(*charset_array, 0x0, sizeof(charset_array)); + *charset_array = calloc(AV_ID3V2_MAX, sizeof(char*)); if (locale != NULL) { (*charset_array)[AV_ID3V2_ISO_8859] = strdup(locale); } else { @@ -1743,6 +1743,11 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo* pInfo, unsigned char *buffer) textEncodingType = AV_ID3V2_UTF16; } + if (textEncodingType > AV_ID3V2_MAX) { + debug_msg ( "WRONG ENCOIDNG TYPE [%d], FRAME[%s]\n", textEncodingType, (char*)CompTmp); + continue; + } + //in order to deliver valid string to MP while((buffer[curPos-purelyFramelen+encodingOffSet] < 0x20) && (encodingOffSet < purelyFramelen)) encodingOffSet++; @@ -2153,6 +2158,7 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo* pInfo, unsigned char *buffer) int inx=0, encodingOffSet=0, realCpyFrameNum=0, checkImgMimeTypeMax=0, imgstartOffset=0, tmp = 0; int textEncodingType = 0; char **charset_array = NULL; + char *MIME_PRFIX = "image/"; make_characterset_array(&charset_array); @@ -2166,6 +2172,20 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo* pInfo, unsigned char *buffer) debug_msg ("ID3tag v223--------------------------------------------------------------\n"); #endif + /* check Extended Header */ + if (buffer[5] & 0x40) + { + /* if extended header exists, skip it*/ + int extendedHeaderLen = (unsigned long)buffer[10] << 21 | (unsigned long)buffer[11] << 14 | (unsigned long)buffer[12] << 7 | (unsigned long)buffer[13]; + + #ifdef __MMFILE_TEST_MODE__ + debug_msg ("--------------- extendedHeaderLen = %d\n", extendedHeaderLen); + #endif + + curPos += extendedHeaderLen; + curPos += 4; + } + if(needToloopv2taglen -MP3_TAGv2_23_TXT_HEADER_LEN > MP3_TAGv2_23_TXT_HEADER_LEN) { v2numOfFrames = 1; @@ -2268,6 +2288,11 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo* pInfo, unsigned char *buffer) } } + if (textEncodingType > AV_ID3V2_MAX) { + debug_msg ( "WRONG ENCOIDNG TYPE [%d], FRAME[%s]\n", textEncodingType, (char*)CompTmp); + continue; + } + memcpy(pExtContent, &buffer[curPos-purelyFramelen+encodingOffSet], purelyFramelen-encodingOffSet); if(realCpyFrameNum > 0) { @@ -2674,6 +2699,7 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo* pInfo, unsigned char *buffer) debug_msg ( "pInfo->pUnsyncLyrics returned = (%s), pInfo->unsynclyricsLen(%d)\n", pInfo->pUnsyncLyrics, pInfo->unsynclyricsLen); #endif pInfo->tagV2Info.bUnsyncLyricsMarked = true; + mmfile_free(lang_info); } else if(strncmp((char *)CompTmp, "TCON", 4) == 0 && pInfo->tagV2Info.bGenreMarked == false) { @@ -2809,6 +2835,12 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo* pInfo, unsigned char *buffer) imgstartOffset += checkImgMimeTypeMax; + if (strncmp(pInfo->imageInfo.imageMIMEType, MIME_PRFIX, strlen(MIME_PRFIX)) != 0) { + pInfo->imageInfo.imgMimetypeLen = 0; + debug_error("APIC NOT VALID"); + continue; + } + if((pExtContent[imgstartOffset] == '\0') && (realCpyFrameNum - imgstartOffset > 0)) { imgstartOffset++;//endofMIME(1byte) @@ -3004,6 +3036,7 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo* pInfo, unsigned char *buffer) int inx=0, encodingOffSet=0, realCpyFrameNum=0, checkImgMimeTypeMax=0, imgstartOffset=0, tmp = 0; int textEncodingType = 0; char **charset_array = NULL; + char *MIME_PRFIX = "image/"; make_characterset_array(&charset_array); @@ -3125,6 +3158,11 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo* pInfo, unsigned char *buffer) } } + if (textEncodingType > AV_ID3V2_MAX) { + debug_msg ( "WRONG ENCOIDNG TYPE [%d], FRAME[%s]\n", textEncodingType, (char*)CompTmp); + continue; + } + memcpy(pExtContent, &buffer[curPos-purelyFramelen+encodingOffSet], purelyFramelen-encodingOffSet); if(realCpyFrameNum > 0) @@ -3780,6 +3818,12 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo* pInfo, unsigned char *buffer) imgstartOffset += checkImgMimeTypeMax; + if (strncmp(pInfo->imageInfo.imageMIMEType, MIME_PRFIX, strlen(MIME_PRFIX)) != 0) { + pInfo->imageInfo.imgMimetypeLen = 0; + debug_error("APIC NOT VALID"); + continue; + } + if((pExtContent[imgstartOffset] == '\0') && (realCpyFrameNum - imgstartOffset > 0)) { imgstartOffset++;//endofMIME(1byte) @@ -3821,7 +3865,6 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo* pInfo, unsigned char *buffer) dis_len = cur_pos + 1; tmp_desc = mmfile_malloc(sizeof(char) * dis_len); - debug_msg ( "tmp_desc %x\n", tmp_desc); memcpy(tmp_desc, pExtContent + imgstartOffset, dis_len); debug_msg ( "tmp_desc %s\n", tmp_desc); diff --git a/utils/mm_file_util_validity.c b/utils/mm_file_util_validity.c index ad6eecb..83d0b28 100755 --- a/utils/mm_file_util_validity.c +++ b/utils/mm_file_util_validity.c @@ -88,7 +88,7 @@ int MMFileFormatIsValidMP3 (const char *mmfileuri, int frameCnt) ret = _MMFileSearchID3Tag (fp, &sizeID3); if (ret == 0) { debug_error("Error in searching the ID3 tag\n"); - goto exit; +// goto exit; } ret = 0; @@ -227,7 +227,7 @@ int MMFileFormatIsValidAAC (const char *mmfileuri) ret = _MMFileSearchID3Tag (fp, &sizeID3); if (ret == 0) { debug_error("Error in searching the ID3 tag\n"); - goto exit; +// goto exit; } ret = 0; @@ -374,7 +374,7 @@ int MMFileFormatIsValidOGG (const char *mmfileuri) ret = _MMFileSearchID3Tag (fp, &sizeID3); if(ret == 0) { debug_error("Error in searching the ID3 tag\n"); - goto exit; +// goto exit; } ret = 0; @@ -1159,7 +1159,7 @@ int MMFileFormatIsValidMatroska (const char *mmfileuri) #endif while (size <= 8 && !(total & len_mask)) { - debug_error ("This case can not be handled yet....") + debug_error ("This case can not be handled yet...."); size++; len_mask >>= 1; } @@ -1169,7 +1169,7 @@ int MMFileFormatIsValidMatroska (const char *mmfileuri) #endif if (size > 8) { - debug_error ("This case can not be handled yet....") + debug_error ("This case can not be handled yet...."); ret = 0; goto exit; } @@ -1178,7 +1178,7 @@ int MMFileFormatIsValidMatroska (const char *mmfileuri) while (n < size) { total = (total << 8) | buffer[4 + n++]; - debug_error ("This case can not be handled yet....") + debug_error ("This case can not be handled yet...."); } /* Does the probe data contain the whole header? */ @@ -1613,6 +1613,7 @@ static int _MMFileSearchID3Tag (MMFileIOHandle *fp, unsigned int *offset) int tagVersion = 0; int encSize = 0; int readed = 0; + int ret = 0; /*init offset*/ *offset = 0; @@ -1671,10 +1672,13 @@ _START_TAG_SEARCH: mmfile_seek(fp, acc_tagsize, MMFILE_SEEK_SET); *offset = acc_tagsize; + + ret = 1; + goto _START_TAG_SEARCH; search_end: - return 1; + return ret; } static int _MMFileIsFLACHeader (void *header) |