]> sjero.net Git - linphone/blob - coreapi/sdphandler.h
purge out p2pproxy
[linphone] / coreapi / sdphandler.h
1  /*
2   * Linphone is sip (RFC3261) compatible internet phone.
3   * This library is free software; you can redistribute it and/or
4   * modify it under the terms of the GNU Lesser General Public
5   * License as published by the Free Software Foundation; either
6   * version 2.1 of the License, or (at your option) any later version.
7   *
8   * This library is distributed in the hope that it will be useful,
9   * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   * Lesser General Public License for more details.
12   *
13   * You should have received a copy of the GNU Lesser General Public
14   * License along with this library; if not, write to the Free Software
15   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16   */
17
18 #ifndef SDP_HANDLER_H
19 #define SDP_HANDLER_H
20
21 #include <osipparser2/sdp_message.h>
22 #include "linphonecore.h"
23
24 typedef struct _sdp_payload
25 {
26         int line;       /* the index of the m= line */
27         int pt;         /*payload type */
28         int localport;
29         int remoteport;
30         int b_as_bandwidth;     /* application specific bandwidth */
31         char *proto;
32         char *c_nettype;
33         char *c_addrtype;
34         char *c_addr;
35         char *c_addr_multicast_ttl;
36         char *c_addr_multicast_int;
37         char *a_rtpmap;
38         char *a_fmtp;
39         char *relay_host;
40         int relay_port;
41         char *relay_session_id;
42         int a_ptime;
43 } sdp_payload_t;
44
45 typedef struct _sdp_context sdp_context_t;
46
47 typedef int (*sdp_handler_read_codec_func_t) (struct _sdp_context *,
48                                                                                         sdp_payload_t *);
49 typedef int (*sdp_handler_write_codec_func_t) (struct _sdp_context *);
50
51 typedef struct _sdp_handler
52 {
53         sdp_handler_read_codec_func_t accept_audio_codecs;   /*from remote sdp */
54         sdp_handler_read_codec_func_t accept_video_codecs;   /*from remote sdp */
55         sdp_handler_write_codec_func_t set_audio_codecs;        /*to local sdp */
56         sdp_handler_write_codec_func_t set_video_codecs;        /*to local sdp */
57         sdp_handler_read_codec_func_t get_audio_codecs; /*from incoming answer  */
58         sdp_handler_read_codec_func_t get_video_codecs; /*from incoming answer  */
59 } sdp_handler_t;
60
61
62 typedef enum _sdp_context_state
63 {
64         SDP_CONTEXT_STATE_INIT,
65         SDP_CONTEXT_STATE_NEGOCIATION_OPENED,
66         SDP_CONTEXT_STATE_NEGOCIATION_CLOSED
67 } sdp_context_state_t;
68
69 struct _sdp_context
70 {
71         sdp_handler_t *handler;
72         char *localip;
73         char *username;
74         void *reference;
75         sdp_message_t *offer;           /* the local sdp to be used for outgoing request */
76         char *offerstr;
77         sdp_message_t *answer;          /* the local sdp generated from an inc request */
78         char *answerstr;
79         char *relay;
80         char *relay_session_id;
81         int negoc_status;       /* in sip code */
82         int incb;
83         sdp_context_state_t state;
84 };
85
86 /* create a context for a sdp negociation: localip is the ip address to be used in the sdp message, can
87 be a firewall address.
88 It can be null when negociating for an incoming offer; In that case it will be guessed. */
89 sdp_context_t *sdp_handler_create_context(sdp_handler_t *handler, const char *localip, const char *username, const char *relay);
90 void sdp_context_set_user_pointer(sdp_context_t * ctx, void* up);
91 void *sdp_context_get_user_pointer(sdp_context_t * ctx);
92 void sdp_context_add_audio_payload( sdp_context_t * ctx, sdp_payload_t * payload);
93 void sdp_context_add_video_payload( sdp_context_t * ctx, sdp_payload_t * payload);
94 char * sdp_context_get_offer(sdp_context_t *ctx);
95 char * sdp_context_get_answer(sdp_context_t* ctx, sdp_message_t *remote_offer);
96 int sdp_context_get_status(sdp_context_t* ctx);
97 void sdp_context_read_answer(sdp_context_t *ctx, sdp_message_t *remote_answer);
98 void sdp_context_free(sdp_context_t *ctx);
99
100 int sdp_payload_init (sdp_payload_t * payload);
101 #endif