*
* 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.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
/**
* <refsect2>
* <title>Example launch line</title>
* |[
- * gst-launch filesrc location=test.dv ! dvdemux name=demux ! dvdec ! xvimagesink
+ * gst-launch-1.0 filesrc location=test.dv ! dvdemux name=demux ! dvdec ! xvimagesink
* ]| This pipeline decodes and renders the raw DV stream to a videosink.
* </refsect2>
*
#include <string.h>
#include <math.h>
#include <gst/video/video.h>
+#include <gst/video/gstvideometa.h>
#include <gst/video/gstvideopool.h>
#include "gstdvdec.h"
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_temp));
- gst_element_class_set_details_simple (gstelement_class, "DV video decoder",
+ gst_element_class_set_static_metadata (gstelement_class, "DV video decoder",
"Codec/Decoder/Video",
"Uses libdv to decode DV video (smpte314) (libdv.sourceforge.net)",
"Erik Walthinsen <omega@cse.ogi.edu>," "Wim Taymans <wim@fluendo.com>");
gst_dvdec_negotiate_pool (GstDVDec * dec, GstCaps * caps, GstVideoInfo * info)
{
GstQuery *query;
- GstBufferPool *pool = NULL;
- guint size, min, max, prefix, alignment;
+ GstBufferPool *pool;
+ guint size, min, max;
GstStructure *config;
/* find a pool for the negotiated caps now */
query = gst_query_new_allocation (caps, TRUE);
- if (gst_pad_peer_query (dec->srcpad, query)) {
- GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints");
+ if (!gst_pad_peer_query (dec->srcpad, query)) {
+ GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints");
+ }
+
+ if (gst_query_get_n_allocation_pools (query) > 0) {
/* we got configuration from our peer, parse them */
- gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
- &alignment, &pool);
+ gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
size = MAX (size, info->size);
} else {
- GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints");
+ pool = NULL;
size = info->size;
min = max = 0;
- prefix = 0;
- alignment = 0;
}
if (pool == NULL) {
/* we did not get a pool, make one ourselves then */
- pool = gst_buffer_pool_new ();
+ pool = gst_video_buffer_pool_new ();
}
- if (dec->pool)
+ if (dec->pool) {
+ gst_buffer_pool_set_active (dec->pool, FALSE);
gst_object_unref (dec->pool);
+ }
dec->pool = pool;
config = gst_buffer_pool_get_config (pool);
- gst_buffer_pool_config_set (config, caps, size, min, max, prefix, alignment);
- /* just set the option, if the pool can support it we will transparently use
- * it through the video info API. We could also see if the pool support this
- * option and only activate it then. */
- gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
-
+ gst_buffer_pool_config_set_params (config, caps, size, min, max);
+
+ if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
+ /* just set the option, if the pool can support it we will transparently use
+ * it through the video info API. We could also see if the pool support this
+ * option and only activate it then. */
+ gst_buffer_pool_config_add_option (config,
+ GST_BUFFER_POOL_OPTION_VIDEO_META);
+ }
gst_buffer_pool_set_config (pool, config);
+
/* and activate */
gst_buffer_pool_set_active (pool, TRUE);
dvdec->vinfo.par_d = dvdec->par_y;
if (dvdec->interlaced) {
dvdec->vinfo.interlace_mode = GST_VIDEO_INTERLACE_MODE_INTERLEAVED;
- dvdec->vinfo.flags |= GST_VIDEO_FLAG_INTERLACED;
} else {
dvdec->vinfo.interlace_mode = GST_VIDEO_INTERLACE_MODE_PROGRESSIVE;
- dvdec->vinfo.flags &= GST_VIDEO_FLAG_INTERLACED;
}
othercaps = gst_video_info_to_caps (&dvdec->vinfo);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP:
gst_segment_init (&dvdec->segment, GST_FORMAT_UNDEFINED);
+ dvdec->need_segment = FALSE;
break;
case GST_EVENT_SEGMENT:{
const GstSegment *segment;
gst_event_parse_segment (event, &segment);
- GST_DEBUG_OBJECT (dvdec, "Got NEWSEGMENT %" GST_SEGMENT_FORMAT, &segment);
+ GST_DEBUG_OBJECT (dvdec, "Got SEGMENT %" GST_SEGMENT_FORMAT, &segment);
gst_segment_copy_into (segment, &dvdec->segment);
+ if (!gst_pad_has_current_caps (dvdec->srcpad)) {
+ dvdec->need_segment = TRUE;
+ gst_event_unref (event);
+ event = NULL;
+ res = TRUE;
+ } else {
+ dvdec->need_segment = FALSE;
+ }
break;
}
case GST_EVENT_CAPS:
GstCaps *caps;
gst_event_parse_caps (event, &caps);
- gst_dvdec_sink_setcaps (dvdec, caps);
+ res = gst_dvdec_sink_setcaps (dvdec, caps);
gst_event_unref (event);
event = NULL;
- res = TRUE;
break;
}
gst_caps_unref (caps);
}
+ if (dvdec->need_segment) {
+ gst_pad_push_event (dvdec->srcpad, gst_event_new_segment (&dvdec->segment));
+ dvdec->need_segment = FALSE;
+ }
+
ret = gst_buffer_pool_acquire_buffer (dvdec->pool, &outbuf, NULL);
if (G_UNLIKELY (ret != GST_FLOW_OK))
goto no_buffer;
gst_segment_init (&dvdec->segment, GST_FORMAT_UNDEFINED);
dvdec->src_negotiated = FALSE;
dvdec->sink_negotiated = FALSE;
+ dvdec->need_segment = FALSE;
/*
* Enable this function call when libdv2 0.100 or higher is more
* common