2 * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
3 * Copyright (C) 2017 Robert Rosengren <robertr@axis.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
25 #include "gstnetutils.h"
26 #include <gst/gstinfo.h>
29 #ifdef HAVE_SYS_SOCKET_H
30 #include <sys/socket.h>
34 #include <netinet/in.h>
38 * gst_net_time_packet_util_set_dscp:
39 * @socket: Socket to configure
40 * @qos_dscp: QoS DSCP value
42 * Configures IP_TOS value of socket, i.e. sets QoS DSCP.
44 * Returns: TRUE if successful, FALSE in case an error occurred.
47 gst_net_utils_set_socket_dscp (GSocket * socket, gint qos_dscp)
53 fd = g_socket_get_fd (socket);
55 /* Extract and shift 6 bits of DSFIELD */
56 tos = (qos_dscp & 0x3f) << 2;
58 if (setsockopt (fd, IPPROTO_IP, IP_TOS, &tos, sizeof (tos)) < 0) {
59 GST_ERROR ("could not set TOS: %s", g_strerror (errno));