1 /* 2 * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include <jni.h> 12 13 #include "rtc_base/time_utils.h" 14 #include "rtc_base/timestamp_aligner.h" 15 #include "sdk/android/generated_video_jni/TimestampAligner_jni.h" 16 #include "sdk/android/src/jni/jni_helpers.h" 17 18 namespace webrtc { 19 namespace jni { 20 JNI_TimestampAligner_RtcTimeNanos(JNIEnv * env)21static jlong JNI_TimestampAligner_RtcTimeNanos(JNIEnv* env) { 22 return rtc::TimeNanos(); 23 } 24 JNI_TimestampAligner_CreateTimestampAligner(JNIEnv * env)25static jlong JNI_TimestampAligner_CreateTimestampAligner(JNIEnv* env) { 26 return jlongFromPointer(new rtc::TimestampAligner()); 27 } 28 JNI_TimestampAligner_ReleaseTimestampAligner(JNIEnv * env,jlong timestamp_aligner)29static void JNI_TimestampAligner_ReleaseTimestampAligner( 30 JNIEnv* env, 31 jlong timestamp_aligner) { 32 delete reinterpret_cast<rtc::TimestampAligner*>(timestamp_aligner); 33 } 34 JNI_TimestampAligner_TranslateTimestamp(JNIEnv * env,jlong timestamp_aligner,jlong camera_time_ns)35static jlong JNI_TimestampAligner_TranslateTimestamp( 36 JNIEnv* env, 37 jlong timestamp_aligner, 38 jlong camera_time_ns) { 39 return reinterpret_cast<rtc::TimestampAligner*>(timestamp_aligner) 40 ->TranslateTimestamp(camera_time_ns / rtc::kNumNanosecsPerMicrosec, 41 rtc::TimeMicros()) * 42 rtc::kNumNanosecsPerMicrosec; 43 } 44 45 } // namespace jni 46 } // namespace webrtc 47