Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: webrtc/sdk/android/src/jni/video_jni.cc

Issue 2854123003: Build WebRTC with data channel only. (Closed)
Patch Set: Rebase. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 "webrtc/api/videosourceproxy.h"
14 #include "webrtc/media/engine/webrtcvideodecoderfactory.h"
15 #include "webrtc/media/engine/webrtcvideoencoderfactory.h"
16 #include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h"
17 #include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h"
18 #include "webrtc/sdk/android/src/jni/androidvideotracksource.h"
19 #include "webrtc/sdk/android/src/jni/classreferenceholder.h"
20 #include "webrtc/sdk/android/src/jni/ownedfactoryandthreads.h"
21 #include "webrtc/sdk/android/src/jni/surfacetexturehelper_jni.h"
22
23 using cricket::WebRtcVideoDecoderFactory;
24 using cricket::WebRtcVideoEncoderFactory;
25 using webrtc::AndroidVideoTrackSource;
26 using webrtc::AudioSourceInterface;
27 using webrtc::VideoTrackSourceInterface;
28 using webrtc::VideoTrackInterface;
29
30 namespace webrtc_jni {
31
32 WebRtcVideoEncoderFactory* CreateVideoEncoderFactory() {
33 return new MediaCodecVideoEncoderFactory();
34 }
35
36 WebRtcVideoDecoderFactory* CreateVideoDecoderFactory() {
37 return new MediaCodecVideoDecoderFactory();
38 }
39
40 jobject GetJavaSurfaceTextureHelper(
41 rtc::scoped_refptr<SurfaceTextureHelper> surface_texture_helper) {
42 return surface_texture_helper
43 ? surface_texture_helper->GetJavaSurfaceTextureHelper()
44 : nullptr;
45 }
46
47 JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource)
48 (JNIEnv* jni,
49 jclass,
50 jlong native_factory,
51 jobject j_surface_texture_helper,
52 jboolean is_screencast) {
53 OwnedFactoryAndThreads* factory =
54 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
55
56 rtc::scoped_refptr<webrtc::AndroidVideoTrackSource> source(
57 new rtc::RefCountedObject<webrtc::AndroidVideoTrackSource>(
58 factory->signaling_thread(), jni, j_surface_texture_helper,
59 is_screencast));
60 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source =
61 webrtc::VideoTrackSourceProxy::Create(factory->signaling_thread(),
62 factory->worker_thread(), source);
63
64 return (jlong)proxy_source.release();
65 }
66
67 JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack)
68 (JNIEnv* jni, jclass, jlong native_factory, jstring id, jlong native_source) {
69 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
70 factoryFromJava(native_factory));
71 rtc::scoped_refptr<VideoTrackInterface> track(factory->CreateVideoTrack(
72 JavaToStdString(jni, id),
73 reinterpret_cast<VideoTrackSourceInterface*>(native_source)));
74 return (jlong)track.release();
75 }
76
77 JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)
78 (JNIEnv* jni,
79 jclass,
80 jlong native_factory,
81 jobject local_egl_context,
82 jobject remote_egl_context) {
83 OwnedFactoryAndThreads* owned_factory =
84 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
85
86 jclass j_eglbase14_context_class =
87 FindClass(jni, "org/webrtc/EglBase14$Context");
88
89 MediaCodecVideoEncoderFactory* encoder_factory =
90 static_cast<MediaCodecVideoEncoderFactory*>(
91 owned_factory->encoder_factory());
92 if (encoder_factory &&
93 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) {
94 LOG(LS_INFO) << "Set EGL context for HW encoding.";
95 encoder_factory->SetEGLContext(jni, local_egl_context);
96 }
97
98 MediaCodecVideoDecoderFactory* decoder_factory =
99 static_cast<MediaCodecVideoDecoderFactory*>(
100 owned_factory->decoder_factory());
101 if (decoder_factory) {
102 LOG(LS_INFO) << "Set EGL context for HW decoding.";
103 decoder_factory->SetEGLContext(jni, remote_egl_context);
104 }
105 }
106
107 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698