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