diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-03-22 21:00:53 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-03-22 21:00:53 +0000 |
commit | f8d17a0d196e42dd886bcdd908085c810b3bba8d (patch) | |
tree | bc17175bf3659f55fe7c8835edfb4cff629268b6 /pjnath/include | |
parent | d83a429d3e7d308b725924078d893c77224d336e (diff) |
Final ICE stream transport
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1096 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/include')
-rw-r--r-- | pjnath/include/pjnath.h | 2 | ||||
-rw-r--r-- | pjnath/include/pjnath/errno.h | 11 | ||||
-rw-r--r-- | pjnath/include/pjnath/ice.h | 24 | ||||
-rw-r--r-- | pjnath/include/pjnath/ice_mt.h | 114 | ||||
-rw-r--r-- | pjnath/include/pjnath/ice_stream_transport.h | 185 |
5 files changed, 208 insertions, 128 deletions
diff --git a/pjnath/include/pjnath.h b/pjnath/include/pjnath.h index c3f85fc3..8574631d 100644 --- a/pjnath/include/pjnath.h +++ b/pjnath/include/pjnath.h @@ -20,7 +20,7 @@ #include <pjnath/config.h> #include <pjnath/errno.h> #include <pjnath/ice.h> -#include <pjnath/ice_mt.h> +#include <pjnath/ice_stream_transport.h> #include <pjnath/stun_auth.h> #include <pjnath/stun_config.h> #include <pjnath/stun_msg.h> diff --git a/pjnath/include/pjnath/errno.h b/pjnath/include/pjnath/errno.h index 0a4d5888..3a7c591f 100644 --- a/pjnath/include/pjnath/errno.h +++ b/pjnath/include/pjnath/errno.h @@ -155,6 +155,17 @@ #define PJ_EICEINCOMPID -1 /** * @hideinitializer + * Invalid ICE candidate ID + */ +#define PJ_EICEINCANDID -1 +/** + * @hideinitializer + * ICE session not available + */ +#define PJ_ENOICE -1 + + /** + * @hideinitializer * ICE check is in progress */ #define PJ_EICEINPROGRESS -1 diff --git a/pjnath/include/pjnath/ice.h b/pjnath/include/pjnath/ice.h index 94cd7a22..8aa77cbc 100644 --- a/pjnath/include/pjnath/ice.h +++ b/pjnath/include/pjnath/ice.h @@ -81,8 +81,6 @@ typedef struct pj_ice pj_ice; typedef struct pj_ice_comp { unsigned comp_id; - pj_stun_session *stun_sess; - pj_sockaddr local_addr; int nominated_check_id; } pj_ice_comp; @@ -99,6 +97,7 @@ typedef struct pj_ice_cand pj_sockaddr addr; pj_sockaddr base_addr; pj_sockaddr srv_addr; + pj_stun_session *stun_sess; } pj_ice_cand; typedef enum pj_ice_check_state @@ -145,11 +144,13 @@ typedef struct pj_ice_checklist typedef struct pj_ice_cb { void (*on_ice_complete)(pj_ice *ice, pj_status_t status); - pj_status_t (*on_tx_pkt)(pj_ice *ice, unsigned comp_id, + pj_status_t (*on_tx_pkt)(pj_ice *ice, unsigned comp_id, + unsigned cand_id, const void *pkt, pj_size_t size, const pj_sockaddr_t *dst_addr, unsigned dst_addr_len); - pj_status_t (*on_rx_data)(pj_ice *ice, unsigned comp_id, + void (*on_rx_data)(pj_ice *ice, unsigned comp_id, + unsigned cand_id, void *pkt, pj_size_t size, const pj_sockaddr_t *src_addr, unsigned src_addr_len); @@ -212,17 +213,11 @@ PJ_DECL(pj_status_t) pj_ice_create(pj_stun_config *stun_cfg, const char *name, pj_ice_role role, const pj_ice_cb *cb, + const pj_str_t *local_ufrag, + const pj_str_t *local_passwd, pj_ice **p_ice); PJ_DECL(pj_status_t) pj_ice_destroy(pj_ice *ice); -PJ_DECL(pj_status_t) pj_ice_add_comp(pj_ice *ice, - unsigned comp_id, - const pj_sockaddr_t *local_addr, - unsigned addr_len); -PJ_DECL(pj_status_t) pj_ice_set_credentials(pj_ice *ice, - const pj_str_t *local_ufrag, - const pj_str_t *local_pass, - const pj_str_t *remote_ufrag, - const pj_str_t *remote_pass); +PJ_DECL(pj_status_t) pj_ice_add_comp(pj_ice *ice, unsigned comp_id); PJ_DECL(pj_status_t) pj_ice_add_cand(pj_ice *ice, unsigned comp_id, pj_ice_cand_type type, @@ -246,6 +241,8 @@ PJ_DECL(pj_status_t) pj_ice_get_cand(pj_ice *ice, pj_ice_cand **p_cand); PJ_DECL(pj_status_t) pj_ice_create_check_list(pj_ice *ice, + const pj_str_t *rem_ufrag, + const pj_str_t *rem_passwd, unsigned rem_cand_cnt, const pj_ice_cand rem_cand[]); PJ_DECL(pj_status_t) pj_ice_start_check(pj_ice *ice); @@ -256,6 +253,7 @@ PJ_DECL(pj_status_t) pj_ice_send_data(pj_ice *ice, pj_size_t data_len); PJ_DECL(pj_status_t) pj_ice_on_rx_pkt(pj_ice *ice, unsigned comp_id, + unsigned cand_id, void *pkt, pj_size_t pkt_size, const pj_sockaddr_t *src_addr, diff --git a/pjnath/include/pjnath/ice_mt.h b/pjnath/include/pjnath/ice_mt.h deleted file mode 100644 index d96f39b6..00000000 --- a/pjnath/include/pjnath/ice_mt.h +++ /dev/null @@ -1,114 +0,0 @@ -/* $Id$ */ -/* - * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __PJNATH_ICE_MT_H__ -#define __PJNATH_ICE_MT_H__ - - -/** - * @file ice_mt.h - * @brief ICE Media Transport. - */ -#include <pjnath/ice.h> -#include <pj/ioqueue.h> - - -PJ_BEGIN_DECL - - -/** - * @defgroup PJNATH_ICE_MEDIA_TRANSPORT ICE Media Transport - * @brief ICE Media Transport - * @ingroup PJNATH_ICE - * @{ - */ - -typedef struct pj_icemt pj_icemt; - -typedef struct pj_icemt_cb -{ - void (*on_ice_complete)(pj_icemt *icemt, - pj_status_t status); - void (*on_rx_rtp)(pj_icemt *icemt, - void *pkt, pj_size_t size, - const pj_sockaddr_t *src_addr, - unsigned src_addr_len); - void (*on_rx_rtcp)(pj_icemt *icemt, - void *pkt, pj_size_t size, - const pj_sockaddr_t *src_addr, - unsigned src_addr_len); - -} pj_icemt_cb; - - -typedef struct pj_icemt_sock -{ - pj_icemt *icemt; - unsigned comp_id; - pj_sock_t sock; - pj_sockaddr addr; - pj_sockaddr base_addr; - pj_ioqueue_key_t *key; - pj_uint8_t pkt[1500]; - pj_ioqueue_op_key_t read_op; - pj_ioqueue_op_key_t write_op; - pj_sockaddr src_addr; - int src_addr_len; -} pj_icemt_sock; - - -struct pj_icemt -{ - pj_pool_t *pool; - pj_ice *ice; - void *user_data; - - pj_icemt_cb cb; - - pj_icemt_sock rtp; - pj_icemt_sock rtcp; - - pj_bool_t has_turn; - pj_sockaddr stun_srv; -}; - - -PJ_DECL(pj_status_t) pj_icemt_create(pj_stun_config *stun_cfg, - const char *name, - pj_ice_role role, - const pj_icemt_cb *cb, - unsigned rtp_port, - pj_bool_t has_rtcp, - pj_bool_t has_turn, - const pj_sockaddr *srv, - pj_icemt **p_icemt); -PJ_DECL(pj_status_t) pj_icemt_destroy(pj_icemt *icemt); - - - -/** - * @} - */ - - -PJ_END_DECL - - - -#endif /* __PJNATH_ICE_MT_H__ */ - diff --git a/pjnath/include/pjnath/ice_stream_transport.h b/pjnath/include/pjnath/ice_stream_transport.h new file mode 100644 index 00000000..c85aff98 --- /dev/null +++ b/pjnath/include/pjnath/ice_stream_transport.h @@ -0,0 +1,185 @@ +/* $Id$ */ +/* + * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJNATH_ICE_STREAM_TRANSPORT_H__ +#define __PJNATH_ICE_STREAM_TRANSPORT_H__ + + +/** + * @file ice_mt.h + * @brief ICE Media Transport. + */ +#include <pjnath/ice.h> +#include <pjlib-util/resolver.h> +#include <pj/ioqueue.h> + + +PJ_BEGIN_DECL + + +/** + * @defgroup PJNATH_ICE_STREAM_TRANSPORT ICE Stream Transport + * @brief Transport for media stream using ICE + * @ingroup PJNATH_ICE + * @{ + */ + +typedef struct pj_ice_st pj_ice_st; + +typedef struct pj_ice_st_cb +{ + void (*on_rx_data)(pj_ice_st *ice_st, + unsigned comp_id, unsigned cand_id, + void *pkt, pj_size_t size, + const pj_sockaddr_t *src_addr, + unsigned src_addr_len); + + void (*on_stun_srv_resolved)(pj_ice_st *ice_st, + pj_status_t status); + void (*on_interface_status)(pj_ice_st *ice_st, + void *notify_data, + pj_status_t status, + int itf_id); + void (*on_ice_complete)(pj_ice_st *ice_st, + pj_status_t status); + +} pj_ice_st_cb; + + +typedef struct pj_ice_st_comp +{ + unsigned comp_id; +} pj_ice_st_comp; + + +typedef struct pj_ice_st_interface +{ + pj_ice_st *ice_st; + pj_ice_cand_type type; + unsigned comp_id; + int cand_id; + pj_str_t foundation; + pj_uint16_t local_pref; + pj_sock_t sock; + pj_sockaddr addr; + pj_sockaddr base_addr; + pj_ioqueue_key_t *key; + pj_uint8_t pkt[1500]; + pj_ioqueue_op_key_t read_op; + pj_ioqueue_op_key_t write_op; + pj_sockaddr src_addr; + int src_addr_len; +} pj_ice_st_interface; + + +struct pj_ice_st +{ + char obj_name[PJ_MAX_OBJ_NAME]; + pj_pool_t *pool; + void *user_data; + pj_stun_config stun_cfg; + pj_ice_st_cb cb; + + pj_ice *ice; + + unsigned comp_cnt; + unsigned comps[PJ_ICE_MAX_COMP]; + + unsigned itf_cnt; + pj_ice_st_interface *itfs[PJ_ICE_MAX_CAND]; + + pj_dns_resolver *resolver; + pj_bool_t relay_enabled; + pj_str_t stun_domain; + pj_sockaddr_in stun_srv; +}; + + +PJ_DECL(pj_status_t) pj_ice_st_create(pj_stun_config *stun_cfg, + const char *name, + void *user_data, + const pj_ice_st_cb *cb, + pj_ice_st **p_ice_st); +PJ_DECL(pj_status_t) pj_ice_st_destroy(pj_ice_st *ice_st); + +PJ_DECL(pj_status_t) pj_ice_st_set_stun(pj_ice_st *ice_st, + pj_dns_resolver *resolver, + pj_bool_t enable_relay, + const pj_str_t *domain); +PJ_DECL(pj_status_t) pj_ice_st_set_stun_addr(pj_ice_st *ice_st, + pj_bool_t enable_relay, + const pj_sockaddr_in *srv_addr); + +PJ_DECL(pj_status_t) pj_ice_st_add_comp(pj_ice_st *ice_st, + unsigned comp_id); + +PJ_DECL(pj_status_t) pj_ice_st_add_host_interface(pj_ice_st *ice_st, + unsigned comp_id, + pj_uint16_t local_pref, + const pj_sockaddr_in *addr, + unsigned *p_itf_id, + pj_bool_t notify, + void *notify_data); +PJ_DECL(pj_status_t) pj_ice_st_add_all_host_interfaces(pj_ice_st *ice_st, + unsigned comp_id, + unsigned port, + pj_bool_t notify, + void *notify_data); +PJ_DECL(pj_status_t) pj_ice_st_add_stun_interface(pj_ice_st *ice_st, + unsigned comp_id, + unsigned local_port, + pj_bool_t notify, + void *notify_data); +PJ_DECL(pj_status_t) pj_ice_st_add_relay_interface(pj_ice_st *ice_st, + unsigned comp_id, + unsigned local_port, + pj_bool_t notify, + void *notify_data); + + +PJ_DECL(pj_status_t) pj_ice_st_init_ice(pj_ice_st *ice_st, + pj_ice_role role, + const pj_str_t *local_ufrag, + const pj_str_t *local_passwd); +PJ_DECL(pj_status_t) pj_ice_st_enum_cands(pj_ice_st *ice_st, + unsigned *count, + pj_ice_cand cand[]); +PJ_DECL(pj_status_t) pj_ice_st_start_ice(pj_ice_st *ice_st, + const pj_str_t *rem_ufrag, + const pj_str_t *rem_passwd, + unsigned rem_cand_cnt, + const pj_ice_cand rem_cand[]); +PJ_DECL(pj_status_t) pj_ice_st_stop_ice(pj_ice_st *ice_st); + +PJ_DECL(pj_status_t) pj_ice_st_send_data(pj_ice_st *ice_st, + unsigned comp_id, + const void *data, + pj_size_t data_len); + + +/** + * @} + */ + + +PJ_END_DECL + + + +#endif /* __PJNATH_ICE_STREAM_TRANSPORT_H__ */ + |