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

Unified Diff: talk/app/webrtc/java/jni/androidvideocapturer_jni.cc

Issue 1395673003: Native changes for VideoCapturerAndroid surface texture support (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « talk/app/webrtc/java/jni/androidvideocapturer_jni.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
diff --git a/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc b/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
index 1455885f1c6ac9fa8bcc196b7e980ee990fd8fcc..45396b6e8375a305681ec6ef51eaae5d83826fe1 100644
--- a/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
+++ b/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
@@ -28,11 +28,40 @@
#include "talk/app/webrtc/java/jni/androidvideocapturer_jni.h"
#include "talk/app/webrtc/java/jni/classreferenceholder.h"
+#include "talk/app/webrtc/java/jni/native_handle_impl.h"
#include "webrtc/base/bind.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
namespace webrtc_jni {
+namespace {
+
+class CameraTextureBuffer : public webrtc::NativeHandleBuffer {
+ public:
+ CameraTextureBuffer(int width, int height,
+ const NativeHandleImpl& native_handle,
+ const rtc::Callback0<void>& no_longer_used)
+ : webrtc::NativeHandleBuffer(&native_handle_, width, height),
+ native_handle_(native_handle),
+ no_longer_used_cb_(no_longer_used) {}
+
+ ~CameraTextureBuffer() {
+ no_longer_used_cb_();
+ }
+
+ rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override {
+ RTC_NOTREACHED()
+ << "CameraTextureBuffer::NativeToI420Buffer not implemented.";
+ return nullptr;
+ }
+
+ private:
+ NativeHandleImpl native_handle_;
+ rtc::Callback0<void> no_longer_used_cb_;
+};
+
+} // anonymous namespace
+
jobject AndroidVideoCapturerJni::application_context_ = nullptr;
// static
@@ -150,12 +179,12 @@ void AndroidVideoCapturerJni::OnCapturerStarted(bool success) {
success);
}
-void AndroidVideoCapturerJni::OnIncomingFrame(void* video_frame,
- int length,
- int width,
- int height,
- int rotation,
- int64_t time_stamp) {
+void AndroidVideoCapturerJni::OnMemoryBufferFrame(void* video_frame,
+ int length,
+ int width,
+ int height,
+ int rotation,
+ int64_t timestamp_ns) {
const uint8_t* y_plane = static_cast<uint8_t*>(video_frame);
// Android guarantees that the stride is a multiple of 16.
// http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setPreviewFormat%28int%29
@@ -172,10 +201,25 @@ void AndroidVideoCapturerJni::OnIncomingFrame(void* video_frame,
new rtc::RefCountedObject<webrtc::WrappedI420Buffer>(
width, height, y_plane, y_stride, u_plane, uv_stride, v_plane,
uv_stride,
- rtc::Bind(&AndroidVideoCapturerJni::ReturnBuffer, this, time_stamp)));
+ rtc::Bind(&AndroidVideoCapturerJni::ReturnBuffer, this,
+ timestamp_ns)));
AsyncCapturerInvoke("OnIncomingFrame",
&webrtc::AndroidVideoCapturer::OnIncomingFrame,
- buffer, rotation, time_stamp);
+ buffer, rotation, timestamp_ns);
+}
+
+void AndroidVideoCapturerJni::OnTextureFrame(int width,
+ int height,
+ int64_t timestamp_ns,
+ const NativeHandleImpl& handle) {
+ rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
+ new rtc::RefCountedObject<CameraTextureBuffer>(
+ width, height, handle,
+ rtc::Bind(&AndroidVideoCapturerJni::ReturnBuffer, this,
+ timestamp_ns)));
+ AsyncCapturerInvoke("OnIncomingFrame",
+ &webrtc::AndroidVideoCapturer::OnIncomingFrame,
+ buffer, 0, timestamp_ns);
}
void AndroidVideoCapturerJni::OnOutputFormatRequest(int width,
@@ -191,7 +235,7 @@ JNIEnv* AndroidVideoCapturerJni::jni() { return AttachCurrentThreadIfNeeded(); }
JOW(void,
VideoCapturerAndroid_00024NativeObserver_nativeOnByteBufferFrameCaptured)
(JNIEnv* jni, jclass, jlong j_capturer, jbyteArray j_frame, jint length,
- jint width, jint height, jint rotation, jlong ts) {
+ jint width, jint height, jint rotation, jlong timestamp) {
jboolean is_copy = true;
jbyte* bytes = jni->GetByteArrayElements(j_frame, &is_copy);
// If this is a copy of the original frame, it means that the memory
@@ -202,10 +246,20 @@ JOW(void,
RTC_CHECK(!is_copy)
<< "NativeObserver_nativeOnFrameCaptured: frame is a copy";
reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)
- ->OnIncomingFrame(bytes, length, width, height, rotation, ts);
+ ->OnMemoryBufferFrame(bytes, length, width, height, rotation, timestamp);
jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT);
}
+JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnTextureFrameCaptured)
+ (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height,
+ jint j_oes_texture_id, jfloatArray j_transform_matrix,
+ jlong j_timestamp) {
+ reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)
+ ->OnTextureFrame(j_width, j_height, j_timestamp,
+ NativeHandleImpl(jni, j_oes_texture_id,
+ j_transform_matrix));
+}
+
JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeCapturerStarted)
(JNIEnv* jni, jclass, jlong j_capturer, jboolean j_success) {
LOG(LS_INFO) << "NativeObserver_nativeCapturerStarted";
« no previous file with comments | « talk/app/webrtc/java/jni/androidvideocapturer_jni.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698