Android: Remove use of EGLContexts in PeerConnectionFactory
Since the legacy video codecs seem to be around for some time more, we need to make them injectable and provide a migration path for clients that still use them so that we can clean up PeerConnectionFactory. This CL moves the creation of EglContexts into the legacy codec factories. Clients can then migrate to setEGLContext() instead of using setVideoHwAccelerationOptions(). Bug: webrtc:9502 Change-Id: I608607b32db73ce3df7704a061e66d9d53946af5 Reviewed-on: https://webrtc-review.googlesource.com/87941 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23934}
This commit is contained in:
committed by
Commit Bot
parent
2234121cfb
commit
0f0e7a6f18
@ -61,11 +61,6 @@ class EglBase14 implements EglBase {
|
||||
public Context(android.opengl.EGLContext eglContext) {
|
||||
this.egl14Context = eglContext;
|
||||
}
|
||||
|
||||
@CalledByNative("Context")
|
||||
static boolean isEgl14Context(EglBase.Context context) {
|
||||
return context instanceof EglBase14.Context;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new context with the specified config type, sharing data with sharedContext.
|
||||
|
||||
@ -64,7 +64,7 @@ class MediaCodecVideoDecoder : public VideoDecoder, public rtc::MessageHandler {
|
||||
public:
|
||||
explicit MediaCodecVideoDecoder(JNIEnv* jni,
|
||||
VideoCodecType codecType,
|
||||
jobject render_egl_context);
|
||||
bool use_surface);
|
||||
~MediaCodecVideoDecoder() override;
|
||||
|
||||
int32_t InitDecode(const VideoCodec* codecSettings,
|
||||
@ -105,14 +105,10 @@ class MediaCodecVideoDecoder : public VideoDecoder, public rtc::MessageHandler {
|
||||
// Type of video codec.
|
||||
VideoCodecType codecType_;
|
||||
|
||||
// Render EGL context - owned by factory, should not be allocated/destroyed
|
||||
// by VideoDecoder.
|
||||
jobject render_egl_context_;
|
||||
|
||||
bool key_frame_required_;
|
||||
bool inited_;
|
||||
bool sw_fallback_required_;
|
||||
bool use_surface_;
|
||||
const bool use_surface_;
|
||||
VideoCodec codec_;
|
||||
I420BufferPool decoded_frame_pool_;
|
||||
DecodedImageCallback* callback_;
|
||||
@ -141,12 +137,12 @@ class MediaCodecVideoDecoder : public VideoDecoder, public rtc::MessageHandler {
|
||||
|
||||
MediaCodecVideoDecoder::MediaCodecVideoDecoder(JNIEnv* jni,
|
||||
VideoCodecType codecType,
|
||||
jobject render_egl_context)
|
||||
bool use_surface)
|
||||
: codecType_(codecType),
|
||||
render_egl_context_(render_egl_context),
|
||||
key_frame_required_(true),
|
||||
inited_(false),
|
||||
sw_fallback_required_(false),
|
||||
use_surface_(use_surface),
|
||||
codec_thread_(Thread::Create()),
|
||||
j_media_codec_video_decoder_(
|
||||
jni,
|
||||
@ -154,7 +150,6 @@ MediaCodecVideoDecoder::MediaCodecVideoDecoder(JNIEnv* jni,
|
||||
codec_thread_->SetName("MediaCodecVideoDecoder", NULL);
|
||||
RTC_CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoDecoder";
|
||||
|
||||
use_surface_ = (render_egl_context_ != NULL);
|
||||
ALOGD << "MediaCodecVideoDecoder ctor. Use surface: " << use_surface_;
|
||||
memset(&codec_, 0, sizeof(codec_));
|
||||
AllowBlockingCalls();
|
||||
@ -228,10 +223,9 @@ int32_t MediaCodecVideoDecoder::InitDecodeOnCodecThread() {
|
||||
|
||||
ScopedJavaLocalRef<jobject> j_video_codec_enum =
|
||||
Java_VideoCodecType_fromNativeIndex(jni, codecType_);
|
||||
jobject j_egl_context = use_surface_ ? render_egl_context_ : nullptr;
|
||||
bool success = Java_MediaCodecVideoDecoder_initDecode(
|
||||
jni, j_media_codec_video_decoder_, j_video_codec_enum, codec_.width,
|
||||
codec_.height, JavaParamRef<jobject>(j_egl_context));
|
||||
codec_.height);
|
||||
|
||||
if (CheckException(jni) || !success) {
|
||||
ALOGE << "Codec initialization error - fallback to SW codec.";
|
||||
@ -779,8 +773,7 @@ void MediaCodecVideoDecoder::OnMessage(rtc::Message* msg) {
|
||||
codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
|
||||
}
|
||||
|
||||
MediaCodecVideoDecoderFactory::MediaCodecVideoDecoderFactory()
|
||||
: egl_context_(nullptr) {
|
||||
MediaCodecVideoDecoderFactory::MediaCodecVideoDecoderFactory() {
|
||||
ALOGD << "MediaCodecVideoDecoderFactory ctor";
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
ScopedLocalRefFrame local_ref_frame(jni);
|
||||
@ -807,23 +800,6 @@ MediaCodecVideoDecoderFactory::MediaCodecVideoDecoderFactory()
|
||||
|
||||
MediaCodecVideoDecoderFactory::~MediaCodecVideoDecoderFactory() {
|
||||
ALOGD << "MediaCodecVideoDecoderFactory dtor";
|
||||
if (egl_context_) {
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
jni->DeleteGlobalRef(egl_context_);
|
||||
}
|
||||
}
|
||||
|
||||
void MediaCodecVideoDecoderFactory::SetEGLContext(JNIEnv* jni,
|
||||
jobject egl_context) {
|
||||
ALOGD << "MediaCodecVideoDecoderFactory::SetEGLContext";
|
||||
if (egl_context_) {
|
||||
jni->DeleteGlobalRef(egl_context_);
|
||||
egl_context_ = nullptr;
|
||||
}
|
||||
egl_context_ = jni->NewGlobalRef(egl_context);
|
||||
if (CheckException(jni)) {
|
||||
ALOGE << "error calling NewGlobalRef for EGL Context.";
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<SdpVideoFormat> MediaCodecVideoDecoderFactory::GetSupportedFormats()
|
||||
@ -843,7 +819,8 @@ std::unique_ptr<VideoDecoder> MediaCodecVideoDecoderFactory::CreateVideoDecoder(
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
ScopedLocalRefFrame local_ref_frame(jni);
|
||||
return rtc::MakeUnique<MediaCodecVideoDecoder>(
|
||||
jni, PayloadStringToCodecType(format.name), egl_context_);
|
||||
jni, PayloadStringToCodecType(format.name),
|
||||
Java_MediaCodecVideoDecoder_useSurface(jni));
|
||||
}
|
||||
}
|
||||
ALOGW << "Can not find HW video decoder for type " << format.name;
|
||||
|
||||
@ -25,8 +25,6 @@ class MediaCodecVideoDecoderFactory : public VideoDecoderFactory {
|
||||
MediaCodecVideoDecoderFactory();
|
||||
~MediaCodecVideoDecoderFactory() override;
|
||||
|
||||
void SetEGLContext(JNIEnv* jni, jobject render_egl_context);
|
||||
|
||||
// VideoDecoderFactory implementation.
|
||||
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
|
||||
std::unique_ptr<VideoDecoder> CreateVideoDecoder(
|
||||
@ -35,7 +33,6 @@ class MediaCodecVideoDecoderFactory : public VideoDecoderFactory {
|
||||
static bool IsH264HighProfileSupported(JNIEnv* env);
|
||||
|
||||
private:
|
||||
jobject egl_context_;
|
||||
std::vector<SdpVideoFormat> supported_formats_;
|
||||
};
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ class MediaCodecVideoEncoder : public VideoEncoder {
|
||||
~MediaCodecVideoEncoder() override;
|
||||
MediaCodecVideoEncoder(JNIEnv* jni,
|
||||
const SdpVideoFormat& format,
|
||||
jobject egl_context);
|
||||
bool has_egl_context);
|
||||
|
||||
// VideoEncoder implementation.
|
||||
int32_t InitEncode(const VideoCodec* codec_settings,
|
||||
@ -115,7 +115,7 @@ class MediaCodecVideoEncoder : public VideoEncoder {
|
||||
int32_t SetRateAllocation(const VideoBitrateAllocation& rate_allocation,
|
||||
uint32_t frame_rate) override;
|
||||
|
||||
bool SupportsNativeHandle() const override { return egl_context_ != nullptr; }
|
||||
bool SupportsNativeHandle() const override { return has_egl_context_; }
|
||||
const char* ImplementationName() const override;
|
||||
|
||||
// Fills the input buffer with data from the buffers passed as parameters.
|
||||
@ -275,9 +275,7 @@ class MediaCodecVideoEncoder : public VideoEncoder {
|
||||
// non-flexible VP9 mode.
|
||||
size_t gof_idx_;
|
||||
|
||||
// EGL context - owned by factory, should not be allocated/destroyed
|
||||
// by MediaCodecVideoEncoder.
|
||||
jobject egl_context_;
|
||||
const bool has_egl_context_;
|
||||
|
||||
// Temporary fix for VP8.
|
||||
// Sends a key frame if frames are largely spaced apart (possibly
|
||||
@ -302,7 +300,7 @@ MediaCodecVideoEncoder::~MediaCodecVideoEncoder() {
|
||||
|
||||
MediaCodecVideoEncoder::MediaCodecVideoEncoder(JNIEnv* jni,
|
||||
const SdpVideoFormat& format,
|
||||
jobject egl_context)
|
||||
bool has_egl_context)
|
||||
: format_(format),
|
||||
callback_(NULL),
|
||||
j_media_codec_video_encoder_(
|
||||
@ -310,7 +308,7 @@ MediaCodecVideoEncoder::MediaCodecVideoEncoder(JNIEnv* jni,
|
||||
Java_MediaCodecVideoEncoder_Constructor(jni)),
|
||||
inited_(false),
|
||||
use_surface_(false),
|
||||
egl_context_(egl_context),
|
||||
has_egl_context_(has_egl_context),
|
||||
sw_fallback_required_(false) {
|
||||
encoder_queue_checker_.Detach();
|
||||
}
|
||||
@ -361,7 +359,7 @@ int32_t MediaCodecVideoEncoder::InitEncode(const VideoCodec* codec_settings,
|
||||
return InitEncodeInternal(
|
||||
init_width, init_height, codec_settings->startBitrate,
|
||||
codec_settings->maxFramerate,
|
||||
codec_settings->expect_encode_from_texture && (egl_context_ != nullptr));
|
||||
codec_settings->expect_encode_from_texture && has_egl_context_);
|
||||
}
|
||||
|
||||
int32_t MediaCodecVideoEncoder::SetChannelParameters(uint32_t /* packet_loss */,
|
||||
@ -475,7 +473,7 @@ int32_t MediaCodecVideoEncoder::InitEncodeInternal(int width,
|
||||
if (sw_fallback_required_) {
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
RTC_CHECK(!use_surface || egl_context_ != nullptr) << "EGL context not set.";
|
||||
RTC_CHECK(!use_surface || has_egl_context_) << "EGL context not set.";
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
ScopedLocalRefFrame local_ref_frame(jni);
|
||||
|
||||
@ -522,8 +520,8 @@ int32_t MediaCodecVideoEncoder::InitEncodeInternal(int width,
|
||||
Java_VideoCodecType_fromNativeIndex(jni, codec_type);
|
||||
const bool encode_status = Java_MediaCodecVideoEncoder_initEncode(
|
||||
jni, j_media_codec_video_encoder_, j_video_codec_enum, profile_, width,
|
||||
height, kbps, fps,
|
||||
JavaParamRef<jobject>(use_surface ? egl_context_ : nullptr));
|
||||
height, kbps, fps, use_surface);
|
||||
|
||||
if (!encode_status) {
|
||||
ALOGE << "Failed to configure encoder.";
|
||||
ProcessHWError(false /* reset_if_fallback_unavailable */);
|
||||
@ -1212,8 +1210,7 @@ const char* MediaCodecVideoEncoder::ImplementationName() const {
|
||||
return "MediaCodec";
|
||||
}
|
||||
|
||||
MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory()
|
||||
: egl_context_(nullptr) {
|
||||
MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory() {
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
ScopedLocalRefFrame local_ref_frame(jni);
|
||||
supported_formats_.clear();
|
||||
@ -1270,23 +1267,6 @@ MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory()
|
||||
|
||||
MediaCodecVideoEncoderFactory::~MediaCodecVideoEncoderFactory() {
|
||||
ALOGD << "MediaCodecVideoEncoderFactory dtor";
|
||||
if (egl_context_) {
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
jni->DeleteGlobalRef(egl_context_);
|
||||
}
|
||||
}
|
||||
|
||||
void MediaCodecVideoEncoderFactory::SetEGLContext(JNIEnv* jni,
|
||||
jobject egl_context) {
|
||||
ALOGD << "MediaCodecVideoEncoderFactory::SetEGLContext";
|
||||
if (egl_context_) {
|
||||
jni->DeleteGlobalRef(egl_context_);
|
||||
egl_context_ = nullptr;
|
||||
}
|
||||
egl_context_ = jni->NewGlobalRef(egl_context);
|
||||
if (CheckException(jni)) {
|
||||
ALOGE << "error calling NewGlobalRef for EGL Context.";
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoEncoder> MediaCodecVideoEncoderFactory::CreateVideoEncoder(
|
||||
@ -1299,7 +1279,8 @@ std::unique_ptr<VideoEncoder> MediaCodecVideoEncoderFactory::CreateVideoEncoder(
|
||||
ALOGD << "Create HW video encoder for " << format.name;
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
ScopedLocalRefFrame local_ref_frame(jni);
|
||||
return rtc::MakeUnique<MediaCodecVideoEncoder>(jni, format, egl_context_);
|
||||
return rtc::MakeUnique<MediaCodecVideoEncoder>(
|
||||
jni, format, Java_MediaCodecVideoEncoder_hasEgl14Context(jni));
|
||||
}
|
||||
ALOGW << "Can not find HW video encoder for type " << format.name;
|
||||
return nullptr;
|
||||
|
||||
@ -28,13 +28,6 @@ VideoDecoderFactory* CreateVideoDecoderFactory(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SetEglContext(JNIEnv* env,
|
||||
VideoEncoderFactory* encoder_factory,
|
||||
const JavaRef<jobject>& egl_context) {}
|
||||
void SetEglContext(JNIEnv* env,
|
||||
VideoDecoderFactory* decoder_factory,
|
||||
const JavaRef<jobject>& egl_context) {}
|
||||
|
||||
void* CreateVideoSource(JNIEnv* env,
|
||||
rtc::Thread* signaling_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
|
||||
@ -36,15 +36,11 @@ class OwnedFactoryAndThreads {
|
||||
OwnedFactoryAndThreads(std::unique_ptr<Thread> network_thread,
|
||||
std::unique_ptr<Thread> worker_thread,
|
||||
std::unique_ptr<Thread> signaling_thread,
|
||||
VideoEncoderFactory* legacy_encoder_factory,
|
||||
VideoDecoderFactory* legacy_decoder_factory,
|
||||
rtc::NetworkMonitorFactory* network_monitor_factory,
|
||||
PeerConnectionFactoryInterface* factory)
|
||||
: network_thread_(std::move(network_thread)),
|
||||
worker_thread_(std::move(worker_thread)),
|
||||
signaling_thread_(std::move(signaling_thread)),
|
||||
legacy_encoder_factory_(legacy_encoder_factory),
|
||||
legacy_decoder_factory_(legacy_decoder_factory),
|
||||
network_monitor_factory_(network_monitor_factory),
|
||||
factory_(factory) {}
|
||||
|
||||
@ -54,12 +50,6 @@ class OwnedFactoryAndThreads {
|
||||
Thread* network_thread() { return network_thread_.get(); }
|
||||
Thread* signaling_thread() { return signaling_thread_.get(); }
|
||||
Thread* worker_thread() { return worker_thread_.get(); }
|
||||
VideoEncoderFactory* legacy_encoder_factory() {
|
||||
return legacy_encoder_factory_;
|
||||
}
|
||||
VideoDecoderFactory* legacy_decoder_factory() {
|
||||
return legacy_decoder_factory_;
|
||||
}
|
||||
rtc::NetworkMonitorFactory* network_monitor_factory() {
|
||||
return network_monitor_factory_;
|
||||
}
|
||||
@ -70,8 +60,6 @@ class OwnedFactoryAndThreads {
|
||||
const std::unique_ptr<Thread> network_thread_;
|
||||
const std::unique_ptr<Thread> worker_thread_;
|
||||
const std::unique_ptr<Thread> signaling_thread_;
|
||||
VideoEncoderFactory* legacy_encoder_factory_;
|
||||
VideoDecoderFactory* legacy_decoder_factory_;
|
||||
rtc::NetworkMonitorFactory* network_monitor_factory_;
|
||||
PeerConnectionFactoryInterface* factory_; // Const after ctor except dtor.
|
||||
};
|
||||
|
||||
@ -112,9 +112,7 @@ jobject NativeToJavaPeerConnectionFactory(
|
||||
rtc::NetworkMonitorFactory* network_monitor_factory) {
|
||||
jni::OwnedFactoryAndThreads* owned_factory = new jni::OwnedFactoryAndThreads(
|
||||
std::move(network_thread), std::move(worker_thread),
|
||||
std::move(signaling_thread), nullptr /* legacy_encoder_factory */,
|
||||
nullptr /* legacy_decoder_factory */, network_monitor_factory,
|
||||
pcf.release());
|
||||
std::move(signaling_thread), network_monitor_factory, pcf.release());
|
||||
owned_factory->InvokeJavaCallbacksOnFactoryThreads();
|
||||
|
||||
return Java_PeerConnectionFactory_Constructor(
|
||||
@ -241,8 +239,6 @@ jlong CreatePeerConnectionFactoryForJava(
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> rtc_event_log_factory(
|
||||
CreateRtcEventLogFactory());
|
||||
|
||||
VideoEncoderFactory* legacy_video_encoder_factory = nullptr;
|
||||
VideoDecoderFactory* legacy_video_decoder_factory = nullptr;
|
||||
std::unique_ptr<VideoEncoderFactory> video_encoder_factory;
|
||||
std::unique_ptr<VideoDecoderFactory> video_decoder_factory;
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine;
|
||||
@ -261,11 +257,8 @@ jlong CreatePeerConnectionFactoryForJava(
|
||||
if (jencoder_factory.is_null()) {
|
||||
// TODO(bugs.webrtc.org/7925): When all clients switched to injectable
|
||||
// factories, remove the legacy codec factories
|
||||
std::unique_ptr<VideoEncoderFactory> legacy_factory =
|
||||
CreateLegacyVideoEncoderFactory();
|
||||
legacy_video_encoder_factory = legacy_factory.get();
|
||||
video_encoder_factory =
|
||||
WrapLegacyVideoEncoderFactory(std::move(legacy_factory));
|
||||
WrapLegacyVideoEncoderFactory(CreateLegacyVideoEncoderFactory());
|
||||
} else {
|
||||
video_encoder_factory = std::unique_ptr<VideoEncoderFactory>(
|
||||
CreateVideoEncoderFactory(jni, jencoder_factory));
|
||||
@ -274,11 +267,8 @@ jlong CreatePeerConnectionFactoryForJava(
|
||||
if (jdecoder_factory.is_null()) {
|
||||
// TODO(bugs.webrtc.org/7925): When all clients switched to injectable
|
||||
// factories, remove the legacy codec factories
|
||||
std::unique_ptr<VideoDecoderFactory> legacy_factory =
|
||||
CreateLegacyVideoDecoderFactory();
|
||||
legacy_video_decoder_factory = legacy_factory.get();
|
||||
video_decoder_factory =
|
||||
WrapLegacyVideoDecoderFactory(std::move(legacy_factory));
|
||||
WrapLegacyVideoDecoderFactory(CreateLegacyVideoDecoderFactory());
|
||||
} else {
|
||||
video_decoder_factory = std::unique_ptr<VideoDecoderFactory>(
|
||||
CreateVideoDecoderFactory(jni, jdecoder_factory));
|
||||
@ -303,8 +293,7 @@ jlong CreatePeerConnectionFactoryForJava(
|
||||
}
|
||||
OwnedFactoryAndThreads* owned_factory = new OwnedFactoryAndThreads(
|
||||
std::move(network_thread), std::move(worker_thread),
|
||||
std::move(signaling_thread), legacy_video_encoder_factory,
|
||||
legacy_video_decoder_factory, network_monitor_factory, factory.release());
|
||||
std::move(signaling_thread), network_monitor_factory, factory.release());
|
||||
owned_factory->InvokeJavaCallbacksOnFactoryThreads();
|
||||
return jlongFromPointer(owned_factory);
|
||||
}
|
||||
@ -478,20 +467,6 @@ static jlong JNI_PeerConnectionFactory_CreateVideoTrack(
|
||||
return jlongFromPointer(track.release());
|
||||
}
|
||||
|
||||
static void JNI_PeerConnectionFactory_SetVideoHwAccelerationOptions(
|
||||
JNIEnv* jni,
|
||||
const JavaParamRef<jclass>&,
|
||||
jlong native_factory,
|
||||
const JavaParamRef<jobject>& local_egl_context,
|
||||
const JavaParamRef<jobject>& remote_egl_context) {
|
||||
OwnedFactoryAndThreads* owned_factory =
|
||||
reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
|
||||
SetEglContext(jni, owned_factory->legacy_encoder_factory(),
|
||||
local_egl_context);
|
||||
SetEglContext(jni, owned_factory->legacy_decoder_factory(),
|
||||
remote_egl_context);
|
||||
}
|
||||
|
||||
static jlong JNI_PeerConnectionFactory_GetNativePeerConnectionFactory(
|
||||
JNIEnv* jni,
|
||||
const JavaParamRef<jclass>&,
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#include "media/engine/convert_legacy_video_factory.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/ptr_util.h"
|
||||
#include "sdk/android/generated_video_jni/jni/EglBase14_jni.h"
|
||||
#include "sdk/android/src/jni/androidmediadecoder_jni.h"
|
||||
#include "sdk/android/src/jni/androidmediaencoder_jni.h"
|
||||
#include "sdk/android/src/jni/androidvideotracksource.h"
|
||||
@ -43,32 +42,6 @@ VideoDecoderFactory* CreateVideoDecoderFactory(
|
||||
return new VideoDecoderFactoryWrapper(jni, j_decoder_factory);
|
||||
}
|
||||
|
||||
void SetEglContext(JNIEnv* env,
|
||||
VideoEncoderFactory* encoder_factory,
|
||||
const JavaRef<jobject>& egl_context) {
|
||||
if (encoder_factory) {
|
||||
MediaCodecVideoEncoderFactory* media_codec_factory =
|
||||
static_cast<MediaCodecVideoEncoderFactory*>(encoder_factory);
|
||||
if (media_codec_factory && Java_Context_isEgl14Context(env, egl_context)) {
|
||||
RTC_LOG(LS_INFO) << "Set EGL context for HW encoding.";
|
||||
media_codec_factory->SetEGLContext(env, egl_context.obj());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetEglContext(JNIEnv* env,
|
||||
VideoDecoderFactory* decoder_factory,
|
||||
const JavaRef<jobject>& egl_context) {
|
||||
if (decoder_factory) {
|
||||
MediaCodecVideoDecoderFactory* media_codec_factory =
|
||||
static_cast<MediaCodecVideoDecoderFactory*>(decoder_factory);
|
||||
if (media_codec_factory) {
|
||||
RTC_LOG(LS_INFO) << "Set EGL context for HW decoding.";
|
||||
media_codec_factory->SetEGLContext(env, egl_context.obj());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* CreateVideoSource(JNIEnv* env,
|
||||
rtc::Thread* signaling_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
|
||||
@ -33,13 +33,6 @@ VideoDecoderFactory* CreateVideoDecoderFactory(
|
||||
JNIEnv* jni,
|
||||
const JavaRef<jobject>& j_decoder_factory);
|
||||
|
||||
void SetEglContext(JNIEnv* env,
|
||||
VideoEncoderFactory* encoder_factory,
|
||||
const JavaRef<jobject>& egl_context);
|
||||
void SetEglContext(JNIEnv* env,
|
||||
VideoDecoderFactory* decoder_factory,
|
||||
const JavaRef<jobject>& egl_context);
|
||||
|
||||
void* CreateVideoSource(JNIEnv* env,
|
||||
rtc::Thread* signaling_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
|
||||
Reference in New Issue
Block a user