1 /* GStreamer
2  * Copyright (C) <2014> Stian Selnes <stian@pexip.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Author: Dejan Sakelsak sahel@kiberpipa.org
20  */
21 
22 #ifndef __GST_RTP_H261_PAY_H__
23 #define __GST_RTP_H261_PAY_H__
24 
25 #include <gst/gst.h>
26 #include <gst/rtp/gstrtpbasepayload.h>
27 #include <gst/base/gstadapter.h>
28 
29 G_BEGIN_DECLS
30 #define GST_TYPE_RTP_H261_PAY                   \
31   (gst_rtp_h261_pay_get_type())
32 #define GST_RTP_H261_PAY(obj)                                           \
33   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_H261_PAY,GstRtpH261Pay))
34 #define GST_RTP_H261_PAY_CLASS(klass)                                   \
35   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_H261_PAY,GstRtpH261PayClass))
36 #define GST_IS_RTP_H261_PAY(obj)                            \
37   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_H261_PAY))
38 #define GST_IS_RTP_H261_PAY_CLASS(klass)                    \
39   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_H261_PAY))
40 typedef struct _GstRtpH261PayClass GstRtpH261PayClass;
41 typedef struct _GstRtpH261Pay GstRtpH261Pay;
42 
43 struct _GstRtpH261Pay
44 {
45   GstRTPBasePayload payload;
46 
47   GstAdapter *adapter;
48   gint offset;
49   GstClockTime timestamp;
50 };
51 
52 struct _GstRtpH261PayClass
53 {
54   GstRTPBasePayloadClass parent_class;
55 };
56 
57 typedef struct _GstRtpH261PayHeader
58 {
59 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
60   unsigned int v:1;             /* Motion vector flag */
61   unsigned int i:1;             /* Intra encoded data */
62   unsigned int ebit:3;          /* End position */
63   unsigned int sbit:3;          /* Start position */
64 
65   unsigned int mbap1:4;         /* MB address predictor - part1 */
66   unsigned int gobn:4;          /* GOB number */
67 
68   unsigned int hmvd1:2;         /* Horizontal motion vector data - part1 */
69   unsigned int quant:5;         /* Quantizer */
70   unsigned int mbap2:1;         /* MB address predictor - part2 */
71 
72   unsigned int vmvd:5;          /* Horizontal motion vector data - part1 */
73   unsigned int hmvd2:3;         /* Vertical motion vector data */
74 #elif G_BYTE_ORDER == G_BIG_ENDIAN
75   unsigned int sbit:3;          /* Start position */
76   unsigned int ebit:3;          /* End position */
77   unsigned int i:1;             /* Intra encoded data */
78   unsigned int v:1;             /* Motion vector flag */
79 
80   unsigned int gobn:4;          /* GOB number */
81   unsigned int mbap1:4;         /* MB address predictor - part1 */
82 
83   unsigned int mbap2:1;         /* MB address predictor - part2 */
84   unsigned int quant:5;         /* Quantizer */
85   unsigned int hmvd1:2;         /* Horizontal motion vector data - part1 */
86 
87   unsigned int hmvd2:3;         /* Vertical motion vector data */
88   unsigned int vmvd:5;          /* Horizontal motion vector data - part1 */
89 #else
90 #error "G_BYTE_ORDER should be big or little endian."
91 #endif
92 } GstRtpH261PayHeader;
93 #define GST_RTP_H261_PAYLOAD_HEADER_LEN 4
94 
95 GType gst_rtp_h261_pay_get_type (void);
96 
97 gboolean gst_rtp_h261_pay_plugin_init (GstPlugin * plugin);
98 
99 G_END_DECLS
100 #endif /* __GST_RTP_H261_PAY_H__ */
101