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 __GST_RTP_STORAGE_ITEM_H__
22 #define __GST_RTP_STORAGE_ITEM_H__
23 
24 #include <gst/rtp/gstrtpbuffer.h>
25 
26 GST_DEBUG_CATEGORY_EXTERN (gst_rtp_storage_debug);
27 
28 typedef struct {
29   GstBuffer *buffer;
30   guint16 seq;
31   guint8 pt;
32 } RtpStorageItem;
33 
34 typedef struct {
35   GQueue queue;
36   GMutex stream_lock;
37   guint32 ssrc;
38   GstClockTime max_arrival_time;
39 } RtpStorageStream;
40 
41 #define STREAM_LOCK(s)   g_mutex_lock   (&(s)->stream_lock)
42 #define STREAM_UNLOCK(s) g_mutex_unlock (&(s)->stream_lock)
43 
44 RtpStorageStream * rtp_storage_stream_new                      (guint32 ssrc);
45 void               rtp_storage_stream_free                     (RtpStorageStream * stream);
46 void               rtp_storage_stream_resize_and_add_item      (RtpStorageStream * stream,
47                                                                 GstClockTime size_time,
48                                                                 GstBuffer *buffer,
49                                                                 guint8 pt,
50                                                                 guint16 seq);
51 void               rtp_storage_stream_add_item                 (RtpStorageStream * stream,
52                                                                 GstBuffer *buffer,
53                                                                 guint8 pt,
54                                                                 guint16 seq);
55 GstBufferList    * rtp_storage_stream_get_packets_for_recovery (RtpStorageStream *stream,
56                                                                 guint8 pt_fec,
57                                                                 guint16 lost_seq);
58 GstBuffer        * rtp_storage_stream_get_redundant_packet     (RtpStorageStream *stream,
59                                                                 guint16 lost_seq);
60 
61 #endif /* __GST_RTP_STORAGE_ITEM_H__ */
62 
63