mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
camerabin2: Move to encodebin
This commit is contained in:
parent
31dbc2eeba
commit
f1d02cf0c0
3 changed files with 52 additions and 16 deletions
|
@ -17,7 +17,7 @@ libgstcamerabin2_la_CFLAGS = \
|
||||||
libgstcamerabin2_la_LIBADD = \
|
libgstcamerabin2_la_LIBADD = \
|
||||||
$(top_builddir)/gst-libs/gst/interfaces/libgstphotography-$(GST_MAJORMINOR).la \
|
$(top_builddir)/gst-libs/gst/interfaces/libgstphotography-$(GST_MAJORMINOR).la \
|
||||||
$(top_builddir)/gst-libs/gst/basecamerabinsrc/libgstbasecamerabinsrc-$(GST_MAJORMINOR).la \
|
$(top_builddir)/gst-libs/gst/basecamerabinsrc/libgstbasecamerabinsrc-$(GST_MAJORMINOR).la \
|
||||||
$(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) -lgsttag-$(GST_MAJORMINOR) -lgstapp-$(GST_MAJORMINOR) \
|
$(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) -lgsttag-$(GST_MAJORMINOR) -lgstapp-$(GST_MAJORMINOR) -lgstpbutils-$(GST_MAJORMINOR) \
|
||||||
$(GST_BASE_LIBS) $(GST_LIBS)
|
$(GST_BASE_LIBS) $(GST_LIBS)
|
||||||
|
|
||||||
libgstcamerabin2_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
libgstcamerabin2_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
/*
|
/*
|
||||||
* Detail Topics:
|
* Detail Topics:
|
||||||
*
|
*
|
||||||
* videorecordingbin state management (for now on videobin)
|
* videorecordingbin state management (for now on called 'videobin')
|
||||||
* - The problem: keeping videobin state in sync with camerabin will make it
|
* - The problem: keeping videobin state in sync with camerabin will make it
|
||||||
* go to playing when it might not be used, causing its internal
|
* go to playing when it might not be used, causing its internal
|
||||||
* filesink to open a file that might be left blank.
|
* filesink to open a file that might be left blank.
|
||||||
|
@ -50,6 +50,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gst/basecamerabinsrc/gstbasecamerasrc.h>
|
#include <gst/basecamerabinsrc/gstbasecamerasrc.h>
|
||||||
|
#include <gst/pbutils/encoding-profile.h>
|
||||||
#include "gstcamerabin2.h"
|
#include "gstcamerabin2.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_camera_bin_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_camera_bin_debug);
|
||||||
|
@ -188,15 +189,17 @@ gst_camera_bin_src_notify_readyforcapture (GObject * obj, GParamSpec * pspec,
|
||||||
|
|
||||||
/* a video recording is about to start, we reset the videobin to clear eos/flushing state
|
/* a video recording is about to start, we reset the videobin to clear eos/flushing state
|
||||||
* also need to clean the queue ! capsfilter before it */
|
* also need to clean the queue ! capsfilter before it */
|
||||||
gst_element_set_state (camera->videobin, GST_STATE_NULL);
|
gst_element_set_state (camera->encodebin, GST_STATE_NULL);
|
||||||
|
gst_element_set_state (camera->videosink, GST_STATE_NULL);
|
||||||
gst_element_set_state (camera->videobin_queue, GST_STATE_NULL);
|
gst_element_set_state (camera->videobin_queue, GST_STATE_NULL);
|
||||||
gst_element_set_state (camera->videobin_capsfilter, GST_STATE_NULL);
|
gst_element_set_state (camera->videobin_capsfilter, GST_STATE_NULL);
|
||||||
location =
|
location =
|
||||||
g_strdup_printf (camera->video_location, camera->video_index++);
|
g_strdup_printf (camera->video_location, camera->video_index++);
|
||||||
GST_DEBUG_OBJECT (camera, "Switching videobin location to %s", location);
|
GST_DEBUG_OBJECT (camera, "Switching videobin location to %s", location);
|
||||||
g_object_set (camera->videobin, "location", location, NULL);
|
g_object_set (camera->videosink, "location", location, NULL);
|
||||||
g_free (location);
|
g_free (location);
|
||||||
gst_element_set_state (camera->videobin, GST_STATE_PLAYING);
|
gst_element_set_state (camera->encodebin, GST_STATE_PLAYING);
|
||||||
|
gst_element_set_state (camera->videosink, GST_STATE_PLAYING);
|
||||||
gst_element_set_state (camera->videobin_capsfilter, GST_STATE_PLAYING);
|
gst_element_set_state (camera->videobin_capsfilter, GST_STATE_PLAYING);
|
||||||
gst_element_set_state (camera->videobin_queue, GST_STATE_PLAYING);
|
gst_element_set_state (camera->videobin_queue, GST_STATE_PLAYING);
|
||||||
}
|
}
|
||||||
|
@ -226,9 +229,10 @@ gst_camera_bin_dispose (GObject * object)
|
||||||
if (camerabin->viewfinderbin_capsfilter)
|
if (camerabin->viewfinderbin_capsfilter)
|
||||||
gst_object_unref (camerabin->viewfinderbin_capsfilter);
|
gst_object_unref (camerabin->viewfinderbin_capsfilter);
|
||||||
|
|
||||||
|
if (camerabin->videosink)
|
||||||
if (camerabin->videobin)
|
gst_object_unref (camerabin->videosink);
|
||||||
gst_object_unref (camerabin->videobin);
|
if (camerabin->encodebin)
|
||||||
|
gst_object_unref (camerabin->encodebin);
|
||||||
if (camerabin->videobin_queue)
|
if (camerabin->videobin_queue)
|
||||||
gst_object_unref (camerabin->videobin_queue);
|
gst_object_unref (camerabin->videobin_queue);
|
||||||
if (camerabin->videobin_capsfilter)
|
if (camerabin->videobin_capsfilter)
|
||||||
|
@ -411,9 +415,31 @@ gst_camera_bin_create_elements (GstCameraBin * camera)
|
||||||
|
|
||||||
if (!camera->elements_created) {
|
if (!camera->elements_created) {
|
||||||
|
|
||||||
camera->videobin =
|
camera->encodebin = gst_element_factory_make ("encodebin", NULL);
|
||||||
gst_element_factory_make ("videorecordingbin", "videobin");
|
camera->videosink =
|
||||||
|
gst_element_factory_make ("filesink", "videobin-filesink");
|
||||||
camera->imagebin = gst_element_factory_make ("imagecapturebin", "imagebin");
|
camera->imagebin = gst_element_factory_make ("imagecapturebin", "imagebin");
|
||||||
|
g_object_set (camera->videosink, "async", FALSE, NULL);
|
||||||
|
|
||||||
|
{
|
||||||
|
GstEncodingContainerProfile *prof;
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
|
caps = gst_caps_new_simple ("application/ogg", NULL);
|
||||||
|
prof = gst_encoding_container_profile_new ("ogg", "theora+ogg", caps,
|
||||||
|
NULL);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
|
caps = gst_caps_new_simple ("video/x-theora", NULL);
|
||||||
|
if (!gst_encoding_container_profile_add_profile (prof,
|
||||||
|
(GstEncodingProfile *) gst_encoding_video_profile_new (caps,
|
||||||
|
NULL, NULL, 1))) {
|
||||||
|
GST_WARNING_OBJECT (camera, "Failed to create encoding profiles");
|
||||||
|
}
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
g_object_set (camera->encodebin, "profile", prof, NULL);
|
||||||
|
gst_encoding_profile_unref (prof);
|
||||||
|
}
|
||||||
|
|
||||||
camera->videobin_queue =
|
camera->videobin_queue =
|
||||||
gst_element_factory_make ("queue", "videobin-queue");
|
gst_element_factory_make ("queue", "videobin-queue");
|
||||||
|
@ -423,14 +449,19 @@ gst_camera_bin_create_elements (GstCameraBin * camera)
|
||||||
gst_element_factory_make ("queue", "viewfinderbin-queue");
|
gst_element_factory_make ("queue", "viewfinderbin-queue");
|
||||||
|
|
||||||
gst_bin_add_many (GST_BIN_CAST (camera),
|
gst_bin_add_many (GST_BIN_CAST (camera),
|
||||||
gst_object_ref (camera->videobin), gst_object_ref (camera->imagebin),
|
gst_object_ref (camera->encodebin),
|
||||||
|
gst_object_ref (camera->videosink),
|
||||||
|
gst_object_ref (camera->imagebin),
|
||||||
gst_object_ref (camera->videobin_queue),
|
gst_object_ref (camera->videobin_queue),
|
||||||
gst_object_ref (camera->imagebin_queue),
|
gst_object_ref (camera->imagebin_queue),
|
||||||
gst_object_ref (camera->viewfinderbin_queue), NULL);
|
gst_object_ref (camera->viewfinderbin_queue), NULL);
|
||||||
|
|
||||||
/* Linking can be optimized TODO */
|
/* Linking can be optimized TODO */
|
||||||
gst_element_link_many (camera->videobin_queue, camera->videobin_capsfilter,
|
gst_element_link_many (camera->videobin_queue, camera->videobin_capsfilter,
|
||||||
camera->videobin, NULL);
|
NULL);
|
||||||
|
gst_element_link (camera->encodebin, camera->videosink);
|
||||||
|
gst_element_link (camera->videobin_capsfilter, camera->encodebin);
|
||||||
|
|
||||||
gst_element_link_many (camera->imagebin_queue, camera->imagebin_capsfilter,
|
gst_element_link_many (camera->imagebin_queue, camera->imagebin_capsfilter,
|
||||||
camera->imagebin, NULL);
|
camera->imagebin, NULL);
|
||||||
gst_element_link_many (camera->viewfinderbin_queue,
|
gst_element_link_many (camera->viewfinderbin_queue,
|
||||||
|
@ -444,9 +475,9 @@ gst_camera_bin_create_elements (GstCameraBin * camera)
|
||||||
* the source's ready-for-capture goes to FALSE it means it is
|
* the source's ready-for-capture goes to FALSE it means it is
|
||||||
* starting recording, so we should prepare the video bin.
|
* starting recording, so we should prepare the video bin.
|
||||||
*/
|
*/
|
||||||
gst_element_set_locked_state (camera->videobin, TRUE);
|
gst_element_set_locked_state (camera->videosink, TRUE);
|
||||||
|
|
||||||
g_object_set (camera->videobin, "location", camera->video_location, NULL);
|
g_object_set (camera->videosink, "location", camera->video_location, NULL);
|
||||||
g_object_set (camera->imagebin, "location", camera->image_location, NULL);
|
g_object_set (camera->imagebin, "location", camera->image_location, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,8 +551,11 @@ gst_camera_bin_change_state (GstElement * element, GstStateChange trans)
|
||||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, trans);
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, trans);
|
||||||
|
|
||||||
switch (trans) {
|
switch (trans) {
|
||||||
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
|
gst_element_set_state (camera->videosink, GST_STATE_READY);
|
||||||
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
gst_element_set_state (camera->videobin, GST_STATE_NULL);
|
gst_element_set_state (camera->videosink, GST_STATE_NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -41,7 +41,9 @@ struct _GstCameraBin
|
||||||
GstElement *user_src;
|
GstElement *user_src;
|
||||||
gulong src_capture_notify_id;
|
gulong src_capture_notify_id;
|
||||||
|
|
||||||
GstElement *videobin;
|
//GstElement *videobin;
|
||||||
|
GstElement *encodebin;
|
||||||
|
GstElement *videosink;
|
||||||
GstElement *videobin_queue;
|
GstElement *videobin_queue;
|
||||||
GstElement *videobin_capsfilter;
|
GstElement *videobin_capsfilter;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue