• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2017 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 "api/media_stream_interface.h"
14 #include "sdk/android/generated_video_jni/VideoTrack_jni.h"
15 #include "sdk/android/src/jni/jni_helpers.h"
16 #include "sdk/android/src/jni/video_sink.h"
17 
18 namespace webrtc {
19 namespace jni {
20 
JNI_VideoTrack_AddSink(JNIEnv * jni,jlong j_native_track,jlong j_native_sink)21 static void JNI_VideoTrack_AddSink(JNIEnv* jni,
22                                    jlong j_native_track,
23                                    jlong j_native_sink) {
24   reinterpret_cast<VideoTrackInterface*>(j_native_track)
25       ->AddOrUpdateSink(
26           reinterpret_cast<rtc::VideoSinkInterface<VideoFrame>*>(j_native_sink),
27           rtc::VideoSinkWants());
28 }
29 
JNI_VideoTrack_RemoveSink(JNIEnv * jni,jlong j_native_track,jlong j_native_sink)30 static void JNI_VideoTrack_RemoveSink(JNIEnv* jni,
31                                       jlong j_native_track,
32                                       jlong j_native_sink) {
33   reinterpret_cast<VideoTrackInterface*>(j_native_track)
34       ->RemoveSink(reinterpret_cast<rtc::VideoSinkInterface<VideoFrame>*>(
35           j_native_sink));
36 }
37 
JNI_VideoTrack_WrapSink(JNIEnv * jni,const JavaParamRef<jobject> & sink)38 static jlong JNI_VideoTrack_WrapSink(JNIEnv* jni,
39                                      const JavaParamRef<jobject>& sink) {
40   return jlongFromPointer(new VideoSinkWrapper(jni, sink));
41 }
42 
JNI_VideoTrack_FreeSink(JNIEnv * jni,jlong j_native_sink)43 static void JNI_VideoTrack_FreeSink(JNIEnv* jni,
44                                     jlong j_native_sink) {
45   delete reinterpret_cast<rtc::VideoSinkInterface<VideoFrame>*>(j_native_sink);
46 }
47 
48 }  // namespace jni
49 }  // namespace webrtc
50