mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
resindvd: Add some GAP event stuff to make still-frames start to work
And remove the dead audiomunge element. It isn't needed now, we just send GAP events
This commit is contained in:
parent
1218cff3dc
commit
211828979b
8 changed files with 34 additions and 486 deletions
|
@ -12,8 +12,7 @@ libgstresindvd_la_SOURCES = \
|
|||
gstpesfilter.c \
|
||||
rsninputselector.c \
|
||||
# rsnparsetter.c \
|
||||
# rsnwrappedbuffer.c \
|
||||
# rsnaudiomunge.c
|
||||
# rsnwrappedbuffer.c
|
||||
|
||||
libgstresindvd_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
|
||||
|
@ -25,7 +24,6 @@ libgstresindvd_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
|||
libgstresindvd_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
noinst_HEADERS = resindvdbin.h \
|
||||
rsnaudiomunge.h \
|
||||
rsndec.h \
|
||||
rsninputselector.h \
|
||||
resindvdsrc.h \
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
#include "gstmpegdefs.h"
|
||||
#include "gstmpegdemux.h"
|
||||
|
@ -122,7 +123,7 @@ static gboolean gst_flups_demux_src_query (GstPad * pad, GstObject * parent,
|
|||
static GstStateChangeReturn gst_flups_demux_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
static inline void gst_flups_demux_send_segment_updates (GstFluPSDemux * demux,
|
||||
static inline void gst_flups_demux_send_gap_updates (GstFluPSDemux * demux,
|
||||
GstClockTime new_time);
|
||||
static inline void gst_flups_demux_clear_times (GstFluPSDemux * demux);
|
||||
|
||||
|
@ -770,6 +771,7 @@ gst_flups_demux_flush (GstFluPSDemux * demux)
|
|||
demux->current_scr = G_MAXUINT64;
|
||||
demux->bytes_since_scr = 0;
|
||||
demux->scr_adjust = GSTTIME_TO_MPEGTIME (SCR_MUNGE);
|
||||
demux->in_still = FALSE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -788,8 +790,7 @@ gst_flups_demux_clear_times (GstFluPSDemux * demux)
|
|||
}
|
||||
|
||||
static inline void
|
||||
gst_flups_demux_send_segment_updates (GstFluPSDemux * demux,
|
||||
GstClockTime new_time)
|
||||
gst_flups_demux_send_gap_updates (GstFluPSDemux * demux, GstClockTime new_time)
|
||||
{
|
||||
gint id;
|
||||
GstEvent *event = NULL;
|
||||
|
@ -807,35 +808,20 @@ gst_flups_demux_send_segment_updates (GstFluPSDemux * demux,
|
|||
stream->last_ts = demux->src_segment.start;
|
||||
if (stream->last_ts + stream->segment_thresh < new_time) {
|
||||
#if 0
|
||||
g_print ("Segment update to pad %s time %" GST_TIME_FORMAT " stop now %"
|
||||
GST_TIME_FORMAT " position %" GST_TIME_FORMAT "\n",
|
||||
GST_PAD_NAME (stream->pad), GST_TIME_ARGS (new_time),
|
||||
GST_TIME_ARGS (demux->src_segment.stop),
|
||||
GST_TIME_ARGS (demux->src_segment.position));
|
||||
g_print ("Gap event update to pad %s from time %" GST_TIME_FORMAT
|
||||
" to %" GST_TIME_FORMAT "\n", GST_PAD_NAME (stream->pad),
|
||||
GST_TIME_ARGS (stream->last_ts), GST_TIME_ARGS (new_time));
|
||||
#endif
|
||||
GST_DEBUG_OBJECT (demux,
|
||||
"Segment update to pad %s time %" GST_TIME_FORMAT,
|
||||
GST_PAD_NAME (stream->pad), GST_TIME_ARGS (new_time));
|
||||
if (event == NULL) {
|
||||
GstSegment segment;
|
||||
gst_segment_init (&segment, GST_FORMAT_TIME);
|
||||
segment.rate = demux->src_segment.rate;
|
||||
segment.applied_rate = demux->src_segment.applied_rate;
|
||||
segment.start = new_time;
|
||||
segment.stop = demux->src_segment.stop;
|
||||
segment.time =
|
||||
demux->src_segment.time + (new_time - demux->src_segment.start);
|
||||
event = gst_event_new_segment (&segment);
|
||||
}
|
||||
gst_event_ref (event);
|
||||
"Gap event update to pad %s from time %" GST_TIME_FORMAT " to %"
|
||||
GST_TIME_FORMAT, GST_PAD_NAME (stream->pad),
|
||||
GST_TIME_ARGS (stream->last_ts), GST_TIME_ARGS (new_time));
|
||||
event = gst_event_new_gap (stream->last_ts, new_time - stream->last_ts);
|
||||
gst_pad_push_event (stream->pad, event);
|
||||
stream->last_seg_start = stream->last_ts = new_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event)
|
||||
gst_event_unref (event);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -934,7 +920,6 @@ gst_flups_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||
"demux: received new segment start %" G_GINT64_FORMAT " stop %"
|
||||
G_GINT64_FORMAT " time %" G_GINT64_FORMAT, start, stop, time);
|
||||
|
||||
|
||||
adjust = base - start + SCR_MUNGE;
|
||||
start = base + SCR_MUNGE;
|
||||
|
||||
|
@ -961,9 +946,14 @@ gst_flups_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||
demux->src_segment.rate = segment->rate;
|
||||
demux->src_segment.applied_rate = segment->applied_rate;
|
||||
demux->src_segment.format = segment->format;
|
||||
demux->src_segment.start = segment->start;
|
||||
demux->src_segment.stop = segment->stop;
|
||||
demux->src_segment.time = segment->time;
|
||||
demux->src_segment.start = start;
|
||||
demux->src_segment.stop = stop;
|
||||
demux->src_segment.time = time;
|
||||
|
||||
if (demux->in_still && stop != -1) {
|
||||
/* Generate gap buffers, due to closing segment from a still-frame */
|
||||
gst_flups_demux_send_gap_updates (demux, stop);
|
||||
}
|
||||
|
||||
gst_event_unref (event);
|
||||
event = gst_event_new_segment (&demux->src_segment);
|
||||
|
@ -983,8 +973,15 @@ gst_flups_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||
case GST_EVENT_CUSTOM_DOWNSTREAM_OOB:
|
||||
{
|
||||
const GstStructure *structure = gst_event_get_structure (event);
|
||||
gboolean in_still;
|
||||
|
||||
if (structure != NULL
|
||||
if (gst_video_event_parse_still_frame (event, &in_still)) {
|
||||
/* Remember the still-frame state, so we can generate a pre-roll
|
||||
* GAP event when a segment event arrives */
|
||||
demux->in_still = in_still;
|
||||
GST_INFO_OBJECT (demux, "still-state now %d", demux->in_still);
|
||||
gst_flups_demux_send_event (demux, event);
|
||||
} else if (structure != NULL
|
||||
&& gst_structure_has_name (structure, "application/x-gst-dvd")) {
|
||||
res = gst_flups_demux_handle_dvd_event (demux, event);
|
||||
} else {
|
||||
|
@ -1473,7 +1470,7 @@ gst_flups_demux_parse_pack_start (GstFluPSDemux * demux)
|
|||
if (new_time != GST_CLOCK_TIME_NONE) {
|
||||
// g_print ("SCR now %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (new_time));
|
||||
gst_segment_set_position (&demux->src_segment, GST_FORMAT_TIME, new_time);
|
||||
gst_flups_demux_send_segment_updates (demux, new_time);
|
||||
gst_flups_demux_send_gap_updates (demux, new_time);
|
||||
}
|
||||
|
||||
/* Reset the bytes_since_scr value to count the data remaining in the
|
||||
|
|
|
@ -97,7 +97,7 @@ struct _GstFluPSDemux {
|
|||
GstPad * sinkpad;
|
||||
gboolean random_access; /* If we operate in pull mode */
|
||||
gboolean flushing;
|
||||
|
||||
gboolean in_still;
|
||||
|
||||
GstAdapter * adapter;
|
||||
GstAdapter * rev_adapter;
|
||||
|
|
|
@ -466,28 +466,12 @@ create_elements (RsnDvdBin * dvdbin)
|
|||
RSN_TYPE_INPUT_SELECTOR, "audioselect", "Audio stream selector"))
|
||||
return FALSE;
|
||||
|
||||
if (!try_create_piece (dvdbin, DVD_ELEM_AUD_MUNGE, "identity",
|
||||
0 /* RSN_TYPE_AUDIOMUNGE */ , "audioearlymunge",
|
||||
"Audio output filter"))
|
||||
return FALSE;
|
||||
|
||||
if (!try_create_piece (dvdbin, DVD_ELEM_AUDDEC, NULL,
|
||||
RSN_TYPE_AUDIODEC, "auddec", "audio decoder"))
|
||||
return FALSE;
|
||||
|
||||
src = gst_element_get_static_pad (dvdbin->pieces[DVD_ELEM_AUD_MUNGE], "src");
|
||||
sink = gst_element_get_static_pad (dvdbin->pieces[DVD_ELEM_AUDDEC], "sink");
|
||||
if (src == NULL || sink == NULL)
|
||||
goto failed_aud_connect;
|
||||
if (GST_PAD_LINK_FAILED (gst_pad_link (src, sink)))
|
||||
goto failed_aud_connect;
|
||||
gst_object_unref (sink);
|
||||
gst_object_unref (src);
|
||||
src = sink = NULL;
|
||||
|
||||
src = gst_element_get_static_pad (dvdbin->pieces[DVD_ELEM_AUD_SELECT], "src");
|
||||
sink =
|
||||
gst_element_get_static_pad (dvdbin->pieces[DVD_ELEM_AUD_MUNGE], "sink");
|
||||
sink = gst_element_get_static_pad (dvdbin->pieces[DVD_ELEM_AUDDEC], "sink");
|
||||
if (src == NULL || sink == NULL)
|
||||
goto failed_aud_connect;
|
||||
if (GST_PAD_LINK_FAILED (gst_pad_link (src, sink)))
|
||||
|
@ -701,7 +685,7 @@ demux_pad_added (GstElement * element, GstPad * pad, RsnDvdBin * dvdbin)
|
|||
gst_element_get_request_pad (dvdbin->pieces[DVD_ELEM_SPU_SELECT],
|
||||
"sink_%u");
|
||||
skip_mq = TRUE;
|
||||
} else if (can_sink_caps (dvdbin->pieces[DVD_ELEM_AUD_MUNGE], caps)) {
|
||||
} else if (can_sink_caps (dvdbin->pieces[DVD_ELEM_AUDDEC], caps)) {
|
||||
GST_LOG_OBJECT (dvdbin, "Found audio pad w/ caps %" GST_PTR_FORMAT, caps);
|
||||
dest_pad =
|
||||
gst_element_get_request_pad (dvdbin->pieces[DVD_ELEM_AUD_SELECT],
|
||||
|
|
|
@ -49,8 +49,7 @@ typedef struct _RsnDvdBinClass RsnDvdBinClass;
|
|||
#define DVD_ELEM_VIDQ 7
|
||||
#define DVD_ELEM_SPU_SELECT 8
|
||||
#define DVD_ELEM_AUD_SELECT 9
|
||||
#define DVD_ELEM_AUD_MUNGE 10
|
||||
#define DVD_ELEM_LAST 11
|
||||
#define DVD_ELEM_LAST 10
|
||||
|
||||
struct _RsnDvdBin
|
||||
{
|
||||
|
|
|
@ -630,7 +630,7 @@ rsn_dvdsrc_do_still (resinDvdSrc * src, int duration)
|
|||
* event, then sleep */
|
||||
still_event = gst_video_event_new_still_frame (TRUE);
|
||||
|
||||
segment->position = src->cur_end_ts;
|
||||
segment->stop = segment->position = src->cur_end_ts;
|
||||
|
||||
seg_event = gst_event_new_segment (segment);
|
||||
|
||||
|
|
|
@ -1,369 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2008 Jan Schmidt <thaytan@noraisin.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
#include "rsnaudiomunge.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (rsn_audiomunge_debug);
|
||||
#define GST_CAT_DEFAULT rsn_audiomunge_debug
|
||||
|
||||
#define AUDIO_FILL_THRESHOLD (GST_SECOND/5)
|
||||
|
||||
/* Filter signals and args */
|
||||
enum
|
||||
{
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_SILENT
|
||||
};
|
||||
|
||||
/* the capabilities of the inputs and outputs.
|
||||
*
|
||||
* describe the real formats here.
|
||||
*/
|
||||
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("ANY")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("ANY")
|
||||
);
|
||||
|
||||
G_DEFINE_TYPE (RsnAudioMunge, rsn_audiomunge, GST_TYPE_ELEMENT);
|
||||
|
||||
static void rsn_audiomunge_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void rsn_audiomunge_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
|
||||
static gboolean rsn_audiomunge_set_caps (GstPad * pad, GstCaps * caps);
|
||||
static GstFlowReturn rsn_audiomunge_chain (GstPad * pad, GstBuffer * buf);
|
||||
static gboolean rsn_audiomunge_sink_event (GstPad * pad, GstEvent * event);
|
||||
|
||||
static GstStateChangeReturn
|
||||
rsn_audiomunge_change_state (GstElement * element, GstStateChange transition);
|
||||
|
||||
static void
|
||||
rsn_audiomunge_class_init (RsnAudioMungeClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *) (klass);
|
||||
GstElementClass *element_class = (GstElementClass *) (klass);
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rsn_audiomunge_debug, "rsnaudiomunge",
|
||||
0, "ResinDVD audio stream regulator");
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&sink_template));
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "RsnAudioMunge",
|
||||
"Audio/Filter",
|
||||
"Resin DVD audio stream regulator", "Jan Schmidt <thaytan@noraisin.net>");
|
||||
|
||||
gobject_class->set_property = rsn_audiomunge_set_property;
|
||||
gobject_class->get_property = rsn_audiomunge_get_property;
|
||||
|
||||
element_class->change_state = rsn_audiomunge_change_state;
|
||||
}
|
||||
|
||||
static void
|
||||
rsn_audiomunge_init (RsnAudioMunge * munge)
|
||||
{
|
||||
munge->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
|
||||
gst_pad_set_getcaps_function (munge->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
||||
gst_pad_set_chain_function (munge->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (rsn_audiomunge_chain));
|
||||
gst_pad_set_event_function (munge->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (rsn_audiomunge_sink_event));
|
||||
gst_element_add_pad (GST_ELEMENT (munge), munge->sinkpad);
|
||||
|
||||
munge->srcpad = gst_pad_new_from_static_template (&src_template, "src");
|
||||
gst_pad_set_getcaps_function (munge->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
||||
gst_element_add_pad (GST_ELEMENT (munge), munge->srcpad);
|
||||
}
|
||||
|
||||
static void
|
||||
rsn_audiomunge_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
//RsnAudioMunge *munge = RSN_AUDIOMUNGE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rsn_audiomunge_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
//RsnAudioMunge *munge = RSN_AUDIOMUNGE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
rsn_audiomunge_set_caps (GstPad * pad, GstCaps * caps)
|
||||
{
|
||||
RsnAudioMunge *munge = RSN_AUDIOMUNGE (gst_pad_get_parent (pad));
|
||||
GstPad *otherpad;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (munge != NULL, FALSE);
|
||||
|
||||
otherpad = (pad == munge->srcpad) ? munge->sinkpad : munge->srcpad;
|
||||
|
||||
gst_object_unref (munge);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
rsn_audiomunge_reset (RsnAudioMunge * munge)
|
||||
{
|
||||
munge->have_audio = FALSE;
|
||||
munge->in_still = FALSE;
|
||||
gst_segment_init (&munge->sink_segment, GST_FORMAT_TIME);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
rsn_audiomunge_chain (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
RsnAudioMunge *munge = RSN_AUDIOMUNGE (GST_OBJECT_PARENT (pad));
|
||||
|
||||
if (!munge->have_audio) {
|
||||
GST_INFO_OBJECT (munge,
|
||||
"First audio after flush has TS %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
|
||||
}
|
||||
|
||||
munge->have_audio = TRUE;
|
||||
|
||||
/* just push out the incoming buffer without touching it */
|
||||
return gst_pad_push (munge->srcpad, buf);
|
||||
}
|
||||
|
||||
/* Create and send a silence buffer downstream */
|
||||
static GstFlowReturn
|
||||
rsn_audiomunge_make_audio (RsnAudioMunge * munge,
|
||||
GstClockTime start, GstClockTime fill_time)
|
||||
{
|
||||
GstFlowReturn ret;
|
||||
GstBuffer *audio_buf;
|
||||
GstCaps *caps;
|
||||
guint buf_size;
|
||||
|
||||
/* Just generate a 48khz stereo buffer for now */
|
||||
/* FIXME: Adapt to the allowed formats, according to the currently
|
||||
* plugged decoder, or at least add a source pad that accepts the
|
||||
* caps we're outputting if the upstream decoder does not */
|
||||
#if 0
|
||||
caps =
|
||||
gst_caps_from_string
|
||||
("audio/x-raw-int,rate=48000,channels=2,width=16,depth=16,signed=(boolean)true,endianness=4321");
|
||||
buf_size = 4 * (48000 * fill_time / GST_SECOND);
|
||||
#else
|
||||
caps = gst_caps_from_string ("audio/x-raw-float, endianness=(int)1234,"
|
||||
"width=(int)32, channels=(int)2, rate=(int)48000");
|
||||
buf_size = 2 * 4 * (48000 * fill_time / GST_SECOND);
|
||||
#endif
|
||||
|
||||
audio_buf = gst_buffer_new_and_alloc (buf_size);
|
||||
|
||||
gst_buffer_set_caps (audio_buf, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (audio_buf) = start;
|
||||
GST_BUFFER_DURATION (audio_buf) = fill_time;
|
||||
GST_BUFFER_FLAG_SET (audio_buf, GST_BUFFER_FLAG_DISCONT);
|
||||
|
||||
memset (GST_BUFFER_DATA (audio_buf), 0, buf_size);
|
||||
|
||||
GST_LOG_OBJECT (munge, "Sending %u bytes (%" GST_TIME_FORMAT
|
||||
") of audio data with TS %" GST_TIME_FORMAT,
|
||||
buf_size, GST_TIME_ARGS (fill_time), GST_TIME_ARGS (start));
|
||||
|
||||
ret = gst_pad_push (munge->srcpad, audio_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
rsn_audiomunge_sink_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
RsnAudioMunge *munge = RSN_AUDIOMUNGE (gst_pad_get_parent (pad));
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_CAPS:
|
||||
{
|
||||
GstCaps *caps;
|
||||
|
||||
gst_event_parse_caps (event, &caps);
|
||||
ret = gst_pad_set_caps (munge->src_pad, caps);
|
||||
gst_event_unref (caps);
|
||||
}
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
rsn_audiomunge_reset (munge);
|
||||
ret = gst_pad_push_event (munge->srcpad, event);
|
||||
break;
|
||||
case GST_EVENT_NEWSEGMENT:
|
||||
{
|
||||
GstSegment *segment;
|
||||
gboolean update;
|
||||
GstFormat format;
|
||||
gdouble rate, arate;
|
||||
gint64 start, stop, time;
|
||||
|
||||
gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
|
||||
&start, &stop, &time);
|
||||
|
||||
/* we need TIME format */
|
||||
if (format != GST_FORMAT_TIME)
|
||||
goto newseg_wrong_format;
|
||||
|
||||
/* now configure the values */
|
||||
segment = &munge->sink_segment;
|
||||
|
||||
gst_segment_set_newsegment_full (segment, update,
|
||||
rate, arate, format, start, stop, time);
|
||||
|
||||
/*
|
||||
* FIXME:
|
||||
* If this is a segment update and accum >= threshold,
|
||||
* or we're in a still frame and there's been no audio received,
|
||||
* then we need to generate some audio data.
|
||||
*
|
||||
* If caused by a segment start update (time advancing in a gap) adjust
|
||||
* the new-segment and send the buffer.
|
||||
*
|
||||
* Otherwise, send the buffer before the newsegment, so that it appears
|
||||
* in the closing segment.
|
||||
*/
|
||||
if (!update) {
|
||||
GST_DEBUG_OBJECT (munge,
|
||||
"Sending newsegment: update %d start %" GST_TIME_FORMAT " stop %"
|
||||
GST_TIME_FORMAT " accum now %" GST_TIME_FORMAT, update,
|
||||
GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
|
||||
GST_TIME_ARGS (segment->accum));
|
||||
|
||||
ret = gst_pad_push_event (munge->srcpad, event);
|
||||
}
|
||||
|
||||
if (!munge->have_audio) {
|
||||
if ((update && segment->accum >= AUDIO_FILL_THRESHOLD)
|
||||
|| munge->in_still) {
|
||||
GST_DEBUG_OBJECT (munge,
|
||||
"Sending audio fill with ts %" GST_TIME_FORMAT ": accum = %"
|
||||
GST_TIME_FORMAT " still-state=%d", GST_TIME_ARGS (segment->start),
|
||||
GST_TIME_ARGS (segment->accum), munge->in_still);
|
||||
|
||||
/* Just generate a 200ms silence buffer for now. FIXME: Fill the gap */
|
||||
if (rsn_audiomunge_make_audio (munge, segment->start,
|
||||
GST_SECOND / 5) == GST_FLOW_OK)
|
||||
munge->have_audio = TRUE;
|
||||
} else {
|
||||
GST_LOG_OBJECT (munge, "Not sending audio fill buffer: "
|
||||
"Not segment update, or segment accum below thresh: accum = %"
|
||||
GST_TIME_FORMAT, GST_TIME_ARGS (segment->accum));
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
GST_DEBUG_OBJECT (munge,
|
||||
"Sending newsegment: update %d start %" GST_TIME_FORMAT " stop %"
|
||||
GST_TIME_FORMAT " accum now %" GST_TIME_FORMAT, update,
|
||||
GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
|
||||
GST_TIME_ARGS (segment->accum));
|
||||
|
||||
ret = gst_pad_push_event (munge->srcpad, event);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GST_EVENT_CUSTOM_DOWNSTREAM:
|
||||
{
|
||||
gboolean in_still;
|
||||
|
||||
if (gst_video_event_parse_still_frame (event, &in_still)) {
|
||||
/* Remember the still-frame state, so we can generate a pre-roll
|
||||
* buffer when a new-segment arrives */
|
||||
munge->in_still = in_still;
|
||||
GST_INFO_OBJECT (munge, "AUDIO MUNGE: still-state now %d",
|
||||
munge->in_still);
|
||||
}
|
||||
|
||||
ret = gst_pad_push_event (munge->srcpad, event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = gst_pad_push_event (munge->srcpad, event);
|
||||
break;
|
||||
}
|
||||
|
||||
gst_object_unref (munge);
|
||||
return ret;
|
||||
|
||||
newseg_wrong_format:
|
||||
|
||||
GST_DEBUG_OBJECT (munge, "received non TIME newsegment");
|
||||
gst_event_unref (event);
|
||||
gst_object_unref (munge);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
rsn_audiomunge_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
RsnAudioMunge *munge = RSN_AUDIOMUNGE (element);
|
||||
GstStateChangeReturn ret;
|
||||
|
||||
if (transition == GST_STATE_CHANGE_READY_TO_PAUSED)
|
||||
rsn_audiomunge_reset (munge);
|
||||
|
||||
ret =
|
||||
GST_ELEMENT_CLASS (rsn_audiomunge_parent_class)->change_state (element,
|
||||
transition);
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2008 Jan Schmidt <thaytan@noraisin.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __RSNAUDIOMUNGE_H__
|
||||
#define __RSNAUDIOMUNGE_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* #defines don't like whitespacey bits */
|
||||
#define RSN_TYPE_AUDIOMUNGE (rsn_audiomunge_get_type())
|
||||
#define RSN_AUDIOMUNGE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),RSN_TYPE_AUDIOMUNGE,RsnAudioMunge))
|
||||
#define RSN_AUDIOMUNGE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),RSN_TYPE_AUDIOMUNGE,RsnAudioMungeClass))
|
||||
#define RSN_IS_AUDIOMUNGE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),RSN_TYPE_AUDIOMUNGE))
|
||||
#define RSN_IS_AUDIOMUNGE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),RSN_TYPE_AUDIOMUNGE))
|
||||
|
||||
typedef struct _RsnAudioMunge RsnAudioMunge;
|
||||
typedef struct _RsnAudioMungeClass RsnAudioMungeClass;
|
||||
|
||||
struct _RsnAudioMunge
|
||||
{
|
||||
GstElement element;
|
||||
|
||||
GstPad *sinkpad, *srcpad;
|
||||
|
||||
GstSegment sink_segment;
|
||||
gboolean have_audio;
|
||||
gboolean in_still;
|
||||
};
|
||||
|
||||
struct _RsnAudioMungeClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
||||
GType rsn_audiomunge_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __RSNAUDIOMUNGE_H__ */
|
Loading…
Reference in a new issue