int __mmplayer_switch_audio_sink (mm_player_t* player);
static gboolean __mmplayer_gst_remove_fakesink(mm_player_t* player, MMPlayerGstElement* fakesink);
static GstPadProbeReturn __mmplayer_audio_stream_probe (GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
-static GstPadProbeReturn __mmplayer_video_stream_probe (GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
+static void __mmplayer_video_stream_decoded_preroll_cb(GstElement* object, GstBuffer *buffer, GstPad *pad, gpointer data);
+static void __mmplayer_video_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer, GstPad *pad, gpointer data);
static GstPadProbeReturn __mmplayer_subtitle_adjust_position_probe (GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
static int __mmplayer_change_selector_pad (mm_player_t* player, MMPlayerTrackType type, int index);
/* don't make video because of not required, and not support multiple track */
if (stype == MM_DISPLAY_SURFACE_NULL)
{
- LOGD ("no video sink by null surface or multiple track (%d)", stype);
+ LOGD ("no video sink by null surface");
MMPlayerResourceState resource_state = RESOURCE_STATE_NONE;
if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state)
== MM_ERROR_NONE)
}
if (stype == MM_DISPLAY_SURFACE_REMOTE) {
- MMPLAYER_SIGNAL_CONNECT (player, sinkpad, MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
+ MMPLAYER_SIGNAL_CONNECT(player, sinkpad, MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
"notify::caps", G_CALLBACK(__mmplayer_gst_caps_notify_cb), player);
}
- if (player->set_mode.media_packet_video_stream)
- player->video_cb_probe_id = gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_BUFFER, __mmplayer_video_stream_probe, player, NULL);
-
- g_object_set (G_OBJECT (fakesink), "async", TRUE, NULL);
- g_object_set (G_OBJECT (fakesink), "sync", TRUE, NULL);
- gst_element_set_state (fakesink, GST_STATE_PAUSED);
+ if (player->set_mode.media_packet_video_stream) {
+ g_object_set(G_OBJECT(fakesink), "signal-handoffs", TRUE, NULL);
+
+ MMPLAYER_SIGNAL_CONNECT(player,
+ G_OBJECT(fakesink),
+ MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
+ "handoff",
+ G_CALLBACK(__mmplayer_video_stream_decoded_render_cb),
+ (gpointer)player);
+
+ MMPLAYER_SIGNAL_CONNECT(player,
+ G_OBJECT(fakesink),
+ MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
+ "preroll-handoff",
+ G_CALLBACK(__mmplayer_video_stream_decoded_preroll_cb),
+ (gpointer)player);
+ }
+ g_object_set(G_OBJECT(fakesink), "async", TRUE, "sync", TRUE, NULL);
+ gst_element_set_state(fakesink, GST_STATE_PAUSED);
goto DONE;
}
continue;
}
}
+static void
+__mmplayer_video_stream_decoded_preroll_cb(GstElement* object, GstBuffer *buffer, GstPad *pad, gpointer data)
+{
+ mm_player_t* player = (mm_player_t*)data;
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_IF_FAIL(player && player->video_stream_cb);
-static GstPadProbeReturn
-__mmplayer_video_stream_probe (GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
+ __mmplayer_video_stream_decoded_render_cb(object, buffer, pad, data);
+
+ /* not to send prerolled pkt again */
+ player->video_stream_prerolled = TRUE;
+}
+
+static void
+__mmplayer_video_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer, GstPad *pad, gpointer data)
{
+ mm_player_t* player = (mm_player_t*)data;
GstCaps *caps = NULL;
MMPlayerVideoStreamDataType stream;
MMVideoBuffer *video_buffer = NULL;
GstStructure *structure = NULL;
const gchar *string_format = NULL;
unsigned int fourcc = 0;
- mm_player_t* player = (mm_player_t*)user_data;
- GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
- MMPLAYER_RETURN_VAL_IF_FAIL(buffer, GST_PAD_PROBE_DROP);
- MMPLAYER_RETURN_VAL_IF_FAIL(gst_buffer_n_memory(buffer) , GST_PAD_PROBE_DROP);
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_IF_FAIL(player && player->video_stream_cb);
+
+ if (player->video_stream_prerolled) {
+ player->video_stream_prerolled = FALSE;
+ LOGD("skip the prerolled pkt not to send it again");
+ return;
+ }
caps = gst_pad_get_current_caps(pad);
if (caps == NULL) {
LOGE( "Caps is NULL." );
- return GST_PAD_PROBE_OK;
+ return;
}
/* MMPLAYER_LOG_GST_CAPS_TYPE(caps); */
if (stream.width == 0 || stream.height == 0 || stream.format == MM_PIXEL_FORMAT_INVALID) {
LOGE("Wrong condition!!");
- return TRUE;
+ return;
}
/* set size and timestamp */
gst_ret = gst_memory_map(dataBlock, &mapinfo, GST_MAP_READWRITE);
if (!gst_ret) {
LOGE("fail to gst_memory_map");
- return GST_PAD_PROBE_OK;
+ return;
}
stream.stride[0] = stride;
} else {
LOGE("Not support format %d", stream.format);
gst_memory_unmap(dataBlock, &mapinfo);
- return GST_PAD_PROBE_OK;
+ return;
}
size = (stream.stride[0] + stream.stride[1]) * elevation;
if(!stream.bo[0]) {
LOGE("Fail to tbm_bo_alloc!!");
gst_memory_unmap(dataBlock, &mapinfo);
- return GST_PAD_PROBE_OK;
+ return;
}
thandle = tbm_bo_map(stream.bo[0], TBM_DEVICE_CPU, TBM_OPTION_WRITE);
if(thandle.ptr && mapinfo.data)
gst_memory_unmap(dataBlock, &mapinfo);
}
- return GST_PAD_PROBE_OK;
+ return;
}
static int
case MM_DISPLAY_SURFACE_REMOTE:
{
if (player->set_mode.media_packet_video_stream) {
- GstPad* sinkpad = NULL;
- sinkpad = gst_element_get_static_pad (player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink");
- g_object_set (player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sync", TRUE, NULL);
-
LOGE("add data probe at videosink");
- player->video_cb_probe_id = gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_BUFFER, __mmplayer_video_stream_probe, player, NULL);
+ g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
+ "sync", TRUE, "signal-handoffs", TRUE, NULL);
+
+ MMPLAYER_SIGNAL_CONNECT(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_SIGNAL_CONNECT(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);
}
break;
}
player->video_stream_cb = NULL;
player->video_stream_cb_user_param = NULL;
+ player->video_stream_prerolled = FALSE;
player->audio_stream_cb = NULL;
player->audio_stream_render_cb_ex = NULL;
player->state_tune_caps = NULL;
}
- if (player->video_cb_probe_id)
- {
- GstPad *pad = NULL;
-
- pad = gst_element_get_static_pad (player->video_fakesink, "sink");
-
- if (pad) {
- LOGD("release video probe\n");
-
- /* release audio callback */
- gst_pad_remove_probe (pad, player->video_cb_probe_id);
- player->video_cb_probe_id = 0;
- player->video_stream_cb = NULL;
- player->video_stream_cb_user_param = NULL;
- }
- }
-
MMPLAYER_FLEAVE();
}