blob: 7226886cb0ffd1e191d668c30cd301d7ebc4fe50 [file] [log] [blame]
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_base/timestamp_aligner.h"
#include <jni.h>
#include "rtc_base/time_utils.h"
#include "sdk/android/generated_video_jni/TimestampAligner_jni.h"
#include "sdk/android/src/jni/jni_helpers.h"
namespace webrtc {
namespace jni {
static jlong JNI_TimestampAligner_RtcTimeNanos(JNIEnv* env) {
return TimeNanos();
}
static jlong JNI_TimestampAligner_CreateTimestampAligner(JNIEnv* env) {
return jlongFromPointer(new TimestampAligner());
}
static void JNI_TimestampAligner_ReleaseTimestampAligner(
JNIEnv* env,
jlong timestamp_aligner) {
delete reinterpret_cast<TimestampAligner*>(timestamp_aligner);
}
static jlong JNI_TimestampAligner_TranslateTimestamp(JNIEnv* env,
jlong timestamp_aligner,
jlong camera_time_ns) {
return reinterpret_cast<TimestampAligner*>(timestamp_aligner)
->TranslateTimestamp(camera_time_ns / kNumNanosecsPerMicrosec,
TimeMicros()) *
kNumNanosecsPerMicrosec;
}
} // namespace jni
} // namespace webrtc