summaryrefslogtreecommitdiff
path: root/pjmedia/src/pjmedia/session.h
blob: d9efeb81b734310300804b182ad5783ad9a759b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* $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_SESSION_H__
#define __PJMEDIA_SESSION_H__


/**
 * @file session.h
 * @brief Media Session.
 */

#include <pj/types.h>
#include <pjmedia/mediamgr.h>
#include <pjmedia/stream.h>
#include <pjmedia/sdp.h>

PJ_BEGIN_DECL 

/**
 * @defgroup PJMED_SES Media session
 * @ingroup PJMEDIA
 * @{
 */

/** Opaque declaration of media session. */
typedef struct pj_media_session_t pj_media_session_t;

/** Media socket info. */
typedef struct pj_media_sock_info
{
    pj_sock_t	    rtp_sock, rtcp_sock;
    pj_sockaddr_in  rtp_addr_name;
} pj_media_sock_info;

/** Stream info. */
typedef struct pj_media_stream_info
{
    pj_str_t		type;
    pj_media_dir_t	dir;
    pj_str_t		transport;
    pj_media_sock_info	sock_info;
    pj_str_t		rem_addr;
    unsigned short	rem_port;
    unsigned		fmt_cnt;
    pj_codec_id		fmt[PJSDP_MAX_FMT];

} pj_media_stream_info;

/** Flag for modifying stream. */
enum
{
    PJ_MEDIA_STREAM_MODIFY_DIR = 1,
};

/**
 * Create new session offering.
 */
PJ_DECL(pj_media_session_t*) 
pj_media_session_create ( pj_med_mgr_t *mgr, const pj_media_sock_info *skinfo );

/**
 * Create new session based on peer's offering.
 */
PJ_DECL(pj_media_session_t*) 
pj_media_session_create_from_sdp ( pj_med_mgr_t *mgr, const pjsdp_session_desc *sdp,
				   const pj_media_sock_info *skinfo);

/**
 * Duplicate session. The new session is inactive.
 */
PJ_DECL(pj_media_session_t*)
pj_media_session_clone (const pj_media_session_t *session);

/**
 * Create SDP description from the session.
 */
PJ_DECL(pjsdp_session_desc*)
pj_media_session_create_sdp ( const pj_media_session_t *session, pj_pool_t *pool,
			      pj_bool_t only_first_fmt);

/**
 * Update session with SDP answer from peer. The session must NOT active.
 */
PJ_DECL(pj_status_t)
pj_media_session_update ( pj_media_session_t *session, 
			  const pjsdp_session_desc *sdp);

/**
 * Enumerate media streams in the session.
 * @return the actual number of streams.
 */
PJ_DECL(unsigned)
pj_media_session_enum_streams (const pj_media_session_t *session, 
			       unsigned count, const pj_media_stream_info *info[]);

/**
 * Get stream statistics.
 */
PJ_DECL(pj_status_t)
pj_media_session_get_stat (const pj_media_session_t *session, unsigned index,
			   pj_media_stream_stat *tx_stat,
			   pj_media_stream_stat *rx_stat);

/**
 * Modify stream, only when stream is inactive.
 */
PJ_DECL(pj_status_t)
pj_media_session_modify_stream (pj_media_session_t *session, unsigned index,
				unsigned modify_flag, const pj_media_stream_info *info);

/**
 * Activate all streams in media session.
 */
PJ_DECL(pj_status_t)
pj_media_session_activate (pj_media_session_t *session);

/**
 * Activate individual stream in media session.
 */
PJ_DECL(pj_status_t)
pj_media_session_activate_stream (pj_media_session_t *session, unsigned index);

/**
 * Destroy media session.
 */
PJ_DECL(pj_status_t)
pj_media_session_destroy (pj_media_session_t *session);


/**
 * @}
 */

PJ_END_DECL

#endif	/* __PJMEDIA_SESSION_H__ */