summaryrefslogtreecommitdiff
path: root/src/jingle-content.h
blob: a9720ec8bc481aa4edf4c5183c6e7c69d9330f13 (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
 * jingle-content.h - Header for GabbleJingleContent
 * Copyright (C) 2008 Collabora Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef __JINGLE_CONTENT_H__
#define __JINGLE_CONTENT_H__

#include <glib-object.h>
#include "types.h"
#include "jingle-factory.h"
#include "jingle-transport-iface.h"

G_BEGIN_DECLS

typedef enum {
  JINGLE_MEDIA_TYPE_NONE = 0,
  JINGLE_MEDIA_TYPE_AUDIO,
  JINGLE_MEDIA_TYPE_VIDEO,
} JingleMediaType;

typedef enum {
  JINGLE_CONTENT_STATE_EMPTY = 0,
  JINGLE_CONTENT_STATE_NEW,
  JINGLE_CONTENT_STATE_SENT,
  JINGLE_CONTENT_STATE_ACKNOWLEDGED,
  JINGLE_CONTENT_STATE_REMOVING
} JingleContentState;

struct _JingleCandidate {
  JingleTransportProtocol protocol;
  JingleCandidateType type;

  gchar *id;
  gchar *address;
  int port;
  int component;
  int generation;

  int preference;
  gchar *username;
  gchar *password;
  int network;
};

typedef struct _GabbleJingleContentClass GabbleJingleContentClass;

GType gabble_jingle_content_get_type (void);

/* TYPE MACROS */
#define GABBLE_TYPE_JINGLE_CONTENT \
  (gabble_jingle_content_get_type ())
#define GABBLE_JINGLE_CONTENT(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_JINGLE_CONTENT, \
                              GabbleJingleContent))
#define GABBLE_JINGLE_CONTENT_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_JINGLE_CONTENT, \
                           GabbleJingleContentClass))
#define GABBLE_IS_JINGLE_CONTENT(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_JINGLE_CONTENT))
#define GABBLE_IS_JINGLE_CONTENT_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_JINGLE_CONTENT))
#define GABBLE_JINGLE_CONTENT_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_JINGLE_CONTENT, \
                              GabbleJingleContentClass))

struct _GabbleJingleContentClass {
    GObjectClass parent_class;

    void  (*parse_description) (GabbleJingleContent *, WockyNode *,
        GError **);
    void  (*produce_description) (GabbleJingleContent *, WockyNode *);
    void  (*transport_created) (GabbleJingleContent *,
        GabbleJingleTransportIface *);
    JingleContentSenders (*get_default_senders) (GabbleJingleContent *);
};

typedef struct _GabbleJingleContentPrivate GabbleJingleContentPrivate;

struct _GabbleJingleContent {
    GObject parent;
    GabbleJingleContentPrivate *priv;

    GabbleConnection *conn;
    GabbleJingleSession *session;
};

void gabble_jingle_content_parse_add (GabbleJingleContent *c,
    WockyNode *content_node, gboolean google_mode, GError **error);
void gabble_jingle_content_update_senders (GabbleJingleContent *c,
    WockyNode *content_node, GError **error);
void gabble_jingle_content_produce_node (GabbleJingleContent *c,
    WockyNode *parent,
    gboolean include_description,
    gboolean include_transport,
    WockyNode **trans_node_out);
void gabble_jingle_content_parse_accept (GabbleJingleContent *c,
  WockyNode *content_node, gboolean google_mode, GError **error);

void gabble_jingle_content_parse_info (GabbleJingleContent *c,
    WockyNode *content_node, GError **error);
void gabble_jingle_content_parse_transport_info (GabbleJingleContent *self,
  WockyNode *trans_node, GError **error);
void gabble_jingle_content_parse_description_info (GabbleJingleContent *self,
  WockyNode *trans_node, GError **error);
guint gabble_jingle_content_create_share_channel (GabbleJingleContent *self,
    const gchar *name);
void gabble_jingle_content_add_candidates (GabbleJingleContent *self, GList *li);
void _gabble_jingle_content_set_media_ready (GabbleJingleContent *self);
gboolean gabble_jingle_content_is_ready (GabbleJingleContent *self);
void gabble_jingle_content_set_transport_state (GabbleJingleContent *content,
    JingleTransportState state);
void gabble_jingle_content_remove (GabbleJingleContent *c, gboolean signal_peer);
void gabble_jingle_content_reject (GabbleJingleContent *c,
    JingleReason reason);

GList *gabble_jingle_content_get_remote_candidates (GabbleJingleContent *c);
GList *gabble_jingle_content_get_local_candidates (GabbleJingleContent *c);
gboolean gabble_jingle_content_get_credentials (GabbleJingleContent *c,
  gchar **ufrag, gchar **pwd);
gboolean gabble_jingle_content_change_direction (GabbleJingleContent *c,
    JingleContentSenders senders);
void gabble_jingle_content_retransmit_candidates (GabbleJingleContent *self,
    gboolean all);
void gabble_jingle_content_inject_candidates (GabbleJingleContent *self,
    WockyNode *transport_node);
gboolean gabble_jingle_content_is_created_by_us (GabbleJingleContent *c);
gboolean gabble_jingle_content_creator_is_initiator (GabbleJingleContent *c);

const gchar *gabble_jingle_content_get_name (GabbleJingleContent *self);
const gchar *gabble_jingle_content_get_ns (GabbleJingleContent *self);
const gchar *gabble_jingle_content_get_disposition (GabbleJingleContent *self);
JingleTransportType gabble_jingle_content_get_transport_type (GabbleJingleContent *c);
const gchar *gabble_jingle_content_get_transport_ns (GabbleJingleContent *self);

void gabble_jingle_content_maybe_send_description (GabbleJingleContent *self);

gboolean gabble_jingle_content_sending (GabbleJingleContent *self);
gboolean gabble_jingle_content_receiving (GabbleJingleContent *self);

void gabble_jingle_content_set_sending (GabbleJingleContent *self,
    gboolean send);
void gabble_jingle_content_request_receiving (GabbleJingleContent *self,
    gboolean receive);

void gabble_jingle_content_send_complete (GabbleJingleContent *self);

JingleMediaType jingle_media_type_from_tp (TpMediaStreamType type);
TpMediaStreamType jingle_media_type_to_tp (JingleMediaType type);

#endif /* __JINGLE_CONTENT_H__ */