summaryrefslogtreecommitdiff
path: root/gst/fsrtpconference/fs-rtp-session.h
blob: 006f82efa7cdaa4686837dfcfb1133d010b2d350 (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
/*
 * Farstream - Farstream RTP Session
 *
 * Copyright 2007 Collabora Ltd.
 *  @author: Olivier Crete <olivier.crete@collabora.co.uk>
 * Copyright 2007 Nokia Corp.
 *
 * fs-rtp-session.h - A Farstream RTP Session gobject
 *
 * 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_RTP_SESSION_H__
#define __FS_RTP_SESSION_H__

#include <gst/gst.h>

#include <farstream/fs-session.h>

#include "fs-rtp-conference.h"

G_BEGIN_DECLS

/* TYPE MACROS */
#define FS_TYPE_RTP_SESSION \
  (fs_rtp_session_get_type ())
#define FS_RTP_SESSION(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_RTP_SESSION, FsRtpSession))
#define FS_RTP_SESSION_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_RTP_SESSION, FsRtpSessionClass))
#define FS_IS_RTP_SESSION(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_RTP_SESSION))
#define FS_IS_RTP_SESSION_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_RTP_SESSION))
#define FS_RTP_SESSION_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_RTP_SESSION, FsRtpSessionClass))
#define FS_RTP_SESSION_CAST(obj) ((FsRtpSession *) (obj))

typedef struct _FsRtpSession FsRtpSession;
typedef struct _FsRtpSessionClass FsRtpSessionClass;
typedef struct _FsRtpSessionPrivate FsRtpSessionPrivate;

struct _FsRtpSessionClass
{
  FsSessionClass parent_class;
};

/**
 * FsRtpSession:
 *
 */
struct _FsRtpSession
{
  FsSession parent;

  /*< private >*/

  /* This ID can be accessed by the stream/substreams for this session */
  guint id;

  GMutex mutex; /* Should only be accessed using the macros */

#ifdef DEBUG_MUTEXES
  guint count;
#endif

  FsRtpSessionPrivate *priv;
};

#ifdef DEBUG_MUTEXES

#define FS_RTP_SESSION_LOCK(session) \
  do { \
    g_mutex_lock (&FS_RTP_SESSION (session)->mutex);   \
    g_assert (FS_RTP_SESSION (session)->count == 0);  \
    FS_RTP_SESSION (session)->count++;                \
  } while (0);
#define FS_RTP_SESSION_UNLOCK(session) \
  do { \
    g_assert (FS_RTP_SESSION (session)->count == 1);  \
    FS_RTP_SESSION (session)->count--;                \
    g_mutex_unlock (&FS_RTP_SESSION (session)->mutex); \
  } while (0);
#define FS_RTP_SESSION_GET_LOCK(session) \
  (&FS_RTP_SESSION (session)->mutex)
#else
#define FS_RTP_SESSION_LOCK(session) \
  g_mutex_lock (&(session)->mutex)
#define FS_RTP_SESSION_UNLOCK(session) \
  g_mutex_unlock (&(session)->mutex)
#define FS_RTP_SESSION_GET_LOCK(session) \
  (&(session)->mutex)
#endif


GType fs_rtp_session_get_type (void);

FsRtpSession *fs_rtp_session_new (FsMediaType media_type,
                                  FsRtpConference *conference,
                                  guint id, GError **error);

GstCaps *fs_rtp_session_request_pt_map (FsRtpSession *session, guint pt);


void fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
  guint32 ssrc, guint pt);

void fs_rtp_session_associate_ssrc_cname (FsRtpSession *session,
    guint32 ssrc,
    const gchar *cname);

void fs_rtp_session_bye_ssrc (FsRtpSession *session,
    guint32 ssrc);

void fs_rtp_session_ssrc_validated (FsRtpSession *session,
    guint32 ssrc);

gboolean fs_rtp_session_handle_dtmf_event_message (FsRtpSession *session,
    GstMessage *message);

/* Those two functions are for the EXCLUSIVE use of the other users
 * of the rtp session lock */
gboolean fs_rtp_session_has_disposed_enter (FsRtpSession *self, GError **error);
void fs_rtp_session_has_disposed_exit (FsRtpSession *self);

/* These functions are to be called from modules in their "new" method
 * or only when called from the session
 */
FsRtpConference *fs_rtp_session_get_conference (FsRtpSession *self);
GstPad *fs_rtp_session_get_rtpbin_recv_rtp_sink (FsRtpSession *self);
GstPad *fs_rtp_session_get_rtpbin_recv_rtcp_sink (FsRtpSession *self);
GObject *fs_rtp_session_get_rtpbin_internal_session (FsRtpSession *self);
GstElement *fs_rtp_session_get_rtpmuxer(FsRtpSession *self);

G_END_DECLS

#endif /* __FS_RTP_SESSION_H__ */