Clock Synchronization
Trenton Miller
tmiller at emacinc.com
Tue Sep 5 23:06:28 UTC 2017
Hello,
Project Description:
Streaming live audio over a point-to-point network (WiFi, 2.4GHz) using
UDP/RTP.
Attributes of highest priority:
Audio quality (44.1KHz at 16bits)
Latency (< 30 ms)
Currently, the application successfully streams audio between host and
target via WiFi with an initial latency (delay) in the range of 160 - 20 ms
between host (input) and target (output). Aside from the initial delay, the
latency will slowly increase (latency_drift, ~ 30 ms / min).
I have been attempting to synchronize the host and target pipeline clocks
in the hope that it will stabilize the initial_latency and eliminate the
latency_drift. However, I have been unsuccessful.
I have attempted to synchronize the pipeline clocks by implementing the
GstNetTimeProvider and GstNetClientClock structures. I'm not sure if this
method requires the use of the GstRTSPServer and GstRTSPMediaFactory
structures or not. Audio failed to stream after implementation.
I added the GstRTSPServer and GstRTSPMediaFactory structures to the
previous implementation, using the following programs as a guide:
https://cgit.freedesktop.org/gstreamer/gst-rtsp-server/tree/examples/test-netclock.c
https://cgit.freedesktop.org/gstreamer/gst-rtsp-server/tree/examples/test-netclock-client.c
Audio failed to stream after implementation.
Below is a snippet of the host application:
main_loop = g_main_loop_new (NULL, FALSE);
data.loop = main_loop;
data.pipe = pipe;
clock = gst_system_clock_obtain();
gst_net_time_provider_new(clock, "192.168.1.2", 5000);
/* create a server instance */
server = gst_rtsp_server_new ();
mounts = gst_rtsp_server_get_mount_points (server);
factory = gst_rtsp_media_factory_new ();
gst_rtsp_media_factory_set_launch (factory, "alsasrc buffer-time=200000
latency-time=5000
provide-clock=fasle ! audioconvert ! audio/x-raw,
channels=1,
depth=16, width=16, rate=44100 !
rtpL16pay ! udpsink host=192.168.1.1
port=5000");
gst_rtsp_media_factory_set_shared (factory, TRUE);
gst_rtsp_media_factory_set_clock (factory, clock);
gst_rtsp_mount_points_add_factory(mounts, "/tmp", factory);
g_object_unref(mounts);
gst_rtsp_server_attach(server, NULL);
Below is a snippet of the target application:
/* Create Pipeline */
pipeline = gst_pipeline_new("my-pipeline");
/* Get Pipeline Clock from Host */
clock = gst_net_client_clock_new("clock", "rtsp://192.168.1.2/tmp", 5000,
0);
if (clock == NULL){
g_print("Failed to create net clock client");
return 1;
}
/* Wait for the clock to stabilize */
gst_clock_wait_for_sync(clock, GST_CLOCK_TIME_NONE);
gst_pipeline_use_clock(GST_PIPELINE(pipeline), clock);
/* Create Elements */
network = gst_element_factory_make("udpsrc", "network");
filter = gst_element_factory_make("capsfilter", "capsfilter");
packet = gst_element_factory_make("rtpL16depay", "packet");
convert = gst_element_factory_make("audioconvert", "audioconvert");
sink = gst_element_factory_make("alsasink", "sink");
Is this the best method for synchronizing the pipeline clocks?
Do I need to create a SDP file in the /tmp directory?
Any advice is greatly appreciated.
Thank you,
Trenton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20170905/6ed3ba4f/attachment.html>
More information about the gstreamer-devel
mailing list