gstrtjpegdec.c 3.26 KB
Newer Older
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
1
/* GStreamer
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15
 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
16 17
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
18 19 20
 */


21 22 23
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
24
#include "gstrtjpegdec.h"
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
25 26

/* GstRTJpegDec signals and args */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
27 28
enum
{
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
29 30 31 32
  /* FILL ME */
  LAST_SIGNAL
};

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
33 34
enum
{
35 36
  PROP_0,
  PROP_QUALITY
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
37 38 39
};


Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
40 41 42
static void gst_rtjpegdec_class_init (GstRTJpegDecClass * klass);
static void gst_rtjpegdec_base_init (GstRTJpegDecClass * klass);
static void gst_rtjpegdec_init (GstRTJpegDec * rtjpegdec);
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
43

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
44
static void gst_rtjpegdec_chain (GstPad * pad, GstData * _data);
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
45 46

static GstElementClass *parent_class = NULL;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
47

48
/*static guint gst_rtjpegdec_signals[LAST_SIGNAL] = { 0 }; */
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
49 50 51 52 53 54 55 56

GType
gst_rtjpegdec_get_type (void)
{
  static GType rtjpegdec_type = 0;

  if (!rtjpegdec_type) {
    static const GTypeInfo rtjpegdec_info = {
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
57 58
      sizeof (GstRTJpegDecClass),
      (GBaseInitFunc) gst_rtjpegdec_base_init,
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
59
      NULL,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
60
      (GClassInitFunc) gst_rtjpegdec_class_init,
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
61 62
      NULL,
      NULL,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
63
      sizeof (GstRTJpegDec),
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
64
      0,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
65
      (GInstanceInitFunc) gst_rtjpegdec_init,
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
66
    };
67

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
68
    rtjpegdec_type =
69 70
        g_type_register_static (GST_TYPE_ELEMENT, "GstRTJpegDec",
        &rtjpegdec_info, 0);
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
71 72 73 74
  }
  return rtjpegdec_type;
}

Ronald S. Bultje's avatar
Ronald S. Bultje committed
75
static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
76
gst_rtjpegdec_base_init (GstRTJpegDecClass * klass)
Ronald S. Bultje's avatar
Ronald S. Bultje committed
77 78 79
{
  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);

80
  gst_element_class_set_static_metadata (element_class, "RTjpeg video decoder",
81 82
      "Codec/Decoder/Video",
      "Decodes video in RTjpeg format", "Erik Walthinsen <omega@cse.ogi.edu>");
Ronald S. Bultje's avatar
Ronald S. Bultje committed
83 84
}

Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
85
static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
86
gst_rtjpegdec_class_init (GstRTJpegDecClass * klass)
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
87 88 89
{
  GstElementClass *gstelement_class;

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
90
  gstelement_class = (GstElementClass *) klass;
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
91

92
  parent_class = g_type_class_peek_parent (klass);
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
93 94 95
}

static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
96
gst_rtjpegdec_init (GstRTJpegDec * rtjpegdec)
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
97
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
98 99 100 101 102
  rtjpegdec->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
  gst_element_add_pad (GST_ELEMENT (rtjpegdec), rtjpegdec->sinkpad);
  gst_pad_set_chain_function (rtjpegdec->sinkpad, gst_rtjpegdec_chain);
  rtjpegdec->srcpad = gst_pad_new ("src", GST_PAD_SRC);
  gst_element_add_pad (GST_ELEMENT (rtjpegdec), rtjpegdec->srcpad);
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
103 104 105
}

static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
106
gst_rtjpegdec_chain (GstPad * pad, GstData * _data)
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
107
{
108
  GstBuffer *buf = GST_BUFFER (_data);
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
109 110 111 112 113 114 115 116 117
  GstRTJpegDec *rtjpegdec;
  guchar *data;
  gulong size;

  g_return_if_fail (pad != NULL);
  g_return_if_fail (GST_IS_PAD (pad));
  g_return_if_fail (buf != NULL);

  rtjpegdec = GST_RTJPEGDEC (GST_OBJECT_PARENT (pad));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
118 119
  data = GST_BUFFER_DATA (buf);
  size = GST_BUFFER_SIZE (buf);
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
120

121
  g_warning ("would be encoding frame here\n");
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
122

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
123
  gst_pad_push (rtjpegdec->srcpad, GST_DATA (buf));
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
124
}