videoencoder: Add negotiate vfunc that is used to negotiate with downstream
The default implementation negotiates a buffer pool and allocator with downstream.
This commit is contained in:
parent
7cb22ef241
commit
e37bb460bd
@ -231,6 +231,7 @@ static gboolean gst_video_encoder_decide_allocation_default (GstVideoEncoder *
|
|||||||
encoder, GstQuery * query);
|
encoder, GstQuery * query);
|
||||||
static gboolean gst_video_encoder_propose_allocation_default (GstVideoEncoder *
|
static gboolean gst_video_encoder_propose_allocation_default (GstVideoEncoder *
|
||||||
encoder, GstQuery * query);
|
encoder, GstQuery * query);
|
||||||
|
static gboolean gst_video_encoder_negotiate_default (GstVideoEncoder * encoder);
|
||||||
|
|
||||||
/* we can't use G_DEFINE_ABSTRACT_TYPE because we need the klass in the _init
|
/* we can't use G_DEFINE_ABSTRACT_TYPE because we need the klass in the _init
|
||||||
* method to get to the padtemplates */
|
* method to get to the padtemplates */
|
||||||
@ -292,6 +293,7 @@ gst_video_encoder_class_init (GstVideoEncoderClass * klass)
|
|||||||
klass->src_event = gst_video_encoder_src_event_default;
|
klass->src_event = gst_video_encoder_src_event_default;
|
||||||
klass->propose_allocation = gst_video_encoder_propose_allocation_default;
|
klass->propose_allocation = gst_video_encoder_propose_allocation_default;
|
||||||
klass->decide_allocation = gst_video_encoder_decide_allocation_default;
|
klass->decide_allocation = gst_video_encoder_decide_allocation_default;
|
||||||
|
klass->negotiate = gst_video_encoder_negotiate_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1391,16 +1393,8 @@ close_failed:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static gboolean
|
||||||
* gst_video_encoder_negotiate:
|
gst_video_encoder_negotiate_default (GstVideoEncoder * encoder)
|
||||||
* @encoder: a #GstVideoEncoder
|
|
||||||
*
|
|
||||||
* Negotiate with downstream elements to currently configured #GstVideoCodecState.
|
|
||||||
*
|
|
||||||
* Returns: #TRUE if the negotiation succeeded, else #FALSE.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
gst_video_encoder_negotiate (GstVideoEncoder * encoder)
|
|
||||||
{
|
{
|
||||||
GstVideoEncoderClass *klass = GST_VIDEO_ENCODER_GET_CLASS (encoder);
|
GstVideoEncoderClass *klass = GST_VIDEO_ENCODER_GET_CLASS (encoder);
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
@ -1481,6 +1475,32 @@ no_decide_allocation:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_video_encoder_negotiate:
|
||||||
|
* @encoder: a #GstVideoEncoder
|
||||||
|
*
|
||||||
|
* Negotiate with downstream elements to currently configured #GstVideoCodecState.
|
||||||
|
*
|
||||||
|
* Returns: #TRUE if the negotiation succeeded, else #FALSE.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_video_encoder_negotiate (GstVideoEncoder * encoder)
|
||||||
|
{
|
||||||
|
GstVideoEncoderClass *klass;
|
||||||
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_VIDEO_ENCODER (encoder), FALSE);
|
||||||
|
|
||||||
|
klass = GST_VIDEO_ENCODER_GET_CLASS (encoder);
|
||||||
|
|
||||||
|
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
|
||||||
|
if (klass->negotiate)
|
||||||
|
ret = klass->negotiate (encoder);
|
||||||
|
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_video_encoder_allocate_output_buffer:
|
* gst_video_encoder_allocate_output_buffer:
|
||||||
* @encoder: a #GstVideoEncoder
|
* @encoder: a #GstVideoEncoder
|
||||||
|
@ -191,6 +191,8 @@ struct _GstVideoEncoder
|
|||||||
* Event handler on the source pad. This function should return
|
* Event handler on the source pad. This function should return
|
||||||
* TRUE if the event was handled and should be discarded
|
* TRUE if the event was handled and should be discarded
|
||||||
* (i.e. not unref'ed).
|
* (i.e. not unref'ed).
|
||||||
|
* @negotiate: Optional.
|
||||||
|
* Negotiate with downstream and configure buffer pools, etc.
|
||||||
* @decide_allocation: Optional.
|
* @decide_allocation: Optional.
|
||||||
* Setup the allocation parameters for allocating output
|
* Setup the allocation parameters for allocating output
|
||||||
* buffers. The passed in query contains the result of the
|
* buffers. The passed in query contains the result of the
|
||||||
@ -240,6 +242,8 @@ struct _GstVideoEncoderClass
|
|||||||
gboolean (*src_event) (GstVideoEncoder *encoder,
|
gboolean (*src_event) (GstVideoEncoder *encoder,
|
||||||
GstEvent *event);
|
GstEvent *event);
|
||||||
|
|
||||||
|
gboolean (*negotiate) (GstVideoEncoder *encoder);
|
||||||
|
|
||||||
gboolean (*decide_allocation) (GstVideoEncoder *encoder, GstQuery *query);
|
gboolean (*decide_allocation) (GstVideoEncoder *encoder, GstQuery *query);
|
||||||
|
|
||||||
gboolean (*propose_allocation) (GstVideoEncoder * encoder,
|
gboolean (*propose_allocation) (GstVideoEncoder * encoder,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user