mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
camerabin: Use running time for muxing
This patch removes the audio source buffer probe that was used to re-timestamp buffers to make them start from 0. As muxers have been fixed to use running time instead of timestamps, this is not needed anymore. Fixes bug #646211
This commit is contained in:
parent
834dc9ca63
commit
72574962ef
2 changed files with 1 additions and 80 deletions
|
@ -93,8 +93,6 @@ gst_camerabin_video_change_state (GstElement * element,
|
||||||
static
|
static
|
||||||
gboolean camerabin_video_pad_tee_src0_have_buffer (GstPad * pad,
|
gboolean camerabin_video_pad_tee_src0_have_buffer (GstPad * pad,
|
||||||
GstBuffer * buffer, gpointer u_data);
|
GstBuffer * buffer, gpointer u_data);
|
||||||
static gboolean camerabin_video_pad_aud_src_have_buffer (GstPad * pad,
|
|
||||||
GstBuffer * buffer, gpointer u_data);
|
|
||||||
static gboolean camerabin_video_sink_have_event (GstPad * pad, GstEvent * event,
|
static gboolean camerabin_video_sink_have_event (GstPad * pad, GstEvent * event,
|
||||||
gpointer u_data);
|
gpointer u_data);
|
||||||
static gboolean gst_camerabin_video_create_elements (GstCameraBinVideo * vid);
|
static gboolean gst_camerabin_video_create_elements (GstCameraBinVideo * vid);
|
||||||
|
@ -185,7 +183,6 @@ gst_camerabin_video_init (GstCameraBinVideo * vid,
|
||||||
vid->mute = ARG_DEFAULT_MUTE;
|
vid->mute = ARG_DEFAULT_MUTE;
|
||||||
vid->flags = DEFAULT_FLAGS;
|
vid->flags = DEFAULT_FLAGS;
|
||||||
|
|
||||||
vid->aud_src_probe_id = 0;
|
|
||||||
vid->vid_src_probe_id = 0;
|
vid->vid_src_probe_id = 0;
|
||||||
vid->vid_tee_probe_id = 0;
|
vid->vid_tee_probe_id = 0;
|
||||||
vid->vid_sink_probe_id = 0;
|
vid->vid_sink_probe_id = 0;
|
||||||
|
@ -316,13 +313,11 @@ gst_camerabin_video_change_state (GstElement * element,
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
vid->calculate_adjust_ts_video = TRUE;
|
vid->calculate_adjust_ts_video = TRUE;
|
||||||
vid->calculate_adjust_ts_aud = TRUE;
|
|
||||||
g_object_set (G_OBJECT (vid->sink), "async", FALSE, NULL);
|
g_object_set (G_OBJECT (vid->sink), "async", FALSE, NULL);
|
||||||
gst_element_set_locked_state (vid->sink, FALSE);
|
gst_element_set_locked_state (vid->sink, FALSE);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
vid->calculate_adjust_ts_video = TRUE;
|
vid->calculate_adjust_ts_video = TRUE;
|
||||||
vid->calculate_adjust_ts_aud = TRUE;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
|
@ -355,8 +350,6 @@ gst_camerabin_video_change_state (GstElement * element,
|
||||||
/* Reset counters related to timestamp rewriting */
|
/* Reset counters related to timestamp rewriting */
|
||||||
vid->adjust_ts_video = 0;
|
vid->adjust_ts_video = 0;
|
||||||
vid->last_ts_video = 0;
|
vid->last_ts_video = 0;
|
||||||
vid->adjust_ts_aud = 0;
|
|
||||||
vid->last_ts_aud = 0;
|
|
||||||
|
|
||||||
if (vid->pending_eos) {
|
if (vid->pending_eos) {
|
||||||
gst_event_unref (vid->pending_eos);
|
gst_event_unref (vid->pending_eos);
|
||||||
|
@ -430,53 +423,6 @@ camerabin_video_pad_tee_src0_have_buffer (GstPad * pad, GstBuffer * buffer,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* camerabin_video_pad_aud_src_have_buffer:
|
|
||||||
* @pad: audio source src pad
|
|
||||||
* @event: received buffer
|
|
||||||
* @u_data: video bin object
|
|
||||||
*
|
|
||||||
* Buffer probe for rewriting audio buffer timestamps.
|
|
||||||
*
|
|
||||||
* Returns: TRUE always
|
|
||||||
*/
|
|
||||||
static gboolean
|
|
||||||
camerabin_video_pad_aud_src_have_buffer (GstPad * pad, GstBuffer * buffer,
|
|
||||||
gpointer u_data)
|
|
||||||
{
|
|
||||||
GstCameraBinVideo *vid = (GstCameraBinVideo *) u_data;
|
|
||||||
|
|
||||||
GST_LOG ("buffer in with size %d duration %" G_GINT64_FORMAT " ts %"
|
|
||||||
GST_TIME_FORMAT, GST_BUFFER_SIZE (buffer), GST_BUFFER_DURATION (buffer),
|
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
|
|
||||||
|
|
||||||
if (vid->calculate_adjust_ts_aud) {
|
|
||||||
GstEvent *event;
|
|
||||||
GstPad *peerpad = NULL;
|
|
||||||
|
|
||||||
vid->adjust_ts_aud = GST_BUFFER_TIMESTAMP (buffer) - vid->last_ts_aud;
|
|
||||||
vid->calculate_adjust_ts_aud = FALSE;
|
|
||||||
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
|
|
||||||
0, GST_CLOCK_TIME_NONE, vid->last_ts_aud);
|
|
||||||
peerpad = gst_pad_get_peer (pad);
|
|
||||||
if (peerpad) {
|
|
||||||
gst_pad_send_event (peerpad, event);
|
|
||||||
gst_object_unref (peerpad);
|
|
||||||
}
|
|
||||||
GST_LOG_OBJECT (vid, "aud ts adjustment: %" GST_TIME_FORMAT,
|
|
||||||
GST_TIME_ARGS (vid->adjust_ts_aud));
|
|
||||||
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
|
|
||||||
}
|
|
||||||
GST_BUFFER_TIMESTAMP (buffer) -= vid->adjust_ts_aud;
|
|
||||||
vid->last_ts_aud = GST_BUFFER_TIMESTAMP (buffer);
|
|
||||||
if (GST_BUFFER_DURATION_IS_VALID (buffer))
|
|
||||||
vid->last_ts_aud += GST_BUFFER_DURATION (buffer);
|
|
||||||
|
|
||||||
GST_LOG ("buffer out with size %d ts %" GST_TIME_FORMAT,
|
|
||||||
GST_BUFFER_SIZE (buffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* camerabin_video_sink_have_event:
|
* camerabin_video_sink_have_event:
|
||||||
* @pad: video bin sink pad
|
* @pad: video bin sink pad
|
||||||
|
@ -532,7 +478,7 @@ camerabin_video_sink_have_event (GstPad * pad, GstEvent * event,
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
|
gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
|
||||||
{
|
{
|
||||||
GstPad *pad = NULL, *vid_sinkpad = NULL, *vid_srcpad = NULL;
|
GstPad *vid_sinkpad = NULL, *vid_srcpad = NULL;
|
||||||
GstBin *vidbin = GST_BIN (vid);
|
GstBin *vidbin = GST_BIN (vid);
|
||||||
GstElement *queue = NULL;
|
GstElement *queue = NULL;
|
||||||
|
|
||||||
|
@ -540,10 +486,6 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
|
||||||
vid->last_ts_video = 0;
|
vid->last_ts_video = 0;
|
||||||
vid->calculate_adjust_ts_video = FALSE;
|
vid->calculate_adjust_ts_video = FALSE;
|
||||||
|
|
||||||
vid->adjust_ts_aud = 0;
|
|
||||||
vid->last_ts_aud = 0;
|
|
||||||
vid->calculate_adjust_ts_aud = FALSE;
|
|
||||||
|
|
||||||
/* Add video post processing element if any */
|
/* Add video post processing element if any */
|
||||||
if (vid->app_post) {
|
if (vid->app_post) {
|
||||||
if (!gst_camerabin_add_element (vidbin, vid->app_post)) {
|
if (!gst_camerabin_add_element (vidbin, vid->app_post)) {
|
||||||
|
@ -695,12 +637,6 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
|
||||||
G_CALLBACK (gst_camerabin_drop_eos_probe), vid);
|
G_CALLBACK (gst_camerabin_drop_eos_probe), vid);
|
||||||
gst_object_unref (vid_srcpad);
|
gst_object_unref (vid_srcpad);
|
||||||
|
|
||||||
if (!(vid->flags & GST_CAMERABIN_FLAG_DISABLE_AUDIO)) {
|
|
||||||
pad = gst_element_get_static_pad (vid->aud_src, "src");
|
|
||||||
vid->aud_src_probe_id = gst_pad_add_buffer_probe (pad,
|
|
||||||
G_CALLBACK (camerabin_video_pad_aud_src_have_buffer), vid);
|
|
||||||
gst_object_unref (pad);
|
|
||||||
}
|
|
||||||
GST_DEBUG ("created video elements");
|
GST_DEBUG ("created video elements");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -726,16 +662,6 @@ gst_camerabin_video_destroy_elements (GstCameraBinVideo * vid)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("destroying video elements");
|
GST_DEBUG ("destroying video elements");
|
||||||
|
|
||||||
/* Remove buffer probe from audio src pad */
|
|
||||||
if (vid->aud_src_probe_id) {
|
|
||||||
GstPad *pad = gst_element_get_static_pad (vid->aud_src, "src");
|
|
||||||
if (pad) {
|
|
||||||
gst_pad_remove_buffer_probe (pad, vid->aud_src_probe_id);
|
|
||||||
gst_object_unref (pad);
|
|
||||||
}
|
|
||||||
vid->aud_src_probe_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove EOS event probe from videobin srcpad (queue's srcpad) */
|
/* Remove EOS event probe from videobin srcpad (queue's srcpad) */
|
||||||
if (vid->vid_src_probe_id) {
|
if (vid->vid_src_probe_id) {
|
||||||
GstPad *pad = gst_ghost_pad_get_target (GST_GHOST_PAD (vid->srcpad));
|
GstPad *pad = gst_ghost_pad_get_target (GST_GHOST_PAD (vid->srcpad));
|
||||||
|
|
|
@ -52,10 +52,6 @@ struct _GstCameraBinVideo
|
||||||
guint64 last_ts_video;
|
guint64 last_ts_video;
|
||||||
gboolean calculate_adjust_ts_video;
|
gboolean calculate_adjust_ts_video;
|
||||||
|
|
||||||
guint64 adjust_ts_aud;
|
|
||||||
guint64 last_ts_aud;
|
|
||||||
gboolean calculate_adjust_ts_aud;
|
|
||||||
|
|
||||||
/* Sink and src pads of video bin */
|
/* Sink and src pads of video bin */
|
||||||
GstPad *sinkpad;
|
GstPad *sinkpad;
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
|
@ -84,7 +80,6 @@ struct _GstCameraBinVideo
|
||||||
GstEvent *pending_eos;
|
GstEvent *pending_eos;
|
||||||
|
|
||||||
/* Probe IDs */
|
/* Probe IDs */
|
||||||
gulong aud_src_probe_id;
|
|
||||||
gulong vid_src_probe_id;
|
gulong vid_src_probe_id;
|
||||||
gulong vid_tee_probe_id;
|
gulong vid_tee_probe_id;
|
||||||
gulong vid_sink_probe_id;
|
gulong vid_sink_probe_id;
|
||||||
|
|
Loading…
Reference in a new issue