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 "sdk/android/src/jni/pc/video.h"
12
13 #include <jni.h>
14 #include <memory>
15
16 #include "api/video_codecs/video_decoder_factory.h"
17 #include "api/video_codecs/video_encoder_factory.h"
18 #include "rtc_base/logging.h"
19 #include "sdk/android/native_api/jni/java_types.h"
20 #include "sdk/android/src/jni/android_video_track_source.h"
21 #include "sdk/android/src/jni/video_decoder_factory_wrapper.h"
22 #include "sdk/android/src/jni/video_encoder_factory_wrapper.h"
23
24 namespace webrtc {
25 namespace jni {
26
CreateVideoEncoderFactory(JNIEnv * jni,const JavaRef<jobject> & j_encoder_factory)27 VideoEncoderFactory* CreateVideoEncoderFactory(
28 JNIEnv* jni,
29 const JavaRef<jobject>& j_encoder_factory) {
30 return IsNull(jni, j_encoder_factory)
31 ? nullptr
32 : new VideoEncoderFactoryWrapper(jni, j_encoder_factory);
33 }
34
CreateVideoDecoderFactory(JNIEnv * jni,const JavaRef<jobject> & j_decoder_factory)35 VideoDecoderFactory* CreateVideoDecoderFactory(
36 JNIEnv* jni,
37 const JavaRef<jobject>& j_decoder_factory) {
38 return IsNull(jni, j_decoder_factory)
39 ? nullptr
40 : new VideoDecoderFactoryWrapper(jni, j_decoder_factory);
41 }
42
CreateVideoSource(JNIEnv * env,rtc::Thread * signaling_thread,rtc::Thread * worker_thread,jboolean is_screencast,jboolean align_timestamps)43 void* CreateVideoSource(JNIEnv* env,
44 rtc::Thread* signaling_thread,
45 rtc::Thread* worker_thread,
46 jboolean is_screencast,
47 jboolean align_timestamps) {
48 rtc::scoped_refptr<AndroidVideoTrackSource> source(
49 new rtc::RefCountedObject<AndroidVideoTrackSource>(
50 signaling_thread, env, is_screencast, align_timestamps));
51 return source.release();
52 }
53
54 } // namespace jni
55 } // namespace webrtc
56