File: netclock-server.c

package info (click to toggle)
gstreamer1.0 1.28.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,676 kB
  • sloc: ansic: 203,122; python: 2,032; sh: 566; lex: 188; lisp: 154; java: 81; makefile: 59; cpp: 58; perl: 46
file content (59 lines) | stat: -rw-r--r-- 1,608 bytes parent folder | download | duplicates (6)
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
/* GStreamer
 * Copyright (C) 2014 Jan Schmidt <jan@centricular.com>
 *
 * netclock-server.c: Publish a network clock provider
 *
 * 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 St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */
#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <stdlib.h>
#include <gst/gst.h>
#include <gst/net/gstnettimeprovider.h>

gint
main (gint argc, gchar * argv[])
{
  GMainLoop *loop;
  GstClock *clock;
  GstNetTimeProvider *net_clock;
  int clock_port = 0;

  gst_init (&argc, &argv);

  if (argc > 1) {
    clock_port = atoi (argv[1]);
  }

  loop = g_main_loop_new (NULL, FALSE);

  clock = gst_system_clock_obtain ();
  net_clock = gst_net_time_provider_new (clock, NULL, clock_port);
  gst_object_unref (clock);

  g_object_get (net_clock, "port", &clock_port, NULL);

  g_print ("Published network clock on port %u\n", clock_port);

  g_main_loop_run (loop);

  /* cleanup */
  g_main_loop_unref (loop);

  return 0;
}