Fixed #1207: Deprecation of pjmedia_session:

- add new APIs in stream so that app can use this directly instead of via session
 - moved some APIs from session to stream


git-svn-id: https://svn.pjsip.org/repos/pjproject/branches/projects/2.0-dev@3446 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Benny Prijono 2011-03-15 11:20:35 +00:00
parent 1641953c2d
commit fe74aec894
3 changed files with 51 additions and 12 deletions

View File

@ -88,7 +88,7 @@ typedef struct pjmedia_channel pjmedia_channel;
* corresponds to one "m=" line in SDP session descriptor, and it has
* its own RTP/RTCP socket pair.
*/
struct pjmedia_stream_info
typedef struct pjmedia_stream_info
{
pjmedia_type type; /**< Media type (audio, video) */
pjmedia_tp_proto proto; /**< Transport protocol (RTP/AVP, etc.) */
@ -134,13 +134,7 @@ struct pjmedia_stream_info
(see #PJMEDIA_STREAM_ENABLE_KA)
is enabled? */
#endif
};
/**
* @see pjmedia_stream_info.
*/
typedef struct pjmedia_stream_info pjmedia_stream_info;
} pjmedia_stream_info;
/**
@ -245,6 +239,17 @@ PJ_DECL(pjmedia_transport*) pjmedia_stream_get_transport(pjmedia_stream *st);
PJ_DECL(pj_status_t) pjmedia_stream_start(pjmedia_stream *stream);
/**
* Get the stream info.
*
* @param stream The media stream.
* @param info Stream info.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_stream_get_info( const pjmedia_stream *stream,
pjmedia_stream_info *info);
/**
* Get the stream statistics. See also
* #pjmedia_stream_get_stat_jbuf()

View File

@ -140,7 +140,7 @@ static void parse_fmtp( pj_pool_t *pool,
}
}
#if 0 // Moved to stream.c
/*
* Create stream info from SDP media line.
*/
@ -604,7 +604,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_info_from_sdp(
return PJ_SUCCESS;
}
#endif
/*
* Initialize session info from SDP session descriptors.

View File

@ -65,6 +65,13 @@
# define TRACE_JB_OPENED(s) (s->trace_jb_fd != TRACE_JB_INVALID_FD)
#endif
#ifndef PJMEDIA_STREAM_SIZE
# define PJMEDIA_STREAM_SIZE 1000
#endif
#ifndef PJMEDIA_STREAM_INC
# define PJMEDIA_STREAM_INC 1000
#endif
/**
@ -100,11 +107,13 @@ struct pjmedia_stream
{
pjmedia_endpt *endpt; /**< Media endpoint. */
pjmedia_codec_mgr *codec_mgr; /**< Codec manager instance. */
pjmedia_stream_info si; /**< Creation parameter. */
pjmedia_port port; /**< Port interface. */
pjmedia_channel *enc; /**< Encoding channel. */
pjmedia_channel *dec; /**< Decoding channel. */
pj_pool_t *own_pool; /**< Only created if not given */
pjmedia_dir dir; /**< Stream direction. */
void *user_data; /**< User data. */
pj_str_t cname; /**< SDES CNAME */
@ -1943,15 +1952,26 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
pj_str_t name;
unsigned jb_init, jb_max, jb_min_pre, jb_max_pre, len;
pjmedia_audio_format_detail *afd;
pj_pool_t *own_pool = NULL;
char *p;
pj_status_t status;
PJ_ASSERT_RETURN(pool && info && p_stream, PJ_EINVAL);
PJ_ASSERT_RETURN(endpt && info && p_stream, PJ_EINVAL);
if (pool == NULL) {
own_pool = pjmedia_endpt_create_pool( endpt, "strm%p",
PJMEDIA_STREAM_SIZE,
PJMEDIA_STREAM_INC);
PJ_ASSERT_RETURN(own_pool != NULL, PJ_ENOMEM);
pool = own_pool;
}
/* Allocate the media stream: */
stream = PJ_POOL_ZALLOC_T(pool, pjmedia_stream);
PJ_ASSERT_RETURN(stream != NULL, PJ_ENOMEM);
stream->own_pool = own_pool;
pj_memcpy(&stream->si, info, sizeof(*info));
/* Init stream/port name */
name.ptr = (char*) pj_pool_alloc(pool, M);
@ -2442,6 +2462,11 @@ PJ_DEF(pj_status_t) pjmedia_stream_destroy( pjmedia_stream *stream )
}
#endif
if (stream->own_pool) {
pj_pool_t *pool = stream->own_pool;
stream->own_pool = NULL;
pj_pool_release(pool);
}
return PJ_SUCCESS;
}
@ -2495,6 +2520,15 @@ PJ_DEF(pj_status_t) pjmedia_stream_start(pjmedia_stream *stream)
}
PJ_DEF(pj_status_t) pjmedia_stream_get_info( const pjmedia_stream *stream,
pjmedia_stream_info *info)
{
PJ_ASSERT_RETURN(stream && info, PJ_EINVAL);
pj_memcpy(info, &stream->si, sizeof(pjmedia_stream_info));
return PJ_SUCCESS;
}
/*
* Get stream statistics.
*/