X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmm_player_priv.c;h=6b19906a6b7585bb4f6c1b9f8f2964c6a4564797;hb=88c7b7ae174c0de56c378c3ed15bd82bd1f74f85;hp=78ae23a2a6f38088b3c9e0a8094d47fcbb087a05;hpb=04f619a0c041d17546ff000a796db67006744f30;p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 78ae23a..6b19906 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -83,7 +83,7 @@ #define MM_VOLUME_FACTOR_MAX 1.0 /* Don't need to sleep for sound fadeout - * fadeout related fucntion will be deleted(Deprecated) + * fadeout related function will be deleted(Deprecated) */ #define MM_PLAYER_FADEOUT_TIME_DEFAULT 0 @@ -140,8 +140,8 @@ static int __mmplayer_gst_create_text_pipeline(mmplayer_t *player); static int __mmplayer_gst_create_video_sink_bin(mmplayer_t *player, GstCaps *caps, MMDisplaySurfaceType surface_type); static int __mmplayer_gst_create_audio_sink_bin(mmplayer_t *player); static int __mmplayer_gst_create_text_sink_bin(mmplayer_t *player); - -static void __mmplayer_gst_create_sinkbin(GstElement *decodebin, GstPad *pad, gpointer data); +static void __mmplayer_gst_create_sink_bin(GstElement *decodebin, GstPad *pad, GstCaps *ref_caps, gpointer data); +static gboolean __mmplayer_create_sink_path(mmplayer_t *player, GstElement *combiner, mmplayer_track_type_e type, GstCaps *caps); static gboolean __mmplayer_is_midi_type(gchar *str_caps); static gboolean __mmplayer_is_only_mp3_type(gchar *str_caps); @@ -157,7 +157,7 @@ static int __mmplayer_change_selector_pad(mmplayer_t *player, mmplayer_track_typ static gboolean __mmplayer_check_subtitle(mmplayer_t *player); static int __mmplayer_handle_missed_plugin(mmplayer_t *player); static int __mmplayer_check_not_supported_codec(mmplayer_t *player, const gchar *factory_class, const gchar *mime); -static void __mmplayer_add_sink(mmplayer_t *player, GstElement *sink); +static void __mmplayer_add_sink(mmplayer_t *player, GstElement *sink, gboolean first); static void __mmplayer_del_sink(mmplayer_t *player, GstElement *sink); static void __mmplayer_release_signal_connection(mmplayer_t *player, mmplayer_signal_type_e type); static gpointer __mmplayer_gapless_play_thread(gpointer data); @@ -173,6 +173,7 @@ static int __mmplayer_gst_set_message_callback(mmplayer_t *player, MMMessageCal static gboolean __mmplayer_verify_gapless_play_path(mmplayer_t *player); static void __mmplayer_check_pipeline_reconfigure_state(mmplayer_t *player); static gboolean __mmplayer_deactivate_selector(mmplayer_t *player, mmplayer_track_type_e type); +static gboolean __mmplayer_deactivate_combiner(mmplayer_t *player, mmplayer_track_type_e type); static void __mmplayer_deactivate_old_path(mmplayer_t *player); static int __mmplayer_gst_create_plain_text_elements(mmplayer_t *player); static guint32 _mmplayer_convert_fourcc_string_to_value(const gchar *format_name); @@ -309,7 +310,7 @@ _mmplayer_get_stream_service_type(mmplayer_t *player) } /* this function sets the player state and also report - * it to applicaton by calling callback function + * it to application by calling callback function */ void _mmplayer_set_state(mmplayer_t *player, int state) @@ -389,7 +390,7 @@ _mmplayer_check_state(mmplayer_t *player, mmplayer_command_state_e command) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); #ifdef __DEBUG__ - LOGD("incomming command : %d ", command); + LOGD("incoming command : %d ", command); #endif current_state = MMPLAYER_CURRENT_STATE(player); pending_state = MMPLAYER_PENDING_STATE(player); @@ -490,7 +491,7 @@ _mmplayer_check_state(mmplayer_t *player, mmplayer_command_state_e command) if (pending_state == MM_PLAYER_STATE_NONE) { if (current_state == MM_PLAYER_STATE_PAUSED) goto NO_OP; - else if (current_state != MM_PLAYER_STATE_PLAYING && current_state != MM_PLAYER_STATE_READY) // support loading state of broswer + else if (current_state != MM_PLAYER_STATE_PLAYING && current_state != MM_PLAYER_STATE_READY) // support loading state of browser goto INVALID_STATE; } else if (pending_state == MM_PLAYER_STATE_PAUSED) { goto ALREADY_GOING; @@ -583,6 +584,7 @@ int _mmplayer_acquire_hw_resource(mmplayer_t *player, mmplayer_resource_type_e t return MM_ERROR_PLAYER_INTERNAL; } + LOGD("commit [%d type] resource", type); rm_ret = mm_resource_manager_commit(player->resource_manager); if (rm_ret != MM_RESOURCE_MANAGER_ERROR_NONE) { LOGE("failed to commit of resource, ret(0x%x)", rm_ret); @@ -593,6 +595,36 @@ int _mmplayer_acquire_hw_resource(mmplayer_t *player, mmplayer_resource_type_e t return MM_ERROR_NONE; } +static void __mmplayer_destroy_hw_resource(mmplayer_t *player) +{ + int rm_ret = MM_RESOURCE_MANAGER_ERROR_NONE; + + MMPLAYER_RETURN_IF_FAIL(player); + MMPLAYER_RETURN_IF_FAIL(player->resource_manager); + + rm_ret = mm_resource_manager_mark_all_for_release(player->resource_manager); + if (rm_ret != MM_RESOURCE_MANAGER_ERROR_NONE) { + LOGW("failed to mark all for release of resource, ret(0x%x)", rm_ret); + goto rm_destroy; + } + + rm_ret = mm_resource_manager_commit(player->resource_manager); + if (rm_ret != MM_RESOURCE_MANAGER_ERROR_NONE) + LOGW("failed to commit resource, ret(0x%x)", rm_ret); + +rm_destroy: + /* de-initialize resource manager */ + rm_ret = mm_resource_manager_destroy(player->resource_manager); + if (rm_ret != MM_RESOURCE_MANAGER_ERROR_NONE) { + LOGW("failed to destroy resource manager, ret(0x%x)", rm_ret); + return; + } + + player->resource_manager = NULL; + + LOGD("resource manager is destroyed"); +} + static int __mmplayer_release_hw_resource(mmplayer_t *player, mmplayer_resource_type_e type) { int rm_ret = MM_RESOURCE_MANAGER_ERROR_NONE; @@ -613,9 +645,10 @@ static int __mmplayer_release_hw_resource(mmplayer_t *player, mmplayer_resource_ player->hw_resource[type] = NULL; + LOGD("commit [%d type] resource", type); rm_ret = mm_resource_manager_commit(player->resource_manager); if (rm_ret != MM_RESOURCE_MANAGER_ERROR_NONE) { - LOGE("failed to commit of resource, ret(0x%x)", rm_ret); + LOGE("failed to commit resource, ret(0x%x)", rm_ret); return MM_ERROR_PLAYER_INTERNAL; } @@ -841,7 +874,7 @@ _mmplayer_gst_remove_fakesink(mmplayer_t *player, mmplayer_gst_element_t *fakesi gst_element_set_locked_state(fakesink->gst, TRUE); /* setting the state to NULL never returns async - * so no need to wait for completion of state transiton + * so no need to wait for completion of state transition */ if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(fakesink->gst, GST_STATE_NULL)) LOGE("fakesink state change failure!"); @@ -962,7 +995,7 @@ __mmplayer_gst_selector_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointer GST_EVENT_TYPE(event) != GST_EVENT_QOS) return ret; - MMPLAYER_GST_GET_CAPS_INFO(pad, caps, str, name, caps_ret); + MMPLAYER_GST_GET_CAPS_INFO_FROM_PAD(pad, caps, str, name, caps_ret); if (!caps_ret) goto ERROR; @@ -1089,7 +1122,7 @@ ERROR: return ret; } -/* create fakesink for audio or video path witout audiobin or videobin */ +/* create fakesink for audio or video path without audiobin or videobin */ static void __mmplayer_gst_make_fakesink(mmplayer_t *player, GstPad *pad, const gchar *name) { @@ -1110,7 +1143,7 @@ __mmplayer_gst_make_fakesink(mmplayer_t *player, GstPad *pad, const gchar *name) } /* store it as it's sink element */ - __mmplayer_add_sink(player, fakesink); + __mmplayer_add_sink(player, fakesink, FALSE); gst_bin_add(GST_BIN(pipeline), fakesink); @@ -1146,6 +1179,35 @@ EXIT: } static GstElement * +__mmplayer_gst_make_concat(mmplayer_t *player, main_element_id_e elem_idx) +{ + GstElement *pipeline = NULL; + GstElement *concat = NULL; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin, NULL); + + concat = gst_element_factory_make("concat", NULL); + if (!concat) { + LOGE("failed to create concat"); + return NULL; + } + + LOGD("Create concat [%d] element", elem_idx); + + player->pipeline->mainbin[elem_idx].id = elem_idx; + player->pipeline->mainbin[elem_idx].gst = concat; + + gst_element_set_state(concat, GST_STATE_PAUSED); + + pipeline = player->pipeline->mainbin[MMPLAYER_M_PIPE].gst; + gst_bin_add(GST_BIN(pipeline), concat); + + MMPLAYER_FLEAVE(); + return concat; +} + +static GstElement * __mmplayer_gst_make_selector(mmplayer_t *player, main_element_id_e elem_idx, mmplayer_track_type_e stream_type) { GstElement *pipeline = NULL; @@ -1190,7 +1252,7 @@ void _mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data) { mmplayer_t *player = (mmplayer_t *)data; - GstElement *selector = NULL; + GstElement *combiner = NULL; GstCaps *caps = NULL; GstStructure *str = NULL; const gchar *name = NULL; @@ -1208,7 +1270,7 @@ _mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data) LOGD("pad-added signal handling"); /* get mimetype from caps */ - MMPLAYER_GST_GET_CAPS_INFO(pad, caps, str, name, caps_ret); + MMPLAYER_GST_GET_CAPS_INFO_FROM_PAD(pad, caps, str, name, caps_ret); if (!caps_ret) goto ERROR; @@ -1233,8 +1295,8 @@ _mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data) LOGD("surface type : %d", stype); - if (MMPLAYER_IS_MS_BUFF_SRC(player) || !MMPLAYER_USE_DECODEBIN(player)) { - __mmplayer_gst_create_sinkbin(elem, pad, player); + if (MMPLAYER_IS_MS_BUFF_SRC(player)) { + __mmplayer_gst_create_sink_bin(elem, pad, caps, player); goto DONE; } @@ -1245,17 +1307,22 @@ _mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data) goto DONE; } - LOGD("video selector is required"); - elem_idx = MMPLAYER_M_V_INPUT_SELECTOR; + if (MMPLAYER_USE_DECODEBIN(player)) { + LOGD("video selector is required"); + elem_idx = MMPLAYER_M_V_INPUT_SELECTOR; + } else { + LOGD("video concat is required"); + elem_idx = MMPLAYER_M_V_CONCAT; + } stream_type = MM_PLAYER_TRACK_TYPE_VIDEO; } else if (strstr(name, "audio")) { gint samplerate = 0; gint channels = 0; - if (MMPLAYER_IS_MS_BUFF_SRC(player) || !MMPLAYER_USE_DECODEBIN(player) || player->build_audio_offload) { + if (MMPLAYER_IS_MS_BUFF_SRC(player) || player->build_audio_offload) { if (player->build_audio_offload) player->no_more_pad = TRUE; /* remove state holder */ - __mmplayer_gst_create_sinkbin(elem, pad, player); + __mmplayer_gst_create_sink_bin(elem, pad, caps, player); goto DONE; } @@ -1266,14 +1333,23 @@ _mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data) __mmplayer_gst_make_fakesink(player, pad, name); goto DONE; } - - LOGD("audio selector is required"); - elem_idx = MMPLAYER_M_A_INPUT_SELECTOR; + if (MMPLAYER_USE_DECODEBIN(player)) { + LOGD("audio selector is required"); + elem_idx = MMPLAYER_M_A_INPUT_SELECTOR; + } else { + LOGD("audio concat is required"); + elem_idx = MMPLAYER_M_A_CONCAT; + } stream_type = MM_PLAYER_TRACK_TYPE_AUDIO; } else if (strstr(name, "text")) { - LOGD("text selector is required"); - elem_idx = MMPLAYER_M_T_INPUT_SELECTOR; + if (MMPLAYER_USE_DECODEBIN(player)) { + LOGD("text selector is required"); + elem_idx = MMPLAYER_M_T_INPUT_SELECTOR; + } else { + LOGD("text concat is required"); + elem_idx = MMPLAYER_M_T_CONCAT; + } stream_type = MM_PLAYER_TRACK_TYPE_TEXT; } else { LOGE("invalid caps info"); @@ -1281,33 +1357,47 @@ _mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data) } /* check selector and create it */ - if (!(selector = player->pipeline->mainbin[elem_idx].gst)) { - selector = __mmplayer_gst_make_selector(player, elem_idx, stream_type); - if (!selector) + if (!(combiner = player->pipeline->mainbin[elem_idx].gst)) { + if (MMPLAYER_USE_DECODEBIN(player)) + combiner = __mmplayer_gst_make_selector(player, elem_idx, stream_type); + else + combiner = __mmplayer_gst_make_concat(player, elem_idx); + + if (!combiner) goto ERROR; first_track = TRUE; } else { - LOGD("input-selector is already created."); + LOGD("Combiner element is already created."); } /* link */ - sinkpad = gst_element_get_request_pad(selector, "sink_%u"); + sinkpad = gst_element_get_request_pad(combiner, "sink_%u"); LOGD("pad link: %s:%s - %s:%s", GST_DEBUG_PAD_NAME(pad), GST_DEBUG_PAD_NAME(sinkpad)); if (gst_pad_link(pad, sinkpad) != GST_PAD_LINK_OK) { - LOGE("failed to link selector"); - gst_object_unref(GST_OBJECT(selector)); + LOGE("failed to link combiner"); + gst_object_unref(GST_OBJECT(combiner)); goto ERROR; } if (first_track) { - LOGD("this track will be activated"); - g_object_set(selector, "active-pad", sinkpad, NULL); + if (MMPLAYER_USE_DECODEBIN(player)) { + LOGD("this track will be activated"); + g_object_set(combiner, "active-pad", sinkpad, NULL); + } } - if (MMPLAYER_USE_DECODEBIN(player)) + if (MMPLAYER_USE_DECODEBIN(player)) { _mmplayer_track_update_stream(player, stream_type, sinkpad); + } else { + /* apply the text track information */ + if (stream_type == MM_PLAYER_TRACK_TYPE_TEXT) + mm_player_set_attribute((MMHandleType)player, NULL, + "content_text_track_num", player->track[stream_type].total_track_num, + "current_text_track_index", player->track[stream_type].active_track_index, NULL); + __mmplayer_create_sink_path(player, combiner, stream_type, caps); + } DONE: ERROR: @@ -1324,7 +1414,7 @@ ERROR: } static gboolean -__mmplayer_create_sink_path(mmplayer_t *player, GstElement *selector, mmplayer_track_type_e type) +__mmplayer_create_sink_path(mmplayer_t *player, GstElement *combiner, mmplayer_track_type_e type, GstCaps *caps) { GstPad *srcpad = NULL; @@ -1333,20 +1423,20 @@ __mmplayer_create_sink_path(mmplayer_t *player, GstElement *selector, mmplayer_t LOGD("type %d", type); - if (!selector) { + if (!combiner) { LOGD("there is no %d track", type); return TRUE; } - srcpad = gst_element_get_static_pad(selector, "src"); + srcpad = gst_element_get_static_pad(combiner, "src"); if (!srcpad) { - LOGE("failed to get srcpad from selector"); + LOGE("failed to get srcpad from combiner"); return FALSE; } - LOGD("got pad %s:%s from selector", GST_DEBUG_PAD_NAME(srcpad)); + LOGD("got pad %s:%s from combiner", GST_DEBUG_PAD_NAME(srcpad)); - __mmplayer_gst_create_sinkbin(selector, srcpad, player); + __mmplayer_gst_create_sink_bin(combiner, srcpad, caps, player); LOGD("unblocking %s:%s", GST_DEBUG_PAD_NAME(srcpad)); if (player->track[type].block_id) { @@ -1422,7 +1512,7 @@ __mmplayer_create_audio_sink_path(mmplayer_t *player, GstElement *audio_selector __mmplayer_set_decode_track_info(player, MM_PLAYER_TRACK_TYPE_AUDIO); /* create audio sink path */ - if (!__mmplayer_create_sink_path(player, audio_selector, MM_PLAYER_TRACK_TYPE_AUDIO)) { + if (!__mmplayer_create_sink_path(player, audio_selector, MM_PLAYER_TRACK_TYPE_AUDIO, NULL)) { LOGE("failed to create audio sink path"); return FALSE; } @@ -1438,7 +1528,7 @@ __mmplayer_create_text_sink_path(mmplayer_t *player, GstElement *text_selector) MMPLAYER_RETURN_VAL_IF_FAIL(player && text_selector, FALSE); if (MMPLAYER_IS_MS_BUFF_SRC(player)) { - LOGD("text path is not supproted"); + LOGD("text path is not supported"); return TRUE; } @@ -1451,7 +1541,7 @@ __mmplayer_create_text_sink_path(mmplayer_t *player, GstElement *text_selector) /* create text decode path */ player->no_more_pad = TRUE; - if (!__mmplayer_create_sink_path(player, text_selector, MM_PLAYER_TRACK_TYPE_TEXT)) { + if (!__mmplayer_create_sink_path(player, text_selector, MM_PLAYER_TRACK_TYPE_TEXT, NULL)) { LOGE("failed to create text sink path"); return FALSE; } @@ -1526,7 +1616,7 @@ _mmplayer_gst_decode_no_more_pads(GstElement *elem, gpointer data) if (video_selector && !audio_selector && !text_selector) player->no_more_pad = TRUE; - if (!__mmplayer_create_sink_path(player, video_selector, MM_PLAYER_TRACK_TYPE_VIDEO)) + if (!__mmplayer_create_sink_path(player, video_selector, MM_PLAYER_TRACK_TYPE_VIDEO, NULL)) goto EXIT; /* create audio path followed by audio-select */ @@ -1607,7 +1697,7 @@ EXIT: } static void -__mmplayer_gst_create_sinkbin(GstElement *elem, GstPad *pad, gpointer data) +__mmplayer_gst_create_sink_bin(GstElement *elem, GstPad *pad, GstCaps *ref_caps, gpointer data) { mmplayer_t *player = NULL; GstCaps *caps = NULL; @@ -1625,10 +1715,15 @@ __mmplayer_gst_create_sinkbin(GstElement *elem, GstPad *pad, gpointer data) MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(elem && pad); MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && MMPLAYER_GET_ATTRS(player)); - - MMPLAYER_GST_GET_CAPS_INFO(pad, caps, str, name, caps_ret); - if (!caps_ret) - goto ERROR; + MMPLAYER_GST_GET_CAPS_INFO_FROM_PAD(pad, caps, str, name, caps_ret); + if (!caps_ret) { + MMPLAYER_GST_GET_CAPS_INFO(ref_caps, str, name, caps_ret); + if (!caps_ret) + goto ERROR; + if (caps) + gst_caps_unref(caps); + caps = gst_caps_ref(ref_caps); + } caps_str = gst_caps_to_string(caps); #ifdef __DEBUG__ @@ -1704,7 +1799,7 @@ __mmplayer_gst_create_sinkbin(GstElement *elem, GstPad *pad, gpointer data) player->textsink_linked = 1; } else { /* linked textbin exist which means that the external subtitle path exist already */ - LOGW("ignoring internal subtutle since external subtitle is available"); + LOGW("ignoring internal subtitle since external subtitle is available"); } } sink_pad_name = "text_sink"; @@ -1770,7 +1865,7 @@ __mmplayer_get_property_value_for_rotation(mmplayer_t *player, int display_angle if (rotation_angle >= 360) rotation_angle -= 360; - /* chech if supported or not */ + /* check if supported or not */ if (rotation_angle % 90) { LOGD("not supported rotation angle = %d", rotation_angle); return FALSE; @@ -1809,7 +1904,7 @@ _mmplayer_get_video_angle(mmplayer_t *player, int *display_angle, int *orientati } if (display_angle) { - /* update user roation */ + /* update user rotation */ mm_attrs_get_int_by_name(attrs, "display_rotation", &display_rotation); /* Counter clockwise */ @@ -2215,11 +2310,7 @@ __mmplayer_gst_caps_notify_cb(GstPad *pad, GParamSpec *unused, gpointer data) MMPLAYER_RETURN_IF_FAIL(unused); MMPLAYER_RETURN_IF_FAIL(data); - caps = gst_pad_get_current_caps(pad); - if (!caps) - return; - - MMPLAYER_GST_GET_CAPS_INFO(pad, caps, str, name, caps_ret); + MMPLAYER_GST_GET_CAPS_INFO_FROM_PAD(pad, caps, str, name, caps_ret); if (!caps_ret) goto ERROR; @@ -2467,7 +2558,7 @@ __mmplayer_gst_audio_deinterleave_pad_added(GstElement *elem, GstPad *pad, gpoin G_CALLBACK(__mmplayer_audio_stream_decoded_render_cb), (gpointer)player); - __mmplayer_add_sink(player, sink); + __mmplayer_add_sink(player, sink, FALSE); if (gst_element_sync_state_with_parent(queue) == GST_STATE_CHANGE_FAILURE) { LOGE("failed to sync state"); @@ -2771,7 +2862,7 @@ __mmplayer_gst_make_audio_playback_sink(mmplayer_t *player, GList **bucket) "notify::caps", G_CALLBACK(__mmplayer_gst_caps_notify_cb), (gpointer)player); gst_object_unref(GST_OBJECT(sink_pad)); - __mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst); + __mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst, FALSE); MMPLAYER_FLEAVE(); return MM_ERROR_NONE; @@ -2927,7 +3018,7 @@ __mmplayer_gst_make_audio_extract_sink(mmplayer_t *player, GList **bucket) G_CALLBACK(__mmplayer_audio_stream_decoded_render_cb), (gpointer)player); - __mmplayer_add_sink(player, audiobin[extract_sink_id].gst); + __mmplayer_add_sink(player, audiobin[extract_sink_id].gst, FALSE); } MMPLAYER_FLEAVE(); @@ -2958,7 +3049,7 @@ __mmplayer_gst_make_audio_bin_element(mmplayer_t *player, GList **bucket) g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "sync", TRUE, "volume", player->sound.volume, "mute", player->sound.mute, NULL); - __mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst); + __mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst, FALSE); goto DONE; } @@ -3089,7 +3180,7 @@ ERROR: } } - /* release audiobin with it's childs */ + /* release audiobin with it's children */ if (audiobin[MMPLAYER_A_BIN].gst) gst_object_unref(GST_OBJECT(audiobin[MMPLAYER_A_BIN].gst)); @@ -3297,7 +3388,7 @@ __mmplayer_video_stream_decoded_render_cb(GstElement *object, GstBuffer *buffer, /* set size and timestamp */ mem = gst_buffer_peek_memory(buffer, 0); stream->length_total = gst_memory_get_sizes(mem, NULL, NULL); - stream->timestamp = (unsigned int)(GST_TIME_AS_MSECONDS(GST_BUFFER_PTS(buffer))); /* nano sec -> mili sec */ + stream->timestamp = (unsigned int)(GST_TIME_AS_MSECONDS(GST_BUFFER_PTS(buffer))); /* nano sec -> milli sec */ /* check zero-copy */ if (player->set_mode.video_zc && @@ -3590,7 +3681,7 @@ __mmplayer_gst_create_video_sink_bin(mmplayer_t *player, GstCaps *caps, MMDispla } /* store it as it's sink element */ - __mmplayer_add_sink(player, videobin[MMPLAYER_V_SINK].gst); + __mmplayer_add_sink(player, videobin[MMPLAYER_V_SINK].gst, TRUE); /* adding created elements to bin */ if (!_mmplayer_gst_element_add_bucket_to_bin(GST_BIN(videobin[MMPLAYER_V_BIN].gst), element_bucket)) { @@ -3639,7 +3730,7 @@ ERROR: if (pad) gst_object_unref(GST_OBJECT(pad)); - /* release videobin with it's childs */ + /* release videobin with it's children */ if (videobin[MMPLAYER_V_BIN].gst) gst_object_unref(GST_OBJECT(videobin[MMPLAYER_V_BIN].gst)); @@ -3674,7 +3765,7 @@ __mmplayer_gst_create_plain_text_elements(mmplayer_t *player) if (!player->play_subtitle) { LOGD("add textbin sink as sink element of whole pipeline."); - __mmplayer_add_sink(player, GST_ELEMENT(textbin[MMPLAYER_T_FAKE_SINK].gst)); + __mmplayer_add_sink(player, GST_ELEMENT(textbin[MMPLAYER_T_FAKE_SINK].gst), FALSE); } /* adding created elements to bin */ @@ -3813,7 +3904,7 @@ ERROR: } } - /* release textbin with it's childs */ + /* release textbin with it's children */ if (textbin[MMPLAYER_T_BIN].gst) gst_object_unref(GST_OBJECT(textbin[MMPLAYER_T_BIN].gst)); @@ -3935,7 +4026,7 @@ __mmplayer_gst_create_text_pipeline(mmplayer_t *player) /* release signal */ __mmplayer_release_signal_connection(player, MM_PLAYER_SIGNAL_TYPE_TEXTBIN); - /* release textbin with it's childs */ + /* release textbin with it's children */ gst_object_unref(GST_OBJECT(textbin[MMPLAYER_T_BIN].gst)); MMPLAYER_FREEIF(player->pipeline->textbin); player->pipeline->textbin = textbin = NULL; @@ -3986,7 +4077,7 @@ ERROR: if (player->pipeline->textbin) { LOGE("remove textbin"); - /* release textbin with it's childs */ + /* release textbin with it's children */ MMPLAYER_RELEASE_ELEMENT(player, player->pipeline->textbin, MMPLAYER_T_BIN); MMPLAYER_FREEIF(player->pipeline->textbin); player->pipeline->textbin = NULL; @@ -4111,7 +4202,7 @@ __mmplayer_gst_adjust_subtitle_position(mmplayer_t *player, int position) return MM_ERROR_NONE; } - /* check current postion */ + /* check current position */ player->adjust_subtitle_pos = position; LOGD("save adjust_subtitle_pos in player"); @@ -4186,7 +4277,7 @@ __mmplayer_gst_create_pipeline(mmplayer_t *player) goto INIT_ERROR; } - /* Note : check whether subtitle atrribute uri is set. If uri is set, then try to play subtitle file */ + /* Note : check whether subtitle attribute uri is set. If uri is set, then try to play subtitle file */ if (__mmplayer_check_subtitle(player) && (__mmplayer_gst_create_text_pipeline(player) != MM_ERROR_NONE)) LOGE("failed to create text pipeline"); @@ -4290,10 +4381,6 @@ __mmplayer_gst_destroy_pipeline(mmplayer_t *player) if (mainbin[MMPLAYER_M_SRC_FAKESINK].gst) gst_object_unref(GST_OBJECT(mainbin[MMPLAYER_M_SRC_FAKESINK].gst)); - /* free avsysaudiosink - avsysaudiosink should be unref when destory pipeline just after start play with BT. - Because audiosink is created but never added to bin, and therefore it will not be unref when pipeline is destroyed. - */ MMPLAYER_FREEIF(audiobin); MMPLAYER_FREEIF(videobin); MMPLAYER_FREEIF(textbin); @@ -4307,6 +4394,11 @@ __mmplayer_gst_destroy_pipeline(mmplayer_t *player) } MMPLAYER_FREEIF(player->album_art); + if (player->type_caps) { + gst_caps_unref(player->type_caps); + player->type_caps = NULL; + } + if (player->v_stream_caps) { gst_caps_unref(player->v_stream_caps); player->v_stream_caps = NULL; @@ -4397,7 +4489,7 @@ __mmplayer_gst_unrealize(mmplayer_t *player) /* destroy pipeline */ ret = __mmplayer_gst_destroy_pipeline(player); if (ret != MM_ERROR_NONE) { - LOGE("failed to destory pipeline"); + LOGE("failed to destroy pipeline"); return ret; } @@ -4481,55 +4573,6 @@ _mmplayer_parse_profile(const char *uri, void *param, mmplayer_parse_profile_t * return ret; } -static gboolean -__mmplayer_can_do_interrupt(mmplayer_t *player) -{ - if (!player || !player->pipeline || !player->attrs) { - LOGW("not initialized"); - goto FAILED; - } - - if (player->audio_decoded_cb) { - LOGW("not support in pcm extraction mode"); - goto FAILED; - } - - /* check if seeking */ - if (player->seek_state != MMPLAYER_SEEK_NONE) { - MMMessageParamType msg_param; - memset(&msg_param, 0, sizeof(MMMessageParamType)); - msg_param.code = MM_ERROR_PLAYER_SEEK; - player->seek_state = MMPLAYER_SEEK_NONE; - MMPLAYER_POST_MSG(player, MM_MESSAGE_ERROR, &msg_param); - goto FAILED; - } - - /* check other thread */ - if (!MMPLAYER_CMD_TRYLOCK(player)) { - LOGW("locked already, cmd state : %d", player->cmd); - - /* check application command */ - if (player->cmd == MMPLAYER_COMMAND_START || player->cmd == MMPLAYER_COMMAND_RESUME) { - LOGW("playing.. should wait cmd lock then, will be interrupted"); - - /* lock will be released at mrp_resource_release_cb() */ - MMPLAYER_CMD_LOCK(player); - goto INTERRUPT; - } - LOGW("nothing to do"); - goto FAILED; - } else { - LOGW("can interrupt immediately"); - goto INTERRUPT; - } - -FAILED: /* with CMD UNLOCKED */ - return FALSE; - -INTERRUPT: /* with CMD LOCKED, will do UNLOCK at __resource_release_cb() */ - return TRUE; -} - static int __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res, void *user_data) @@ -4543,14 +4586,25 @@ __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res, if (!user_data) { LOGE("user_data is null"); - return FALSE; + return TRUE; } + player = (mmplayer_t *)user_data; - if (!__mmplayer_can_do_interrupt(player)) { - LOGW("no need to interrupt, so leave"); - /* FIXME: there is no way to avoid releasing resource. */ - return FALSE; + if (!player->pipeline || !player->attrs) { + LOGW("not initialized"); + return TRUE; + } + + LOGD("cmd lock player, cmd state : %d", player->cmd); + MMPLAYER_CMD_LOCK(player); + LOGD("cmd locked player"); + + if (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_NULL + || MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_NONE) { + LOGW("player already destroyed"); + MMPLAYER_CMD_UNLOCK(player); + return TRUE; } player->interrupted_by_resource = TRUE; @@ -4568,7 +4622,6 @@ __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res, if (_mmplayer_unrealize((MMHandleType)player) != MM_ERROR_NONE) LOGE("failed to unrealize"); - /* lock is called in __mmplayer_can_do_interrupt() */ MMPLAYER_CMD_UNLOCK(player); for (res_idx = MMPLAYER_RESOURCE_TYPE_VIDEO_DECODER; res_idx < MMPLAYER_RESOURCE_TYPE_MAX; res_idx++) { @@ -4664,7 +4717,7 @@ _mmplayer_create_player(MMHandleType handle) if (mm_resource_manager_create(MM_RESOURCE_MANAGER_APP_CLASS_MEDIA, __resource_release_cb, player, &player->resource_manager) != MM_RESOURCE_MANAGER_ERROR_NONE) { - LOGE("failed to initialize resource manager"); + LOGE("failed to create resource manager"); ret = MM_ERROR_PLAYER_INTERNAL; goto ERROR; } @@ -4931,7 +4984,7 @@ _mmplayer_destroy(MMHandleType handle) MMPLAYER_GAPLESS_PLAY_THREAD_SIGNAL(player); MMPLAYER_GAPLESS_PLAY_THREAD_UNLOCK(player); - LOGD("waitting for gapless play thread exit"); + LOGD("waiting for gapless play thread exit"); g_thread_join(player->gapless_play_thread); g_mutex_clear(&player->gapless_play_thread_mutex); g_cond_clear(&player->gapless_play_thread_cond); @@ -4940,20 +4993,17 @@ _mmplayer_destroy(MMHandleType handle) _mmplayer_release_video_capture(player); - /* de-initialize resource manager */ - if (MM_RESOURCE_MANAGER_ERROR_NONE != mm_resource_manager_destroy( - player->resource_manager)) - LOGE("failed to deinitialize resource manager"); - /* release miscellaneous information */ __mmplayer_release_misc(player); /* release pipeline */ - if (MM_ERROR_NONE != __mmplayer_gst_destroy_pipeline(player)) { - LOGE("failed to destory pipeline"); + if (__mmplayer_gst_destroy_pipeline(player) != MM_ERROR_NONE) { + LOGE("failed to destroy pipeline"); return MM_ERROR_PLAYER_INTERNAL; } + __mmplayer_destroy_hw_resource(player); + g_queue_free(player->bus_msg_q); /* release subtitle info lock and cond */ @@ -4997,9 +5047,7 @@ _mmplayer_realize(MMHandleType hplayer) char *uri = NULL; void *param = NULL; MMHandleType attrs = 0; - int video_codec_type = 0; - int audio_codec_type = 0; - int default_codec_type = 0; + MMPLAYER_FENTER(); /* check player handle */ @@ -5082,23 +5130,6 @@ _mmplayer_realize(MMHandleType hplayer) player->streamer->buffering_req.rebuffer_time); } - mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_AUDIO_CODEC_TYPE, &audio_codec_type); - if (!strcmp(player->ini.audiocodec_default_type, "hw")) - default_codec_type = MM_PLAYER_CODEC_TYPE_HW; - else - default_codec_type = MM_PLAYER_CODEC_TYPE_SW; - - if (audio_codec_type != default_codec_type) { - LOGD("audio dec sorting is required"); - player->need_audio_dec_sorting = TRUE; - } - - mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_VIDEO_CODEC_TYPE, &video_codec_type); - if (video_codec_type != MM_PLAYER_CODEC_TYPE_DEFAULT) { - LOGD("video dec sorting is required"); - player->need_video_dec_sorting = TRUE; - } - /* realize pipeline */ ret = __mmplayer_gst_realize(player); if (ret != MM_ERROR_NONE) @@ -5116,6 +5147,8 @@ _mmplayer_unrealize(MMHandleType hplayer) { mmplayer_t *player = (mmplayer_t *)hplayer; int ret = MM_ERROR_NONE; + int rm_ret = MM_ERROR_NONE; + mmplayer_resource_type_e res_idx = MMPLAYER_RESOURCE_TYPE_MAX; MMPLAYER_FENTER(); @@ -5137,17 +5170,14 @@ _mmplayer_unrealize(MMHandleType hplayer) /* unrealize pipeline */ ret = __mmplayer_gst_unrealize(player); - if (!player->interrupted_by_resource) { - int rm_ret = MM_ERROR_NONE; - mmplayer_resource_type_e res_idx = MMPLAYER_RESOURCE_TYPE_MAX; - - for (res_idx = MMPLAYER_RESOURCE_TYPE_VIDEO_DECODER; res_idx < MMPLAYER_RESOURCE_TYPE_MAX; res_idx++) { - rm_ret = __mmplayer_release_hw_resource(player, res_idx); - if (rm_ret != MM_ERROR_NONE) - LOGE("failed to release [%d] resources", res_idx); - } + for (res_idx = MMPLAYER_RESOURCE_TYPE_VIDEO_DECODER; res_idx < MMPLAYER_RESOURCE_TYPE_MAX; res_idx++) { + rm_ret = __mmplayer_release_hw_resource(player, res_idx); + if (rm_ret != MM_ERROR_NONE) + LOGE("failed to release [%d] resources", res_idx); } + player->interrupted_by_resource = FALSE; + MMPLAYER_FLEAVE(); return ret; } @@ -5555,14 +5585,14 @@ _mmplayer_pause(MMHandleType hplayer) /* check current state */ MMPLAYER_CHECK_STATE(player, MMPLAYER_COMMAND_PAUSE); - /* check pipline reconfigure state */ + /* check pipeline reconfigure state */ __mmplayer_check_pipeline_reconfigure_state(player); switch (MMPLAYER_CURRENT_STATE(player)) { case MM_PLAYER_STATE_READY: { /* check prepare async or not. - * In the case of streaming playback, it's recommned to avoid blocking wait. + * In the case of streaming playback, it's recommended to avoid blocking wait. */ mm_attrs_get_int_by_name(player->attrs, "profile_prepare_async", &async); LOGD("prepare working mode : %s", (async ? "async" : "sync")); @@ -5605,9 +5635,11 @@ _mmplayer_pause(MMHandleType hplayer) /* pause pipeline */ ret = _mmplayer_gst_pause(player, async); - - if (ret != MM_ERROR_NONE) + if (ret != MM_ERROR_NONE) { LOGE("failed to pause player. ret : 0x%x", ret); + MMPLAYER_GENERATE_DOT_IF_ENABLED(player, "pipeline-pause-err"); + return ret; + } if (MMPLAYER_PREV_STATE(player) == MM_PLAYER_STATE_READY && MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PAUSED) { if (_mmplayer_update_video_overlay_param(player, "display_rotation") != MM_ERROR_NONE) @@ -5615,8 +5647,7 @@ _mmplayer_pause(MMHandleType hplayer) } MMPLAYER_FLEAVE(); - - return ret; + return MM_ERROR_NONE; } /* in case of streaming, pause could take long time.*/ @@ -5763,7 +5794,7 @@ _mmplayer_set_position(MMHandleType hplayer, gint64 position) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - /* check pipline reconfigure state */ + /* check pipeline reconfigure state */ __mmplayer_check_pipeline_reconfigure_state(player); ret = _mmplayer_gst_set_position(player, position, FALSE); @@ -5803,7 +5834,7 @@ _mmplayer_get_buffer_position(MMHandleType hplayer, int *start_pos, int *end_pos } int -_mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int position) +_mmplayer_adjust_subtitle_position(MMHandleType hplayer, int position) { mmplayer_t *player = (mmplayer_t *)hplayer; int ret = MM_ERROR_NONE; @@ -5922,6 +5953,14 @@ _mmplayer_typefind_have_type(GstElement *tf, guint probability, MMPLAYER_RETURN_IF_FAIL(player && tf && caps); /* store type string */ + if (player->type_caps) { + gst_caps_unref(player->type_caps); + player->type_caps = NULL; + } + + player->type_caps = gst_caps_copy(caps); + MMPLAYER_LOG_GST_CAPS_TYPE(player->type_caps); + MMPLAYER_FREEIF(player->type); player->type = gst_caps_to_string(caps); if (player->type) @@ -6472,6 +6511,92 @@ ERROR: return FALSE; } +static void +__mmplayer_remove_sinkpad (const GValue *item, gpointer user_data) +{ + GstPad *sinkpad = g_value_get_object (item); + GstElement *element = GST_ELEMENT(user_data); + if (!sinkpad || !element) { + LOGE("invalid parameter"); + return; + } + + LOGD("(%s)element release request pad(%s)", GST_ELEMENT_NAME(element), GST_PAD_NAME(sinkpad)); + gst_element_release_request_pad(element, GST_PAD(sinkpad)); +} + +static gboolean +__mmplayer_deactivate_combiner(mmplayer_t *player, mmplayer_track_type_e type) +{ + mmplayer_gst_element_t *sinkbin = NULL; + main_element_id_e concatId = MMPLAYER_M_NUM; + main_element_id_e sinkId = MMPLAYER_M_NUM; + gboolean send_notice = FALSE; + GstElement *element; + GstIterator *iter; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE); + + LOGD("type %d", type); + + switch (type) { + case MM_PLAYER_TRACK_TYPE_AUDIO: + concatId = MMPLAYER_M_A_CONCAT; + sinkId = MMPLAYER_A_BIN; + sinkbin = player->pipeline->audiobin; + break; + case MM_PLAYER_TRACK_TYPE_VIDEO: + concatId = MMPLAYER_M_V_CONCAT; + sinkId = MMPLAYER_V_BIN; + sinkbin = player->pipeline->videobin; + send_notice = TRUE; + break; + case MM_PLAYER_TRACK_TYPE_TEXT: + concatId = MMPLAYER_M_T_CONCAT; + sinkId = MMPLAYER_T_BIN; + sinkbin = player->pipeline->textbin; + break; + default: + LOGE("requested type is not supportable"); + return FALSE; + break; + } + + element = player->pipeline->mainbin[concatId].gst; + if (!element) + return TRUE; + + if ((sinkbin) && (sinkbin[sinkId].gst)) { + GstPad *srcpad = gst_element_get_static_pad(element, "src"); + GstPad *sinkpad = gst_element_get_static_pad(sinkbin[sinkId].gst, "sink"); + if (srcpad && sinkpad) { + /* after getting drained signal there is no data flows, so no need to do pad_block */ + LOGD("unlink %s:%s, %s:%s", GST_DEBUG_PAD_NAME(srcpad), GST_DEBUG_PAD_NAME(sinkpad)); + gst_pad_unlink(srcpad, sinkpad); + + /* send custom event to sink pad to handle it at video sink */ + if (send_notice) { + LOGD("send custom event to sinkpad"); + GstStructure *s = gst_structure_new_empty("tizen/flush-buffer"); + GstEvent *event = gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM, s); + gst_pad_send_event(sinkpad, event); + } + } + gst_object_unref(srcpad); + gst_object_unref(sinkpad); + } + + LOGD("release concat request pad"); + /* release and unref requests pad from the selector */ + iter = gst_element_iterate_sink_pads(element); + while (gst_iterator_foreach(iter, __mmplayer_remove_sinkpad, element) == GST_ITERATOR_RESYNC) + gst_iterator_resync(iter); + gst_iterator_free(iter); + + return TRUE; +} + static gboolean __mmplayer_deactivate_selector(mmplayer_t *player, mmplayer_track_type_e type) { @@ -6569,11 +6694,20 @@ __mmplayer_deactivate_old_path(mmplayer_t *player) MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(player); - if ((!__mmplayer_deactivate_selector(player, MM_PLAYER_TRACK_TYPE_AUDIO)) || - (!__mmplayer_deactivate_selector(player, MM_PLAYER_TRACK_TYPE_VIDEO)) || - (!__mmplayer_deactivate_selector(player, MM_PLAYER_TRACK_TYPE_TEXT))) { - LOGE("deactivate selector error"); - goto ERROR; + if (MMPLAYER_USE_DECODEBIN(player)) { + if ((!__mmplayer_deactivate_selector(player, MM_PLAYER_TRACK_TYPE_AUDIO)) || + (!__mmplayer_deactivate_selector(player, MM_PLAYER_TRACK_TYPE_VIDEO)) || + (!__mmplayer_deactivate_selector(player, MM_PLAYER_TRACK_TYPE_TEXT))) { + LOGE("deactivate selector error"); + goto ERROR; + } + } else { + if ((!__mmplayer_deactivate_combiner(player, MM_PLAYER_TRACK_TYPE_AUDIO)) || + (!__mmplayer_deactivate_combiner(player, MM_PLAYER_TRACK_TYPE_VIDEO)) || + (!__mmplayer_deactivate_combiner(player, MM_PLAYER_TRACK_TYPE_TEXT))) { + LOGE("deactivate concat error"); + goto ERROR; + } } _mmplayer_track_destroy(player); @@ -6650,9 +6784,9 @@ _mmplayer_set_next_uri(MMHandleType hplayer, const char *uri, bool is_first_path player->uri_info.uri_list = g_list_append(player->uri_info.uri_list, g_strdup(uri)); SECURE_LOGD("add original path : %s", uri); } else { - player->uri_info.uri_list = g_list_delete_link(player->uri_info.uri_list, g_list_nth(player->uri_info.uri_list, 0)); - player->uri_info.uri_list = g_list_insert(player->uri_info.uri_list, g_strdup(uri), 0); - + g_free(g_list_nth_data(player->uri_info.uri_list, 0)); + player->uri_info.uri_list = g_list_prepend( + g_list_delete_link(player->uri_info.uri_list, player->uri_info.uri_list), g_strdup(uri)); SECURE_LOGD("change original path : %s", uri); } } else { @@ -6700,7 +6834,7 @@ _mmplayer_get_next_uri(MMHandleType hplayer, char **uri) if (num_of_list > 0) { gint uri_idx = player->uri_info.uri_idx; - if (uri_idx < num_of_list-1) + if (uri_idx < num_of_list - 1) uri_idx++; else uri_idx = 0; @@ -7225,7 +7359,7 @@ _mmplayer_gst_decode_autoplug_select(GstElement *bin, GstPad *pad, /* filtering exclude keyword */ for (idx = 0; player->ini.exclude_element_keyword[idx][0] != '\0'; idx++) { if (strstr(factory_name, player->ini.exclude_element_keyword[idx])) { - LOGW("skipping [%s] by exculde keyword [%s]", + LOGW("skipping [%s] by exclude keyword [%s]", factory_name, player->ini.exclude_element_keyword[idx]); result = GST_AUTOPLUG_SELECT_SKIP; @@ -7353,6 +7487,36 @@ _mmplayer_gst_decode_pad_removed(GstElement *elem, GstPad *new_pad, } void +_mmplayer_gst_about_to_finish(GstElement *bin, gpointer data) +{ + mmplayer_t *player = (mmplayer_t *)data; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_IF_FAIL(player); + + LOGD("got about to finish signal"); + + if (!MMPLAYER_CMD_TRYLOCK(player)) { + LOGW("Fail to get cmd lock"); + return; + } + + if (!__mmplayer_verify_gapless_play_path(player)) { + LOGD("decoding is finished."); + MMPLAYER_CMD_UNLOCK(player); + return; + } + + _mmplayer_set_reconfigure_state(player, TRUE); + MMPLAYER_CMD_UNLOCK(player); + + MMPLAYER_POST_MSG(player, MM_MESSAGE_GAPLESS_CONSTRUCTION, NULL); + __mmplayer_deactivate_old_path(player); + + MMPLAYER_FLEAVE(); +} + +void _mmplayer_gst_decode_drained(GstElement *bin, gpointer data) { mmplayer_t *player = (mmplayer_t *)data; @@ -7602,7 +7766,7 @@ __mmplayer_release_misc(mmplayer_t *player) static void __mmplayer_release_misc_post(mmplayer_t *player) { - char *original_uri = NULL; + gchar *original_uri = NULL; MMPLAYER_FENTER(); /* player->pipeline is already released before. */ @@ -7639,7 +7803,7 @@ __mmplayer_release_misc_post(mmplayer_t *player) mm_player_set_attribute((MMHandleType)player, NULL, "profile_uri", original_uri, (original_uri) ? strlen(original_uri) : (0), NULL); - + MMPLAYER_FREEIF(original_uri); } /* clear the audio stream buffer list */ @@ -7702,14 +7866,17 @@ _mmplayer_cancel_eos_timer(mmplayer_t *player) } static void -__mmplayer_add_sink(mmplayer_t *player, GstElement *sink) +__mmplayer_add_sink(mmplayer_t *player, GstElement *sink, gboolean first) { MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(player); MMPLAYER_RETURN_IF_FAIL(sink); - player->sink_elements = g_list_append(player->sink_elements, sink); + if (first) + player->sink_elements = g_list_prepend(player->sink_elements, sink); + else + player->sink_elements = g_list_append(player->sink_elements, sink); MMPLAYER_FLEAVE(); } @@ -7976,7 +8143,7 @@ ERROR: /* release signal */ __mmplayer_release_signal_connection(player, MM_PLAYER_SIGNAL_TYPE_TEXTBIN); - /* release textbin with it's childs */ + /* release textbin with it's children */ MMPLAYER_RELEASE_ELEMENT(player, player->pipeline->textbin, MMPLAYER_T_BIN); MMPLAYER_FREEIF(player->pipeline->textbin); player->pipeline->textbin = NULL; @@ -8334,15 +8501,15 @@ _mmplayer_change_track_language(MMHandleType hplayer, mmplayer_track_type_e type current_state = GST_STATE(mainbin[MMPLAYER_M_PIPE].gst); if (current_state < GST_STATE_PAUSED) { result = MM_ERROR_PLAYER_INVALID_STATE; - LOGW("Pipeline not in porper state"); + LOGW("Pipeline not in proper state"); goto EXIT; } - if (MMPLAYER_USE_DECODEBIN(player)) { + if (MMPLAYER_USE_DECODEBIN(player)) result = __mmplayer_change_selector_pad(player, type, index); - } else { + else result = __mmplayer_switch_stream(player, type, index); - } + if (result != MM_ERROR_NONE) { LOGE("failed to change track"); goto EXIT; @@ -8567,7 +8734,7 @@ _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int state) if (state != STORAGE_STATE_UNMOUNTABLE && state != STORAGE_STATE_REMOVED) return MM_ERROR_NONE; - /* FIXME: text path should be handled seperately. */ + /* FIXME: text path should be handled separately. */ if (((player->storage_info[MMPLAYER_PATH_VOD].type == STORAGE_TYPE_EXTERNAL) && (player->storage_info[MMPLAYER_PATH_VOD].id == id)) || ((player->storage_info[MMPLAYER_PATH_TEXT].type == STORAGE_TYPE_EXTERNAL) @@ -8711,47 +8878,62 @@ _mmplayer_set_codec_type(MMHandleType hplayer, mmplayer_stream_type_e stream_typ { #define IDX_FIRST_SW_CODEC 0 mmplayer_t *player = (mmplayer_t *)hplayer; - const char *attr_name = (stream_type == MM_PLAYER_STREAM_TYPE_AUDIO) ? (MM_PLAYER_AUDIO_CODEC_TYPE) : (MM_PLAYER_VIDEO_CODEC_TYPE); + int default_codec_type = MM_PLAYER_CODEC_TYPE_DEFAULT; + const char *attr_name = NULL; + const char *default_type = NULL; + const char *element_hw = NULL; + const char *element_sw = NULL; MMPLAYER_FENTER(); MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - LOGD("ini setting : [a][h:%s][s:%s] / [v][h:%s][s:%s]", - player->ini.audiocodec_element_hw, player->ini.audiocodec_element_sw[IDX_FIRST_SW_CODEC], - player->ini.videocodec_element_hw, player->ini.videocodec_element_sw[IDX_FIRST_SW_CODEC]); + LOGD("stream type: %d, codec_type: %d", stream_type, codec_type); + /* FIXME: player need to know whether the decoder exist or not about required codec type since 6.0*/ switch (stream_type) { case MM_PLAYER_STREAM_TYPE_AUDIO: - /* to support audio codec selection, codec info have to be added in ini file as below. - audio codec element hw = xxxx - audio codec element sw = avdec - and in case of audio hw codec is supported and selected, - audio filter elements should be applied depending on the hw capabilities. - */ - if (((codec_type == MM_PLAYER_CODEC_TYPE_HW) && - (!strcmp(player->ini.audiocodec_element_hw, ""))) || - ((codec_type == MM_PLAYER_CODEC_TYPE_SW) && - (!strcmp(player->ini.audiocodec_element_sw[IDX_FIRST_SW_CODEC], "")))) { - LOGE("There is no audio codec info for codec_type %d", codec_type); - return MM_ERROR_PLAYER_NO_OP; - } - break; + attr_name = MM_PLAYER_AUDIO_CODEC_TYPE; + default_type = player->ini.audiocodec_default_type; + element_hw = player->ini.audiocodec_element_hw; + element_sw = player->ini.audiocodec_element_sw[IDX_FIRST_SW_CODEC]; + break; case MM_PLAYER_STREAM_TYPE_VIDEO: - /* to support video codec selection, codec info have to be added in ini file as below. - video codec element hw = omx - video codec element sw = avdec */ - if (((codec_type == MM_PLAYER_CODEC_TYPE_HW) && - (!strcmp(player->ini.videocodec_element_hw, ""))) || - ((codec_type == MM_PLAYER_CODEC_TYPE_SW) && - (!strcmp(player->ini.videocodec_element_sw[IDX_FIRST_SW_CODEC], "")))) { - LOGE("There is no video codec info for codec_type %d", codec_type); - return MM_ERROR_PLAYER_NO_OP; - } - break; + attr_name = MM_PLAYER_VIDEO_CODEC_TYPE; + default_type = player->ini.videocodec_default_type; + element_hw = player->ini.videocodec_element_hw; + element_sw = player->ini.videocodec_element_sw[IDX_FIRST_SW_CODEC]; + break; default: LOGE("Invalid stream type %s", MMPLAYER_STREAM_TYPE_GET_NAME(stream_type)); return MM_ERROR_COMMON_INVALID_ARGUMENT; - break; + break; + } + + LOGD("default setting: [%s][%s][h:%s][s:%s]", attr_name, default_type, element_hw, element_sw); + + if (!strcmp(default_type, "sw")) + default_codec_type = MM_PLAYER_CODEC_TYPE_SW; + else + default_codec_type = MM_PLAYER_CODEC_TYPE_HW; + + if (codec_type == MM_PLAYER_CODEC_TYPE_DEFAULT) + codec_type = default_codec_type; + + /* to support codec selection, codec info have to be added in ini file. + in case of hw codec is selected, filter elements should be applied + depending on the hw capabilities. */ + if (codec_type != default_codec_type) { + if (((codec_type == MM_PLAYER_CODEC_TYPE_HW) && (!strcmp(element_hw, ""))) || + ((codec_type == MM_PLAYER_CODEC_TYPE_SW) && (!strcmp(element_sw, "")))) { + LOGE("There is no codec for type %d", codec_type); + return MM_ERROR_PLAYER_NO_OP; + } + + LOGD("sorting is required"); + if (stream_type == MM_PLAYER_STREAM_TYPE_AUDIO) + player->need_audio_dec_sorting = TRUE; + else + player->need_video_dec_sorting = TRUE; } LOGD("update %s codec_type to %d", attr_name, codec_type); @@ -9098,7 +9280,7 @@ __mmplayer_update_video_attrs(mmplayer_t *player, MMHandleType attrs) } if (!caps_v) { - LOGD("no negitiated caps from videosink"); + LOGD("no negotiated caps from videosink"); gst_object_unref(pad); return FALSE; } @@ -9134,7 +9316,7 @@ __mmplayer_update_bitrate_attrs(mmplayer_t *player, MMHandleType attrs) gchar *path = NULL; struct stat sb; - /* FIXIT : please make it clear the dependancy with duration/codec/uritype */ + /* FIXIT : please make it clear the dependency with duration/codec/uritype */ if (!player->duration) return FALSE; @@ -9528,7 +9710,7 @@ __mmplayer_set_playing_state(mmplayer_t *player) /* try to get content metadata */ /* NOTE : giving ATTR_MISSING_ONLY may have dependency with - * c-api since c-api doesn't use _start() anymore. It may not work propery with + * c-api since c-api doesn't use _start() anymore. It may not work properly with * legacy mmfw-player api */ _mmplayer_update_content_attrs(player, ATTR_MISSING_ONLY);