1 /* 2 * Farstream - Farstream RTP TFRC Support 3 * 4 * Copyright 2010 Collabora Ltd. 5 * @author: Olivier Crete <olivier.crete@collabora.co.uk> 6 * Copyright 2010 Nokia Corp. 7 * 8 * fs-rtp-tfrc.h - Rate control for Farstream RTP sessions 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 26 #ifndef __FS_RTP_TFRC_H__ 27 #define __FS_RTP_TFRC_H__ 28 29 #include <gst/gst.h> 30 31 #include "tfrc.h" 32 33 #include "fs-rtp-session.h" 34 #include "fs-rtp-keyunit-manager.h" 35 36 G_BEGIN_DECLS 37 38 /* TYPE MACROS */ 39 #define FS_TYPE_RTP_TFRC \ 40 (fs_rtp_tfrc_get_type ()) 41 #define FS_RTP_TFRC(obj) \ 42 (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_RTP_TFRC, FsRtpTfrc)) 43 #define FS_RTP_TFRC_CLASS(klass) \ 44 (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_RTP_TFRC, FsRtpTfrcClass)) 45 #define FS_IS_RTP_TFRC(obj) \ 46 (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_RTP_TFRC)) 47 #define FS_IS_RTP_TFRC_CLASS(klass) \ 48 (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_RTP_TFRC)) 49 #define FS_RTP_TFRC_GET_CLASS(obj) \ 50 (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_RTP_TFRC, FsRtpTfrcClass)) 51 #define FS_RTP_TFRC_CAST(obj) ((FsRtpTfrc *) (obj)) 52 53 typedef struct _FsRtpTfrc FsRtpTfrc; 54 typedef struct _FsRtpTfrcClass FsRtpTfrcClass; 55 56 typedef enum { 57 EXTENSION_NONE, 58 EXTENSION_ONE_BYTE, 59 EXTENSION_TWO_BYTES 60 } ExtensionType; 61 62 63 struct TrackedSource { 64 FsRtpTfrc *self; 65 66 guint32 ssrc; 67 GObject *rtpsource; 68 69 TfrcSender *sender; 70 GstClockID sender_id; 71 TfrcIsDataLimited *idl; 72 guint64 send_ts_base; 73 guint64 send_ts_cycles; 74 guint32 fb_last_ts; 75 guint64 fb_ts_cycles; 76 77 TfrcReceiver *receiver; 78 GstClockID receiver_id; 79 guint32 seq_cycles; 80 guint32 last_seq; 81 guint64 ts_cycles; 82 guint32 last_ts; 83 guint64 last_now; 84 guint32 last_rtt; 85 gboolean send_feedback; 86 87 guint64 next_feedback_timer; 88 89 gboolean got_nohdr_pkt; 90 }; 91 92 /** 93 * FsRtpTfrc: 94 * 95 */ 96 struct _FsRtpTfrc 97 { 98 GstObject parent; 99 100 GstClock *systemclock; 101 102 FsRtpSession *fsrtpsession; 103 GstBin *parent_bin; 104 GObject *rtpsession; 105 106 GstPad *in_rtp_pad; 107 GstPad *in_rtcp_pad; 108 GstPad *out_rtp_pad; 109 110 gulong in_rtp_probe_id; 111 gulong in_rtcp_probe_id; 112 113 gulong on_ssrc_validated_id; 114 gulong on_sending_rtcp_id; 115 116 gulong modder_check_probe_id; 117 GstElement *packet_modder; 118 119 GHashTable *tfrc_sources; 120 struct TrackedSource *initial_src; 121 struct TrackedSource *last_src; 122 123 /* Sender stuff */ 124 gboolean sending; 125 gint byte_reservoir; 126 GstClockTime last_sent_ts; 127 guint send_bitrate; 128 129 ExtensionType extension_type; 130 guint extension_id; 131 132 gboolean pts[128]; 133 }; 134 135 struct _FsRtpTfrcClass 136 { 137 GstObjectClass parent_class; 138 }; 139 140 141 GType fs_rtp_tfrc_get_type (void); 142 143 FsRtpTfrc *fs_rtp_tfrc_new (FsRtpSession *fsrtpsession); 144 145 void fs_rtp_tfrc_destroy (FsRtpTfrc *self); 146 147 void fs_rtp_tfrc_filter_codecs (GList **codec_associations, 148 GList **header_extensions); 149 150 void fs_rtp_tfrc_codecs_updated (FsRtpTfrc *self, 151 GList *codec_associations, 152 GList *header_extensions); 153 154 gboolean fs_rtp_tfrc_is_enabled (FsRtpTfrc *self, guint pt); 155 156 G_END_DECLS 157 158 #endif /* __FS_RTP_TFRC_H__ */ 159