2015-02-18 18:42:55 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
2015-02-18 18:42:55 +00:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* 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.
|
2015-02-18 18:42:55 +00:00
|
|
|
*/
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#ifndef WEBRTC_API_JAVA_JNI_NATIVE_HANDLE_IMPL_H_
|
|
|
|
|
#define WEBRTC_API_JAVA_JNI_NATIVE_HANDLE_IMPL_H_
|
2015-02-18 18:42:55 +00:00
|
|
|
|
2015-10-02 13:56:04 +02:00
|
|
|
#include <jni.h>
|
|
|
|
|
|
2015-11-16 13:52:24 -08:00
|
|
|
#include "webrtc/common_video/include/video_frame_buffer.h"
|
2015-12-11 09:32:37 +01:00
|
|
|
#include "webrtc/common_video/rotation.h"
|
2015-10-12 06:53:20 -07:00
|
|
|
|
2015-02-18 18:42:55 +00:00
|
|
|
namespace webrtc_jni {
|
|
|
|
|
|
2015-04-09 13:44:16 +02:00
|
|
|
// Wrapper for texture object.
|
2015-11-19 10:43:36 +01:00
|
|
|
struct NativeHandleImpl {
|
|
|
|
|
NativeHandleImpl(JNIEnv* jni,
|
|
|
|
|
jint j_oes_texture_id,
|
|
|
|
|
jfloatArray j_transform_matrix);
|
2015-06-05 11:08:03 +02:00
|
|
|
|
2015-10-07 22:57:06 +02:00
|
|
|
const int oes_texture_id;
|
|
|
|
|
float sampling_matrix[16];
|
2015-06-05 11:08:03 +02:00
|
|
|
};
|
|
|
|
|
|
2015-10-12 06:53:20 -07:00
|
|
|
class AndroidTextureBuffer : public webrtc::NativeHandleBuffer {
|
|
|
|
|
public:
|
|
|
|
|
AndroidTextureBuffer(int width,
|
|
|
|
|
int height,
|
2015-11-19 10:43:36 +01:00
|
|
|
const NativeHandleImpl& native_handle,
|
2015-12-10 06:23:33 -08:00
|
|
|
jobject surface_texture_helper,
|
2015-10-12 06:53:20 -07:00
|
|
|
const rtc::Callback0<void>& no_longer_used);
|
|
|
|
|
~AndroidTextureBuffer();
|
|
|
|
|
rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override;
|
|
|
|
|
|
2015-12-11 09:32:37 +01:00
|
|
|
rtc::scoped_refptr<AndroidTextureBuffer> ScaleAndRotate(
|
2015-11-26 13:41:44 +01:00
|
|
|
int dst_widht,
|
2015-12-11 09:32:37 +01:00
|
|
|
int dst_height,
|
|
|
|
|
webrtc::VideoRotation rotation);
|
2015-11-26 13:41:44 +01:00
|
|
|
|
2015-10-12 06:53:20 -07:00
|
|
|
private:
|
2015-11-19 10:43:36 +01:00
|
|
|
NativeHandleImpl native_handle_;
|
2015-12-10 06:23:33 -08:00
|
|
|
// Raw object pointer, relying on the caller, i.e.,
|
|
|
|
|
// AndroidVideoCapturerJni or the C++ SurfaceTextureHelper, to keep
|
|
|
|
|
// a global reference. TODO(nisse): Make this a reference to the C++
|
|
|
|
|
// SurfaceTextureHelper instead, but that requires some refactoring
|
|
|
|
|
// of AndroidVideoCapturerJni.
|
|
|
|
|
jobject surface_texture_helper_;
|
2015-10-12 06:53:20 -07:00
|
|
|
rtc::Callback0<void> no_longer_used_cb_;
|
|
|
|
|
};
|
|
|
|
|
|
2015-02-18 18:42:55 +00:00
|
|
|
} // namespace webrtc_jni
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#endif // WEBRTC_API_JAVA_JNI_NATIVE_HANDLE_IMPL_H_
|