summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/libwebrtcglue/SystemTime.h
blob: 5c042e689fb4b10e37ea064179be6063ae4e3e28 (plain)
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
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef DOM_MEDIA_WEBRTC_LIBWEBRTCGLUE_SYSTEMTIMENANOS_H_
#define DOM_MEDIA_WEBRTC_LIBWEBRTCGLUE_SYSTEMTIMENANOS_H_

#include "jsapi/RTCStatsReport.h"
#include "mozilla/TimeStamp.h"
#include "system_wrappers/include/clock.h"

namespace mozilla {
class RTCStatsTimestampMakerRealtimeClock : public webrtc::Clock {
 public:
  explicit RTCStatsTimestampMakerRealtimeClock(
      const dom::RTCStatsTimestampMaker& aTimestampMaker);

  webrtc::Timestamp CurrentTime() override;

  // Upstream, this method depend on rtc::TimeUTCMicros for converting the
  // monotonic system clock to Ntp, if only for the first call when deciding the
  // Ntp offset.
  // We override this to be able to use our own clock instead of
  // rtc::TimeUTCMicros for ntp timestamps.
  webrtc::NtpTime ConvertTimestampToNtpTime(
      webrtc::Timestamp aRealtime) override;

  const dom::RTCStatsTimestampMaker mTimestampMaker;
};

// The time base used for WebrtcSystemTime(). Completely arbitrary. Constant.
TimeStamp WebrtcSystemTimeBase();

// The returned timestamp denotes the monotonic time passed since
// WebrtcSystemTimeBase(). Libwebrtc uses this to track how time advances from a
// specific point in time. It adds an offset to make the timestamps absolute.
webrtc::Timestamp WebrtcSystemTime();

webrtc::NtpTime CreateNtp(webrtc::Timestamp aTime);
}  // namespace mozilla

#endif