From b9b747cf8015e1a873a41cd5880fdac4f439a50d Mon Sep 17 00:00:00 2001 From: Boris Grozev <boris@jitsi.org> Date: Fri, 20 Jun 2014 10:23:16 +0200 Subject: [PATCH] Adds the Synchronizer interface. --- .../impl/neomedia/recording/RecorderImpl.java | 22 +++++++ .../service/neomedia/recording/Recorder.java | 12 ++++ .../neomedia/recording/Synchronizer.java | 65 +++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/org/jitsi/service/neomedia/recording/Synchronizer.java diff --git a/src/org/jitsi/impl/neomedia/recording/RecorderImpl.java b/src/org/jitsi/impl/neomedia/recording/RecorderImpl.java index b677ee9c..b39076f7 100644 --- a/src/org/jitsi/impl/neomedia/recording/RecorderImpl.java +++ b/src/org/jitsi/impl/neomedia/recording/RecorderImpl.java @@ -386,4 +386,26 @@ public void setEventHandler(RecorderEventHandler eventHandler) { this.eventHandler = eventHandler; } + + + /** + * {@inheritDoc} + * + * This <tt>Recorder</tt> implementation does not use a + * <tt>Synchronizer</tt>. + */ + public Synchronizer getSynchronizer() + { + return null; + } + + /** + * {@inheritDoc} + * + * This <tt>Recorder</tt> implementation does not use a + * <tt>Synchronizer</tt>. + */ + public void setSynchronizer(Synchronizer synchronizer) + { + } } diff --git a/src/org/jitsi/service/neomedia/recording/Recorder.java b/src/org/jitsi/service/neomedia/recording/Recorder.java index f298b7df..23ae0fb9 100644 --- a/src/org/jitsi/service/neomedia/recording/Recorder.java +++ b/src/org/jitsi/service/neomedia/recording/Recorder.java @@ -129,4 +129,16 @@ public interface Listener * @param eventHandler the <tt>RecorderEventHandler</tt> to set. */ public void setEventHandler(RecorderEventHandler eventHandler); + + /** + * Gets the <tt>Synchronizer</tt> of this <tt>Recorder</tt>. + * @return the <tt>Synchronizer</tt> of this <tt>Recorder</tt>. + */ + public Synchronizer getSynchronizer(); + + /** + * Sets the <tt>Synchronizer</tt> that this instance should use. + * @param synchronizer the <tt>Synchronizer</tt> to set. + */ + public void setSynchronizer(Synchronizer synchronizer); } diff --git a/src/org/jitsi/service/neomedia/recording/Synchronizer.java b/src/org/jitsi/service/neomedia/recording/Synchronizer.java new file mode 100644 index 00000000..defc64ca --- /dev/null +++ b/src/org/jitsi/service/neomedia/recording/Synchronizer.java @@ -0,0 +1,65 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jitsi.service.neomedia.recording; + +/** + * @author Boris Grozev + */ +public interface Synchronizer +{ + /** + * Sets the clock rate of the RTP clock for a specific SSRC. + * @param ssrc the SSRC for which to set the RTP clock rate. + * @param clockRate the clock rate. + */ + public void setRtpClockRate(long ssrc, long clockRate); + + /** + * Sets the endpoint identifier for a specific SSRC. + * @param ssrc the SSRC for which to set the endpoint identifier. + * @param endpointId the endpoint identifier to set. + */ + public void setEndpoint(long ssrc, String endpointId); + + /** + * Notifies this <tt>Synchronizer</tt> that the RTP timestamp + * <tt>rtpTime</tt> (for SSRC <tt>ssrc</tt>) corresponds to the + * NTP timestamp <tt>ntpTime</tt>. + * @param ssrc the SSRC. + * @param rtpTime the RTP timestamp which corresponds to <tt>ntpTime</tt>. + * @param ntpTime the NTP timestamp which corresponds to <tt>rtpTime</tt>. + */ + public void mapRtpToNtp(long ssrc, long rtpTime, double ntpTime); + + /** + * Notifies this <tt>Synchronizer</tt> that the local timestamp + * <tt>localTime</tt> corresponds to the NTP timestamp <tt>ntpTime</tt> + * (for SSRC <tt>ssrc</tt>). + * @param ssrc the SSRC. + * @param localTime the local timestamp which corresponds to <tt>ntpTime</tt>. + * @param ntpTime the NTP timestamp which corresponds to <tt>localTime</tt>. + */ + public void mapLocalToNtp(long ssrc, long localTime, double ntpTime); + + /** + * Tries to find the local time (as returned by + * <tt>System.currentTimeMillis()</tt>) that corresponds to the RTP + * timestamp <tt>rtpTime</tt> for the SSRC <tt>ssrc</tt>. + * + * Returns -1 if the local time cannot be found (for example because not + * enough information for the SSRC has been previously provided to the + * <tt>Synchronizer</tt>). + * + * @param ssrc the SSRC with which <tt>rtpTime</tt> is associated. + * @param rtpTime the RTP timestamp + * @return the local time corresponding to <tt>rtpTime</tt> for SSRC + * <tt>ssrc</tt> if it can be calculated, and -1 otherwise. + */ + public long getLocalTime(long ssrc, long rtpTime); +} + + -- GitLab