author: CarlsonLee(carlsonlee.freec@hotmail.com), 本代码是freecamera的一部分,freecamera源代码存在:http://gitorious.org/freecamera
#include <glib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include <gst/gst.h>
#include <gst/app/gstappsink.h>
#include <gst/app/gstappsrc.h>
#include <gst/app/gstappbuffer.h>
#include "cam_midware.h"
#include "cam_global.h"
#include "cam_display.h"
#include "cam_files.h"
#include "color_space.h"
#include "review_data.h"
#include "cam_ui.h"
#include "cam_utils.h"
#include "cam_err.h"
#define SKIP_FRAMES 10
static struct tag_CAM_MW_DATA
{
gint camera_status;
GMainLoop* video_cap_loop;
char* filename;
gint skip_frames;
GMutex* mutex;
}cam_video_data;
static gboolean video_bus_call (GstBus *bus,
GstMessage *msg,
gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
bus = bus;
switch (GST_MESSAGE_TYPE (msg))
{
case GST_MESSAGE_EOS:
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:
{
gchar *debug;
GError *error;
gst_message_parse_error (msg, &error, &debug);
g_print ("Error**##: %s, %s/n", error->message, debug);
g_free (debug);
g_error_free (error);
g_main_loop_quit (loop);
}
break;
default:
break;
}
return TRUE;
}
static gboolean link_video_cap_src(GstElement *src, GstElement *sink)
{
gboolean link_ok = FALSE;
GstCaps *caps;
guint width = cam_global_data.cam_res.video_res[cam_global_data.cam_res.video_res_cur].width;
guint height = cam_global_data.cam_res.video_res[cam_global_data.cam_res.video_res_cur].height;
caps = gst_caps_new_simple ("video/x-raw-yuv",
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, NULL);
link_ok = gst_element_link_filtered (src, sink, caps);
gst_caps_unref (caps);
return link_ok;
}
static gboolean link_video_cap_pp(GstElement *src, GstElement *sink)
{
gboolean link_ok = FALSE;
GstCaps *caps;
guint width = cam_global_data.cam_res.video_res[cam_global_data.cam_res.video_res_cur].width;
guint height