| 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 | |
|---|
| 23 | typedef struct _sdp_payload |
|---|
| 24 | { |
|---|
| 25 | int line; /* the index of the m= line */ |
|---|
| 26 | int pt; /*payload type */ |
|---|
| 27 | int localport; |
|---|
| 28 | int localrtcpport; |
|---|
| 29 | int remoteport; |
|---|
| 30 | int remotertcpport; |
|---|
| 31 | int b_as_bandwidth; /* application specific bandwidth */ |
|---|
| 32 | char *proto; |
|---|
| 33 | char *c_nettype; |
|---|
| 34 | char *c_addrtype; |
|---|
| 35 | char *c_addr; |
|---|
| 36 | char *c_addr_multicast_ttl; |
|---|
| 37 | char *c_addr_multicast_int; |
|---|
| 38 | char *a_rtpmap; |
|---|
| 39 | char *a_fmtp; |
|---|
| 40 | char *relay_host; |
|---|
| 41 | int relay_port; |
|---|
| 42 | char *relay_session_id; |
|---|
| 43 | int a_ptime; |
|---|
| 44 | } sdp_payload_t; |
|---|
| 45 | |
|---|
| 46 | typedef struct _sdp_context sdp_context_t; |
|---|
| 47 | |
|---|
| 48 | typedef int (*sdp_handler_read_codec_func_t) (struct _sdp_context *, 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, int ptime); |
|---|
| 93 | void sdp_context_add_video_payload(sdp_context_t * ctx, sdp_payload_t * payload); |
|---|
| 94 | char * sdp_context_build_offer(sdp_context_t *ctx); |
|---|
| 95 | char * sdp_context_build_answer(sdp_context_t* ctx, sdp_message_t *remote_offer, int ptime); |
|---|
| 96 | int sdp_context_get_status(sdp_context_t* ctx); |
|---|
| 97 | void sdp_context_process_answer(sdp_context_t *ctx, sdp_message_t *remote_answer); |
|---|
| 98 | void sdp_context_free(sdp_context_t *ctx); |
|---|
| 99 | int sdp_message_m_attr_has_type(sdp_message_t *sdp, const char *type); |
|---|
| 100 | |
|---|
| 101 | int sdp_payload_init (sdp_payload_t * payload); |
|---|
| 102 | void sdp_payload_free(void *data); |
|---|
| 103 | int sdp_payload_clone(void *src, void **dst); |
|---|
| 104 | int sdp_equal_payload(const sdp_payload_t *cur_payload, const sdp_payload_t *payload); |
|---|
| 105 | int sdp_payload_list_add(struct osip_list* list, int pt, char *rtpmap, int line); |
|---|
| 106 | #endif |
|---|