This CL changes the interface by adding a SurfaceTextureHelper argument to VideoCapturer.startCapture(). This removes the need for the VideoCapturer to create the SurfaceTextureHelper itself. This also means that it is no longer necessary to send an EGLContext to the VideoCapturerAndroid.create() function. The SurfaceTextureHelper is now created in AndroidVideoCapturerJni, and the EGLContext is passed from PeerConnectionFactory in nativeCreateVideoSource(). Another change in this CL is that the C++ SurfaceTextureHelper creates the Java SurfaceTextureHelper instead of getting it passed as an argument in the ctor. BUG=webrtc:5519 Review URL: https://codereview.webrtc.org/1783793002 Cr-Commit-Position: refs/heads/master@{#11977}
62 lines
2.1 KiB
C++
62 lines
2.1 KiB
C++
/*
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
|
|
#include "webrtc/api/java/jni/surfacetexturehelper_jni.h"
|
|
|
|
#include "webrtc/api/java/jni/classreferenceholder.h"
|
|
#include "webrtc/base/bind.h"
|
|
#include "webrtc/base/checks.h"
|
|
|
|
namespace webrtc_jni {
|
|
|
|
SurfaceTextureHelper::SurfaceTextureHelper(
|
|
JNIEnv* jni, jobject j_egl_context)
|
|
: j_surface_texture_helper_(jni, jni->CallStaticObjectMethod(
|
|
FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
|
|
GetStaticMethodID(jni,
|
|
FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
|
|
"create",
|
|
"(Lorg/webrtc/EglBase$Context;)"
|
|
"Lorg/webrtc/SurfaceTextureHelper;"),
|
|
j_egl_context)),
|
|
j_return_texture_method_(
|
|
GetMethodID(jni,
|
|
FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
|
|
"returnTextureFrame",
|
|
"()V")) {
|
|
CHECK_EXCEPTION(jni) << "error during initialization of SurfaceTextureHelper";
|
|
}
|
|
|
|
SurfaceTextureHelper::~SurfaceTextureHelper() {
|
|
}
|
|
|
|
jobject SurfaceTextureHelper::GetJavaSurfaceTextureHelper() const {
|
|
return *j_surface_texture_helper_;
|
|
}
|
|
|
|
void SurfaceTextureHelper::ReturnTextureFrame() const {
|
|
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
|
jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_);
|
|
|
|
CHECK_EXCEPTION(
|
|
jni) << "error during SurfaceTextureHelper.returnTextureFrame";
|
|
}
|
|
|
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer>
|
|
SurfaceTextureHelper::CreateTextureFrame(int width, int height,
|
|
const NativeHandleImpl& native_handle) {
|
|
return new rtc::RefCountedObject<AndroidTextureBuffer>(
|
|
width, height, native_handle, *j_surface_texture_helper_,
|
|
rtc::Bind(&SurfaceTextureHelper::ReturnTextureFrame, this));
|
|
}
|
|
|
|
} // namespace webrtc_jni
|