mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
baseparse: don't expose GstAdapter in public header
None of the existing subclasses needs access to that, so there's no reason to expose it for now. https://bugzilla.gnome.org/show_bug.cgi?id=518857
This commit is contained in:
parent
e2bf3647f8
commit
f691be223e
2 changed files with 28 additions and 26 deletions
|
@ -195,6 +195,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <gst/base/gstadapter.h>
|
||||||
|
|
||||||
#include "gstbaseparse.h"
|
#include "gstbaseparse.h"
|
||||||
|
|
||||||
#define MIN_FRAMES_TO_POST_BITRATE 10
|
#define MIN_FRAMES_TO_POST_BITRATE 10
|
||||||
|
@ -218,6 +220,8 @@ struct _GstBaseParsePrivate
|
||||||
{
|
{
|
||||||
GstActivateMode pad_mode;
|
GstActivateMode pad_mode;
|
||||||
|
|
||||||
|
GstAdapter *adapter;
|
||||||
|
|
||||||
gint64 duration;
|
gint64 duration;
|
||||||
GstFormat duration_fmt;
|
GstFormat duration_fmt;
|
||||||
gint64 estimated_duration;
|
gint64 estimated_duration;
|
||||||
|
@ -414,7 +418,7 @@ gst_base_parse_finalize (GObject * object)
|
||||||
GstBaseParse *parse = GST_BASE_PARSE (object);
|
GstBaseParse *parse = GST_BASE_PARSE (object);
|
||||||
GstEvent **p_ev;
|
GstEvent **p_ev;
|
||||||
|
|
||||||
g_object_unref (parse->adapter);
|
g_object_unref (parse->priv->adapter);
|
||||||
|
|
||||||
if (parse->priv->pending_segment) {
|
if (parse->priv->pending_segment) {
|
||||||
p_ev = &parse->priv->pending_segment;
|
p_ev = &parse->priv->pending_segment;
|
||||||
|
@ -515,7 +519,7 @@ gst_base_parse_init (GstBaseParse * parse, GstBaseParseClass * bclass)
|
||||||
gst_element_add_pad (GST_ELEMENT (parse), parse->srcpad);
|
gst_element_add_pad (GST_ELEMENT (parse), parse->srcpad);
|
||||||
GST_DEBUG_OBJECT (parse, "src created");
|
GST_DEBUG_OBJECT (parse, "src created");
|
||||||
|
|
||||||
parse->adapter = gst_adapter_new ();
|
parse->priv->adapter = gst_adapter_new ();
|
||||||
|
|
||||||
parse->priv->pad_mode = GST_ACTIVATE_NONE;
|
parse->priv->pad_mode = GST_ACTIVATE_NONE;
|
||||||
|
|
||||||
|
@ -914,7 +918,7 @@ gst_base_parse_sink_eventfunc (GstBaseParse * parse, GstEvent * event)
|
||||||
gst_base_parse_drain (parse);
|
gst_base_parse_drain (parse);
|
||||||
else
|
else
|
||||||
gst_base_parse_process_fragment (parse, FALSE);
|
gst_base_parse_process_fragment (parse, FALSE);
|
||||||
gst_adapter_clear (parse->adapter);
|
gst_adapter_clear (parse->priv->adapter);
|
||||||
parse->priv->offset = offset;
|
parse->priv->offset = offset;
|
||||||
parse->priv->sync_offset = offset;
|
parse->priv->sync_offset = offset;
|
||||||
parse->priv->next_ts = next_ts;
|
parse->priv->next_ts = next_ts;
|
||||||
|
@ -936,7 +940,7 @@ gst_base_parse_sink_eventfunc (GstBaseParse * parse, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GST_EVENT_FLUSH_STOP:
|
case GST_EVENT_FLUSH_STOP:
|
||||||
gst_adapter_clear (parse->adapter);
|
gst_adapter_clear (parse->priv->adapter);
|
||||||
gst_base_parse_clear_queues (parse);
|
gst_base_parse_clear_queues (parse);
|
||||||
parse->priv->flushing = FALSE;
|
parse->priv->flushing = FALSE;
|
||||||
parse->priv->discont = TRUE;
|
parse->priv->discont = TRUE;
|
||||||
|
@ -1821,7 +1825,7 @@ gst_base_parse_drain (GstBaseParse * parse)
|
||||||
parse->priv->drain = TRUE;
|
parse->priv->drain = TRUE;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
avail = gst_adapter_available (parse->adapter);
|
avail = gst_adapter_available (parse->priv->adapter);
|
||||||
if (!avail)
|
if (!avail)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1830,9 +1834,9 @@ gst_base_parse_drain (GstBaseParse * parse)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nothing changed, maybe due to truncated frame; break infinite loop */
|
/* nothing changed, maybe due to truncated frame; break infinite loop */
|
||||||
if (avail == gst_adapter_available (parse->adapter)) {
|
if (avail == gst_adapter_available (parse->priv->adapter)) {
|
||||||
GST_DEBUG_OBJECT (parse, "no change during draining; flushing");
|
GST_DEBUG_OBJECT (parse, "no change during draining; flushing");
|
||||||
gst_adapter_clear (parse->adapter);
|
gst_adapter_clear (parse->priv->adapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1909,7 +1913,7 @@ gst_base_parse_process_fragment (GstBaseParse * parse, gboolean push_only)
|
||||||
buf = GST_BUFFER_CAST (parse->priv->buffers_pending->data);
|
buf = GST_BUFFER_CAST (parse->priv->buffers_pending->data);
|
||||||
GST_LOG_OBJECT (parse, "adding pending buffer (size %d)",
|
GST_LOG_OBJECT (parse, "adding pending buffer (size %d)",
|
||||||
GST_BUFFER_SIZE (buf));
|
GST_BUFFER_SIZE (buf));
|
||||||
gst_adapter_push (parse->adapter, buf);
|
gst_adapter_push (parse->priv->adapter, buf);
|
||||||
parse->priv->buffers_pending =
|
parse->priv->buffers_pending =
|
||||||
g_slist_delete_link (parse->priv->buffers_pending,
|
g_slist_delete_link (parse->priv->buffers_pending,
|
||||||
parse->priv->buffers_pending);
|
parse->priv->buffers_pending);
|
||||||
|
@ -1992,10 +1996,10 @@ push:
|
||||||
ret = gst_base_parse_send_buffers (parse);
|
ret = gst_base_parse_send_buffers (parse);
|
||||||
|
|
||||||
/* any trailing unused no longer usable (ideally none) */
|
/* any trailing unused no longer usable (ideally none) */
|
||||||
if (G_UNLIKELY (gst_adapter_available (parse->adapter))) {
|
if (G_UNLIKELY (gst_adapter_available (parse->priv->adapter))) {
|
||||||
GST_DEBUG_OBJECT (parse, "discarding %d trailing bytes",
|
GST_DEBUG_OBJECT (parse, "discarding %d trailing bytes",
|
||||||
gst_adapter_available (parse->adapter));
|
gst_adapter_available (parse->priv->adapter));
|
||||||
gst_adapter_clear (parse->adapter);
|
gst_adapter_clear (parse->priv->adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2057,10 +2061,10 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GST_DEBUG_OBJECT (parse, "buffer starts new reverse playback fragment");
|
GST_DEBUG_OBJECT (parse, "buffer starts new reverse playback fragment");
|
||||||
ret = gst_base_parse_process_fragment (parse, FALSE);
|
ret = gst_base_parse_process_fragment (parse, FALSE);
|
||||||
}
|
}
|
||||||
gst_adapter_push (parse->adapter, buffer);
|
gst_adapter_push (parse->priv->adapter, buffer);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
gst_adapter_push (parse->adapter, buffer);
|
gst_adapter_push (parse->priv->adapter, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse and push as many frames as possible */
|
/* Parse and push as many frames as possible */
|
||||||
|
@ -2074,7 +2078,7 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
/* Synchronization loop */
|
/* Synchronization loop */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
min_size = MAX (parse->priv->min_frame_size, fsize);
|
min_size = MAX (parse->priv->min_frame_size, fsize);
|
||||||
av = gst_adapter_available (parse->adapter);
|
av = gst_adapter_available (parse->priv->adapter);
|
||||||
|
|
||||||
/* loop safety check */
|
/* loop safety check */
|
||||||
if (G_UNLIKELY (old_min_size >= min_size))
|
if (G_UNLIKELY (old_min_size >= min_size))
|
||||||
|
@ -2099,7 +2103,7 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* always pass all available data */
|
/* always pass all available data */
|
||||||
data = gst_adapter_peek (parse->adapter, av);
|
data = gst_adapter_peek (parse->priv->adapter, av);
|
||||||
GST_BUFFER_DATA (tmpbuf) = (guint8 *) data;
|
GST_BUFFER_DATA (tmpbuf) = (guint8 *) data;
|
||||||
GST_BUFFER_SIZE (tmpbuf) = min_size;
|
GST_BUFFER_SIZE (tmpbuf) = min_size;
|
||||||
GST_BUFFER_OFFSET (tmpbuf) = parse->priv->offset;
|
GST_BUFFER_OFFSET (tmpbuf) = parse->priv->offset;
|
||||||
|
@ -2115,10 +2119,10 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
res = bclass->check_valid_frame (parse, frame, &fsize, &skip);
|
res = bclass->check_valid_frame (parse, frame, &fsize, &skip);
|
||||||
gst_buffer_replace (&frame->buffer, NULL);
|
gst_buffer_replace (&frame->buffer, NULL);
|
||||||
if (res) {
|
if (res) {
|
||||||
if (gst_adapter_available (parse->adapter) < fsize) {
|
if (gst_adapter_available (parse->priv->adapter) < fsize) {
|
||||||
GST_DEBUG_OBJECT (parse,
|
GST_DEBUG_OBJECT (parse,
|
||||||
"found valid frame but not enough data available (only %d bytes)",
|
"found valid frame but not enough data available (only %d bytes)",
|
||||||
gst_adapter_available (parse->adapter));
|
gst_adapter_available (parse->priv->adapter));
|
||||||
gst_buffer_unref (tmpbuf);
|
gst_buffer_unref (tmpbuf);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -2135,15 +2139,15 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
/* reverse playback, and no frames found yet, so we are skipping
|
/* reverse playback, and no frames found yet, so we are skipping
|
||||||
* the leading part of a fragment, which may form the tail of
|
* the leading part of a fragment, which may form the tail of
|
||||||
* fragment coming later, hopefully subclass skips efficiently ... */
|
* fragment coming later, hopefully subclass skips efficiently ... */
|
||||||
timestamp = gst_adapter_prev_timestamp (parse->adapter, NULL);
|
timestamp = gst_adapter_prev_timestamp (parse->priv->adapter, NULL);
|
||||||
outbuf = gst_adapter_take_buffer (parse->adapter, skip);
|
outbuf = gst_adapter_take_buffer (parse->priv->adapter, skip);
|
||||||
outbuf = gst_buffer_make_metadata_writable (outbuf);
|
outbuf = gst_buffer_make_metadata_writable (outbuf);
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
||||||
parse->priv->buffers_pending =
|
parse->priv->buffers_pending =
|
||||||
g_slist_prepend (parse->priv->buffers_pending, outbuf);
|
g_slist_prepend (parse->priv->buffers_pending, outbuf);
|
||||||
outbuf = NULL;
|
outbuf = NULL;
|
||||||
} else {
|
} else {
|
||||||
gst_adapter_flush (parse->adapter, skip);
|
gst_adapter_flush (parse->priv->adapter, skip);
|
||||||
}
|
}
|
||||||
parse->priv->offset += skip;
|
parse->priv->offset += skip;
|
||||||
if (!parse->priv->discont)
|
if (!parse->priv->discont)
|
||||||
|
@ -2165,7 +2169,7 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
if (skip > 0) {
|
if (skip > 0) {
|
||||||
/* Subclass found the sync, but still wants to skip some data */
|
/* Subclass found the sync, but still wants to skip some data */
|
||||||
GST_LOG_OBJECT (parse, "skipping %d bytes", skip);
|
GST_LOG_OBJECT (parse, "skipping %d bytes", skip);
|
||||||
gst_adapter_flush (parse->adapter, skip);
|
gst_adapter_flush (parse->priv->adapter, skip);
|
||||||
parse->priv->offset += skip;
|
parse->priv->offset += skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2181,14 +2185,14 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
|
|
||||||
/* move along with upstream timestamp (if any),
|
/* move along with upstream timestamp (if any),
|
||||||
* but interpolate in between */
|
* but interpolate in between */
|
||||||
timestamp = gst_adapter_prev_timestamp (parse->adapter, NULL);
|
timestamp = gst_adapter_prev_timestamp (parse->priv->adapter, NULL);
|
||||||
if (GST_CLOCK_TIME_IS_VALID (timestamp) &&
|
if (GST_CLOCK_TIME_IS_VALID (timestamp) &&
|
||||||
(parse->priv->prev_ts != timestamp)) {
|
(parse->priv->prev_ts != timestamp)) {
|
||||||
parse->priv->prev_ts = parse->priv->next_ts = timestamp;
|
parse->priv->prev_ts = parse->priv->next_ts = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Would it be more efficient to make a subbuffer instead? */
|
/* FIXME: Would it be more efficient to make a subbuffer instead? */
|
||||||
outbuf = gst_adapter_take_buffer (parse->adapter, fsize);
|
outbuf = gst_adapter_take_buffer (parse->priv->adapter, fsize);
|
||||||
outbuf = gst_buffer_make_metadata_writable (outbuf);
|
outbuf = gst_buffer_make_metadata_writable (outbuf);
|
||||||
|
|
||||||
/* Subclass may want to know the data offset */
|
/* Subclass may want to know the data offset */
|
||||||
|
@ -2345,7 +2349,7 @@ gst_base_parse_handle_previous_fragment (GstBaseParse * parse)
|
||||||
/* offset will increase again as fragment is processed/parsed */
|
/* offset will increase again as fragment is processed/parsed */
|
||||||
parse->priv->last_offset = offset;
|
parse->priv->last_offset = offset;
|
||||||
|
|
||||||
gst_adapter_push (parse->adapter, buffer);
|
gst_adapter_push (parse->priv->adapter, buffer);
|
||||||
ret = gst_base_parse_process_fragment (parse, FALSE);
|
ret = gst_base_parse_process_fragment (parse, FALSE);
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#define __GST_BASE_PARSE_H__
|
#define __GST_BASE_PARSE_H__
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstadapter.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -190,7 +189,6 @@ typedef struct _GstBaseParsePrivate GstBaseParsePrivate;
|
||||||
*/
|
*/
|
||||||
struct _GstBaseParse {
|
struct _GstBaseParse {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
GstAdapter *adapter;
|
|
||||||
|
|
||||||
/*< protected >*/
|
/*< protected >*/
|
||||||
/* source and sink pads */
|
/* source and sink pads */
|
||||||
|
|
Loading…
Reference in a new issue