mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
gst/wavenc/gstwavenc.c: Added proper event handlind, made downstream newsegment event use GST_FORMAT_BYTES (otherwise...
Original commit message from CVS: * gst/wavenc/gstwavenc.c: (gst_wavenc_stop_file), (gst_wavenc_init), (gst_wavenc_event), (gst_wavenc_chain): Added proper event handlind, made downstream newsegment event use GST_FORMAT_BYTES (otherwise it's ignored), and don't set a duration of 0 for buffers otherwise they are discarded by GstBaseSink. GstWavEnc needs some serious loving, after going through the code I'm really wondering how this can stay in -good ...
This commit is contained in:
parent
b1b1fe52d6
commit
53840faa46
2 changed files with 48 additions and 20 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2005-11-01 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
|
* gst/wavenc/gstwavenc.c: (gst_wavenc_stop_file),
|
||||||
|
(gst_wavenc_init), (gst_wavenc_event), (gst_wavenc_chain):
|
||||||
|
Added proper event handlind,
|
||||||
|
made downstream newsegment event use GST_FORMAT_BYTES (otherwise it's
|
||||||
|
ignored),
|
||||||
|
and don't set a duration of 0 for buffers otherwise they are discarded
|
||||||
|
by GstBaseSink.
|
||||||
|
|
||||||
|
GstWavEnc needs some serious loving, after going through the code I'm
|
||||||
|
really wondering how this can stay in -good ...
|
||||||
|
|
||||||
2005-11-01 Thomas Vander Stichele <thomas at apestaart dot org>
|
2005-11-01 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* check/elements/matroskamux.c: (setup_src_pad), (setup_sink_pad),
|
* check/elements/matroskamux.c: (setup_src_pad), (setup_sink_pad),
|
||||||
|
|
|
@ -34,6 +34,7 @@ static void gst_wavenc_base_init (gpointer g_class);
|
||||||
static void gst_wavenc_class_init (GstWavEncClass * klass);
|
static void gst_wavenc_class_init (GstWavEncClass * klass);
|
||||||
static void gst_wavenc_init (GstWavEnc * wavenc);
|
static void gst_wavenc_init (GstWavEnc * wavenc);
|
||||||
static GstFlowReturn gst_wavenc_chain (GstPad * pad, GstBuffer * buf);
|
static GstFlowReturn gst_wavenc_chain (GstPad * pad, GstBuffer * buf);
|
||||||
|
static gboolean gst_wavenc_event (GstPad * pad, GstEvent * event);
|
||||||
|
|
||||||
#define WAVE_FORMAT_PCM 0x0001
|
#define WAVE_FORMAT_PCM 0x0001
|
||||||
|
|
||||||
|
@ -264,7 +265,7 @@ gst_wavenc_stop_file (GstWavEnc * wavenc)
|
||||||
GstEvent *event;
|
GstEvent *event;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
|
||||||
event = gst_event_new_newsegment (FALSE, 1.0, GST_FORMAT_TIME,
|
event = gst_event_new_newsegment (FALSE, 1.0, GST_FORMAT_BYTES,
|
||||||
0, GST_CLOCK_TIME_NONE, 0);
|
0, GST_CLOCK_TIME_NONE, 0);
|
||||||
|
|
||||||
gst_pad_push_event (wavenc->srcpad, event);
|
gst_pad_push_event (wavenc->srcpad, event);
|
||||||
|
@ -277,9 +278,9 @@ gst_wavenc_stop_file (GstWavEnc * wavenc)
|
||||||
GST_BUFFER_OFFSET (outbuf) = 0;
|
GST_BUFFER_OFFSET (outbuf) = 0;
|
||||||
GST_BUFFER_OFFSET_END (outbuf) = WAV_HEADER_LEN;
|
GST_BUFFER_OFFSET_END (outbuf) = WAV_HEADER_LEN;
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = 0;
|
GST_BUFFER_TIMESTAMP (outbuf) = 0;
|
||||||
GST_BUFFER_DURATION (outbuf) = 0;
|
|
||||||
|
|
||||||
gst_pad_push (wavenc->srcpad, outbuf);
|
if ((gst_pad_push (wavenc->srcpad, outbuf)) != GST_FLOW_OK)
|
||||||
|
GST_WARNING_OBJECT (wavenc, "couldn't push header....");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -292,6 +293,7 @@ gst_wavenc_init (GstWavEnc * wavenc)
|
||||||
"sink"), "sink");
|
"sink"), "sink");
|
||||||
gst_element_add_pad (GST_ELEMENT (wavenc), wavenc->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (wavenc), wavenc->sinkpad);
|
||||||
gst_pad_set_chain_function (wavenc->sinkpad, gst_wavenc_chain);
|
gst_pad_set_chain_function (wavenc->sinkpad, gst_wavenc_chain);
|
||||||
|
gst_pad_set_event_function (wavenc->sinkpad, gst_wavenc_event);
|
||||||
gst_pad_set_setcaps_function (wavenc->sinkpad, gst_wavenc_sink_setcaps);
|
gst_pad_set_setcaps_function (wavenc->sinkpad, gst_wavenc_sink_setcaps);
|
||||||
|
|
||||||
wavenc->srcpad =
|
wavenc->srcpad =
|
||||||
|
@ -601,16 +603,16 @@ write_labels (GstWavEnc * wavenc)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static GstFlowReturn
|
static gboolean
|
||||||
gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
|
gst_wavenc_event (GstPad * pad, GstEvent * event)
|
||||||
{
|
{
|
||||||
|
gboolean res = TRUE;
|
||||||
GstWavEnc *wavenc;
|
GstWavEnc *wavenc;
|
||||||
GstFlowReturn result = GST_FLOW_OK;
|
|
||||||
|
|
||||||
wavenc = GST_WAVENC (gst_pad_get_parent (pad));
|
wavenc = GST_WAVENC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
if (GST_IS_EVENT (buf)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
if (GST_EVENT_TYPE (buf) == GST_EVENT_EOS) {
|
case GST_EVENT_EOS:
|
||||||
wavenc->pad_eos = TRUE;
|
wavenc->pad_eos = TRUE;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -623,30 +625,41 @@ gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gst_wavenc_stop_file (wavenc);
|
gst_wavenc_stop_file (wavenc);
|
||||||
gst_pad_push (wavenc->srcpad, buf);
|
|
||||||
gst_pad_push_event (wavenc->srcpad, gst_event_new_eos ());
|
break;
|
||||||
} else if (GST_EVENT_TYPE (buf) == GST_EVENT_NEWSEGMENT) {
|
case GST_EVENT_NEWSEGMENT:
|
||||||
//if (GST_EVENT_DISCONT_NEW_MEDIA (buf)) {
|
|
||||||
if (wavenc->newmediacount++ > 0) {
|
if (wavenc->newmediacount++ > 0) {
|
||||||
gst_wavenc_stop_file (wavenc);
|
gst_wavenc_stop_file (wavenc);
|
||||||
wavenc->setup = FALSE;
|
wavenc->setup = FALSE;
|
||||||
wavenc->flush_header = TRUE;
|
wavenc->flush_header = TRUE;
|
||||||
gst_wavenc_setup (wavenc);
|
gst_wavenc_setup (wavenc);
|
||||||
}
|
}
|
||||||
gst_pad_event_default (wavenc->sinkpad, GST_EVENT (buf));
|
break;
|
||||||
//}
|
default:
|
||||||
} else {
|
break;
|
||||||
gst_pad_event_default (wavenc->sinkpad, GST_EVENT (buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* and forward it */
|
||||||
|
res = gst_pad_event_default (pad, event);
|
||||||
|
|
||||||
|
gst_object_unref (wavenc);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstFlowReturn
|
||||||
|
gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
|
||||||
|
{
|
||||||
|
GstWavEnc *wavenc;
|
||||||
|
GstFlowReturn result = GST_FLOW_OK;
|
||||||
|
|
||||||
|
wavenc = GST_WAVENC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
if (!wavenc->setup) {
|
if (!wavenc->setup) {
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
GST_ELEMENT_ERROR (wavenc, CORE, NEGOTIATION, (NULL),
|
GST_ELEMENT_ERROR (wavenc, CORE, NEGOTIATION, (NULL),
|
||||||
("encoder not initialised (input is not audio?)"));
|
("encoder not initialised (input is not audio?)"));
|
||||||
return GST_FLOW_ERROR;
|
result = GST_FLOW_ERROR;
|
||||||
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GST_PAD_IS_USABLE (wavenc->srcpad)) {
|
if (GST_PAD_IS_USABLE (wavenc->srcpad)) {
|
||||||
|
@ -665,6 +678,8 @@ gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
|
||||||
gst_pad_push (wavenc->srcpad, buf);
|
gst_pad_push (wavenc->srcpad, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beach:
|
||||||
|
gst_object_unref (wavenc);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue