summaryrefslogtreecommitdiff
path: root/farstream/fs-stream.h
blob: 38650d830704b1cfe98269ef877a4eb94a451186 (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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
 * Farstream - Farstream Stream
 *
 * Copyright 2007 Collabora Ltd.
 *  @author: Philippe Kalaf <philippe.kalaf@collabora.co.uk>
 * Copyright 2007 Nokia Corp.
 *
 * fs-stream.h - A Farstream Stream (base implementation)
 *
 * 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 Street, Fifth Floor, Boston, MA  02110-1301 USA
 */

#ifndef __FS_STREAM_H__
#define __FS_STREAM_H__

#include <glib.h>
#include <glib-object.h>

#include <farstream/fs-candidate.h>
#include <farstream/fs-codec.h>

G_BEGIN_DECLS

/**
 * FsStreamDirection:
 * @FS_DIRECTION_NONE: No direction specified
 * @FS_DIRECTION_SEND: Send only
 * @FS_DIRECTION_RECV: Receive only
 * @FS_DIRECTION_BOTH: Send and receive
 *
 * An enum for specifying the direction of a stream
 *
 */
typedef enum
{
  FS_DIRECTION_NONE = 0,
  FS_DIRECTION_SEND = 1<<0,
  FS_DIRECTION_RECV = 1<<1,
  FS_DIRECTION_BOTH = FS_DIRECTION_SEND | FS_DIRECTION_RECV
} FsStreamDirection;

/**
 * FsStreamState:
 * @FS_STREAM_STATE_FAILED: connectivity checks have been completed,
 *                          but connectivity was not established
 * @FS_STREAM_STATE_DISCONNECTED: no activity scheduled
 * @FS_STREAM_STATE_GATHERING: gathering local candidates
 * @FS_STREAM_STATE_CONNECTING: establishing connectivity
 * @FS_STREAM_STATE_CONNECTED: at least one working candidate pair
 * @FS_STREAM_STATE_READY: ICE concluded, candidate pair selection is now final
 *
 * These are the possible states of a stream, a simple multicast stream
 * could only be in "disconnected" or "ready" state.
 * An stream using an ICE transmitter would use all of these.
 */

typedef enum
{
  FS_STREAM_STATE_FAILED,
  FS_STREAM_STATE_DISCONNECTED,
  FS_STREAM_STATE_GATHERING,
  FS_STREAM_STATE_CONNECTING,
  FS_STREAM_STATE_CONNECTED,
  FS_STREAM_STATE_READY
} FsStreamState;

/* TYPE MACROS */
#define FS_TYPE_STREAM \
  (fs_stream_get_type ())
#define FS_STREAM(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_STREAM, FsStream))
#define FS_STREAM_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_STREAM, FsStreamClass))
#define FS_IS_STREAM(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_STREAM))
#define FS_IS_STREAM_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_STREAM))
#define FS_STREAM_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_STREAM, FsStreamClass))
#define FS_STREAM_CAST(obj) ((FsStream *) (obj))

typedef struct _FsStream FsStream;
typedef struct _FsStreamClass FsStreamClass;
typedef struct _FsStreamPrivate FsStreamPrivate;


/**
 * FsStreamClass:
 * @parent_class: Our parent
 * @add_remote_candidates: Set sthe remote candidates
 * @force_remote_candidates: Forces certain remote candidates
 * @set_remote_codecs: Sets the list of remote codecs
 * @add_id: Add a known id to be associated with this stream
 * @set_transmitter: Set the transmitter to use for this stream
 * @set_decryption_parameters: Set decryption parameters
 *
 * You must override add_remote_candidate in a subclass.
 * If you have to negotiate codecs, then you must override set_remote_codecs too
 */

struct _FsStreamClass
{
  GObjectClass parent_class;

  /*virtual functions */
  gboolean (*add_remote_candidates) (FsStream *stream,
                                     GList *candidates,
                                     GError **error);

  gboolean (*force_remote_candidates) (FsStream *stream,
      GList *remote_candidates,
      GError **error);

  gboolean (*set_remote_codecs) (FsStream *stream,
                                 GList *remote_codecs, GError **error);

  void (*add_id) (FsStream *stream,
                  guint id);

  gboolean (*set_transmitter) (FsStream *stream,
      const gchar *transmitter,
      GParameter *stream_transmitter_parameters,
      guint stream_transmitter_n_parameters,
      GError **error);

  gboolean (* set_decryption_parameters) (FsStream *stream,
      GstStructure *parameters, GError **error);

  /*< private >*/
  gpointer _padding[7];
};

/**
 * FsStream:
 *
 * All members are private, access them using methods and properties
 */
struct _FsStream
{
  GObject parent;

  /*< private >*/

  FsStreamPrivate *priv;

  gpointer _padding[8];
};

GType fs_stream_get_type (void);

gboolean fs_stream_add_remote_candidates (FsStream *stream,
                                          GList *candidates,
                                          GError **error);

gboolean fs_stream_force_remote_candidates (FsStream *stream,
    GList *remote_candidates,
    GError **error);

gboolean fs_stream_set_remote_codecs (FsStream *stream,
                                      GList *remote_codecs, GError **error);

void fs_stream_add_id (FsStream *stream, guint id);

void fs_stream_emit_error (FsStream *stream,
    gint error_no,
    const gchar *error_msg);

void fs_stream_emit_src_pad_added (FsStream *stream,
    GstPad *pad,
    FsCodec *codec);

GstIterator *fs_stream_iterate_src_pads (FsStream *stream);

gboolean fs_stream_set_transmitter (FsStream *stream,
    const gchar *transmitter,
    GParameter *stream_transmitter_parameters,
    guint stream_transmitter_n_parameters,
    GError **error);

gboolean fs_stream_set_transmitter_ht (FsStream *stream,
    const gchar *transmitter,
    GHashTable *stream_transmitter_parameters,
    GError **error);

gboolean fs_stream_set_decryption_parameters (FsStream *stream,
    GstStructure *parameters, GError **error);

void fs_stream_destroy (FsStream *stream);

gboolean fs_stream_parse_new_local_candidate (FsStream *stream,
    GstMessage *message,
    FsCandidate **candidate);
gboolean fs_stream_parse_local_candidates_prepared (FsStream *stream,
    GstMessage *message);
gboolean fs_stream_parse_new_active_candidate_pair (FsStream *stream,
    GstMessage *message,
    FsCandidate **local_candidate,
    FsCandidate **remote_candidate);
gboolean fs_stream_parse_recv_codecs_changed (FsStream *stream,
    GstMessage *message,
    GList **codecs);
gboolean fs_stream_parse_component_state_changed (FsStream *stream,
    GstMessage *message,
    guint *component,
    FsStreamState *state);


G_END_DECLS

#endif /* __FS_STREAM_H__ */