• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer plugin for forward error correction
2  * Copyright (C) 2017 Pexip
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Author: Mikhail Fludkov <misha@pexip.com>
19  */
20 
21 #ifndef __RTP_RED_COMMON_H__
22 #define __RTP_RED_COMMON_H__
23 
24 #include <glib.h>
25 
26 G_BEGIN_DECLS
27 
28 typedef struct _RedBlockHeader RedBlockHeader;
29 
30 /* RFC 2198 */
31 /*
32     0                   1                   2                   3
33     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
34    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35    |F|   block PT  |  timestamp offset         |   block length    |
36    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 */
38 
39 struct _RedBlockHeader {
40 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
41   guint pt:7;
42   guint F:1;
43 
44   guint timestamp_offset_hi: 8;
45 
46   guint length_hi: 2;
47   guint timestamp_offset_lo: 6;
48 
49   guint length_lo: 8;
50 #elif G_BYTE_ORDER == G_BIG_ENDIAN
51   guint F:1;
52   guint pt:7;
53 
54   guint timestamp_offset_hi: 8;
55 
56   guint timestamp_offset_lo: 6;
57   guint length_hi: 2;
58 
59   guint length_lo: 8;
60 #else
61 #error "G_BYTE_ORDER should be big or little endian."
62 #endif
63 };
64 
65 #define RED_BLOCK_TIMESTAMP_OFFSET_MAX ((1<<14) - 1)
66 #define RED_BLOCK_LENGTH_MAX ((1<<10) - 1)
67 
68 gsize    rtp_red_block_header_get_length    (gboolean is_redundant);
69 gboolean rtp_red_block_is_redundant         (gpointer red_block);
70 void     rtp_red_block_set_payload_type     (gpointer red_block, guint8 pt);
71 void     rtp_red_block_set_timestamp_offset (gpointer red_block, guint16 timestamp_offset);
72 void     rtp_red_block_set_payload_length   (gpointer red_block, guint16 length);
73 guint16  rtp_red_block_get_timestamp_offset (gpointer red_block);
74 guint8   rtp_red_block_get_payload_type     (gpointer red_block);
75 void     rtp_red_block_set_is_redundant     (gpointer red_block, gboolean is_redundant);
76 guint16  rtp_red_block_get_payload_length   (gpointer red_block);
77 
78 G_END_DECLS
79 
80 #endif
81