*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
+ * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
+ * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
-#include <sys/socket.h>
+#include <fcntl.h>
+#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <mm_debug.h>
+#include <unicode/ucsdet.h>
+#include <dlog.h>
+#include <storage.h>
+#include <tzplatform_config.h>
#include "mm_player_utils.h"
+#include "media_format.h"
-bool util_exist_file_path(const char *file_path)
+#define MEDIA_PATH_EXTERNAL tzplatform_getenv(TZ_SYS_STORAGE) /* external storage, sd card, usb */
+#define FD_NUM_FOR_DEBUG 10
+
+const gchar *
+_mmplayer_get_stream_type_name(int type)
{
- debug_log("\n");
+ switch (type) {
+ case MM_PLAYER_STREAM_TYPE_AUDIO:
+ return "AUDIO";
+ case MM_PLAYER_STREAM_TYPE_VIDEO:
+ return "VIDEO";
+ case MM_PLAYER_STREAM_TYPE_TEXT:
+ return "TEXT";
+ case MM_PLAYER_STREAM_TYPE_DEFAULT: /* fall through */
+ case MM_PLAYER_STREAM_TYPE_MAX: /* fall through */
+ default:
+ return "INVAID";
+ }
+}
- if (!file_path || !strlen(file_path))
- return FALSE;
+const gchar *
+_mmplayer_get_state_name(int state)
+{
+ switch (state) {
+ case MM_PLAYER_STATE_NULL:
+ return "NULL";
+ case MM_PLAYER_STATE_READY:
+ return "READY";
+ case MM_PLAYER_STATE_PAUSED:
+ return "PAUSED";
+ case MM_PLAYER_STATE_PLAYING:
+ return "PLAYING";
+ case MM_PLAYER_STATE_NONE:
+ return "NONE";
+ default:
+ return "INVAID";
+ }
+}
- int res = access(file_path, R_OK);
- if (res)
- return FALSE;
+gboolean
+_mmplayer_is_rtsp_streaming(mmplayer_t *player)
+{
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
- return TRUE;
+ return (player->profile.uri_type == MM_PLAYER_URI_TYPE_URL_RTSP) ? TRUE : FALSE;
}
-bool util_write_file_backup(const char *backup_path, char *data_ptr, int data_size)
+gboolean
+_mmplayer_is_http_streaming(mmplayer_t *player)
{
- debug_log("\n");
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
- FILE *fp = NULL;
- int wsize = 0;
+ return (player->profile.uri_type == MM_PLAYER_URI_TYPE_URL_HTTP) ? TRUE : FALSE;
+}
- fp = fopen(backup_path, "wb");
- if (!fp)
- return FALSE;
+gboolean
+_mmplayer_is_streaming(mmplayer_t *player)
+{
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
+
+ return (_mmplayer_is_rtsp_streaming(player) || _mmplayer_is_http_streaming(player)
+ || _mmplayer_is_http_live_streaming(player) || _mmplayer_is_dash_streaming(player)
+ || _mmplayer_is_smooth_streaming(player)) ? TRUE : FALSE;
+}
- wsize = fwrite(data_ptr, sizeof(char), data_size, fp);
+gboolean
+_mmplayer_is_live_streaming(mmplayer_t *player)
+{
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
- fclose(fp);
+ return (_mmplayer_is_rtsp_streaming(player) && player->streaming_type == STREAMING_SERVICE_LIVE) ? TRUE : FALSE;
+}
- if (wsize != data_size) {
- if (!access(backup_path, R_OK))
- remove(backup_path);
+gboolean
+_mmplayer_is_http_live_streaming(mmplayer_t *player)
+{
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
- debug_error("No space to write!\n");
+ return (player->profile.uri_type == MM_PLAYER_URI_TYPE_HLS) ? TRUE : FALSE;
+}
- return FALSE;
- }
+gboolean
+_mmplayer_is_dash_streaming(mmplayer_t *player)
+{
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
- return TRUE;
+ return (player->profile.uri_type == MM_PLAYER_URI_TYPE_DASH) ? TRUE : FALSE;
}
-#if 1 //tskim:MidiModuleRequires:+: for Midi player
-bool util_remove_file_backup(const char *backup_path)
+gboolean
+_mmplayer_is_smooth_streaming(mmplayer_t *player)
{
- debug_log("\n");
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
- if (!backup_path || !strlen(backup_path))
- return FALSE;
+ return (player->profile.uri_type == MM_PLAYER_URI_TYPE_SS) ? TRUE : FALSE;
+}
-/*
- Prevent defect patch. CID:22389 Checker:TOTCU
- int res = access(backup_path, R_OK);
- if (!res)
-*/
- remove(backup_path);
+gboolean
+_mmplayer_is_ms_buff_src(mmplayer_t *player)
+{
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
- return TRUE;
+ return (player->profile.uri_type == MM_PLAYER_URI_TYPE_MS_BUFF) ? TRUE : FALSE;
}
-#endif
-#define DETECTION_PREFIX_SIZE 20
-//bool util_is_midi_type_by_mem(void *mem, int size)
-int util_is_midi_type_by_mem(void *mem, int size)
+gboolean
+_mmplayer_has_suffix(mmplayer_t *player, const gchar *suffix)
{
- debug_log("\n");
-
- const char *p = (const char *)mem;
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
+ MMPLAYER_RETURN_VAL_IF_FAIL(suffix, FALSE);
- if (size < DETECTION_PREFIX_SIZE)
- return MM_AUDIO_CODEC_INVALID; //FALSE; // sbs:+:080903
+ gboolean ret = FALSE;
+ gchar *t_url = g_ascii_strdown(player->profile.uri, -1);
+ gchar *t_suffix = g_ascii_strdown(suffix, -1);
+ gchar *opt = strchr(t_url, '?');
- /* mmf file detection */
- if (p[0] == 'M' && p[1] == 'M' && p[2] == 'M' && p[3] == 'D') {
- debug_log("MM_AUDIO_CODEC_MMF\n");
- return MM_AUDIO_CODEC_MMF; // TRUE;// sbs:+:080903
- }
+ if (opt)
+ *opt = '\0';
- /* midi file detection */
- if (p[0] == 'M' && p[1] == 'T' && p[2] == 'h' && p[3] == 'd') {
- debug_log ("MM_AUDIO_CODEC_MIDI, %d\n", MM_AUDIO_CODEC_MIDI);
- return MM_AUDIO_CODEC_MIDI;//TRUE;// sbs:+:080903
- }
- /* mxmf file detection */ // sbs:+:080903
- if (p[0] == 'X' && p[1] == 'M' && p[2] == 'F' && p[3] == '_') {
- debug_log ("MM_AUDIO_CODEC_MXMF\n");
- return MM_AUDIO_CODEC_MXMF;
- }
+ ret = g_str_has_suffix(t_url, t_suffix);
- /* wave file detection */
- if (p[0] == 'R' && p[1] == 'I' && p[2] == 'F' && p[3] == 'F' &&
- p[8] == 'W' && p[9] == 'A' && p[10] == 'V' && p[11] == 'E' &&
- p[12] == 'f' && p[13] == 'm' && p[14] == 't') {
- debug_log ("MM_AUDIO_CODEC_WAVE\n");
- return MM_AUDIO_CODEC_WAVE;//TRUE;// sbs:+:080903
- }
- /* i-melody file detection */ // sbs:+:080903
- if (memcmp(p, "BEGIN:IMELODY", 13) == 0)
- {
- debug_log ("MM_AUDIO_CODEC_IMELODY\n");
- return MM_AUDIO_CODEC_IMELODY;
- }
+ MMPLAYER_FREEIF(t_url);
+ MMPLAYER_FREEIF(t_suffix);
- return MM_AUDIO_CODEC_INVALID;//FALSE; // sbs:+:080903
+ return ret;
}
-//bool util_is_midi_type_by_file(const char *file_path)
-int util_is_midi_type_by_file(const char *file_path)
+gboolean
+_mmplayer_is_videosink_ready(mmplayer_t *player, int surface_type)
{
- debug_log("\n");
-
- struct stat file_attrib;
- FILE *fp = NULL;
- char prefix[DETECTION_PREFIX_SIZE] = {0,};
- int size;
-
- if (!file_path)
+ int curr_type = MM_DISPLAY_SURFACE_NUM;
+
+ if (!player ||
+ !player->pipeline ||
+ !player->pipeline->mainbin ||
+ !player->pipeline->videobin ||
+ !player->pipeline->videobin[MMPLAYER_V_BIN].gst ||
+ !player->pipeline->videobin[MMPLAYER_V_SINK].gst) {
+ LOGW("videosink is not ready yet");
return FALSE;
+ }
- /* Prevent defect patch. CID: 22388 Checker: TOCTOU */
- fp = fopen(file_path, "r");
+ if (surface_type == MM_DISPLAY_SURFACE_NUM) /* don't care the surface type */
+ return TRUE;
- if (!fp)
- return FALSE;
+ mm_attrs_get_int_by_name(player->attrs, "display_surface_type", &curr_type);
- memset(&file_attrib, 0, sizeof(file_attrib));
-
- if (stat(file_path, &file_attrib) != 0)
- {
- fclose(fp);
+ if (curr_type != surface_type) {
+ LOGW("surface type is mismatched %d, %d", curr_type, surface_type);
return FALSE;
}
- size = (int) file_attrib.st_size;
+ return TRUE;
+}
- if (size < DETECTION_PREFIX_SIZE)
- {
- fclose(fp);
+gboolean
+_mmplayer_post_message(mmplayer_t *player, enum MMMessageType msgtype, MMMessageParamType *param)
+{
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
+
+ if (!player->msg_cb)
return FALSE;
- }
-
- size = fread(prefix, sizeof(char), DETECTION_PREFIX_SIZE, fp);
+#ifdef __DEBUG__
+ LOGD("Message (type : %d) will be posted using msg-cb(%p).", msgtype, player->msg_cb);
+#endif
- fclose(fp);
+ player->msg_cb(msgtype, param, player->msg_cb_param);
- return util_is_midi_type_by_mem(prefix, size);
+ return TRUE;
}
-/* messages are treated as warnings bcz those code should not be checked in.
- * and no error handling will supported for same manner.
- */
-gboolean
-__util_gst_pad_probe(GstPad *pad, GstBuffer *buffer, gpointer u_data)
+gboolean
+_mmplayer_dump_pipeline_state(mmplayer_t *player)
{
- gint flag = (gint) u_data;
- GstElement* parent = NULL;
- gboolean ret = TRUE;
-
- /* show name as default */
- parent = (GstElement*)gst_object_get_parent(GST_OBJECT(pad));
- debug_warning("PAD PROBE : %s:%s\n", GST_ELEMENT_NAME(parent), GST_PAD_NAME(pad));
-
- /* show time stamp */
- if ( flag & MM_PROBE_TIMESTAMP )
- {
- debug_warning("ts : %u:%02u:%02u.%09u\n", GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)));
+ GstIterator *iter = NULL;
+ gboolean done = FALSE;
+
+ GValue item = {0, };
+ GstElement *element = NULL;
+ GstElementFactory *factory = NULL;
+
+ GstState state = GST_STATE_VOID_PENDING;
+ GstState pending = GST_STATE_VOID_PENDING;
+ GstClockTime time = 200 * GST_MSECOND;
+
+ MMPLAYER_FENTER();
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(player &&
+ player->pipeline &&
+ player->pipeline->mainbin,
+ FALSE);
+
+ MMPLAYER_GENERATE_DOT_IF_ENABLED(player, "pipeline-status-error-dump");
+
+ iter = gst_bin_iterate_recurse(GST_BIN(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst));
+
+ if (iter != NULL) {
+ while (!done) {
+ switch (gst_iterator_next(iter, &item)) {
+ case GST_ITERATOR_OK:
+ element = g_value_get_object(&item);
+ if (element) {
+ gst_element_get_state(element, &state, &pending, time);
+
+ factory = gst_element_get_factory(element) ;
+ if (factory)
+ LOGE("%s:%s : From:%s To:%s refcount : %d", GST_OBJECT_NAME(factory) , GST_ELEMENT_NAME(element) ,
+ gst_element_state_get_name(state), gst_element_state_get_name(pending) , GST_OBJECT_REFCOUNT_VALUE(element));
+ }
+ g_value_reset(&item);
+ break;
+ case GST_ITERATOR_RESYNC:
+ gst_iterator_resync(iter);
+ break;
+ case GST_ITERATOR_ERROR:
+ done = TRUE;
+ break;
+ case GST_ITERATOR_DONE:
+ done = TRUE;
+ break;
+ }
+ }
}
- /* show buffer size */
- if ( flag & MM_PROBE_BUFFERSIZE )
- {
- debug_warning("buffer size : %ud\n", GST_BUFFER_SIZE(buffer));
- }
+ element = GST_ELEMENT(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst);
- /* show buffer duration */
- if ( flag & MM_PROBE_BUFFER_DURATION )
- {
- debug_warning("dur : %lld\n", GST_BUFFER_DURATION(buffer));
- }
+ gst_element_get_state(element, &state, &pending, time);
- /* show buffer caps */
- if ( flag & MM_PROBE_CAPS )
- {
- debug_warning("caps : %s\n", gst_caps_to_string(GST_BUFFER_CAPS(buffer)));
+ factory = gst_element_get_factory(element) ;
+
+ if (factory) {
+ LOGE("%s:%s : From:%s To:%s refcount : %d",
+ GST_OBJECT_NAME(factory),
+ GST_ELEMENT_NAME(element),
+ gst_element_state_get_name(state),
+ gst_element_state_get_name(pending),
+ GST_OBJECT_REFCOUNT_VALUE(element));
}
- /* drop buffer if flag is on */
- if ( flag & MM_PROBE_DROP_BUFFER )
- {
- debug_warning("dropping\n");
- ret = FALSE;
+ g_value_unset(&item);
+
+ if (iter)
+ gst_iterator_free(iter);
+
+ MMPLAYER_FLEAVE();
+
+ return FALSE;
+}
+
+int
+_mmplayer_exist_file_path(const char *file_path)
+{
+ int fd = 0;
+ struct stat stat_results = {0, };
+
+ if (!file_path || !strlen(file_path))
+ return MM_ERROR_PLAYER_FILE_NOT_FOUND;
+
+ fd = open(file_path, O_RDONLY);
+
+ if (fd < 0) {
+ char str_error[256];
+ strerror_r(errno, str_error, sizeof(str_error));
+ LOGE("failed to open file by %s (%d)", str_error, errno);
+
+ if (EACCES == errno)
+ return MM_ERROR_PLAYER_PERMISSION_DENIED;
+
+ return MM_ERROR_PLAYER_FILE_NOT_FOUND;
}
-
- /* show clock time */
- if ( flag & MM_PROBE_CLOCK_TIME )
- {
- GstClock* clock = NULL;
- GstClockTime now = GST_CLOCK_TIME_NONE;
-
- clock = GST_ELEMENT_CLOCK ( parent );
-
- if ( clock )
- {
- now = gst_clock_get_time( clock );
- debug_warning("clock time : %" GST_TIME_FORMAT "\n", GST_TIME_ARGS( now ));
- }
+
+ if (fstat(fd, &stat_results) < 0) {
+ LOGE("failed to get file status");
+ } else if (stat_results.st_size == 0) {
+ LOGE("file size is zero");
+ if (fd < FD_NUM_FOR_DEBUG)
+ LOGW("close fd %d", fd);
+ close(fd);
+ return MM_ERROR_PLAYER_FILE_NOT_FOUND;
+ } else {
+ LOGW("file size : %lld bytes", (long long)stat_results.st_size);
}
- if ( parent )
- gst_object_unref(parent);
+ if (fd < FD_NUM_FOR_DEBUG)
+ LOGW("close fd %d", fd);
+ close(fd);
- return ret;
+ return MM_ERROR_NONE;
}
-char**
-util_get_cookie_list ( const char *cookies )
+char **
+_mmplayer_get_cookie_list(const char *cookies)
{
char **cookie_list = NULL;
char *temp = NULL;
gint i = 0;
- if ( !cookies || !strlen(cookies) )
+ if (!cookies || !strlen(cookies))
return NULL;
- debug_log("cookies : %d[bytes] - %s \n", strlen(cookies), cookies);
+ SECURE_LOGD("cookies : %zu[bytes] - %s", strlen(cookies), cookies);
temp = g_strdup(cookies);
/* split */
cookie_list = g_strsplit(temp, ";", 100);
- for ( i = 0; i < g_strv_length(cookie_list); i++ )
- {
- if ( cookie_list[i] && strlen(cookie_list[i]) )
- {
- g_strstrip(cookie_list[i]);
- debug_log("cookie_list[%d] : %d[bytes] - %s \n", i, strlen(cookie_list[i]), cookie_list[i]);
- }
- else
- {
- cookie_list[i][0]='\0';
+ if (!cookie_list) {
+ LOGE("failed to get cookie list");
+ goto EXIT;
+ }
+
+ for (i = 0; i < g_strv_length(cookie_list); i++) {
+ if (cookie_list[i]) {
+ if (strlen(cookie_list[i])) {
+ g_strstrip(cookie_list[i]);
+ SECURE_LOGD("cookie_list[%d] : %zu[bytes] - %s", i, strlen(cookie_list[i]), cookie_list[i]);
+ } else {
+ cookie_list[i][0] = '\0';
+ }
}
}
- if (temp)
- g_free (temp);
- temp=NULL;
+EXIT:
+ MMPLAYER_FREEIF(temp);
return cookie_list;
}
-bool util_check_valid_url ( const char *proxy )
-{
- struct in_addr proxy_addr;
- bool ret = TRUE;
-
- return_val_if_fail ( proxy, FALSE );
- return_val_if_fail ( strlen(proxy), FALSE );
-
- if ( inet_aton(proxy, &proxy_addr) != 0 )
- {
- debug_warning("invalid proxy is set. \n");
- ret = FALSE;
- }
-
- return ret;
-}
-
/* check the given path is indicating sdp file */
-bool
-util_is_sdp_file ( const char *path )
+bool
+_mmplayer_is_sdp_file(const char *path)
{
gboolean ret = FALSE;
- gchar* uri = NULL;
-
- debug_fenter();
-
- return_val_if_fail ( path, FALSE );
+ gchar *uri = NULL;
+
+ MMPLAYER_FENTER();
- uri = g_ascii_strdown ( path, -1 );
+ MMPLAYER_RETURN_VAL_IF_FAIL(path, FALSE);
+
+ uri = g_ascii_strdown(path, -1);
+
+ if (uri == NULL)
+ return FALSE;
/* trimming */
- g_strstrip( uri );
+ g_strstrip(uri);
/* strlen(".sdp") == 4 */
- if ( strlen( uri ) <= 4 )
- {
- debug_warning ( "path is too short.\n" );
+ if (strlen(uri) <= 4) {
+ LOGW("path is too short.");
+ MMPLAYER_FREEIF(uri);
return ret;
}
/* first, check extension name */
- ret = g_str_has_suffix ( uri, "sdp" );
+ ret = g_str_has_suffix(uri, "sdp");
/* second, if no suffix is there, check it's contents */
- if ( ! ret )
- {
+ if (!ret)
/* FIXIT : do it soon */
- debug_warning("determining whether it's sdp or not with it's content is not implemented yet. ;)\n");
- }
+ LOGD("no suffix");
- if ( uri )
- g_free( uri);
- uri = NULL;
+ MMPLAYER_FREEIF(uri);
return ret;
}
-int64_t
-util_get_time ( void )
+const char *
+_mmplayer_get_charset(const char *file_path)
{
- struct timeval tv;
- gettimeofday(&tv,NULL);
- return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
+ UCharsetDetector *ucsd;
+ const UCharsetMatch *ucm;
+ UErrorCode status = U_ZERO_ERROR;
+
+ const char *charset = NULL;
+ char *buf = NULL;
+ FILE *fin = 0;
+ size_t n_size = 0;
+
+ fin = fopen(file_path, "r");
+ if (!fin) {
+ SECURE_LOGE("fail to open file %s", file_path);
+ return NULL;
+ }
+
+ ucsd = ucsdet_open(&status);
+ if (U_FAILURE(status)) {
+ LOGE("fail to ucsdet_open");
+ goto done;
+ }
+
+ ucsdet_enableInputFilter(ucsd, TRUE);
+
+ buf = g_try_malloc(1024 * 1024);
+ if (!buf) {
+ LOGE("fail to alloc");
+ goto done;
+ }
+
+ n_size = fread(buf, 1, 1024*1024, fin);
+ buf[1024 * 1024 - 1] = '\0';
+ if (!n_size)
+ goto done;
+
+ ucsdet_setText(ucsd, buf, strlen(buf), &status);
+ if (U_FAILURE(status)) {
+ LOGE("fail to ucsdet_setText");
+ goto done;
+ }
+
+ ucm = ucsdet_detect(ucsd, &status);
+ if (U_FAILURE(status)) {
+ LOGE("fail to ucsdet_detect");
+ goto done;
+ }
+
+ charset = ucsdet_getName(ucm, &status);
+ if (U_FAILURE(status)) {
+ LOGE("fail to ucsdet_getName");
+ goto done;
+ }
+
+ /* CP949 encoding is an extension of the EUC-KR and it is backwards compatible.*/
+ if (charset && !strcmp(charset, "EUC-KR"))
+ charset = "CP949";
+
+done:
+ if (fin)
+ fclose(fin);
+
+ if (ucsd)
+ ucsdet_close(ucsd);
+
+ MMPLAYER_FREEIF(buf);
+
+ return charset;
}
-int
-util_get_rank_increase ( const char *factory_class )
+int
+_mmplayer_get_pixtype(unsigned int fourcc)
{
- gint rank_pri_inc = 20;
- gint rank_sec_inc = 10;
- gint ret = 0;
+ int pixtype = MM_PIXEL_FORMAT_INVALID;
- if ( g_strrstr(factory_class,"Dsp") )
- ret = rank_pri_inc;
- else if ( g_strrstr(factory_class,"HW") )
- ret = rank_pri_inc;
- else if ( g_strrstr(factory_class,"Arm") )
- ret = rank_sec_inc;
+#ifdef __DEBUG__
+ char *pfourcc = (char *)&fourcc;
- return ret;
+ LOGD("fourcc(%c%c%c%c)",
+ pfourcc[0], pfourcc[1], pfourcc[2], pfourcc[3]);
+#endif
+
+ switch (fourcc) {
+ case GST_MAKE_FOURCC('S', 'N', '1', '2'):
+ case GST_MAKE_FOURCC('N', 'V', '1', '2'):
+ pixtype = MM_PIXEL_FORMAT_NV12;
+ break;
+ case GST_MAKE_FOURCC('S', 'T', '1', '2'):
+ pixtype = MM_PIXEL_FORMAT_NV12T;
+ break;
+ case GST_MAKE_FOURCC('S', 'N', '2', '1'):
+ case GST_MAKE_FOURCC('N', 'V', '2', '1'):
+ pixtype = MM_PIXEL_FORMAT_NV21;
+ break;
+ case GST_MAKE_FOURCC('S', 'U', 'Y', 'V'):
+ case GST_MAKE_FOURCC('Y', 'U', 'Y', 'V'):
+ case GST_MAKE_FOURCC('Y', 'U', 'Y', '2'):
+ pixtype = MM_PIXEL_FORMAT_YUYV;
+ break;
+ case GST_MAKE_FOURCC('S', 'Y', 'V', 'Y'):
+ case GST_MAKE_FOURCC('U', 'Y', 'V', 'Y'):
+ pixtype = MM_PIXEL_FORMAT_UYVY;
+ break;
+ case GST_MAKE_FOURCC('S', '4', '2', '0'):
+ case GST_MAKE_FOURCC('I', '4', '2', '0'):
+ pixtype = MM_PIXEL_FORMAT_I420;
+ break;
+ case GST_MAKE_FOURCC('Y', 'V', '1', '2'):
+ pixtype = MM_PIXEL_FORMAT_YV12;
+ break;
+ case GST_MAKE_FOURCC('4', '2', '2', 'P'):
+ pixtype = MM_PIXEL_FORMAT_422P;
+ break;
+ case GST_MAKE_FOURCC('R', 'G', 'B', 'P'):
+ pixtype = MM_PIXEL_FORMAT_RGB565;
+ break;
+ case GST_MAKE_FOURCC('R', 'G', 'B', '3'):
+ pixtype = MM_PIXEL_FORMAT_RGB888;
+ break;
+ case GST_MAKE_FOURCC('A', 'R', 'G', 'B'):
+ case GST_MAKE_FOURCC('x', 'R', 'G', 'B'):
+ pixtype = MM_PIXEL_FORMAT_ARGB;
+ break;
+ case GST_MAKE_FOURCC('B', 'G', 'R', 'A'):
+ case GST_MAKE_FOURCC('B', 'G', 'R', 'x'):
+ case GST_MAKE_FOURCC('S', 'R', '3', '2'):
+ pixtype = MM_PIXEL_FORMAT_RGBA;
+ break;
+ case GST_MAKE_FOURCC('J', 'P', 'E', 'G'):
+ case GST_MAKE_FOURCC('P', 'N', 'G', ' '):
+ pixtype = MM_PIXEL_FORMAT_ENCODED;
+ break;
+ case GST_MAKE_FOURCC('I', 'T', 'L', 'V'):
+ pixtype = MM_PIXEL_FORMAT_ITLV_JPEG_UYVY;
+ break;
+ default:
+ LOGE("Not supported fourcc type(%c%c%c%c)",
+ fourcc, fourcc>>8, fourcc>>16, fourcc>>24);
+ pixtype = MM_PIXEL_FORMAT_INVALID;
+ break;
+ }
+
+ return pixtype;
+}
+
+static int
+__mmplayer_storage_supported_cb(int storage_id, storage_type_e type,
+ storage_state_e state, const char *path, void *user_data)
+{
+ mmplayer_storage_info_t *storage_info = (mmplayer_storage_info_t *)user_data;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(storage_info, FALSE);
+
+ if (type == storage_info->type && strstr(storage_info->path, path)) {
+ storage_info->id = storage_id;
+ storage_info->state = state;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+bool
+_mmplayer_get_storage_info(const char *path, mmplayer_storage_info_t *storage_info)
+{
+ int ret = 0;
+ const char *file_path = path;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(file_path && storage_info, false);
+
+ if (strncmp(file_path, "file://", strlen("file://")) == 0)
+ file_path = path + 7; /* remove file prefix */
+
+ if (strncmp(file_path, MEDIA_PATH_EXTERNAL, strlen(MEDIA_PATH_EXTERNAL)) == 0) {
+ storage_info->type = STORAGE_TYPE_EXTERNAL;
+
+ memset(storage_info->path, 0x00, MM_MAX_URL_LEN);
+ g_snprintf(storage_info->path, MM_MAX_URL_LEN, "%s", file_path);
+
+ ret = storage_foreach_device_supported((storage_device_supported_cb)__mmplayer_storage_supported_cb, storage_info);
+ if (ret != STORAGE_ERROR_NONE) {
+ LOGE("failed to check supported storage 0x%x", ret);
+ return false;
+ }
+
+ if (storage_info->state <= STORAGE_STATE_REMOVED) {
+ LOGE("need to check the external storage state %d:%d", storage_info->id, storage_info->state);
+ return false;
+ }
+ } else {
+ storage_info->type = STORAGE_TYPE_INTERNAL;
+ storage_info->state = STORAGE_STATE_MOUNTED;
+ }
+
+ LOGD("storage info %d:%d:%d", storage_info->type, storage_info->id, storage_info->state);
+ return true;
}
-int
-util_factory_rank_compare(GstPluginFeature *f1, GstPluginFeature *f2) // @
+media_format_mimetype_e _mmplayer_convert_audio_pcm_str_to_media_format_mime(const gchar *audio_pcm_str)
{
- const gchar *klass;
- int f1_rank_inc=0, f2_rank_inc=0;
+ if (!audio_pcm_str) {
+ LOGW("audio pcm str is NULL");
+ return MEDIA_FORMAT_MAX;
+ }
- klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(f1));
- f1_rank_inc = util_get_rank_increase ( klass );
+ if (strstr(audio_pcm_str, "S16LE"))
+ return MEDIA_FORMAT_PCM_S16LE;
+ else if (strstr(audio_pcm_str, "S24LE"))
+ return MEDIA_FORMAT_PCM_S24LE;
+ else if (strstr(audio_pcm_str, "S32LE"))
+ return MEDIA_FORMAT_PCM_S32LE;
+ else if (strstr(audio_pcm_str, "S16BE"))
+ return MEDIA_FORMAT_PCM_S16BE;
+ else if (strstr(audio_pcm_str, "S24BE"))
+ return MEDIA_FORMAT_PCM_S24BE;
+ else if (strstr(audio_pcm_str, "S32BE"))
+ return MEDIA_FORMAT_PCM_S32BE;
+ else if (strstr(audio_pcm_str, "F32LE"))
+ return MEDIA_FORMAT_PCM_F32LE;
+ else if (strstr(audio_pcm_str, "F32BE"))
+ return MEDIA_FORMAT_PCM_F32BE;
+ else if (strstr(audio_pcm_str, "U16LE"))
+ return MEDIA_FORMAT_PCM_U16LE;
+ else if (strstr(audio_pcm_str, "U24LE"))
+ return MEDIA_FORMAT_PCM_U24LE;
+ else if (strstr(audio_pcm_str, "U32LE"))
+ return MEDIA_FORMAT_PCM_U32LE;
+ else if (strstr(audio_pcm_str, "U16BE"))
+ return MEDIA_FORMAT_PCM_U16BE;
+ else if (strstr(audio_pcm_str, "U24BE"))
+ return MEDIA_FORMAT_PCM_U24BE;
+ else if (strstr(audio_pcm_str, "U32BE"))
+ return MEDIA_FORMAT_PCM_U32BE;
+ else {
+ LOGW("Not supported audio pcm format str : %s", audio_pcm_str);
+ return MEDIA_FORMAT_MAX;
+ }
+}
+
+gboolean _mmplayer_use_uridecodebin3(mmplayer_t *player) /* MMPLAYER_USE_URIDECODEBIN3(player) */
+{
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
- klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(f2));
- f2_rank_inc = util_get_rank_increase ( klass );
+ if (MMPLAYER_IS_RTSP_STREAMING(player) ||
+ MMPLAYER_IS_MS_BUFF_SRC(player))
+ return FALSE;
+
+ if (!player->ini.use_uridecodebin3)
+ return FALSE;
- return (gst_plugin_feature_get_rank(f2)+f2_rank_inc) - (gst_plugin_feature_get_rank(f1)+f1_rank_inc );
+ return TRUE;
}