1 /* 2 * Farstream - Farstream Codec 3 * 4 * Copyright 2007 Collabora Ltd. 5 * @author: Philippe Kalaf <philippe.kalaf@collabora.co.uk> 6 * Copyright 2007 Nokia Corp. 7 * 8 * Copyright 2005 Collabora Ltd. 9 * @author: Rob Taylor <rob.taylor@collabora.co.uk> 10 * 11 * fs-codec.h - A Farstream codec 12 * 13 * This library is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU Lesser General Public 15 * License as published by the Free Software Foundation; either 16 * version 2.1 of the License, or (at your option) any later version. 17 * 18 * This library is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * Lesser General Public License for more details. 22 * 23 * You should have received a copy of the GNU Lesser General Public 24 * License along with this library; if not, write to the Free Software 25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 26 */ 27 28 #ifndef __FS_CODEC_H__ 29 #define __FS_CODEC_H__ 30 31 #include <gst/gst.h> 32 33 G_BEGIN_DECLS 34 35 typedef struct _FsCodec FsCodec; 36 typedef struct _FsCodecParameter FsCodecParameter; 37 typedef struct _FsFeedbackParameter FsFeedbackParameter; 38 39 #define FS_TYPE_CODEC \ 40 (fs_codec_get_type ()) 41 42 #define FS_TYPE_CODEC_LIST \ 43 (fs_codec_list_get_type ()) 44 45 /** 46 * FsMediaType: 47 * @FS_MEDIA_TYPE_AUDIO: A media type that encodes audio. 48 * @FS_MEDIA_TYPE_VIDEO: A media type that encodes video. 49 * @FS_MEDIA_TYPE_APPLICATION: A media type for application data. 50 * @FS_MEDIA_TYPE_LAST: Largest valid #FsMediaType 51 * 52 * Enum used to signify the media type of a codec or stream. 53 */ 54 typedef enum { 55 FS_MEDIA_TYPE_AUDIO, 56 FS_MEDIA_TYPE_VIDEO, 57 FS_MEDIA_TYPE_APPLICATION, 58 FS_MEDIA_TYPE_LAST = FS_MEDIA_TYPE_APPLICATION 59 } FsMediaType; 60 61 /** 62 * FS_CODEC_ID_ANY: 63 * 64 * If the id of a #FsCodec is #FS_CODEC_ID_ANY, then it will be replaced 65 * with a dynamic payload type at runtime 66 */ 67 68 /** 69 * FS_CODEC_ID_DISABLE: 70 * 71 * If the id of a #FsCodec is #FS_CODEC_ID_DISABLE, then this codec will 72 * not be used 73 */ 74 75 #define FS_CODEC_ID_ANY (-1) 76 #define FS_CODEC_ID_DISABLE (-2) 77 78 /** 79 * FsCodec: 80 * @id: numeric identifier for encoding, eg. PT for SDP 81 * @encoding_name: the name of the codec 82 * @media_type: type of media this codec is for 83 * @clock_rate: clock rate of this stream 84 * @channels: Number of channels codec should decode 85 * @optional_params: (element-type FsCodecParameter): key pairs of param name to param data 86 * @minimum_reporting_interval: The minimum interval between two RTCP reports, 87 * If it is not specified (G_MAXUINT), it is up to the protocol to decide 88 * (it is 5 seconds for RTP). 89 * @feedback_params: (element-type FsFeedbackParameter): key triplets of 90 * feedbck param type, subtype and extra string that is supported for this codec 91 * 92 * This structure reprensents one codec that can be offered or received 93 */ 94 struct _FsCodec 95 { 96 gint id; 97 char *encoding_name; 98 FsMediaType media_type; 99 guint clock_rate; 100 guint channels; 101 guint minimum_reporting_interval; 102 GList *optional_params; 103 GList *feedback_params; 104 }; 105 106 /** 107 * FsCodecParameter: 108 * @name: paramter name. 109 * @value: parameter value. 110 * 111 * Used to store arbitary parameters for a codec 112 */ 113 struct _FsCodecParameter { 114 gchar *name; 115 gchar *value; 116 }; 117 118 /** 119 * FsFeedbackParameter: 120 * @type: the type of feedback, like "ack", "name", "ccm" 121 * @subtype: the subtype of feedback (can be an empty string) 122 * @extra_params: a string containing extra parameters (can be empty) 123 * 124 * Use to store feedback parameters 125 */ 126 struct _FsFeedbackParameter { 127 gchar *type; 128 gchar *subtype; 129 gchar *extra_params; 130 }; 131 132 133 /** 134 * FS_CODEC_FORMAT: 135 * 136 * A format that can be used in printf like format strings to format a FsCodec 137 */ 138 139 /** 140 * FS_CODEC_ARGS: 141 * @codec: a #FsCodec 142 * 143 * Formats the codec in args for FS_CODEC_FORMAT 144 */ 145 146 #define FS_CODEC_FORMAT "%d: %s %s clock:%d channels:%d params:%p" 147 #define FS_CODEC_ARGS(codec) \ 148 (codec)->id, \ 149 fs_media_type_to_string ((codec)->media_type), \ 150 (codec)->encoding_name, \ 151 (codec)->clock_rate, \ 152 (codec)->channels, \ 153 (codec)->optional_params 154 155 GType fs_codec_get_type (void); 156 GType fs_codec_list_get_type (void); 157 158 159 FsCodec *fs_codec_new (int id, const char *encoding_name, 160 FsMediaType media_type, guint clock_rate); 161 162 void fs_codec_destroy (FsCodec * codec); 163 FsCodec *fs_codec_copy (const FsCodec * codec); 164 void fs_codec_list_destroy (GList *codec_list); 165 GList *fs_codec_list_copy (const GList *codec_list); 166 167 GList *fs_codec_list_from_keyfile (const gchar *filename, GError **error); 168 gchar *fs_codec_to_string (const FsCodec *codec); 169 const gchar *fs_media_type_to_string (FsMediaType media_type); 170 171 gboolean fs_codec_are_equal (const FsCodec *codec1, const FsCodec *codec2); 172 gboolean fs_codec_list_are_equal (GList *list1, GList *list2); 173 174 175 void fs_codec_add_optional_parameter (FsCodec *codec, const gchar *name, 176 const gchar *value); 177 void fs_codec_remove_optional_parameter (FsCodec *codec, 178 FsCodecParameter *param); 179 FsCodecParameter *fs_codec_get_optional_parameter (FsCodec *codec, 180 const gchar *name, const gchar *value); 181 182 #define FS_TYPE_CODEC_PARAMETER (fs_codec_parameter_get_type ()) 183 GType fs_codec_parameter_get_type (void); 184 185 FsCodecParameter *fs_codec_parameter_copy (const FsCodecParameter *param); 186 void fs_codec_parameter_free (FsCodecParameter *param); 187 188 189 void fs_codec_add_feedback_parameter (FsCodec *codec, const gchar *type, 190 const gchar *subtype, const gchar *extra_params); 191 FsFeedbackParameter *fs_codec_get_feedback_parameter (FsCodec *codec, 192 const gchar *type, const gchar *subtype, const gchar *extra_params); 193 void fs_codec_remove_feedback_parameter (FsCodec *codec, GList *item); 194 195 196 #define FS_TYPE_FEEDBACK_PARAMETER (fs_feedback_parameter_get_type ()) 197 GType fs_feedback_parameter_get_type (void); 198 199 FsFeedbackParameter *fs_feedback_parameter_copy ( 200 const FsFeedbackParameter *param); 201 void fs_feedback_parameter_free (FsFeedbackParameter *param); 202 203 204 205 G_END_DECLS 206 207 #endif /* __FS_CODEC_H__ */ 208