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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 private: | 57 private: |
58 NativeHandleImpl native_handle_; | 58 NativeHandleImpl native_handle_; |
59 const rtc::scoped_refptr<SurfaceTextureHelper> pool_; | 59 const rtc::scoped_refptr<SurfaceTextureHelper> pool_; |
60 }; | 60 }; |
61 | 61 |
62 SurfaceTextureHelper::SurfaceTextureHelper(JNIEnv* jni, | 62 SurfaceTextureHelper::SurfaceTextureHelper(JNIEnv* jni, |
63 jobject egl_shared_context) | 63 jobject egl_shared_context) |
64 : j_surface_texture_helper_class_( | 64 : j_surface_texture_helper_class_( |
65 jni, | 65 jni, |
66 FindClass(jni, "org/webrtc/SurfaceTextureHelper")), | 66 FindClass(jni, "org/webrtc/SurfaceTextureHelper")), |
67 j_surface_texture_helper_( | 67 j_surface_texture_helper_(jni, jni->CallStaticObjectMethod( |
68 jni, | 68 *j_surface_texture_helper_class_, |
69 jni->NewObject(*j_surface_texture_helper_class_, | 69 GetStaticMethodID( |
70 GetMethodID(jni, | 70 jni, |
71 *j_surface_texture_helper_class_, | 71 *j_surface_texture_helper_class_, |
72 "<init>", | 72 "create", |
73 "(Landroid/opengl/EGLContext;)V"), | 73 "(Landroid/opengl/EGLContext;)Lorg/webrtc/SurfaceTextureHelper;"), |
74 egl_shared_context)), | 74 egl_shared_context)), |
75 j_return_texture_method_( | 75 j_return_texture_method_(GetMethodID(jni, |
76 GetMethodID(jni, | 76 *j_surface_texture_helper_class_, |
77 *j_surface_texture_helper_class_, | 77 "returnTextureFrame", |
78 "returnTextureFrame", | 78 "()V")) { |
79 "()V")) { | |
80 CHECK_EXCEPTION(jni) << "error during initialization of SurfaceTextureHelper"; | 79 CHECK_EXCEPTION(jni) << "error during initialization of SurfaceTextureHelper"; |
81 } | 80 } |
82 | 81 |
83 SurfaceTextureHelper::~SurfaceTextureHelper() { | 82 SurfaceTextureHelper::~SurfaceTextureHelper() { |
84 } | 83 } |
85 | 84 |
86 void SurfaceTextureHelper::ReturnTextureFrame() const { | 85 void SurfaceTextureHelper::ReturnTextureFrame() const { |
87 JNIEnv* jni = AttachCurrentThreadIfNeeded(); | 86 JNIEnv* jni = AttachCurrentThreadIfNeeded(); |
88 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_); | 87 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_); |
89 | 88 |
90 CHECK_EXCEPTION( | 89 CHECK_EXCEPTION( |
91 jni) << "error during SurfaceTextureHelper.returnTextureFrame"; | 90 jni) << "error during SurfaceTextureHelper.returnTextureFrame"; |
92 } | 91 } |
93 | 92 |
94 rtc::scoped_refptr<webrtc::VideoFrameBuffer> | 93 rtc::scoped_refptr<webrtc::VideoFrameBuffer> |
95 SurfaceTextureHelper::CreateTextureFrame(int width, int height, | 94 SurfaceTextureHelper::CreateTextureFrame(int width, int height, |
96 const NativeHandleImpl& native_handle) { | 95 const NativeHandleImpl& native_handle) { |
97 return new rtc::RefCountedObject<TextureBuffer>( | 96 return new rtc::RefCountedObject<TextureBuffer>( |
98 width, height, this, native_handle); | 97 width, height, this, native_handle); |
99 } | 98 } |
100 | 99 |
101 } // namespace webrtc_jni | 100 } // namespace webrtc_jni |
OLD | NEW |