OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 12 matching lines...) Expand all Loading... |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 * | 26 * |
27 */ | 27 */ |
28 | 28 |
29 | 29 |
30 #include "talk/app/webrtc/java/jni/surfacetexturehelper_jni.h" | 30 #include "talk/app/webrtc/java/jni/surfacetexturehelper_jni.h" |
31 | 31 |
32 #include "talk/app/webrtc/java/jni/classreferenceholder.h" | 32 #include "talk/app/webrtc/java/jni/classreferenceholder.h" |
33 #include "webrtc/base/bind.h" | |
34 #include "webrtc/base/checks.h" | 33 #include "webrtc/base/checks.h" |
35 | 34 |
36 namespace webrtc_jni { | 35 namespace webrtc_jni { |
37 | 36 |
| 37 class SurfaceTextureHelper::TextureBuffer : public webrtc::NativeHandleBuffer { |
| 38 public: |
| 39 TextureBuffer(int width, |
| 40 int height, |
| 41 const rtc::scoped_refptr<SurfaceTextureHelper>& pool, |
| 42 const NativeHandleImpl& native_handle) |
| 43 : webrtc::NativeHandleBuffer(&native_handle_, width, height), |
| 44 native_handle_(native_handle), |
| 45 pool_(pool) {} |
| 46 |
| 47 ~TextureBuffer() { |
| 48 pool_->ReturnTextureFrame(); |
| 49 } |
| 50 |
| 51 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override { |
| 52 RTC_NOTREACHED() |
| 53 << "SurfaceTextureHelper::NativeToI420Buffer not implemented."; |
| 54 return nullptr; |
| 55 } |
| 56 |
| 57 private: |
| 58 NativeHandleImpl native_handle_; |
| 59 const rtc::scoped_refptr<SurfaceTextureHelper> pool_; |
| 60 }; |
| 61 |
38 SurfaceTextureHelper::SurfaceTextureHelper(JNIEnv* jni, | 62 SurfaceTextureHelper::SurfaceTextureHelper(JNIEnv* jni, |
39 jobject egl_shared_context) | 63 jobject egl_shared_context) |
40 : j_surface_texture_helper_class_( | 64 : j_surface_texture_helper_class_( |
41 jni, | 65 jni, |
42 FindClass(jni, "org/webrtc/SurfaceTextureHelper")), | 66 FindClass(jni, "org/webrtc/SurfaceTextureHelper")), |
43 j_surface_texture_helper_( | 67 j_surface_texture_helper_( |
44 jni, | 68 jni, |
45 jni->NewObject(*j_surface_texture_helper_class_, | 69 jni->NewObject(*j_surface_texture_helper_class_, |
46 GetMethodID(jni, | 70 GetMethodID(jni, |
47 *j_surface_texture_helper_class_, | 71 *j_surface_texture_helper_class_, |
(...skipping 15 matching lines...) Expand all Loading... |
63 JNIEnv* jni = AttachCurrentThreadIfNeeded(); | 87 JNIEnv* jni = AttachCurrentThreadIfNeeded(); |
64 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_); | 88 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_); |
65 | 89 |
66 CHECK_EXCEPTION( | 90 CHECK_EXCEPTION( |
67 jni) << "error during SurfaceTextureHelper.returnTextureFrame"; | 91 jni) << "error during SurfaceTextureHelper.returnTextureFrame"; |
68 } | 92 } |
69 | 93 |
70 rtc::scoped_refptr<webrtc::VideoFrameBuffer> | 94 rtc::scoped_refptr<webrtc::VideoFrameBuffer> |
71 SurfaceTextureHelper::CreateTextureFrame(int width, int height, | 95 SurfaceTextureHelper::CreateTextureFrame(int width, int height, |
72 const NativeHandleImpl& native_handle) { | 96 const NativeHandleImpl& native_handle) { |
73 return new rtc::RefCountedObject<AndroidTextureBuffer>( | 97 return new rtc::RefCountedObject<TextureBuffer>( |
74 width, height, native_handle, | 98 width, height, this, native_handle); |
75 rtc::Bind(&SurfaceTextureHelper::ReturnTextureFrame, this)); | |
76 } | 99 } |
77 | 100 |
78 } // namespace webrtc_jni | 101 } // namespace webrtc_jni |
OLD | NEW |