2 * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include <glib-unix.h>
23 #include <gst/rtsp-server/rtsp-server-wfd.h>
24 #include <gst/rtsp-server/rtsp-media-factory-wfd.h>
27 #define VIDEO_PIPELINE "ximagesrc ! videorate ! videoscale ! videoconvert ! " \
28 "video/x-raw,width=640,height=480,framerate=30/1 ! " \
29 "x264enc aud=false byte-stream=true bitrate=512 ! video/x-h264,profile=baseline ! mpegtsmux wfd-mode=TRUE ! " \
30 "rtpmp2tpay name=pay0 pt=33"
31 #define AUDIO_PIPELINE "pulsesrc device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor ! audioconvert ! " \
32 "faac ! mpegtsmux wfd-mode=TRUE ! " \
33 "rtpmp2tpay name=pay0 pt=33"
35 #define VIDEO_PIPELINE "ximagesrc ! videoscale ! videoconvert ! " \
36 "video/x-raw,width=640,height=480,framerate=60/1 ! " \
37 "x264enc aud=false byte-stream=true bitrate=512 ! video/x-h264,profile=baseline ! mpegtsmux name=mux " \
38 "pulsesrc device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor ! audioconvert ! " \
39 "faac ! mux. mux. ! " \
40 "rtpmp2tpay name=pay0 pt=33"
42 #define VIDEO_PIPELINE "ximagesrc startx=0 starty=0 endx=1919 endy=1079 ! videorate ! videoscale ! video/x-raw,width=1280,height=720,framerate=30/1 ! videoconvert ! " \
43 "x264enc aud=false byte-stream=true bitrate=512 ! video/x-h264,profile=baseline ! mpegtsmux name=mux wfd-mode=TRUE " \
44 "pulsesrc device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor ! audioconvert ! " \
45 "faac ! mux. mux. ! " \
46 "rtpmp2tpay name=pay0 pt=33"
49 #define VIDEO_PIPELINE "ximagesrc do-timestamp=true ! videoscale ! video/x-raw,width=1280,height=720,framerate=30/1 ! videoconvert ! " \
50 "x264enc aud=false byte-stream=true bitrate=512 ! video/x-h264,profile=baseline ! mpegtsmux name=mux wfd-mode=TRUE " \
51 "pulsesrc device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor provide-clock=false ! audioconvert ! " \
52 "faac ! mux. mux. ! " \
53 "rtpmp2tpay name=pay0 pt=33"
57 #define WFD_RTSP_PORT "2022"
58 #define TEST_MOUNT_POINT "/wfd1.0/streamid=0"
63 teardown(gpointer data)
65 GstRTSPWFDServer *server = NULL;
66 server = (GstRTSPWFDServer *) data;
68 g_print("teardown\n");
70 if (server == NULL) return FALSE;
72 gst_rtsp_wfd_server_trigger_request (GST_RTSP_SERVER(server), WFD_TRIGGER_TEARDOWN);
77 int main (int argc, char *argv[])
79 GstRTSPWFDServer *server;
81 GstRTSPMountPoints *mounts;
82 GstRTSPMediaFactoryWFD *factory;
83 GMainContext *context = NULL;
84 GSource * signal_handler_src = NULL;
86 gst_init (&argc, &argv);
88 loop = g_main_loop_new (NULL, FALSE);
89 context = g_main_loop_get_context(loop);
91 /* create a server instance */
92 server = gst_rtsp_wfd_server_new ();
94 gst_rtsp_server_set_address(GST_RTSP_SERVER(server), "192.168.3.100");
95 //gst_rtsp_server_set_address(GST_RTSP_SERVER(server), "192.168.49.194");
96 //gst_rtsp_server_set_address(GST_RTSP_SERVER(server), "192.168.49.20");
97 gst_rtsp_server_set_service(GST_RTSP_SERVER(server), WFD_RTSP_PORT);
98 mounts = gst_rtsp_server_get_mount_points (GST_RTSP_SERVER(server));
100 factory = gst_rtsp_media_factory_wfd_new ();
102 gst_rtsp_media_factory_set_launch (GST_RTSP_MEDIA_FACTORY(factory),
103 "( " VIDEO_PIPELINE " )");
104 g_object_ref (factory);
105 gst_rtsp_mount_points_add_factory (mounts, TEST_MOUNT_POINT, GST_RTSP_MEDIA_FACTORY(factory));
106 g_object_unref (mounts);
108 /* attach the server to the default maincontext */
109 if ((id = gst_rtsp_server_attach (GST_RTSP_SERVER_CAST(server), NULL)) == 0)
112 signal_handler_src = (GSource *)g_unix_signal_source_new (SIGINT);
113 /* Set callback to be called when socket is readable */
114 g_source_set_callback(signal_handler_src, teardown, server, NULL);
115 g_source_attach(signal_handler_src, context);
118 g_main_loop_run (loop);
121 g_source_remove (id);
122 g_object_unref (server);
123 g_main_loop_unref (loop);
130 g_print ("failed to attach the server\n");