Don't reuse file names
[harmattan/cameraplus] / lib / gst / gstcopy.cpp
1 /*!
2  * This file is part of CameraPlus.
3  *
4  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21 #include "gstcopy.h"
22
23 GST_DEBUG_CATEGORY_STATIC (gst_copy_debug);
24 #define GST_CAT_DEFAULT gst_copy_debug
25
26 #ifndef PACKAGE
27 #define PACKAGE "copy"
28 #endif
29
30 #ifndef VERSION
31 #define VERSION "0.1"
32 #endif
33
34 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
35                                                                    GST_PAD_SRC,
36                                                                    GST_PAD_ALWAYS,
37                                                                    GST_STATIC_CAPS ("ANY")
38                                                                    );
39
40 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
41                                                                     GST_PAD_SINK,
42                                                                     GST_PAD_ALWAYS,
43                                                                     GST_STATIC_CAPS ("ANY")
44                                                                     );
45
46 GST_BOILERPLATE (GstCopy, gst_copy, GstBaseTransform,
47                  GST_TYPE_BASE_TRANSFORM);
48
49 static GstFlowReturn gst_copy_transform_ip(GstBaseTransform *trans, GstBuffer *buf);
50 static GstFlowReturn gst_copy_prepare_output_buffer(GstBaseTransform *trans, GstBuffer *input,
51                                                     gint size, GstCaps *caps, GstBuffer **buf);
52
53 static void
54 gst_copy_base_init(gpointer gclass) {
55   GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
56
57   gst_element_class_set_details_simple(element_class,
58                                        "Copy",
59                                        "Generic",
60                                        "Copy buffers",
61                                        "Mohammed Sameer <msameer@foolab.org>>");
62
63   gst_element_class_add_pad_template(element_class,
64                                      gst_static_pad_template_get(&src_factory));
65   gst_element_class_add_pad_template(element_class,
66                                      gst_static_pad_template_get(&sink_factory));
67 }
68
69 static void
70 gst_copy_class_init(GstCopyClass *klass) {
71   GstBaseTransformClass *gstbasetrans_class = (GstBaseTransformClass *)klass;
72
73   gstbasetrans_class->transform_ip = GST_DEBUG_FUNCPTR(gst_copy_transform_ip);
74   gstbasetrans_class->prepare_output_buffer = GST_DEBUG_FUNCPTR(gst_copy_prepare_output_buffer);
75 }
76
77 static void
78 gst_copy_init(GstCopy *copy, GstCopyClass *) {
79   GstBaseTransform *trans = GST_BASE_TRANSFORM(copy);
80
81   gst_base_transform_set_passthrough(trans, FALSE);
82   gst_base_transform_set_in_place(trans, TRUE);
83 }
84
85 static GstFlowReturn
86 gst_copy_transform_ip(GstBaseTransform *trans, GstBuffer *) {
87   GST_DEBUG_OBJECT(trans, "transform ip");
88
89   return GST_FLOW_OK;
90 }
91
92 static GstFlowReturn
93 gst_copy_prepare_output_buffer(GstBaseTransform *trans, GstBuffer *input,
94                                gint, GstCaps *, GstBuffer **buf) {
95
96   GST_DEBUG_OBJECT(trans, "prepare output buffer");
97
98   *buf = gst_buffer_copy(input);
99
100   return GST_FLOW_OK;
101 }
102
103 static gboolean
104 copy_init(GstPlugin *copy) {
105   GST_DEBUG_CATEGORY_INIT(gst_copy_debug, "copy",
106                           0, "Copy element");
107
108   return gst_element_register(copy, "copy", GST_RANK_NONE,
109                               GST_TYPE_COPY);
110 }
111
112
113 GST_PLUGIN_DEFINE(GST_VERSION_MAJOR, GST_VERSION_MINOR, "copy", "Copy element",
114                   copy_init, VERSION, "GPL", "", "")
115
116 gboolean qt_cam_copy_register() {
117   return gst_plugin_register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
118                                   "copy", "Copy element",
119                                   copy_init, VERSION,
120                                   "GPL", "", "", "");
121 }