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

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

Issue 2992523002: Fix a crash in PeerConnectionFactory.SetVideoHwAccelerationOptions. (Closed)
Patch Set: Created 3 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 10 matching lines...) Expand all
21 #include "webrtc/sdk/android/src/jni/ownedfactoryandthreads.h" 21 #include "webrtc/sdk/android/src/jni/ownedfactoryandthreads.h"
22 #include "webrtc/sdk/android/src/jni/surfacetexturehelper_jni.h" 22 #include "webrtc/sdk/android/src/jni/surfacetexturehelper_jni.h"
23 #include "webrtc/sdk/android/src/jni/videodecoderfactorywrapper.h" 23 #include "webrtc/sdk/android/src/jni/videodecoderfactorywrapper.h"
24 24
25 namespace webrtc_jni { 25 namespace webrtc_jni {
26 26
27 // TODO(sakal): Remove this once MediaCodecVideoDecoder/Encoder are no longer 27 // TODO(sakal): Remove this once MediaCodecVideoDecoder/Encoder are no longer
28 // used and all applications inject their own codecs. 28 // used and all applications inject their own codecs.
29 // This is semi broken if someone wants to create multiple peerconnection 29 // This is semi broken if someone wants to create multiple peerconnection
30 // factories. 30 // factories.
31 static MediaCodecVideoDecoderFactory* media_codec_decoder_factory; 31 static bool use_media_codec_decoder_factory;
32 32
33 cricket::WebRtcVideoEncoderFactory* CreateVideoEncoderFactory( 33 cricket::WebRtcVideoEncoderFactory* CreateVideoEncoderFactory(
34 JNIEnv* jni, 34 JNIEnv* jni,
35 jobject j_encoder_factory) { 35 jobject j_encoder_factory) {
36 RTC_DCHECK(j_encoder_factory == nullptr) 36 RTC_DCHECK(j_encoder_factory == nullptr)
37 << "Injectable video encoders are not supported yet."; 37 << "Injectable video encoders are not supported yet.";
38 return new MediaCodecVideoEncoderFactory(); 38 return new MediaCodecVideoEncoderFactory();
39 } 39 }
40 40
41 cricket::WebRtcVideoDecoderFactory* CreateVideoDecoderFactory( 41 cricket::WebRtcVideoDecoderFactory* CreateVideoDecoderFactory(
42 JNIEnv* jni, 42 JNIEnv* jni,
43 jobject j_decoder_factory) { 43 jobject j_decoder_factory) {
44 if (j_decoder_factory != nullptr) { 44 use_media_codec_decoder_factory = j_decoder_factory == nullptr;
45 media_codec_decoder_factory = nullptr; 45
46 if (use_media_codec_decoder_factory) {
47 return new MediaCodecVideoDecoderFactory();
48 } else {
46 return new VideoDecoderFactoryWrapper(jni, j_decoder_factory); 49 return new VideoDecoderFactoryWrapper(jni, j_decoder_factory);
47 } else {
48 media_codec_decoder_factory = new MediaCodecVideoDecoderFactory();
49 return media_codec_decoder_factory;
50 } 50 }
51 } 51 }
52 52
53 jobject GetJavaSurfaceTextureHelper( 53 jobject GetJavaSurfaceTextureHelper(
54 const rtc::scoped_refptr<SurfaceTextureHelper>& surface_texture_helper) { 54 const rtc::scoped_refptr<SurfaceTextureHelper>& surface_texture_helper) {
55 return surface_texture_helper 55 return surface_texture_helper
56 ? surface_texture_helper->GetJavaSurfaceTextureHelper() 56 ? surface_texture_helper->GetJavaSurfaceTextureHelper()
57 : nullptr; 57 : nullptr;
58 } 58 }
59 59
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 MediaCodecVideoEncoderFactory* encoder_factory = 103 MediaCodecVideoEncoderFactory* encoder_factory =
104 static_cast<MediaCodecVideoEncoderFactory*>( 104 static_cast<MediaCodecVideoEncoderFactory*>(
105 owned_factory->encoder_factory()); 105 owned_factory->encoder_factory());
106 if (encoder_factory && 106 if (encoder_factory &&
107 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) { 107 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) {
108 LOG(LS_INFO) << "Set EGL context for HW encoding."; 108 LOG(LS_INFO) << "Set EGL context for HW encoding.";
109 encoder_factory->SetEGLContext(jni, local_egl_context); 109 encoder_factory->SetEGLContext(jni, local_egl_context);
110 } 110 }
111 111
112 if (media_codec_decoder_factory) { 112 MediaCodecVideoDecoderFactory* decoder_factory =
113 static_cast<MediaCodecVideoDecoderFactory*>(
114 owned_factory->decoder_factory());
115 if (use_media_codec_decoder_factory && decoder_factory) {
113 LOG(LS_INFO) << "Set EGL context for HW decoding."; 116 LOG(LS_INFO) << "Set EGL context for HW decoding.";
114 media_codec_decoder_factory->SetEGLContext(jni, remote_egl_context); 117 decoder_factory->SetEGLContext(jni, remote_egl_context);
115 } 118 }
116 } 119 }
117 120
118 } // namespace webrtc_jni 121 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698