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

Side by Side Diff: talk/app/webrtc/java/jni/surfacetexturehelper_jni.cc

Issue 1391403004: Android: Put common native VideoFrameBuffer implementation in androidvideocapturer_jni (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 unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/java/jni/surfacetexturehelper_jni.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"
33 #include "webrtc/base/checks.h" 34 #include "webrtc/base/checks.h"
34 35
35 namespace webrtc_jni { 36 namespace webrtc_jni {
36 37
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
62 SurfaceTextureHelper::SurfaceTextureHelper(JNIEnv* jni, 38 SurfaceTextureHelper::SurfaceTextureHelper(JNIEnv* jni,
63 jobject egl_shared_context) 39 jobject egl_shared_context)
64 : j_surface_texture_helper_class_( 40 : j_surface_texture_helper_class_(
65 jni, 41 jni,
66 FindClass(jni, "org/webrtc/SurfaceTextureHelper")), 42 FindClass(jni, "org/webrtc/SurfaceTextureHelper")),
67 j_surface_texture_helper_( 43 j_surface_texture_helper_(
68 jni, 44 jni,
69 jni->NewObject(*j_surface_texture_helper_class_, 45 jni->NewObject(*j_surface_texture_helper_class_,
70 GetMethodID(jni, 46 GetMethodID(jni,
71 *j_surface_texture_helper_class_, 47 *j_surface_texture_helper_class_,
(...skipping 15 matching lines...) Expand all
87 JNIEnv* jni = AttachCurrentThreadIfNeeded(); 63 JNIEnv* jni = AttachCurrentThreadIfNeeded();
88 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_); 64 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_);
89 65
90 CHECK_EXCEPTION( 66 CHECK_EXCEPTION(
91 jni) << "error during SurfaceTextureHelper.returnTextureFrame"; 67 jni) << "error during SurfaceTextureHelper.returnTextureFrame";
92 } 68 }
93 69
94 rtc::scoped_refptr<webrtc::VideoFrameBuffer> 70 rtc::scoped_refptr<webrtc::VideoFrameBuffer>
95 SurfaceTextureHelper::CreateTextureFrame(int width, int height, 71 SurfaceTextureHelper::CreateTextureFrame(int width, int height,
96 const NativeHandleImpl& native_handle) { 72 const NativeHandleImpl& native_handle) {
97 return new rtc::RefCountedObject<TextureBuffer>( 73 return new rtc::RefCountedObject<AndroidTextureBuffer>(
98 width, height, this, native_handle); 74 width, height, native_handle,
75 rtc::Bind(&SurfaceTextureHelper::ReturnTextureFrame, this));
99 } 76 }
100 77
101 } // namespace webrtc_jni 78 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « talk/app/webrtc/java/jni/surfacetexturehelper_jni.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698