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 17 matching lines...) Expand all Loading... |
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" | 33 #include "webrtc/base/bind.h" |
34 #include "webrtc/base/checks.h" | 34 #include "webrtc/base/checks.h" |
35 | 35 |
36 namespace webrtc_jni { | 36 namespace webrtc_jni { |
37 | 37 |
38 SurfaceTextureHelper::SurfaceTextureHelper(JNIEnv* jni, | 38 SurfaceTextureHelper::SurfaceTextureHelper( |
39 jobject egl_shared_context) | 39 JNIEnv* jni, jobject surface_texture_helper) |
40 : j_surface_texture_helper_class_( | 40 : j_surface_texture_helper_(jni, surface_texture_helper), |
41 jni, | 41 j_return_texture_method_( |
42 FindClass(jni, "org/webrtc/SurfaceTextureHelper")), | 42 GetMethodID(jni, |
43 j_surface_texture_helper_( | 43 FindClass(jni, "org/webrtc/SurfaceTextureHelper"), |
44 jni, | 44 "returnTextureFrame", |
45 jni->CallStaticObjectMethod( | 45 "()V")) { |
46 *j_surface_texture_helper_class_, | |
47 GetStaticMethodID(jni, | |
48 *j_surface_texture_helper_class_, | |
49 "create", | |
50 "(Lorg/webrtc/EglBase$Context;)" | |
51 "Lorg/webrtc/SurfaceTextureHelper;"), | |
52 egl_shared_context)), | |
53 j_return_texture_method_(GetMethodID(jni, | |
54 *j_surface_texture_helper_class_, | |
55 "returnTextureFrame", | |
56 "()V")) { | |
57 CHECK_EXCEPTION(jni) << "error during initialization of SurfaceTextureHelper"; | 46 CHECK_EXCEPTION(jni) << "error during initialization of SurfaceTextureHelper"; |
58 } | 47 } |
59 | 48 |
60 SurfaceTextureHelper::~SurfaceTextureHelper() { | 49 SurfaceTextureHelper::~SurfaceTextureHelper() { |
61 } | 50 } |
62 | 51 |
63 void SurfaceTextureHelper::ReturnTextureFrame() const { | 52 void SurfaceTextureHelper::ReturnTextureFrame() const { |
64 JNIEnv* jni = AttachCurrentThreadIfNeeded(); | 53 JNIEnv* jni = AttachCurrentThreadIfNeeded(); |
65 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_); | 54 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_); |
66 | 55 |
67 CHECK_EXCEPTION( | 56 CHECK_EXCEPTION( |
68 jni) << "error during SurfaceTextureHelper.returnTextureFrame"; | 57 jni) << "error during SurfaceTextureHelper.returnTextureFrame"; |
69 } | 58 } |
70 | 59 |
71 rtc::scoped_refptr<webrtc::VideoFrameBuffer> | 60 rtc::scoped_refptr<webrtc::VideoFrameBuffer> |
72 SurfaceTextureHelper::CreateTextureFrame(int width, int height, | 61 SurfaceTextureHelper::CreateTextureFrame(int width, int height, |
73 const NativeHandleImpl& native_handle) { | 62 const NativeHandleImpl& native_handle) { |
74 return new rtc::RefCountedObject<AndroidTextureBuffer>( | 63 return new rtc::RefCountedObject<AndroidTextureBuffer>( |
75 width, height, native_handle, *j_surface_texture_helper_, | 64 width, height, native_handle, *j_surface_texture_helper_, |
76 rtc::Bind(&SurfaceTextureHelper::ReturnTextureFrame, this)); | 65 rtc::Bind(&SurfaceTextureHelper::ReturnTextureFrame, this)); |
77 } | 66 } |
78 | 67 |
79 } // namespace webrtc_jni | 68 } // namespace webrtc_jni |
OLD | NEW |