diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-05-17 17:17:39 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-05-17 17:17:39 +0000 |
commit | 1b3863ac6dcae1a7bed7e0b0cb6a2f482c093989 (patch) | |
tree | 8ead72c61a60697246ab48fde099fb063c3fbaff /pjmedia/include | |
parent | 79e6d6ac5ae27d653d1724059f081a6be1c39b7e (diff) |
Major modification in pjmedia to split stream transport into separate functionality, to allow using custom transports with streams
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@452 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia/include')
-rw-r--r-- | pjmedia/include/pjmedia.h | 1 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/session.h | 18 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/stream.h | 94 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/transport_udp.h | 59 |
4 files changed, 157 insertions, 15 deletions
diff --git a/pjmedia/include/pjmedia.h b/pjmedia/include/pjmedia.h index c0869e9d..9e363769 100644 --- a/pjmedia/include/pjmedia.h +++ b/pjmedia/include/pjmedia.h @@ -43,6 +43,7 @@ #include <pjmedia/sdp_neg.h> #include <pjmedia/silencedet.h> #include <pjmedia/session.h> +#include <pjmedia/transport_udp.h> #include <pjmedia/sound.h> #include <pjmedia/sound_port.h> #include <pjmedia/wav_port.h> diff --git a/pjmedia/include/pjmedia/session.h b/pjmedia/include/pjmedia/session.h index c93d4343..38fe1e2c 100644 --- a/pjmedia/include/pjmedia/session.h +++ b/pjmedia/include/pjmedia/session.h @@ -88,10 +88,6 @@ typedef struct pjmedia_session_info pjmedia_session_info; * @param endpt Pjmedia endpoint. * @param max_streams Maximum number of stream infos to be created. * @param si Session info structure to be initialized. - * @param skinfo Optional array of media socket info to be copied - * to the stream info. If this argument is specified, - * the array must contain sufficient elements for - * each stream to be initialized. * @param local Local SDP session descriptor. * @param remote Remote SDP session descriptor. * @param stream_idx Media stream index in the session descriptor. @@ -103,7 +99,6 @@ pjmedia_session_info_from_sdp( pj_pool_t *pool, pjmedia_endpt *endpt, unsigned max_streams, pjmedia_session_info *si, - const pjmedia_sock_info skinfo[], const pjmedia_sdp_session *local, const pjmedia_sdp_session *remote); @@ -118,7 +113,6 @@ pjmedia_session_info_from_sdp( pj_pool_t *pool, * @param si Stream info structure to be initialized. * @param pool Pool to allocate memory. * @param endpt PJMEDIA endpoint instance. - * @param skinfo Optional socket info to be copied to the stream info. * @param local Local SDP session descriptor. * @param remote Remote SDP session descriptor. * @param stream_idx Media stream index in the session descriptor. @@ -129,7 +123,6 @@ PJ_DECL(pj_status_t) pjmedia_stream_info_from_sdp( pjmedia_stream_info *si, pj_pool_t *pool, pjmedia_endpt *endpt, - const pjmedia_sock_info *skinfo, const pjmedia_sdp_session *local, const pjmedia_sdp_session *remote, unsigned stream_idx); @@ -145,11 +138,11 @@ pjmedia_stream_info_from_sdp( pjmedia_stream_info *si, * no media frames transmitted or received by the session. * * @param endpt The PJMEDIA endpoint instance. - * @param stream_cnt Maximum number of streams to be created. This - * also denotes the number of elements in the - * socket information. - * @param local_sdp The SDP describing local capability. - * @param rem_sdp The SDP describing remote capability. + * @param si Session info containing stream count and array of + * stream info. The stream count indicates how many + * streams to be created in the session. + * @param transports Array of media stream transports, with + * sufficient number of elements (one for each stream). * @param user_data Arbitrary user data to be kept in the session. * @param p_session Pointer to receive the media session. * @@ -159,6 +152,7 @@ pjmedia_stream_info_from_sdp( pjmedia_stream_info *si, PJ_DECL(pj_status_t) pjmedia_session_create( pjmedia_endpt *endpt, const pjmedia_session_info *si, + pjmedia_transport *transports[], void *user_data, pjmedia_session **p_session ); diff --git a/pjmedia/include/pjmedia/stream.h b/pjmedia/include/pjmedia/stream.h index 335a40e2..94101d46 100644 --- a/pjmedia/include/pjmedia/stream.h +++ b/pjmedia/include/pjmedia/stream.h @@ -69,7 +69,6 @@ struct pjmedia_stream_info { pjmedia_type type; /**< Media type (audio, video) */ pjmedia_dir dir; /**< Media direction. */ - pjmedia_sock_info sock_info; /**< Media transport (RTP/RTCP sockets) */ pj_sockaddr_in rem_addr; /**< Remote RTP address */ pjmedia_codec_info fmt; /**< Incoming codec format info. */ pjmedia_codec_param *param; /**< Optional codec param. */ @@ -100,6 +99,80 @@ typedef struct pjmedia_stream pjmedia_stream; /** + * @see pjmedia_transport_op. + */ +typedef struct pjmedia_transport pjmedia_transport; + + +/** + * This structure describes the operations for the stream transport. + */ +struct pjmedia_transport_op +{ + /** + * This function is called by the stream when the transport is about + * to be used by the stream for the first time, and it tells the transport + * about remote RTP address to send the packet and some callbacks to be + * called for incoming packets. + */ + pj_status_t (*attach)(pjmedia_transport *tp, + pjmedia_stream *strm, + const pj_sockaddr_t *rem_addr, + unsigned addr_len, + void (*rtp_cb)(pjmedia_stream*, + const void*, + pj_ssize_t), + void (*rtcp_cb)(pjmedia_stream*, + const void*, + pj_ssize_t)); + + /** + * This function is called by the stream when the stream is no longer + * need the transport (normally when the stream is about to be closed). + */ + void (*detach)(pjmedia_transport *tp, + pjmedia_stream *strm); + + /** + * This function is called by the stream to send RTP packet using the + * transport. + */ + pj_status_t (*send_rtp)(pjmedia_transport *tp, + const void *pkt, + pj_size_t size); + + /** + * This function is called by the stream to send RTCP packet using the + * transport. + */ + pj_status_t (*send_rtcp)(pjmedia_transport *tp, + const void *pkt, + pj_size_t size); + +}; + + +/** + * @see pjmedia_transport_op. + */ +typedef struct pjmedia_transport_op pjmedia_transport_op; + + +/** + * This structure declares stream transport. A stream transport is called + * by the stream to transmit a packet, and will notify stream when + * incoming packet is arrived. + */ +struct pjmedia_transport +{ + char name[PJ_MAX_OBJ_NAME]; + + pjmedia_transport_op *op; +}; + + + +/** * Create a media stream based on the specified parameter. After the stream * has been created, application normally would want to get the media port * interface of the streams, by calling pjmedia_stream_get_port(). The @@ -114,6 +187,9 @@ typedef struct pjmedia_stream pjmedia_stream; * number of memory may be needed because jitter * buffer needs to preallocate some storage. * @param info Stream information. + * @param tp Stream transport instance used to transmit + * and receive RTP/RTCP packets to/from the underlying + * transport. * @param user_data Arbitrary user data (for future callback feature). * @param p_stream Pointer to receive the media stream. * @@ -122,6 +198,7 @@ typedef struct pjmedia_stream pjmedia_stream; PJ_DECL(pj_status_t) pjmedia_stream_create(pjmedia_endpt *endpt, pj_pool_t *pool, const pjmedia_stream_info *info, + pjmedia_transport *tp, void *user_data, pjmedia_stream **p_stream); @@ -151,6 +228,16 @@ PJ_DECL(pj_status_t) pjmedia_stream_get_port(pjmedia_stream *stream, /** + * Get the media transport object associated with this stream. + * + * @param st The media stream. + * + * @return The transport object being used by the stream. + */ +PJ_DECL(pjmedia_transport*) pjmedia_stream_get_transport(pjmedia_stream *st); + + +/** * Start the media stream. This will start the appropriate channels * in the media stream, depending on the media direction that was set * when the stream was created. @@ -224,8 +311,9 @@ PJ_DECL(pj_bool_t) pjmedia_stream_check_dtmf(pjmedia_stream *stream); /** - * Retrieve the incoming DTMF digits from the stream. Note that the digits - * buffer will not be NULL terminated. + * Retrieve the incoming DTMF digits from the stream, and remove the digits + * from stream's DTMF buffer. Note that the digits buffer will not be NULL + * terminated. * * @param stream The media stream. * @param ascii_digits Buffer to receive the digits. The length of this diff --git a/pjmedia/include/pjmedia/transport_udp.h b/pjmedia/include/pjmedia/transport_udp.h new file mode 100644 index 00000000..a84da98c --- /dev/null +++ b/pjmedia/include/pjmedia/transport_udp.h @@ -0,0 +1,59 @@ +/* $Id$ */ +/* + * Copyright (C) 2003-2006 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 __PJMEDIA_TRANSPORT_UDP_H__ +#define __PJMEDIA_TRANSPORT_UDP_H__ + + +/** + * @file stream_transport_udp.h + * @brief Stream transport with UDP. + */ + +#include <pjmedia/stream.h> + + +/** + * Create UDP stream transport. + */ +PJ_DECL(pj_status_t) pjmedia_transport_udp_create(pjmedia_endpt *endpt, + const char *name, + int port, + pjmedia_transport **p_tp); + + +/** + * Create UDP stream transport from existing socket info. + */ +PJ_DECL(pj_status_t) pjmedia_transport_udp_attach(pjmedia_endpt *endpt, + const char *name, + const pjmedia_sock_info *si, + pjmedia_transport **p_tp); + + +/** + * Close UDP transport. + */ +PJ_DECL(pj_status_t) pjmedia_transport_udp_close(pjmedia_transport *tp); + + + + +#endif /* __PJMEDIA_TRANSPORT_UDP_H__ */ + + |