}
void
+_mmplayer_watcher_removed_notify(gpointer data)
+{
+ mmplayer_t *player = (mmplayer_t *)data;
+ MMPLAYER_RETURN_IF_FAIL(player);
+
+ MMPLAYER_BUS_WATCHER_LOCK(player);
+ player->bus_watcher = 0;
+ MMPLAYER_BUS_WATCHER_SIGNAL(player);
+ MMPLAYER_BUS_WATCHER_UNLOCK(player);
+}
+
+void
+_mmplayer_bus_watcher_remove(MMHandleType hplayer)
+{
+ mmplayer_t *player = (mmplayer_t *)hplayer;
+ gint64 end_time = 0;
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_IF_FAIL(player);
+
+ /* disconnecting bus watch */
+ if (player->bus_watcher > 0) {
+ __mmplayer_remove_g_source_from_context(player->context.thread_default, player->bus_watcher);
+ MMPLAYER_BUS_WATCHER_LOCK(player);
+ end_time = g_get_monotonic_time () + 2 * G_TIME_SPAN_SECOND;
+ while (player->bus_watcher > 0)
+ MMPLAYER_BUS_WATCHER_WAIT_UNTIL(player, end_time);
+ MMPLAYER_BUS_WATCHER_UNLOCK(player);
+
+ g_mutex_clear(&player->bus_watcher_mutex);
+ g_cond_clear(&player->bus_watcher_cond);
+ }
+
+ MMPLAYER_FLEAVE();
+}
+
+void
_mmplayer_bus_msg_thread_destroy(MMHandleType hplayer)
{
mmplayer_t *player = (mmplayer_t *)hplayer;
MMPLAYER_FENTER();
MMPLAYER_RETURN_IF_FAIL(player);
- /* disconnecting bus watch */
- if (player->bus_watcher)
- __mmplayer_remove_g_source_from_context(player->context.thread_default, player->bus_watcher);
- player->bus_watcher = 0;
-
/* destroy the gst bus msg thread */
if (player->bus_msg_thread) {
MMPLAYER_BUS_MSG_THREAD_LOCK(player);
for (idx = MM_PLAYER_TRACK_TYPE_AUDIO; idx < MM_PLAYER_TRACK_TYPE_TEXT; idx++) {
if ((player->gapless.update_segment[idx] == TRUE) ||
- !(player->selector[idx].event_probe_id)) {
+ !(player->track[idx].event_probe_id)) {
#ifdef __DEBUG__
LOGW("[%d] skip", idx);
#endif
player->pipeline->mainbin[elem_idx].id = elem_idx;
player->pipeline->mainbin[elem_idx].gst = selector;
- /* player->selector[stream_type].active_pad_index = DEFAULT_TRACK; */
+ /* player->track[stream_type].active_track_index = DEFAULT_TRACK; */
srcpad = gst_element_get_static_pad(selector, "src");
LOGD("blocking %s:%s", GST_DEBUG_PAD_NAME(srcpad));
- player->selector[stream_type].block_id = gst_pad_add_probe(srcpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
+ player->track[stream_type].block_id = gst_pad_add_probe(srcpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
__mmplayer_gst_selector_blocked, NULL, NULL);
- player->selector[stream_type].event_probe_id = gst_pad_add_probe(srcpad, GST_PAD_PROBE_TYPE_EVENT_BOTH|GST_PAD_PROBE_TYPE_EVENT_FLUSH,
+ player->track[stream_type].event_probe_id = gst_pad_add_probe(srcpad, GST_PAD_PROBE_TYPE_EVENT_BOTH|GST_PAD_PROBE_TYPE_EVENT_FLUSH,
__mmplayer_gst_selector_event_probe, player, NULL);
gst_element_set_state(selector, GST_STATE_PAUSED);
g_object_set(selector, "active-pad", sinkpad, NULL);
}
- _mmplayer_track_update_selector_info(player, stream_type, sinkpad);
+ if (!MMPLAYER_USE_URIDECODEBIN3(player))
+ _mmplayer_track_update_stream(player, stream_type, sinkpad);
DONE:
ERROR:
__mmplayer_gst_create_sinkbin(selector, srcpad, player);
LOGD("unblocking %s:%s", GST_DEBUG_PAD_NAME(srcpad));
- if (player->selector[type].block_id) {
- gst_pad_remove_probe(srcpad, player->selector[type].block_id);
- player->selector[type].block_id = 0;
+ if (player->track[type].block_id) {
+ gst_pad_remove_probe(srcpad, player->track[type].block_id);
+ player->track[type].block_id = 0;
}
if (srcpad) {
MMPLAYER_FENTER();
MMPLAYER_RETURN_IF_FAIL(player);
- LOGD("type: %d, the num of track: %d", type, player->selector[type].total_track_num);
+ LOGD("type: %d, the num of track: %d", type, player->track[type].total_track_num);
/* change track to active pad */
- active_index = player->selector[type].active_pad_index;
+ active_index = player->track[type].active_track_index;
if ((active_index != DEFAULT_TRACK) &&
(__mmplayer_change_selector_pad(player, type, active_index) != MM_ERROR_NONE)) {
LOGW("failed to change %d type track to %d", type, active_index);
- player->selector[type].active_pad_index = DEFAULT_TRACK;
+ player->track[type].active_track_index = DEFAULT_TRACK;
return;
}
if (type == MM_PLAYER_TRACK_TYPE_TEXT)
mm_player_set_attribute((MMHandleType)player, NULL,
- "content_text_track_num", player->selector[type].total_track_num,
- "current_text_track_index", player->selector[type].active_pad_index, NULL);
+ "content_text_track_num", player->track[type].total_track_num,
+ "current_text_track_index", player->track[type].active_track_index, NULL);
MMPLAYER_FLEAVE();
return;
}
/* apply the audio track information */
- __mmplayer_set_decode_track_info(player, MM_PLAYER_TRACK_TYPE_AUDIO);
+ if (!MMPLAYER_USE_URIDECODEBIN3(player))
+ __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)) {
/* apply the text track information */
__mmplayer_set_decode_track_info(player, MM_PLAYER_TRACK_TYPE_TEXT);
- if (player->selector[MM_PLAYER_TRACK_TYPE_TEXT].total_track_num > 0)
+ if (player->track[MM_PLAYER_TRACK_TYPE_TEXT].total_track_num > 0)
player->has_closed_caption = TRUE;
/* create text decode path */
player->pipeline->mainbin = mainbin;
/* create the source and decoder elements */
- if (MMPLAYER_IS_MS_BUFF_SRC(player))
+ if (MMPLAYER_IS_MS_BUFF_SRC(player)) {
ret = _mmplayer_gst_build_es_pipeline(player);
- else
- ret = _mmplayer_gst_build_pipeline(player);
+ } else {
+ if (player->ini.use_uridecodebin3)
+ ret = _mmplayer_gst_build_pipeline_with_src(player);
+ else
+ ret = _mmplayer_gst_build_pipeline(player);
+ }
if (ret != MM_ERROR_NONE) {
LOGE("failed to create some elements");
return MM_ERROR_NONE;
INIT_ERROR:
+ _mmplayer_bus_watcher_remove(player);
__mmplayer_gst_destroy_pipeline(player);
return MM_ERROR_PLAYER_INTERNAL;
}
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
MMPLAYER_CMD_UNLOCK(player);
+ _mmplayer_bus_watcher_remove(player);
/* destroy the gst bus msg thread which is created during realize.
this funct have to be called before getting cmd lock. */
_mmplayer_bus_msg_thread_destroy(player);
static gboolean
__mmplayer_deactivate_selector(mmplayer_t *player, mmplayer_track_type_e type)
{
- mmplayer_selector_t *selector = &player->selector[type];
+ mmplayer_track_t *selector = &player->track[type];
mmplayer_gst_element_t *sinkbin = NULL;
main_element_id_e selectorId = MMPLAYER_M_NUM;
main_element_id_e sinkId = MMPLAYER_M_NUM;
LOGD("selector release");
/* release and unref requests pad from the selector */
- for (n = 0; n < selector->channels->len; n++) {
- GstPad *sinkpad = g_ptr_array_index(selector->channels, n);
+ for (n = 0; n < selector->streams->len; n++) {
+ GstPad *sinkpad = g_ptr_array_index(selector->streams, n);
gst_element_release_request_pad((player->pipeline->mainbin[selectorId].gst), sinkpad);
}
- g_ptr_array_set_size(selector->channels, 0);
+
+ g_ptr_array_set_size(selector->streams, 0);
gst_element_set_state(player->pipeline->mainbin[selectorId].gst, GST_STATE_NULL);
gst_bin_remove(GST_BIN_CAST(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst), player->pipeline->mainbin[selectorId].gst);
}
static int
+__mmplayer_switch_stream(mmplayer_t *player, mmplayer_track_type_e type, int index)
+{
+ guint active_idx = 0;
+ GstStream *stream = NULL;
+ GList *streams = NULL;
+ GstEvent *ev = NULL;
+
+ LOGD("Switching Streams... type: %d, index: %d", type, index);
+
+ player->track[type].active_track_index = index;
+
+ for (int i = 0; i < MM_PLAYER_TRACK_TYPE_MAX; i++) {
+ /* FIXME: need to consider the non display type or audio only in case of MM_PLAYER_TRACK_TYPE_VIDEO */
+ if (player->track[i].total_track_num > 0) {
+ active_idx = player->track[i].active_track_index;
+ stream = g_ptr_array_index(player->track[i].streams, active_idx);
+ streams = g_list_append (streams, (gchar *)gst_stream_get_stream_id(stream));
+ LOGD("Selecting %d type stream : %s\n", i, gst_stream_get_stream_id(stream));
+ }
+ }
+
+ ev = gst_event_new_select_streams(streams);
+ gst_element_send_event(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, ev);
+ g_list_free(streams);
+
+ return MM_ERROR_NONE;
+}
+
+static int
__mmplayer_change_selector_pad(mmplayer_t *player, mmplayer_track_type_e type, int index)
{
int result = MM_ERROR_NONE;
goto EXIT;
}
- total_track_num = player->selector[type].total_track_num;
+ total_track_num = player->track[type].total_track_num;
if (total_track_num <= 0) {
result = MM_ERROR_PLAYER_NO_OP;
LOGD("Language list is not available");
gint current_active_index = 0;
GstState current_state = GST_STATE_VOID_PENDING;
- GstEvent *event = NULL;
gint64 time = 0;
MMPLAYER_FENTER();
if (!player->pipeline) {
LOGE("Track %d pre setting -> %d", type, index);
- player->selector[type].active_pad_index = index;
+ player->track[type].active_track_index = index;
goto EXIT;
}
mainbin = player->pipeline->mainbin;
- current_active_index = player->selector[type].active_pad_index;
+ current_active_index = player->track[type].active_track_index;
/*If index is same as running index no need to change the pad*/
if (current_active_index == index)
goto EXIT;
}
- result = __mmplayer_change_selector_pad(player, type, index);
+ if (MMPLAYER_USE_URIDECODEBIN3(player)) {
+ result = __mmplayer_switch_stream(player, type, index);
+ } else {
+ result = __mmplayer_change_selector_pad(player, type, index);
+ }
if (result != MM_ERROR_NONE) {
- LOGE("change selector pad error");
+ LOGE("failed to change track");
goto EXIT;
}
- player->selector[type].active_pad_index = index;
+ player->track[type].active_track_index = index;
- if (current_state == GST_STATE_PLAYING) {
- event = gst_event_new_seek(player->playback_rate, GST_FORMAT_TIME,
- (GstSeekFlags)(GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SKIP),
- GST_SEEK_TYPE_SET, time, GST_SEEK_TYPE_NONE, -1);
- if (event) {
- _mmplayer_gst_send_event_to_sink(player, event);
- } else {
- result = MM_ERROR_PLAYER_INTERNAL;
- goto EXIT;
+ if (!MMPLAYER_USE_URIDECODEBIN3(player)) {
+ GstEvent *event = NULL;
+ if (current_state == GST_STATE_PLAYING) {
+ event = gst_event_new_seek(player->playback_rate, GST_FORMAT_TIME,
+ (GstSeekFlags)(GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SKIP),
+ GST_SEEK_TYPE_SET, time, GST_SEEK_TYPE_NONE, -1);
+ if (event) {
+ _mmplayer_gst_send_event_to_sink(player, event);
+ } else {
+ result = MM_ERROR_PLAYER_INTERNAL;
+ goto EXIT;
+ }
}
}