audio: fixes for call hangup/resume on both local and remote sides
[siplcs.git] / src / api / sipe-media.h
blobcf1ba66df7dcd24f399eeddb7c5be1fbc97875d1
1 /**
2 * @file sipe-media.h
4 * pidgin-sipe
6 * Copyright (C) 2010 Jakub Adam <jakub.adam@tieto.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 struct sipe_account_data;
25 typedef enum sipe_media_type {
26 SIPE_MEDIA_AUDIO,
27 SIPE_MEDIA_VIDEO
28 } SipeMediaType;
30 typedef enum sipe_call_state {
31 SIPE_CALL_CONNECTING,
32 SIPE_CALL_RUNNING,
33 SIPE_CALL_HELD,
34 SIPE_CALL_FINISHED
35 } SipeCallState;
37 typedef enum sipe_component_type {
38 SIPE_COMPONENT_NONE = 0,
39 SIPE_COMPONENT_RTP = 1,
40 SIPE_COMPONENT_RTCP = 2
41 } SipeComponentType;
43 typedef enum sipe_candidate_type {
44 SIPE_CANDIDATE_TYPE_HOST,
45 SIPE_CANDIDATE_TYPE_RELAY,
46 SIPE_CANDIDATE_TYPE_SRFLX
47 } SipeCandidateType;
49 typedef enum sipe_network_protocol {
50 SIPE_NETWORK_PROTOCOL_TCP,
51 SIPE_NETWORK_PROTOCOL_UDP
52 } SipeNetworkProtocol;
54 typedef gpointer sipe_media;
55 typedef gpointer sipe_codec;
56 typedef gpointer sipe_candidate;
58 typedef struct _sipe_media_call {
59 sipe_media media;
60 struct sipe_account_data *sip;
61 struct sip_session *session;
62 struct sip_dialog *dialog;
64 gchar *remote_ip;
65 guint16 remote_port;
67 GSList *sdp_attrs;
68 struct sipmsg *invitation;
69 GList *remote_candidates;
70 GList *remote_codecs;
71 gboolean legacy_mode;
73 gboolean local_on_hold;
74 gboolean remote_on_hold;
76 void (*candidates_prepared_cb)(struct _sipe_media_call*);
77 void (*media_connected_cb)(struct _sipe_media_call*);
78 void (*call_accept_cb)(struct _sipe_media_call*, gboolean local);
79 void (*call_reject_cb)(struct _sipe_media_call*, gboolean local);
80 void (*call_hold_cb) (struct _sipe_media_call*, gboolean local, gboolean state);
81 void (*call_hangup_cb)(struct _sipe_media_call*, gboolean local);
82 } sipe_media_call;
84 void sipe_media_initiate_call(struct sipe_account_data *sip, const char *participant);
86 void sipe_media_incoming_invite(struct sipe_account_data *sip, struct sipmsg *msg);
88 void sipe_media_hangup(struct sipe_account_data *sip);
90 gchar *sipe_media_get_callid(sipe_media_call *call);
93 /* Backend functions **********************************************************/
95 sipe_media * sipe_backend_media_new(sipe_media_call *call, const gchar* participant,
96 gboolean initiator);
98 gboolean sipe_backend_media_add_stream(sipe_media *media, const gchar* participant,
99 SipeMediaType type, gboolean use_nice,
100 gboolean initiator);
102 void sipe_backend_media_add_remote_candidates(sipe_media *media, gchar* participant,
103 GList *candidates);
105 gboolean sipe_backend_media_is_initiator(sipe_media *media, gchar *participant);
107 sipe_codec * sipe_backend_codec_new(int id, const char *name,
108 SipeMediaType type, guint clock_rate);
110 void sipe_backend_codec_free(sipe_codec *codec);
112 int sipe_backend_codec_get_id(sipe_codec *codec);
114 gchar * sipe_backend_codec_get_name(sipe_codec *codec);
116 guint sipe_backend_codec_get_clock_rate(sipe_codec *codec);
118 void sipe_backend_codec_add_optional_parameter(sipe_codec *codec,
119 const gchar *name, const gchar *value);
120 GList *sipe_backend_codec_get_optional_parameters(sipe_codec *codec);
122 gboolean sipe_backend_set_remote_codecs(sipe_media_call* call, gchar* participant);
124 GList* sipe_backend_get_local_codecs(sipe_media_call* call);
127 sipe_candidate * sipe_backend_candidate_new(const gchar *foundation,
128 SipeComponentType component,
129 SipeCandidateType type,
130 SipeNetworkProtocol proto,
131 const gchar *ip, guint port);
133 void sipe_backend_candidate_free(sipe_candidate *candidate);
135 gchar *sipe_backend_candidate_get_username(sipe_candidate *candidate);
136 gchar *sipe_backend_candidate_get_password(sipe_candidate *candidate);
137 gchar *sipe_backend_candidate_get_foundation(sipe_candidate *candidate);
138 gchar *sipe_backend_candidate_get_ip(sipe_candidate *candidate);
139 guint sipe_backend_candidate_get_port(sipe_candidate *candidate);
140 guint32 sipe_backend_candidate_get_priority(sipe_candidate *candidate);
141 void sipe_backend_candidate_set_priority(sipe_candidate *candidate, guint32 priority);
142 SipeComponentType sipe_backend_candidate_get_component_type(sipe_candidate *candidate);
143 SipeCandidateType sipe_backend_candidate_get_type(sipe_candidate *candidate);
144 SipeNetworkProtocol sipe_backend_candidate_get_protocol(sipe_candidate *candidate);
146 void sipe_backend_candidate_set_username_and_pwd(sipe_candidate *candidate,
147 const gchar *username,
148 const gchar *password);
150 GList* sipe_backend_get_local_candidates(sipe_media_call* call, gchar* participant);
152 void sipe_backend_media_hold(sipe_media* call, gboolean local);
153 void sipe_backend_media_unhold(sipe_media* call, gboolean local);
154 void sipe_backend_media_hangup(sipe_media* media, gboolean local);