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
|
/* GStreamer Streaming Server
* Copyright (C) 2009-2012 Entropy Wave Inc <info@entropywave.com>
* Copyright (C) 2009-2012 David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library 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.
*/
#include "config.h"
#include "gss-rtsp.h"
#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>
/**
* SECTION:gss-rtsp
* @short_description: Misc RTSP junk that's probably bitrotten
*
*/
void
gss_server_rtsp_init (GssServer * server)
{
server->rtsp_server = gst_rtsp_server_new ();
if (getuid () == 0) {
gst_rtsp_server_set_service (server->rtsp_server, "554");
} else {
gst_rtsp_server_set_service (server->rtsp_server, "8554");
}
}
GssRtspStream *
gss_rtsp_stream_new (GssStream * stream)
{
GssRtspStream *rtsp_stream;
rtsp_stream = g_new0 (GssRtspStream, 1);
rtsp_stream->stream = stream;
rtsp_stream->server = GSS_OBJECT_SERVER (stream->program)->rtsp_server;
return rtsp_stream;
}
void
gss_rtsp_stream_free (GssRtspStream * rtsp_stream)
{
g_free (rtsp_stream);
}
void
gss_rtsp_stream_start (GssRtspStream * rtsp_stream)
{
GstRTSPMountPoints *mounts;
GString *pipe_desc;
int pipe_fds[2];
int ret;
ret = pipe (pipe_fds);
if (ret < 0) {
return;
}
pipe_desc = g_string_new ("");
g_string_append (pipe_desc, "( ");
g_string_append_printf (pipe_desc, "fdsrc fd=%d name=src ! ", pipe_fds[0]);
g_string_append (pipe_desc, "oggdemux name=demux ! ");
g_string_append (pipe_desc, "queue ! rtptheorapay name=pay0 pt=96 ");
g_string_append (pipe_desc, "demux. ! queue ! rtpvorbispay name=pay1 pt=97 ");
g_string_append (pipe_desc, ")");
GST_DEBUG ("%s", pipe_desc->str);
rtsp_stream->factory = gst_rtsp_media_factory_new ();
gst_rtsp_media_factory_set_launch (rtsp_stream->factory, pipe_desc->str);
g_string_free (pipe_desc, FALSE);
mounts = gst_rtsp_server_get_mount_points (rtsp_stream->server);
gst_rtsp_mount_points_add_factory (mounts, "/stream", rtsp_stream->factory);
g_object_unref (mounts);
g_signal_emit_by_name (rtsp_stream->stream->sink, "add", pipe_fds[1]);
gst_rtsp_server_attach (rtsp_stream->server, NULL);
}
|