mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
camerabin: update preview buffer pushing
need to pass a GstSample to the utilitary preview buffer post functions as a GstBuffer doesn't have caps anymore. The GstSample has the GstCaps and it is used to inform the preview's pipeline about the format of the input, before it gets converted to the user's requested output format.
This commit is contained in:
parent
8b36de8b41
commit
0a831613a8
5 changed files with 24 additions and 11 deletions
|
@ -556,10 +556,10 @@ gst_base_camera_src_init (GstBaseCameraSrc * self)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_base_camera_src_post_preview (GstBaseCameraSrc * self, GstBuffer * buf)
|
gst_base_camera_src_post_preview (GstBaseCameraSrc * self, GstSample * sample)
|
||||||
{
|
{
|
||||||
if (self->post_preview) {
|
if (self->post_preview) {
|
||||||
gst_camerabin_preview_pipeline_post (self->preview_pipeline, buf);
|
gst_camerabin_preview_pipeline_post (self->preview_pipeline, sample);
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (self, "Previews not enabled, not posting");
|
GST_DEBUG_OBJECT (self, "Previews not enabled, not posting");
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ void gst_base_camera_src_setup_preview (GstBaseCameraSrc * self, GstCaps * previ
|
||||||
void gst_base_camera_src_finish_capture (GstBaseCameraSrc *self);
|
void gst_base_camera_src_finish_capture (GstBaseCameraSrc *self);
|
||||||
|
|
||||||
|
|
||||||
void gst_base_camera_src_post_preview (GstBaseCameraSrc *self, GstBuffer * buf);
|
void gst_base_camera_src_post_preview (GstBaseCameraSrc *self, GstSample * sample);
|
||||||
// XXX add methods to get/set img capture and vid capture caps..
|
// XXX add methods to get/set img capture and vid capture caps..
|
||||||
|
|
||||||
#endif /* __GST_BASE_CAMERA_SRC_H__ */
|
#endif /* __GST_BASE_CAMERA_SRC_H__ */
|
||||||
|
|
|
@ -249,20 +249,20 @@ gst_camerabin_destroy_preview_pipeline (GstCameraBinPreviewPipelineData *
|
||||||
/**
|
/**
|
||||||
* gst_camerabin_preview_pipeline_post:
|
* gst_camerabin_preview_pipeline_post:
|
||||||
* @preview: the #GstCameraBinPreviewPipelineData
|
* @preview: the #GstCameraBinPreviewPipelineData
|
||||||
* @buffer: the buffer to be posted as a preview
|
* @sample: the sample to be posted as a preview
|
||||||
*
|
*
|
||||||
* Converts the @buffer to the desired format and posts the preview
|
* Converts the @sample to the desired format and posts the preview
|
||||||
* message to the bus.
|
* message to the bus.
|
||||||
*
|
*
|
||||||
* Returns: %TRUE on success
|
* Returns: %TRUE on success
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_camerabin_preview_pipeline_post (GstCameraBinPreviewPipelineData * preview,
|
gst_camerabin_preview_pipeline_post (GstCameraBinPreviewPipelineData * preview,
|
||||||
GstBuffer * buffer)
|
GstSample * sample)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (preview != NULL, FALSE);
|
g_return_val_if_fail (preview != NULL, FALSE);
|
||||||
g_return_val_if_fail (preview->pipeline != NULL, FALSE);
|
g_return_val_if_fail (preview->pipeline != NULL, FALSE);
|
||||||
g_return_val_if_fail (buffer, FALSE);
|
g_return_val_if_fail (sample, FALSE);
|
||||||
|
|
||||||
g_mutex_lock (&preview->processing_lock);
|
g_mutex_lock (&preview->processing_lock);
|
||||||
g_return_val_if_fail (preview->pipeline != NULL, FALSE);
|
g_return_val_if_fail (preview->pipeline != NULL, FALSE);
|
||||||
|
@ -277,8 +277,9 @@ gst_camerabin_preview_pipeline_post (GstCameraBinPreviewPipelineData * preview,
|
||||||
|
|
||||||
preview->processing++;
|
preview->processing++;
|
||||||
|
|
||||||
|
g_object_set (preview->appsrc, "caps", gst_sample_get_caps (sample), NULL);
|
||||||
gst_app_src_push_buffer ((GstAppSrc *) preview->appsrc,
|
gst_app_src_push_buffer ((GstAppSrc *) preview->appsrc,
|
||||||
gst_buffer_ref (buffer));
|
gst_buffer_ref (gst_sample_get_buffer (sample)));
|
||||||
|
|
||||||
g_mutex_unlock (&preview->processing_lock);
|
g_mutex_unlock (&preview->processing_lock);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ typedef struct
|
||||||
|
|
||||||
GstCameraBinPreviewPipelineData *gst_camerabin_create_preview_pipeline (GstElement * element, GstElement * filter);
|
GstCameraBinPreviewPipelineData *gst_camerabin_create_preview_pipeline (GstElement * element, GstElement * filter);
|
||||||
void gst_camerabin_destroy_preview_pipeline (GstCameraBinPreviewPipelineData * preview);
|
void gst_camerabin_destroy_preview_pipeline (GstCameraBinPreviewPipelineData * preview);
|
||||||
gboolean gst_camerabin_preview_pipeline_post (GstCameraBinPreviewPipelineData * preview, GstBuffer * buffer);
|
gboolean gst_camerabin_preview_pipeline_post (GstCameraBinPreviewPipelineData * preview, GstSample * sample);
|
||||||
void gst_camerabin_preview_set_caps (GstCameraBinPreviewPipelineData * preview, GstCaps * caps);
|
void gst_camerabin_preview_set_caps (GstCameraBinPreviewPipelineData * preview, GstCaps * caps);
|
||||||
gboolean gst_camerabin_preview_set_filter (GstCameraBinPreviewPipelineData * preview, GstElement * filter);
|
gboolean gst_camerabin_preview_set_filter (GstCameraBinPreviewPipelineData * preview, GstElement * filter);
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,8 @@ gst_wrapper_camera_bin_src_imgsrc_probe (GstPad * pad, GstPadProbeInfo * info,
|
||||||
|
|
||||||
g_mutex_lock (&camerasrc->capturing_mutex);
|
g_mutex_lock (&camerasrc->capturing_mutex);
|
||||||
if (self->image_capture_count > 0) {
|
if (self->image_capture_count > 0) {
|
||||||
|
GstSample *sample;
|
||||||
|
GstCaps *caps;
|
||||||
ret = GST_PAD_PROBE_OK;
|
ret = GST_PAD_PROBE_OK;
|
||||||
self->image_capture_count--;
|
self->image_capture_count--;
|
||||||
|
|
||||||
|
@ -212,7 +214,11 @@ gst_wrapper_camera_bin_src_imgsrc_probe (GstPad * pad, GstPadProbeInfo * info,
|
||||||
/* TODO This can likely be optimized if the viewfinder caps is the same as
|
/* TODO This can likely be optimized if the viewfinder caps is the same as
|
||||||
* the preview caps, avoiding another scaling of the same buffer. */
|
* the preview caps, avoiding another scaling of the same buffer. */
|
||||||
GST_DEBUG_OBJECT (self, "Posting preview for image");
|
GST_DEBUG_OBJECT (self, "Posting preview for image");
|
||||||
gst_base_camera_src_post_preview (camerasrc, buffer);
|
caps = gst_pad_get_current_caps (pad);
|
||||||
|
sample = gst_sample_new (buffer, caps, NULL, NULL);
|
||||||
|
gst_base_camera_src_post_preview (camerasrc, sample);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
gst_sample_unref (sample);
|
||||||
|
|
||||||
if (self->image_capture_count == 0) {
|
if (self->image_capture_count == 0) {
|
||||||
gst_base_camera_src_finish_capture (camerasrc);
|
gst_base_camera_src_finish_capture (camerasrc);
|
||||||
|
@ -251,6 +257,8 @@ gst_wrapper_camera_bin_src_vidsrc_probe (GstPad * pad, GstPadProbeInfo * info,
|
||||||
} else if (self->video_rec_status == GST_VIDEO_RECORDING_STATUS_STARTING) {
|
} else if (self->video_rec_status == GST_VIDEO_RECORDING_STATUS_STARTING) {
|
||||||
GstClockTime ts;
|
GstClockTime ts;
|
||||||
GstSegment segment;
|
GstSegment segment;
|
||||||
|
GstCaps *caps;
|
||||||
|
GstSample *sample;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Starting video recording");
|
GST_DEBUG_OBJECT (self, "Starting video recording");
|
||||||
self->video_rec_status = GST_VIDEO_RECORDING_STATUS_RUNNING;
|
self->video_rec_status = GST_VIDEO_RECORDING_STATUS_RUNNING;
|
||||||
|
@ -264,7 +272,11 @@ gst_wrapper_camera_bin_src_vidsrc_probe (GstPad * pad, GstPadProbeInfo * info,
|
||||||
|
|
||||||
/* post preview */
|
/* post preview */
|
||||||
GST_DEBUG_OBJECT (self, "Posting preview for video");
|
GST_DEBUG_OBJECT (self, "Posting preview for video");
|
||||||
gst_base_camera_src_post_preview (camerasrc, buffer);
|
caps = gst_pad_get_current_caps (pad);
|
||||||
|
sample = gst_sample_new (buffer, caps, NULL, NULL);
|
||||||
|
gst_base_camera_src_post_preview (camerasrc, sample);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
gst_sample_unref (sample);
|
||||||
|
|
||||||
ret = GST_PAD_PROBE_OK;
|
ret = GST_PAD_PROBE_OK;
|
||||||
} else if (self->video_rec_status == GST_VIDEO_RECORDING_STATUS_FINISHING) {
|
} else if (self->video_rec_status == GST_VIDEO_RECORDING_STATUS_FINISHING) {
|
||||||
|
|
Loading…
Reference in a new issue