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

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

Issue 2854123003: Build WebRTC with data channel only. (Closed)
Patch Set: Replace the rtc_ prefix with webrtc_ to avoid naming conflict. 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_egl_context,
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_egl_context, is_screencast));
59 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source =
60 webrtc::VideoTrackSourceProxy::Create(factory->signaling_thread(),
61 factory->worker_thread(), source);
62
63 return (jlong)proxy_source.release();
64 }
65
66 JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack)
67 (JNIEnv* jni, jclass, jlong native_factory, jstring id, jlong native_source) {
68 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
69 factoryFromJava(native_factory));
70 rtc::scoped_refptr<VideoTrackInterface> track(factory->CreateVideoTrack(
71 JavaToStdString(jni, id),
72 reinterpret_cast<VideoTrackSourceInterface*>(native_source)));
73 return (jlong)track.release();
74 }
75
76 JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)
77 (JNIEnv* jni,
78 jclass,
79 jlong native_factory,
80 jobject local_egl_context,
81 jobject remote_egl_context) {
82 OwnedFactoryAndThreads* owned_factory =
83 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
84
85 jclass j_eglbase14_context_class =
86 FindClass(jni, "org/webrtc/EglBase14$Context");
87
88 MediaCodecVideoEncoderFactory* encoder_factory =
89 static_cast<MediaCodecVideoEncoderFactory*>(
90 owned_factory->encoder_factory());
91 if (encoder_factory &&
92 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) {
93 LOG(LS_INFO) << "Set EGL context for HW encoding.";
94 encoder_factory->SetEGLContext(jni, local_egl_context);
95 }
96
97 MediaCodecVideoDecoderFactory* decoder_factory =
98 static_cast<MediaCodecVideoDecoderFactory*>(
99 owned_factory->decoder_factory());
100 if (decoder_factory) {
101 LOG(LS_INFO) << "Set EGL context for HW decoding.";
102 decoder_factory->SetEGLContext(jni, remote_egl_context);
103 }
104 }
105
106 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698