LOGD("error code=%d, msg=%s, src element=%s, class=%s",
error->code, error->message, src_element_name, klass);
- if (!MMPLAYER_USE_URIDECODEBIN3(player) &&
+ if (MMPLAYER_USE_DECODEBIN(player) &&
!__mmplayer_check_error_posted_from_activated_track(player, src_element_name))
return MM_ERROR_NONE;
}
case GST_MESSAGE_STREAMS_SELECTED:
{
- if (!MMPLAYER_USE_URIDECODEBIN3(player))
+ if (MMPLAYER_USE_DECODEBIN(player))
break; /* drop msg */
if ((MMPLAYER_IS_HTTP_STREAMING(player)) &&
LOGD("GST_MESSAGE_STREAMS_SELECTED");
player->no_more_pad = TRUE;
+ _mmplayer_set_reconfigure_state(player, FALSE);
_mmplayer_pipeline_complete(NULL, player);
retval = TRUE;
break;
MMPLAYER_FLEAVE();
}
-gint __mmplayer_gst_select_stream (GstElement * uridecodebin, GstStreamCollection * collection,
+static gint
+__mmplayer_gst_select_stream (GstElement * uridecodebin, GstStreamCollection * collection,
GstStream * stream, gpointer data)
{
- GstStreamType stype = gst_stream_get_stream_type (stream);
+ gint ret = 0; /* 1: select, 0: skip, -1: depends on decodebin */
+ GstStreamType stype = gst_stream_get_stream_type(stream);
mmplayer_t *player = (mmplayer_t *)data;
mmplayer_track_type_e type = MM_PLAYER_TRACK_TYPE_MAX;
+ GstCaps *caps = gst_stream_get_caps(stream);
+ gchar *caps_str = NULL;
- if (stype & GST_STREAM_TYPE_AUDIO) {
- LOGW("AUDIO type 0x%X", stype);
- type = MM_PLAYER_TRACK_TYPE_AUDIO;
+ LOGD("Stream type %s flags 0x%x",
+ gst_stream_type_get_name(stype),
+ gst_stream_get_stream_flags(stream));
+ LOGD(" ID: %s", gst_stream_get_stream_id(stream));
+
+ if (caps) {
+ caps_str = gst_caps_to_string(caps);
+ LOGD(" caps: %s", caps_str);
}
- if (stype & GST_STREAM_TYPE_VIDEO) {
- LOGW("VIDEO type 0x%X", stype);
- if (type != MM_PLAYER_TRACK_TYPE_MAX) {
- LOGE("Multi Stream 0x%X", type);
- return -1;
+ switch (stype) {
+ case GST_STREAM_TYPE_AUDIO:
+ {
+ GstStructure *caps_structure = NULL;
+ gint samplerate = 0;
+ gint channels = 0;
+
+ type = MM_PLAYER_TRACK_TYPE_AUDIO;
+
+ if (caps) {
+ caps_structure = gst_caps_get_structure(caps, 0);
+ gst_structure_get_int(caps_structure, "rate", &samplerate);
+ gst_structure_get_int(caps_structure, "channels", &channels);
+
+ if (channels > 0 && samplerate == 0) {
+ LOGW("Skip corrupted audio stream");
+ goto EXIT;
+ }
+
+ if (g_strrstr(caps_str, "mobile-xmf"))
+ mm_player_set_attribute((MMHandleType)player, NULL,
+ "content_audio_codec", "mobile-xmf", strlen("mobile-xmf"), NULL);
}
- type = MM_PLAYER_TRACK_TYPE_VIDEO;
+ break;
}
+ case GST_STREAM_TYPE_VIDEO:
+ {
+ GstStructure *caps_structure = NULL;
+ gint stype = 0;
+ gint width = 0;
+
+ type = MM_PLAYER_TRACK_TYPE_VIDEO;
+
+ /* do not support multi track video */
+ if (player->track[MM_PLAYER_TRACK_TYPE_VIDEO].total_track_num >= 1)
+ goto EXIT;
- if (stype & GST_STREAM_TYPE_TEXT) {
- LOGW("TEXT type 0x%X", stype);
- if (type != MM_PLAYER_TRACK_TYPE_MAX) {
- LOGE("Multi Stream 0x%X", type);
- return -1;
+ mm_attrs_get_int_by_name(player->attrs, "display_surface_type", &stype);
+
+ /* don't make video because of not required */
+ if ((stype == MM_DISPLAY_SURFACE_NULL) &&
+ (!player->set_mode.video_export)) {
+ LOGD("no need video decoding, skip video stream");
+ goto EXIT;
+ }
+
+ if (caps) {
+ caps_structure = gst_caps_get_structure(caps, 0);
+ gst_structure_get_int(caps_structure, "width", &width);
+
+ if (width != 0) {
+ if (player->v_stream_caps) {
+ gst_caps_unref(player->v_stream_caps);
+ player->v_stream_caps = NULL;
+ }
+
+ player->v_stream_caps = gst_caps_copy(caps);
+ MMPLAYER_LOG_GST_CAPS_TYPE(player->v_stream_caps);
+ }
}
+ break;
+ }
+ case GST_STREAM_TYPE_TEXT:
type = MM_PLAYER_TRACK_TYPE_TEXT;
+ break;
+ default:
+ LOGW("Skip not supported stream type");
+ goto EXIT;
}
_mmplayer_track_update_stream(player, type, stream);
if (player->track[type].active_track_index == (player->track[type].total_track_num - 1)) {
- LOGD("select this stream, type : %d, idx : %d", type, player->track[type].active_track_index);
- return 1;
+ LOGD("select this stream, active idx : %d", player->track[type].active_track_index);
+ if (type == MM_PLAYER_TRACK_TYPE_AUDIO)
+ _mmplayer_set_audio_attrs(player, caps);
+ ret = 1;
}
- return -1;
+EXIT:
+ g_free(caps_str);
+ if (caps)
+ gst_caps_unref(caps);
+
+ LOGD("ret %d", ret);
+ return ret;
}
-void
+static gboolean
+__mmplayer_gst_decode_request_resource(GstElement * uridecodebin, GstStreamCollection * collection,
+ GstStream * stream, gpointer data)
+{
+ mmplayer_t *player = (mmplayer_t *)data;
+ GstStreamType stype = gst_stream_get_stream_type(stream);
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
+
+ LOGD("stream type %s", gst_stream_type_get_name(stype));
+
+ /* public does not support audio hw decoder at the moment */
+
+ if (player->hw_resource[MMPLAYER_RESOURCE_TYPE_VIDEO_DECODER] != NULL) {
+ LOGW("video decoder resource is already acquired, skip it.");
+ return TRUE;
+ }
+
+ if (_mmplayer_acquire_hw_resource(player, MMPLAYER_RESOURCE_TYPE_VIDEO_DECODER) != MM_ERROR_NONE) {
+ LOGE("failed to acquire video decoder resource");
+ return FALSE;
+ }
+ player->interrupted_by_resource = FALSE;
+ MMPLAYER_FLEAVE();
+ return TRUE;
+}
+
+static void
__mmplayer_gst_deep_element_added(GstElement *bin, GstBin *child, GstElement *element, gpointer data)
{
gchar *factory_name = NULL;
}
if (g_strrstr(factory_name, "parsebin")) {
+ int video_codec_type = 0;
+ int audio_codec_type = 0;
g_object_set(G_OBJECT(child), "message-forward", TRUE, NULL);
g_object_set(G_OBJECT(element), "message-forward", TRUE, NULL);
+ mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_VIDEO_CODEC_TYPE, &video_codec_type);
+ mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_AUDIO_CODEC_TYPE, &audio_codec_type);
+
+ /* CAUTION: if there is hw decoder, the rank value has to be higher than sw decoder
+ and codec default type in ini has to be hw.
+ */
+ if (video_codec_type == MM_PLAYER_CODEC_TYPE_SW)
+ g_object_set(G_OBJECT(child), "force-sw-decoder-for-video", TRUE, NULL);
+ if (audio_codec_type == MM_PLAYER_CODEC_TYPE_SW)
+ g_object_set(G_OBJECT(child), "force-sw-decoder-for-audio", TRUE, NULL);
+
mainbin[MMPLAYER_M_AUTOPLUG_PARSEBIN].id = MMPLAYER_M_AUTOPLUG_PARSEBIN;
mainbin[MMPLAYER_M_AUTOPLUG_PARSEBIN].gst = element;
_mmplayer_add_signal_connection(player, G_OBJECT(element),
_mmplayer_add_signal_connection(player, G_OBJECT(element),
MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "autoplug-continue", G_CALLBACK(_mmplayer_gst_decode_autoplug_continue), (gpointer)player);
- if (player->need_video_dec_sorting || player->need_audio_dec_sorting)
- _mmplayer_add_signal_connection(player, G_OBJECT(element),
- MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "autoplug-sort", G_CALLBACK(_mmplayer_gst_decode_autoplug_sort), (gpointer)player);
-
_mmplayer_add_signal_connection(player, G_OBJECT(element),
MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "autoplug-select", G_CALLBACK(_mmplayer_gst_decode_autoplug_select), (gpointer)player);
+ _mmplayer_add_signal_connection(player, G_OBJECT(child),
+ MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "request-resource", G_CALLBACK(__mmplayer_gst_decode_request_resource), (gpointer)player);
+
} else {
_mmplayer_gst_element_added((GstElement *)child, element, data);
}
_mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "select-stream", G_CALLBACK(__mmplayer_gst_select_stream), (gpointer)player);
-/* FIXME: need to be added for gapless playback
- _mmplayer_add_signal_connection(player, G_OBJECT(element),
- MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "about-to-finish", G_CALLBACK(_mmplayer_gst_decode_drained), (gpointer)player);
-*/
+ _mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
+ MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "about-to-finish", G_CALLBACK(_mmplayer_gst_about_to_finish), (gpointer)player);
_mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "deep-element-added", G_CALLBACK(__mmplayer_gst_deep_element_added), (gpointer)player);
return ret;
}
- if (!MMPLAYER_USE_URIDECODEBIN3(player)) {
+ if (MMPLAYER_USE_DECODEBIN(player)) {
if ((!MMPLAYER_IS_RTSP_STREAMING(player)) && (!player->video_decoded_cb) &&
(!player->pipeline->videobin) && (!player->pipeline->audiobin))
return MM_ERROR_PLAYER_CODEC_NOT_FOUND;
void
_mmplayer_activate_next_source(mmplayer_t *player, GstState target)
{
+ int ret = MM_ERROR_NONE;
mmplayer_gst_element_t *mainbin = NULL;
MMMessageParamType msg_param = {0,};
GstElement *element = NULL;
goto ERROR;
}
+ if (!MMPLAYER_USE_DECODEBIN(player)) {
+ ret = _mmplayer_gst_build_pipeline_with_src(player);
+ if (ret != MM_ERROR_NONE)
+ goto ERROR;
+
+ if (gst_element_set_state(mainbin[MMPLAYER_M_AUTOPLUG].gst, target) == GST_STATE_CHANGE_FAILURE) {
+ LOGE("Failed to change state of uridecodebin3 element");
+ goto ERROR;
+ }
+ goto DONE;
+ }
+
element = _mmplayer_gst_create_source(player);
if (!element) {
LOGE("no source element was created");
}
if (gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), element) == FALSE) {
- LOGE("failed to add sinkbin to pipeline");
+ LOGE("failed to add %s to pipeline", GST_ELEMENT_NAME(element));
gst_object_unref(GST_OBJECT(element));
element = NULL;
goto ERROR;
goto ERROR;
}
+DONE:
player->gapless.stream_changed = TRUE;
player->gapless.running = TRUE;
MMPLAYER_FLEAVE();