/* get video surface type */
int surface_type = 0;
mm_attrs_get_int_by_name(player->attrs, "display_surface_type", &surface_type);
- LOGD("display_surface_type(%d)\n", surface_type);
+ LOGD("display_surface_type (%d)", surface_type);
if (surface_type == MM_DISPLAY_SURFACE_NULL) {
- LOGD("not make videobin because it dose not want\n");
+ LOGD("surface_type is NULL");
goto ERROR;
}
goto ERROR;
}
- if (FALSE == gst_element_add_pad(audiobin[MMPLAYER_A_BIN].gst, ghostpad)) {
+ if (!gst_element_add_pad(audiobin[MMPLAYER_A_BIN].gst, ghostpad)) {
LOGE("failed to add ghostpad to audiobin\n");
goto ERROR;
}
return;
}
+static void
+__mmplayer_gst_set_video360_property(mm_player_t *player)
+{
+ MMPlayerGstElement *videobin = NULL;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->videobin);
+
+ videobin = player->pipeline->videobin;
+
+ /* Set spatial media metadata and/or user settings to the element.
+ * */
+ g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
+ "projection-type", player->video360_metadata.projection_type, NULL);
+
+ g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
+ "stereo-mode", player->video360_metadata.stereo_mode, NULL);
+
+ if (player->video360_metadata.full_pano_width_pixels &&
+ player->video360_metadata.full_pano_height_pixels &&
+ player->video360_metadata.cropped_area_image_width &&
+ player->video360_metadata.cropped_area_image_height) {
+ g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
+ "projection-bounds-top", player->video360_metadata.cropped_area_top,
+ "projection-bounds-bottom", player->video360_metadata.full_pano_height_pixels -
+ player->video360_metadata.cropped_area_top - player->video360_metadata.cropped_area_image_height,
+ "projection-bounds-left", player->video360_metadata.cropped_area_left,
+ "projection-bounds-right", player->video360_metadata.full_pano_width_pixels -
+ player->video360_metadata.cropped_area_left - player->video360_metadata.cropped_area_image_width,
+ NULL);
+ }
+
+ if (player->video360_horizontal_fov && player->video360_vertical_fov) {
+ g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
+ "horizontal-fov", player->video360_horizontal_fov,
+ "vertical-fov", player->video360_vertical_fov, NULL);
+ }
+
+ if (player->video360_zoom <= VIDEO360_MAX_ZOOM && player->video360_zoom > 1.0f) {
+ g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
+ "zoom", 1.0f / player->video360_zoom, NULL);
+ }
+
+ if (player->video360_yaw_radians <= M_PI &&
+ player->video360_yaw_radians >= -M_PI &&
+ player->video360_pitch_radians <= M_PI_2 &&
+ player->video360_pitch_radians >= -M_PI_2) {
+ g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
+ "pose-yaw", (int) (player->video360_yaw_radians * 180.0 / M_PI),
+ "pose-pitch", (int) (player->video360_pitch_radians * 180.0 / M_PI), NULL);
+ } else if (player->video360_metadata.init_view_heading || player->video360_metadata.init_view_pitch) {
+ g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
+ "pose-yaw", player->video360_metadata.init_view_heading,
+ "pose-pitch", player->video360_metadata.init_view_pitch, NULL);
+ }
+
+ g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
+ "passthrough", !player->is_video360_enabled, NULL);
+
+
+ MMPLAYER_FLEAVE();
+}
+
static int
-__mmplayer_gst_create_video_filters(mm_player_t* player, GList** bucket)
+__mmplayer_gst_create_video_filters(mm_player_t *player, MMDisplaySurfaceType surface_type, GList **bucket)
{
- gchar* video_csc = "videoconvert"; /* default colorspace converter */
- GList* element_bucket = NULL;
+ gchar *video_csc = "videoconvert"; /* default colorspace converter */
+ GList *element_bucket = NULL;
+ MMPLAYER_FENTER();
MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->videobin, MM_ERROR_PLAYER_NOT_INITIALIZED);
- MMPLAYER_FENTER();
+ /* create video360 filter */
+ if (player->is_360_feature_enabled && player->is_content_spherical) {
+ LOGD("create video360 element");
+ MMPLAYER_CREATE_ELEMENT(player->pipeline->videobin, MMPLAYER_V_360, "video360", "video-360", TRUE, player);
+ __mmplayer_gst_set_video360_property(player);
+ goto EXIT;
+ }
- if (player->set_mode.video_zc || (player->is_360_feature_enabled && player->is_content_spherical)) {
- LOGD("do not need to add video filters.");
+ if (surface_type != MM_DISPLAY_SURFACE_OVERLAY || player->set_mode.video_zc) {
+ LOGD("skip creating the videoconv and rotator");
return MM_ERROR_NONE;
}
- /* in case of sw codec except 360 playback,
+ /* in case of sw codec & overlay surface type, except 360 playback.
* if libav video decoder is selected, videoconvert is required to render the shm wl-buffer which support RGB only via tizenwlsink. */
+ LOGD("create video converter: %s", video_csc);
MMPLAYER_CREATE_ELEMENT(player->pipeline->videobin, MMPLAYER_V_CONV, video_csc, "video converter", TRUE, player);
- LOGD("using video converter: %s", video_csc);
/* set video rotator */
MMPLAYER_CREATE_ELEMENT(player->pipeline->videobin, MMPLAYER_V_FLIP, "videoflip", "video rotator", TRUE, player);
+EXIT:
*bucket = element_bucket;
MMPLAYER_FLEAVE();
return MM_ERROR_NONE;
return MM_ERROR_PLAYER_INTERNAL;
}
-/**
- * This function is to create video pipeline.
- *
- * @param player [in] handle of player
- * caps [in] src caps of decoder
- * surface_type [in] surface type for video rendering
- *
- * @return This function returns zero on success.
- * @remark
- * @see __mmplayer_gst_create_audio_pipeline, __mmplayer_gst_create_midi_pipeline
- */
-/**
- * VIDEO PIPELINE
- * - video overlay surface(arm/x86) : tizenwlsink
- */
-static int
-__mmplayer_gst_create_video_pipeline(mm_player_t* player, GstCaps* caps, MMDisplaySurfaceType surface_type)
+static gchar*
+__mmplayer_get_videosink_factory_name(mm_player_t *player, MMDisplaySurfaceType surface_type)
{
- GstPad *pad = NULL;
- MMHandleType attrs;
- GList*element_bucket = NULL;
- MMPlayerGstElement* first_element = NULL;
- MMPlayerGstElement* videobin = NULL;
- gchar *videosink_element = NULL;
-
- MMPLAYER_FENTER();
+ gchar *factory_name = NULL;
- MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
- /* alloc handles */
- videobin = (MMPlayerGstElement*)g_malloc0(sizeof(MMPlayerGstElement) * MMPLAYER_V_NUM);
- if (!videobin)
- return MM_ERROR_PLAYER_NO_FREE_SPACE;
-
- player->pipeline->videobin = videobin;
-
- attrs = MMPLAYER_GET_ATTRS(player);
- if (!attrs) {
- LOGE("cannot get content attribute");
- return MM_ERROR_PLAYER_INTERNAL;
- }
-
- /* create bin */
- videobin[MMPLAYER_V_BIN].id = MMPLAYER_V_BIN;
- videobin[MMPLAYER_V_BIN].gst = gst_bin_new("videobin");
- if (!videobin[MMPLAYER_V_BIN].gst) {
- LOGE("failed to create videobin");
- goto ERROR;
- }
-
- if (player->is_360_feature_enabled && player->is_content_spherical) {
- LOGD("video360 elem will be added.");
-
- MMPLAYER_CREATE_ELEMENT(videobin, MMPLAYER_V_360, "video360",
- "video-360", TRUE, player);
-
- /* Set spatial media metadata and/or user settings to the element.
- * */
- g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
- "projection-type", player->video360_metadata.projection_type, NULL);
-
- g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
- "stereo-mode", player->video360_metadata.stereo_mode, NULL);
-
- if (player->video360_metadata.full_pano_width_pixels &&
- player->video360_metadata.full_pano_height_pixels &&
- player->video360_metadata.cropped_area_image_width &&
- player->video360_metadata.cropped_area_image_height) {
- g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
- "projection-bounds-top", player->video360_metadata.cropped_area_top,
- "projection-bounds-bottom", player->video360_metadata.full_pano_height_pixels -
- player->video360_metadata.cropped_area_top - player->video360_metadata.cropped_area_image_height,
- "projection-bounds-left", player->video360_metadata.cropped_area_left,
- "projection-bounds-right", player->video360_metadata.full_pano_width_pixels -
- player->video360_metadata.cropped_area_left - player->video360_metadata.cropped_area_image_width,
- NULL);
- }
-
- if (player->video360_horizontal_fov && player->video360_vertical_fov) {
- g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
- "horizontal-fov", player->video360_horizontal_fov,
- "vertical-fov", player->video360_vertical_fov, NULL);
- }
-
- if (player->video360_zoom <= VIDEO360_MAX_ZOOM && player->video360_zoom > 1.0f) {
- g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
- "zoom", 1.0f / player->video360_zoom, NULL);
- }
-
- if (player->video360_yaw_radians <= M_PI &&
- player->video360_yaw_radians >= -M_PI &&
- player->video360_pitch_radians <= M_PI_2 &&
- player->video360_pitch_radians >= -M_PI_2) {
- g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
- "pose-yaw", (int) (player->video360_yaw_radians * 180.0 / M_PI),
- "pose-pitch", (int) (player->video360_pitch_radians * 180.0 / M_PI), NULL);
- } else if (player->video360_metadata.init_view_heading || player->video360_metadata.init_view_pitch) {
- g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
- "pose-yaw", player->video360_metadata.init_view_heading,
- "pose-pitch", player->video360_metadata.init_view_pitch, NULL);
- }
-
- g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
- "passthrough", !player->is_video360_enabled, NULL);
- }
-
- /* set video sink */
switch (surface_type) {
case MM_DISPLAY_SURFACE_OVERLAY:
- if (__mmplayer_gst_create_video_filters(player, &element_bucket) != MM_ERROR_NONE)
- goto ERROR;
if (strlen(player->ini.videosink_element_overlay) > 0)
- videosink_element = player->ini.videosink_element_overlay;
- else
- goto ERROR;
+ factory_name = player->ini.videosink_element_overlay;
break;
case MM_DISPLAY_SURFACE_NULL:
if (strlen(player->ini.videosink_element_fake) > 0)
- videosink_element = player->ini.videosink_element_fake;
- else
- goto ERROR;
+ factory_name = player->ini.videosink_element_fake;
break;
case MM_DISPLAY_SURFACE_REMOTE:
if (strlen(player->ini.videosink_element_fake) > 0)
- videosink_element = player->ini.videosink_element_fake;
- else
- goto ERROR;
+ factory_name = player->ini.videosink_element_fake;
break;
default:
LOGE("unidentified surface type");
- goto ERROR;
+ break;
}
- LOGD("surface_type %d, selected videosink name: %s", surface_type, videosink_element);
- MMPLAYER_CREATE_ELEMENT(videobin, MMPLAYER_V_SINK, videosink_element, "videosink", TRUE, player);
+ LOGD("surface_type %d, videosink is %s", surface_type, factory_name);
+ return factory_name;
+}
- /* additional setting for sink plug-in */
- switch (surface_type) {
- case MM_DISPLAY_SURFACE_OVERLAY:
- {
- bool use_tbm = (player->set_mode.video_zc || (player->is_360_feature_enabled && player->is_content_spherical));
- if (!use_tbm) {
- LOGD("selected videosink name: %s", videosink_element);
-
- /* support shard memory with S/W codec on HawkP */
- if (strncmp(videosink_element, "tizenwlsink", strlen(videosink_element)) == 0) {
- g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst,
- "use-tbm", use_tbm, NULL);
- }
- } else {
- if (attrs) {
- int gapless = 0;
+static int
+__mmplayer_gst_set_videosink_property(mm_player_t *player, MMDisplaySurfaceType surface_type)
+{
+ gchar *factory_name = NULL;
+ MMPlayerGstElement *videobin = NULL;
+ MMHandleType attrs;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->videobin, MM_ERROR_PLAYER_NOT_INITIALIZED);
- mm_attrs_get_int_by_name(attrs, "gapless_mode", &gapless);
+ videobin = player->pipeline->videobin;
+ factory_name = GST_OBJECT_NAME(gst_element_get_factory(videobin[MMPLAYER_V_SINK].gst));
- if (gapless > 0) {
- LOGD("disable last-sample");
- g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
+ attrs = MMPLAYER_GET_ATTRS(player);
+ if (!attrs) {
+ LOGE("cannot get content attribute");
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
+
+ if (surface_type == MM_DISPLAY_SURFACE_OVERLAY || surface_type == MM_DISPLAY_SURFACE_REMOTE) {
+ int gapless = 0;
+
+ if (surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+ bool use_tbm = (player->set_mode.video_zc || (player->is_360_feature_enabled && player->is_content_spherical));
+ LOGD("OVERLAY: selected videosink is %s", factory_name);
+
+ if (!use_tbm) {
+ /* support shard memory with S/W codec on HawkP */
+ if (strncmp(factory_name, "tizenwlsink", strlen(factory_name)) == 0) {
+ g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst,
+ "use-tbm", use_tbm, NULL);
}
}
+ } else {
+ LOGE("REMOTE : add data probe at videosink");
+ g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
+ "sync", TRUE, "max-lateness", FAKE_SINK_MAX_LATENESS, NULL);
+ }
+
+ mm_attrs_get_int_by_name(attrs, "gapless_mode", &gapless);
+ if (gapless > 0) {
+ LOGD("disable last-sample");
+ g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
}
+
if (player->set_mode.media_packet_video_stream) {
int enable = 0;
mm_attrs_get_int_by_name(player->attrs, "enable_video_decoded_cb", &enable);
- if (enable)
+ if (enable || (surface_type == MM_DISPLAY_SURFACE_REMOTE))
g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst), "signal-handoffs", TRUE, NULL);
__mmplayer_add_signal_connection(player,
G_CALLBACK(__mmplayer_video_stream_decoded_preroll_cb),
(gpointer)player);
}
- break;
- }
- case MM_DISPLAY_SURFACE_REMOTE:
- {
- if (player->set_mode.media_packet_video_stream) {
- LOGE("add data probe at videosink");
- g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
- "sync", TRUE, "signal-handoffs", TRUE, "max-lateness", FAKE_SINK_MAX_LATENESS, NULL);
-
- __mmplayer_add_signal_connection(player,
- G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
- MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
- "handoff",
- G_CALLBACK(__mmplayer_video_stream_decoded_render_cb),
- (gpointer)player);
-
- __mmplayer_add_signal_connection(player,
- G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
- MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
- "preroll-handoff",
- G_CALLBACK(__mmplayer_video_stream_decoded_preroll_cb),
- (gpointer)player);
- if (attrs) {
- int gapless = 0;
-
- mm_attrs_get_int_by_name(attrs, "gapless_mode", &gapless);
-
- if (gapless > 0) {
- LOGD("disable last-sample");
- g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
- }
- }
- }
- break;
- }
- default:
- break;
}
if (_mmplayer_update_video_param(player, "update_all_param") != MM_ERROR_NONE)
- goto ERROR;
+ return MM_ERROR_PLAYER_INTERNAL;
if (videobin[MMPLAYER_V_SINK].gst) {
GstPad *sink_pad = NULL;
__mmplayer_add_signal_connection(player, G_OBJECT(sink_pad), MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
"notify::caps", G_CALLBACK(__mmplayer_gst_caps_notify_cb), (gpointer)player);
gst_object_unref(GST_OBJECT(sink_pad));
- } else
- LOGW("failed to get sink pad from videosink\n");
+ } else {
+ LOGE("failed to get sink pad from videosink");
+ }
+ }
+
+ return MM_ERROR_NONE;
+}
+
+/**
+ * VIDEO PIPELINE
+ * - video overlay surface(arm/x86) : tizenwlsink
+ */
+static int
+__mmplayer_gst_create_video_pipeline(mm_player_t* player, GstCaps* caps, MMDisplaySurfaceType surface_type)
+{
+ GstPad *pad = NULL;
+ GList *element_bucket = NULL;
+ MMPlayerGstElement *first_element = NULL;
+ MMPlayerGstElement *videobin = NULL;
+ gchar *videosink_factory_name = NULL;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+ /* alloc handles */
+ videobin = (MMPlayerGstElement*)g_malloc0(sizeof(MMPlayerGstElement) * MMPLAYER_V_NUM);
+ if (!videobin)
+ return MM_ERROR_PLAYER_NO_FREE_SPACE;
+
+ player->pipeline->videobin = videobin;
+
+ /* create bin */
+ videobin[MMPLAYER_V_BIN].id = MMPLAYER_V_BIN;
+ videobin[MMPLAYER_V_BIN].gst = gst_bin_new("videobin");
+ if (!videobin[MMPLAYER_V_BIN].gst) {
+ LOGE("failed to create videobin");
+ goto ERROR;
+ }
+
+ if (__mmplayer_gst_create_video_filters(player, surface_type, &element_bucket) != MM_ERROR_NONE)
+ goto ERROR;
+
+ videosink_factory_name = __mmplayer_get_videosink_factory_name(player, surface_type);
+ MMPLAYER_CREATE_ELEMENT(videobin, MMPLAYER_V_SINK, videosink_factory_name, "videosink", TRUE, player);
+
+ /* additional setting for sink plug-in */
+ if (__mmplayer_gst_set_videosink_property(player, surface_type) != MM_ERROR_NONE) {
+ LOGE("failed to set video property");
+ goto ERROR;
}
/* store it as it's sink element */
/* adding created elements to bin */
if (!__mmplayer_gst_element_add_bucket_to_bin(GST_BIN(videobin[MMPLAYER_V_BIN].gst), element_bucket)) {
- LOGE("failed to add elements\n");
+ LOGE("failed to add elements");
goto ERROR;
}
/* Linking elements in the bucket by added order */
if (__mmplayer_gst_element_link_bucket(element_bucket) == -1) {
- LOGE("failed to link elements\n");
+ LOGE("failed to link elements");
goto ERROR;
}
/* get first element's sinkpad for creating ghostpad */
- if (element_bucket)
- first_element = (MMPlayerGstElement *)element_bucket->data;
+ first_element = (MMPlayerGstElement *)element_bucket->data;
if (!first_element) {
- LOGE("failed to get first element from bucket\n");
+ LOGE("failed to get first element from bucket");
goto ERROR;
}
pad = gst_element_get_static_pad(GST_ELEMENT(first_element->gst), "sink");
if (!pad) {
- LOGE("failed to get pad from first element\n");
+ LOGE("failed to get pad from first element");
goto ERROR;
}
/* create ghostpad */
player->ghost_pad_for_videobin = gst_ghost_pad_new("sink", pad);
- if (FALSE == gst_element_add_pad(videobin[MMPLAYER_V_BIN].gst, player->ghost_pad_for_videobin)) {
- LOGE("failed to add ghostpad to videobin\n");
+ if (!gst_element_add_pad(videobin[MMPLAYER_V_BIN].gst, player->ghost_pad_for_videobin)) {
+ LOGE("failed to add ghostpad to videobin");
goto ERROR;
}
gst_object_unref(pad);
/* done. free allocated variables */
- if (element_bucket)
- g_list_free(element_bucket);
+ g_list_free(element_bucket);
MMPLAYER_FLEAVE();
return MM_ERROR_NONE;
ERROR:
- LOGE("ERROR : releasing videobin\n");
-
+ LOGE("ERROR : releasing videobin");
g_list_free(element_bucket);
if (pad)
if (videobin[MMPLAYER_V_BIN].gst)
gst_object_unref(GST_OBJECT(videobin[MMPLAYER_V_BIN].gst));
-
MMPLAYER_FREEIF(videobin);
-
player->pipeline->videobin = NULL;
return MM_ERROR_PLAYER_INTERNAL;
return;
}
- if (!__mmplayer_try_to_plug_decodebin(player, pad, caps)) {
+ if (!__mmplayer_gst_create_decoder(player, pad, caps)) {
gboolean async = FALSE;
LOGE("failed to autoplug %s\n", player->type);
}
GstElement *
-__mmplayer_create_decodebin(mm_player_t* player)
+__mmplayer_gst_make_decodebin(mm_player_t* player)
{
GstElement *decodebin = NULL;
return decodebin;
}
-gboolean
-__mmplayer_try_to_plug_decodebin(mm_player_t* player, GstPad *srcpad, const GstCaps *caps)
+static GstElement*
+__mmplayer_gst_make_queue2(mm_player_t *player)
{
- MMPlayerGstElement* mainbin = NULL;
- GstElement* decodebin = NULL;
GstElement* queue2 = NULL;
- GstPad* sinkpad = NULL;
- GstPad* qsrcpad = NULL;
gint64 dur_bytes = 0L;
-
guint max_buffer_size_bytes = 0;
- gint init_buffering_time = player->streamer->buffering_req.prebuffer_time;
+ MMPlayerGstElement *mainbin = NULL;
+ MuxedBufferType type = MUXED_BUFFER_TYPE_MEM_QUEUE;
MMPLAYER_FENTER();
- MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin, FALSE);
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin, NULL);
mainbin = player->pipeline->mainbin;
- if ((!MMPLAYER_IS_HTTP_PD(player)) &&
- (MMPLAYER_IS_HTTP_STREAMING(player))) {
- LOGD("creating http streaming buffering queue(queue2)\n");
+ queue2 = gst_element_factory_make("queue2", "queue2");
+ if (!queue2) {
+ LOGE("failed to create buffering queue element");
+ return NULL;
+ }
- if (mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst) {
- LOGE("MMPLAYER_M_MUXED_S_BUFFER is not null\n");
+ if (!gst_element_query_duration(mainbin[MMPLAYER_M_SRC].gst, GST_FORMAT_BYTES, &dur_bytes))
+ LOGE("failed to get duration from source %s", GST_ELEMENT_NAME(mainbin[MMPLAYER_M_SRC].gst));
+
+ LOGD("dur_bytes = %"G_GINT64_FORMAT, dur_bytes);
+
+ if (dur_bytes > 0) {
+ if (MMPLAYER_USE_FILE_FOR_BUFFERING(player)) {
+ type = MUXED_BUFFER_TYPE_FILE;
} else {
- queue2 = gst_element_factory_make("queue2", "queue2");
- if (!queue2) {
- LOGE("failed to create buffering queue element\n");
- goto ERROR;
- }
+ type = MUXED_BUFFER_TYPE_MEM_RING_BUFFER;
+ player->streamer->ring_buffer_size = player->ini.http_ring_buffer_size;
+ }
+ } else {
+ dur_bytes = 0;
+ }
- if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), queue2)) {
- LOGE("failed to add buffering queue\n");
- goto ERROR;
- }
+ /* NOTE : in case of ts streaming, player cannot get the correct duration info *
+ * skip the pull mode(file or ring buffering) setting. */
+ if (!g_strrstr(player->type, "video/mpegts")) {
+ max_buffer_size_bytes = (type == MUXED_BUFFER_TYPE_FILE) ? (player->ini.http_max_size_bytes) : (5*1024*1024);
+ LOGD("max_buffer_size_bytes = %d", max_buffer_size_bytes);
- sinkpad = gst_element_get_static_pad(queue2, "sink");
- qsrcpad = gst_element_get_static_pad(queue2, "src");
+ __mm_player_streaming_set_queue2(player->streamer,
+ queue2,
+ FALSE,
+ max_buffer_size_bytes,
+ player->ini.http_buffering_time,
+ 1.0, /* no meaning */
+ player->ini.http_buffering_limit, /* no meaning */
+ type,
+ player->http_file_buffering_path,
+ (guint64)dur_bytes);
+ }
- if (GST_PAD_LINK_OK != gst_pad_link(srcpad, sinkpad)) {
- LOGE("failed to link buffering queue");
- goto ERROR;
- }
+ return queue2;
+}
- if (!gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, GST_FORMAT_BYTES, &dur_bytes))
- LOGE("fail to get duration");
+gboolean
+__mmplayer_gst_create_decoder(mm_player_t* player, GstPad *srcpad, const GstCaps *caps)
+{
+ MMPlayerGstElement* mainbin = NULL;
+ GstElement* decodebin = NULL;
+ GstElement* queue2 = NULL;
+ GstPad* sinkpad = NULL;
+ GstPad* qsrcpad = NULL;
+ gint init_buffering_time = player->streamer->buffering_req.prebuffer_time;
- LOGD("dur_bytes = %"G_GINT64_FORMAT, dur_bytes);
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin, FALSE);
- MuxedBufferType type = MUXED_BUFFER_TYPE_MEM_QUEUE;
+ mainbin = player->pipeline->mainbin;
- if (dur_bytes > 0) {
- if (MMPLAYER_USE_FILE_FOR_BUFFERING(player)) {
- type = MUXED_BUFFER_TYPE_FILE;
- } else {
- type = MUXED_BUFFER_TYPE_MEM_RING_BUFFER;
- player->streamer->ring_buffer_size = player->ini.http_ring_buffer_size;
- }
- } else {
- dur_bytes = 0;
- }
+ if ((!MMPLAYER_IS_HTTP_PD(player)) && (MMPLAYER_IS_HTTP_STREAMING(player))) {
- /* NOTE : in case of ts streaming, player cannot get the correct duration info *
- * skip the pull mode(file or ring buffering) setting. */
- if (!g_strrstr(player->type, "video/mpegts")) {
- max_buffer_size_bytes = (type == MUXED_BUFFER_TYPE_FILE) ? (player->ini.http_max_size_bytes) : (5*1024*1024);
- LOGD("max_buffer_size_bytes = %d", max_buffer_size_bytes);
-
- __mm_player_streaming_set_queue2(player->streamer,
- queue2,
- FALSE,
- max_buffer_size_bytes,
- player->ini.http_buffering_time,
- 1.0, /* no meaning */
- player->ini.http_buffering_limit, /* no meaning */
- type,
- player->http_file_buffering_path,
- (guint64)dur_bytes);
- }
+ if (mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst) {
+ LOGW("need to check: muxed buffer is not null");
+ }
- if (GST_STATE_CHANGE_FAILURE == gst_element_sync_state_with_parent(queue2)) {
- LOGE("failed to sync queue2 state with parent\n");
- goto ERROR;
- }
+ queue2 = __mmplayer_gst_make_queue2(player);
+ if (!queue2) {
+ LOGE("failed to make queue2");
+ goto ERROR;
+ }
- srcpad = qsrcpad;
+ if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), queue2)) {
+ LOGE("failed to add buffering queue");
+ goto ERROR;
+ }
- gst_object_unref(GST_OBJECT(sinkpad));
+ sinkpad = gst_element_get_static_pad(queue2, "sink");
+ qsrcpad = gst_element_get_static_pad(queue2, "src");
+
+ if (gst_pad_link(srcpad, sinkpad) != GST_PAD_LINK_OK) {
+ LOGE("failed to link [%s:%s]-[%s:%s]",
+ GST_DEBUG_PAD_NAME(srcpad), GST_DEBUG_PAD_NAME(sinkpad));
+ goto ERROR;
+ }
- mainbin[MMPLAYER_M_MUXED_S_BUFFER].id = MMPLAYER_M_MUXED_S_BUFFER;
- mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst = queue2;
+ if (gst_element_sync_state_with_parent(queue2) == GST_STATE_CHANGE_FAILURE) {
+ LOGE("failed to sync queue2 state with parent");
+ goto ERROR;
}
+
+ mainbin[MMPLAYER_M_MUXED_S_BUFFER].id = MMPLAYER_M_MUXED_S_BUFFER;
+ mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst = queue2;
+
+ srcpad = qsrcpad;
+
+ gst_object_unref(GST_OBJECT(sinkpad));
+ sinkpad = NULL;
}
/* create decodebin */
- decodebin = __mmplayer_create_decodebin(player);
-
+ decodebin = __mmplayer_gst_make_decodebin(player);
if (!decodebin) {
- LOGE("can not create autoplug element\n");
+ LOGE("failed to make decodebin");
goto ERROR;
}
sinkpad = gst_element_get_static_pad(decodebin, "sink");
if (GST_PAD_LINK_OK != gst_pad_link(srcpad, sinkpad)) {
- LOGE("failed to link decodebin\n");
+ LOGE("failed to link [%s:%s]-[%s:%s]",
+ GST_DEBUG_PAD_NAME(srcpad), GST_DEBUG_PAD_NAME(sinkpad));
goto ERROR;
}
gst_object_unref(GST_OBJECT(sinkpad));
+ sinkpad = NULL;
mainbin[MMPLAYER_M_AUTOPLUG].id = MMPLAYER_M_AUTOPLUG;
mainbin[MMPLAYER_M_AUTOPLUG].gst = decodebin;
goto ERROR;
}
- element = __mmplayer_gst_build_source(player);
+ element = __mmplayer_gst_create_source(player);
if (!element) {
LOGE("no source element was created");
goto ERROR;
MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "have-type", G_CALLBACK(__mmplayer_typefind_have_type), (gpointer)player);
} else {
elemId = MMPLAYER_M_AUTOPLUG;
- element = __mmplayer_create_decodebin(player);
+ element = __mmplayer_gst_make_decodebin(player);
}
/* check autoplug element is OK */