update for allocation query changes

This commit is contained in:
Wim Taymans 2012-03-15 20:38:27 +01:00
parent 76460a0d7a
commit 583f5d1dc7
2 changed files with 41 additions and 36 deletions

View File

@ -313,8 +313,8 @@ gst_base_video_decoder_setcaps (GstBaseVideoDecoder * base_video_decoder,
} }
if (ret) { if (ret) {
gst_buffer_replace (&GST_BASE_VIDEO_CODEC (base_video_decoder)-> gst_buffer_replace (&GST_BASE_VIDEO_CODEC (base_video_decoder)->state.
state.codec_data, NULL); codec_data, NULL);
gst_caps_replace (&GST_BASE_VIDEO_CODEC (base_video_decoder)->state.caps, gst_caps_replace (&GST_BASE_VIDEO_CODEC (base_video_decoder)->state.caps,
NULL); NULL);
GST_BASE_VIDEO_CODEC (base_video_decoder)->state = state; GST_BASE_VIDEO_CODEC (base_video_decoder)->state = state;
@ -1990,9 +1990,9 @@ gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder * base_video_decoder)
GstVideoState *state = &codec->state; GstVideoState *state = &codec->state;
GstVideoInfo *info = &codec->info; GstVideoInfo *info = &codec->info;
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool;
GstStructure *config; GstStructure *config;
guint size, min, max, prefix, padding, alignment; guint size, min, max;
gboolean ret; gboolean ret;
/* minimum sense */ /* minimum sense */
@ -2041,39 +2041,42 @@ gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder * base_video_decoder)
/* Negotiate pool */ /* Negotiate pool */
query = gst_query_new_allocation (caps, TRUE); query = gst_query_new_allocation (caps, TRUE);
if (gst_pad_peer_query (codec->srcpad, query)) { if (!gst_pad_peer_query (codec->srcpad, query)) {
GST_DEBUG_OBJECT (codec, "got downstream ALLOCATION hints"); GST_DEBUG_OBJECT (codec, "didn't get downstream ALLOCATION hints");
}
if (gst_query_get_n_allocation_pools (query) > 0) {
/* we got configuration from our peer, parse them */ /* we got configuration from our peer, parse them */
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
&padding, &alignment, &pool);
size = MAX (size, info->size); size = MAX (size, info->size);
} else { } else {
GST_DEBUG_OBJECT (codec, "didn't get downstream ALLOCATION hints"); pool = NULL;
size = info->size; size = info->size;
min = max = 0; min = max = 0;
prefix = 0;
padding = 0;
alignment = 0;
} }
if (pool == NULL) { if (pool == NULL) {
/* we did not get a pool, make one ourselves then */ /* we did not get a pool, make one ourselves then */
pool = gst_buffer_pool_new (); pool = gst_video_buffer_pool_new ();
} }
if (base_video_decoder->pool) if (base_video_decoder->pool) {
gst_buffer_pool_set_active (base_video_decoder->pool, FALSE);
gst_object_unref (base_video_decoder->pool); gst_object_unref (base_video_decoder->pool);
}
base_video_decoder->pool = pool; base_video_decoder->pool = pool;
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding, gst_buffer_pool_config_set (config, caps, size, min, max, 0, 0, 0);
alignment);
state->bytes_per_picture = size; state->bytes_per_picture = size;
if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE)) {
/* just set the option, if the pool can support it we will transparently use /* 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 * it through the video info API. We could also see if the pool support this
* option and only activate it then. */ * option and only activate it then. */
gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
}
/* check if downstream supports cropping */ /* check if downstream supports cropping */
base_video_decoder->use_cropping = base_video_decoder->use_cropping =

View File

@ -668,8 +668,9 @@ gst_base_audio_visualizer_src_negotiate (GstBaseAudioVisualizer * scope)
GstStructure *structure; GstStructure *structure;
GstCaps *templ; GstCaps *templ;
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool;
guint size, min, max, prefix, padding, alignment; GstStructure *config;
guint size, min, max;
templ = gst_pad_get_pad_template_caps (scope->srcpad); templ = gst_pad_get_pad_template_caps (scope->srcpad);
@ -705,32 +706,33 @@ gst_base_audio_visualizer_src_negotiate (GstBaseAudioVisualizer * scope)
/* find a pool for the negotiated caps now */ /* find a pool for the negotiated caps now */
query = gst_query_new_allocation (target, TRUE); query = gst_query_new_allocation (target, TRUE);
if (gst_pad_peer_query (scope->srcpad, query)) { if (!gst_pad_peer_query (scope->srcpad, query)) {
/* not a problem, we use the query defaults */
GST_DEBUG_OBJECT (scope, "allocation query failed");
}
if (gst_query_get_n_allocation_pools (query) > 0) {
/* we got configuration from our peer, parse them */ /* we got configuration from our peer, parse them */
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
&padding, &alignment, &pool);
} else { } else {
pool = NULL;
size = scope->bpf; size = scope->bpf;
min = max = 0; min = max = 0;
prefix = 0;
padding = 0;
alignment = 0;
} }
if (pool == NULL) { if (pool == NULL) {
GstStructure *config;
/* we did not get a pool, make one ourselves then */ /* we did not get a pool, make one ourselves then */
pool = gst_buffer_pool_new (); pool = gst_buffer_pool_new ();
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, target, size, min, max, prefix,
padding, alignment);
gst_buffer_pool_set_config (pool, config);
} }
if (scope->pool) config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, target, size, min, max, 0, 0, 0);
gst_buffer_pool_set_config (pool, config);
if (scope->pool) {
gst_buffer_pool_set_active (scope->pool, FALSE);
gst_object_unref (scope->pool); gst_object_unref (scope->pool);
}
scope->pool = pool; scope->pool = pool;
/* and activate */ /* and activate */