[longomatch/livecapturemerged] WIP
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/livecapturemerged] WIP
- Date: Fri, 21 May 2010 23:18:03 +0000 (UTC)
commit e6f1e7c0f2c41a5fe24b3c577b3262bd1644e444
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sat May 15 19:54:34 2010 +0200
WIP
libcesarplayer/src/gst-camera-capturer.c | 112 ++++++++++++++++++++++-------
libcesarplayer/src/gst-camera-capturer.h | 9 +++
2 files changed, 94 insertions(+), 27 deletions(-)
---
diff --git a/libcesarplayer/src/gst-camera-capturer.c b/libcesarplayer/src/gst-camera-capturer.c
index 3b83b84..1905288 100644
--- a/libcesarplayer/src/gst-camera-capturer.c
+++ b/libcesarplayer/src/gst-camera-capturer.c
@@ -96,6 +96,7 @@ struct GstCameraCapturerPrivate
gint video_fps_d;
gboolean media_has_video;
gboolean media_has_audio;
+ GccSourceType source_type;
/* Snapshots */
GstBuffer *last_buffer;
@@ -104,6 +105,7 @@ struct GstCameraCapturerPrivate
GstElement *main_pipeline;
GstElement *camerabin;
GstElement *videosrc;
+ GstElement *videofilter;
GstElement *audiosrc;
GstElement *videoenc;
GstElement *audioenc;
@@ -144,6 +146,8 @@ static void gcc_element_msg_sync (GstBus * bus, GstMessage * msg,
static void gcc_update_interface_implementations (GstCameraCapturer * gcc);
static int gcc_parse_video_stream_info (GstCaps * caps,
GstCameraCapturer * gcc);
+static GstElement * gst_camera_capturer_create_element (GstCameraCapturer *gcc,
+ gchar *element, gchar *element_name, GError **err);
G_DEFINE_TYPE (GstCameraCapturer, gst_camera_capturer, GTK_TYPE_EVENT_BOX);
@@ -167,6 +171,7 @@ gst_camera_capturer_init (GstCameraCapturer * object)
priv->audio_bitrate = 128;
priv->video_bitrate = 5000;
priv->last_buffer = NULL;
+ priv->source_type = GCC_SOURCE_TYPE_RAW;
priv->lock = g_mutex_new ();
}
@@ -213,21 +218,24 @@ gst_camera_capturer_finalize (GObject * object)
static void
gst_camera_capturer_apply_resolution (GstCameraCapturer * gcc)
{
- GstCaps *caps;
- gchar *caps_string;
+ /*GstCaps *caps;*/
+ /*gchar *caps_string;*/
GST_INFO_OBJECT (gcc, "Changed video resolution to %dx%d %d/%dfps",
gcc->priv->output_width, gcc->priv->output_height,
gcc->priv->output_fps_n, gcc->priv->output_fps_d);
- caps_string =
- g_strdup_printf
- ("video/x-raw-yuv, format=(fourcc)I420,width=(int)%d,height=(int)%d",
- gcc->priv->output_width, gcc->priv->output_height);
- caps = gst_caps_from_string (caps_string);
- g_object_set (gcc->priv->camerabin, "filter-caps", caps, NULL);
- gst_caps_unref (caps);
- g_free (caps_string);
+ /*caps_string =*/
+ /*g_strdup_printf*/
+ /*("video/x-raw-yuv, format=(fourcc)I420,width=(int)%d,height=(int)%d",*/
+ /*gcc->priv->output_width, gcc->priv->output_height);*/
+ /*caps = gst_caps_from_string (caps_string);*/
+ /*g_object_set (gcc->priv->camerabin, "filter-caps", caps, NULL);*/
+ /*gst_caps_unref (caps);*/
+ /*g_free (caps_string);*/
+ g_signal_emit_by_name (G_OBJECT (gcc->priv->camerabin), "set-video-resolution-fps",
+ gcc->priv->output_width, gcc->priv->output_height,
+ gcc->priv->output_fps_n, gcc->priv->output_fps_d);
}
static void
@@ -837,6 +845,67 @@ gst_camera_capture_videosrc_buffer_probe (GstPad * pad, GstBuffer * buf,
return TRUE;
}
+static GstElement *
+gst_camera_capturer_create_element (GstCameraCapturer *gcc,
+ gchar *element, gchar *element_name, GError **err)
+{
+ GstElement * gst_element;
+
+ gst_element = gst_element_factory_make (element, element_name);
+ if (!gst_element){
+ g_set_error (err, GCC_ERROR, ERROR_PLUGIN_LOAD,
+ ("Failed to create a GStreamer element. "
+ "The element \"%s\" is missing. "
+ "Please check your GStreamer installation."),element);
+ g_object_ref_sink (gcc);
+ g_object_unref (gcc);
+ return NULL;
+ }
+ return gst_element;
+}
+
+static void
+gst_camera_capturer_set_source(GstCameraCapturer * gcc, GError **err)
+{
+ gchar *bin;
+ gchar *source_element;
+
+ switch (gcc->priv->source_type){
+ case GCC_SOURCE_TYPE_DV:
+ {
+#ifdef WIN32
+ source_element = "dshowvideosrc";
+#else
+ source_element = "dv1394src";
+#endif
+ bin = g_strdup_printf("%s ! queue ! video/x-dv "
+ "! dvdemux name=demux .video ! queue "
+ "! ffdec_dv ! queue ! ffmpegcolorspace ! videoscale ! videorate "
+ " .demux ", source_element);
+ gcc->priv->videosrc = gst_parse_bin_from_description(bin, TRUE, err);
+ if (*err){
+ g_print ("Error is %s\n",(*err)->message);
+ return;
+ }
+ gcc->priv->audiosrc = gcc->priv->videosrc;
+ }
+ case GCC_SOURCE_TYPE_RAW:
+ {
+#ifdef WIN32
+ source_element = "dshowvideosrc";
+#else
+ source_element = "v4l2src ! ffmpegcolorspace ! videorate ! videoscale";
+#endif
+ bin = g_strdup_printf("%s",
+ source_element);
+ gcc->priv->videosrc = gst_parse_bin_from_description(bin, TRUE, err);
+ if (*err){
+ return;
+ }
+ }
+ }
+}
+
GstCameraCapturer *
gst_camera_capturer_new (gchar * filename, GError ** err)
{
@@ -864,29 +933,18 @@ gst_camera_capturer_new (gchar * filename, GError ** err)
GST_INFO_OBJECT (gcc, "Setting capture mode to \"video\"");
g_object_set (gcc->priv->camerabin, "mode", 1, NULL);
- GST_INFO_OBJECT (gcc, "Setting video source ");
- gcc->priv->videosrc = gst_element_factory_make (VIDEOSRC, "videosource");
+ g_print ("Seeting audio source \n");
+ GST_INFO_OBJECT (gcc, "Setting video/audio source ");
+ gst_camera_capturer_set_source(gcc, err);
+ if (*err != NULL) {
+ return NULL;
+ }
g_object_set (gcc->priv->camerabin, "video-source", gcc->priv->videosrc,
NULL);
- if (!gcc->priv->videosrc) {
- plugin = VIDEOSRC;
- goto missing_plugin;
- }
- g_object_set (gcc->priv->videosrc, "do-timestamp", TRUE, NULL);
- GST_INFO_OBJECT (gcc, "Setting audio source ");
- gcc->priv->audiosrc = gst_element_factory_make (AUDIOSRC, "audiosource");
- g_object_set (gcc->priv->camerabin, "audio-source", gcc->priv->audiosrc,
- NULL);
- if (!gcc->priv->audiosrc) {
- plugin = AUDIOSRC;
- goto missing_plugin;
- }
GST_INFO_OBJECT (gcc, "Setting capture mode to \"video\"");
g_object_set (gcc->priv->camerabin, "mode", 1, NULL);
- g_object_set (gcc->priv->camerabin, "mute", TRUE, NULL);
-
/* assume we're always called from the main Gtk+ GUI thread */
gui_thread = g_thread_self ();
diff --git a/libcesarplayer/src/gst-camera-capturer.h b/libcesarplayer/src/gst-camera-capturer.h
index 3227015..a06f516 100644
--- a/libcesarplayer/src/gst-camera-capturer.h
+++ b/libcesarplayer/src/gst-camera-capturer.h
@@ -63,6 +63,12 @@ struct _GstCameraCapturer
GstCameraCapturerPrivate *priv;
};
+typedef enum
+{
+ GCC_SOURCE_TYPE_DV,
+ GCC_SOURCE_TYPE_RAW
+}GccSourceType;
+
EXPORT GType gst_camera_capturer_get_type (void) G_GNUC_CONST;
EXPORT void gst_camera_capturer_init_backend (int *argc, char ***argv);
@@ -82,6 +88,9 @@ EXPORT gboolean gst_camera_capturer_set_audio_encoder (GstCameraCapturer * gcc,
EXPORT gboolean gst_camera_capturer_set_video_muxer (GstCameraCapturer * gcc,
VideoMuxerType type,
GError ** err);
+EXPORT gboolean gst_camera_capturer_set_video_source_type (GstCameraCapturer * gcc,
+ GccSourceType type,
+ GError ** err);
EXPORT GList* gst_camera_capturer_enum_audio_devices (void);
EXPORT GList* gst_camera_capturer_enum_video_devices (void);
EXPORT GdkPixbuf* gst_camera_capturer_get_current_frame(GstCameraCapturer *gcc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]