audio: sipe-media.c is purple-free
[siplcs.git] / src / api / sipe-media.h
blobf888a8918da9b5125135fed2f47b1edc4c9bdfb2
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 gpointer 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 gchar *sdp_response;
72 gboolean legacy_mode;
73 SipeCallState state;
75 void (*candidates_prepared_cb)(struct _sipe_media_call*);
76 void (*call_accept_cb)(struct _sipe_media_call*, gboolean local);
77 void (*call_reject_cb)(struct _sipe_media_call*, gboolean local);
78 void (*call_hold_cb) (struct _sipe_media_call*, gboolean local);
79 void (*call_unhold_cb)(struct _sipe_media_call*, gboolean local);
80 void (*call_hangup_cb)(struct _sipe_media_call*, gboolean local);
81 } sipe_media_call;
83 void sipe_media_incoming_invite(struct sipe_account_data *sip, struct sipmsg *msg);
85 void sipe_media_hangup(struct sipe_account_data *sip);
87 gchar *sipe_media_get_callid(sipe_media_call *call);
90 /* Backend functions **********************************************************/
92 sipe_media * sipe_backend_media_new(sipe_media_call *call, gpointer account,
93 gchar* participant, gboolean initiator);
95 gboolean sipe_backend_media_add_stream(sipe_media *media, gchar* participant,
96 SipeMediaType type, gboolean use_nice,
97 gboolean initiator);
99 void sipe_backend_media_add_remote_candidates(sipe_media *media, gchar* participant,
100 GList *candidates);
102 sipe_codec * sipe_backend_codec_new(int id, const char *name,
103 SipeMediaType type, guint clock_rate);
105 void sipe_backend_codec_free(sipe_codec *codec);
107 int sipe_backend_codec_get_id(sipe_codec *codec);
109 gchar * sipe_backend_codec_get_name(sipe_codec *codec);
111 guint sipe_backend_codec_get_clock_rate(sipe_codec *codec);
113 GList *sipe_backend_codec_get_optional_parameters(sipe_codec *codec);
115 gboolean sipe_backend_set_remote_codecs(sipe_media_call* call, gchar* participant);
117 GList* sipe_backend_get_local_codecs(sipe_media_call* call);
120 sipe_candidate * sipe_backend_candidate_new(const gchar *foundation,
121 SipeComponentType component,
122 SipeCandidateType type,
123 SipeNetworkProtocol proto,
124 const gchar *ip, guint port);
126 void sipe_backend_candidate_free(sipe_candidate *candidate);
128 gchar *sipe_backend_candidate_get_username(sipe_candidate *candidate);
129 gchar *sipe_backend_candidate_get_password(sipe_candidate *candidate);
130 gchar *sipe_backend_candidate_get_foundation(sipe_candidate *candidate);
131 gchar *sipe_backend_candidate_get_ip(sipe_candidate *candidate);
132 guint sipe_backend_candidate_get_port(sipe_candidate *candidate);
133 guint32 sipe_backend_candidate_get_priority(sipe_candidate *candidate);
134 void sipe_backend_candidate_set_priority(sipe_candidate *candidate, guint32 priority);
135 SipeComponentType sipe_backend_candidate_get_component_type(sipe_candidate *candidate);
136 SipeCandidateType sipe_backend_candidate_get_type(sipe_candidate *candidate);
137 SipeNetworkProtocol sipe_backend_candidate_get_protocol(sipe_candidate *candidate);
139 void sipe_backend_candidate_set_username_and_pwd(sipe_candidate *candidate,
140 const gchar *username,
141 const gchar *password);
143 GList* sipe_backend_get_local_candidates(sipe_media_call* call, gchar* participant);
145 void sipe_backend_media_hold(sipe_media* call, gboolean local);
146 void sipe_backend_media_unhold(sipe_media* call, gboolean local);
147 void sipe_backend_media_hangup(sipe_media* media, gboolean local);