• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  *
3  * uvch264_mjpg_demux: a demuxer for muxed stream in UVC H264 compliant MJPG
4  *
5  * Copyright (C) 2012 Cisco Systems, Inc.
6  *   Author: Youness Alaoui <youness.alaoui@collabora.co.uk>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef __GST_UVC_H264_MJPG_DEMUX_H__
25 #define __GST_UVC_H264_MJPG_DEMUX_H__
26 
27 #include <gst/gst.h>
28 
29 
30 G_BEGIN_DECLS
31 
32 #define GST_TYPE_UVC_H264_MJPG_DEMUX             \
33   (gst_uvc_h264_mjpg_demux_get_type())
34 #define GST_UVC_H264_MJPG_DEMUX(obj)             \
35   (G_TYPE_CHECK_INSTANCE_CAST((obj),            \
36       GST_TYPE_UVC_H264_MJPG_DEMUX,              \
37       GstUvcH264MjpgDemux))
38 #define GST_UVC_H264_MJPG_DEMUX_CLASS(klass)     \
39   (G_TYPE_CHECK_CLASS_CAST((klass),             \
40       GST_TYPE_UVC_H264_MJPG_DEMUX,              \
41       GstUvcH264MjpgDemuxClass))
42 #define GST_IS_UVC_H264_MJPG_DEMUX(obj)          \
43   (G_TYPE_CHECK_INSTANCE_TYPE((obj),            \
44       GST_TYPE_UVC_H264_MJPG_DEMUX))
45 #define GST_IS_UVC_H264_MJPG_DEMUX_CLASS(klass)  \
46   (G_TYPE_CHECK_CLASS_TYPE((klass),             \
47       GST_TYPE_UVC_H264_MJPG_DEMUX))
48 
49 typedef struct _GstUvcH264MjpgDemux           GstUvcH264MjpgDemux;
50 typedef struct _GstUvcH264MjpgDemuxClass      GstUvcH264MjpgDemuxClass;
51 
52 typedef struct
53 {
54   guint32 dev_stc;
55   guint32 dev_sof;
56   GstClockTime host_ts;
57   guint32 host_sof;
58 } GstUvcH264ClockSample;
59 
60 typedef struct
61 {
62   guint16 version;
63   guint16 header_len;
64   guint32 type;
65   guint16 width;
66   guint16 height;
67   guint32 frame_interval;
68   guint16 delay;
69   guint32 pts;
70 } __attribute__ ((packed)) AuxiliaryStreamHeader;
71 
72 struct _GstUvcH264MjpgDemux {
73   GstElement element;
74 
75   /* private */
76   int device_fd;
77   int num_clock_samples;
78   GstUvcH264ClockSample *clock_samples;
79   int last_sample;
80   int num_samples;
81   GstPad *sink_pad;
82   GstPad *jpeg_pad;
83   GstPad *h264_pad;
84   GstPad *yuy2_pad;
85   GstPad *nv12_pad;
86   GstCaps *h264_caps;
87   GstCaps *yuy2_caps;
88   GstCaps *nv12_caps;
89   guint16 h264_width;
90   guint16 h264_height;
91   guint16 yuy2_width;
92   guint16 yuy2_height;
93   guint16 nv12_width;
94   guint16 nv12_height;
95 
96   /* input segment */
97   GstSegment segment;
98   GstClockTime last_pts;
99   gboolean pts_reordered_warning;};
100 
101 struct _GstUvcH264MjpgDemuxClass {
102   GstElementClass  parent_class;
103 };
104 
105 GType gst_uvc_h264_mjpg_demux_get_type (void);
106 
107 GST_ELEMENT_REGISTER_DECLARE (uvch264mjpgdemux);
108 
109 G_END_DECLS
110 
111 #endif /* __GST_UVC_H264_MJPG_DEMUX_H__ */
112