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

Side by Side Diff: webrtc/api/android/jni/surfacetexturehelper_jni.cc

Issue 2547483003: Move /webrtc/api/android files to /webrtc/sdk/android (Closed)
Patch Set: Move to api folder under Android instead of src Created 4 years 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11
12 #include "webrtc/api/android/jni/surfacetexturehelper_jni.h"
13
14 #include "webrtc/api/android/jni/classreferenceholder.h"
15 #include "webrtc/base/bind.h"
16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/logging.h"
18
19 namespace webrtc_jni {
20
21 rtc::scoped_refptr<SurfaceTextureHelper> SurfaceTextureHelper::create(
22 JNIEnv* jni,
23 const char* thread_name,
24 jobject j_egl_context) {
25 jobject j_surface_texture_helper = jni->CallStaticObjectMethod(
26 FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
27 GetStaticMethodID(jni, FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
28 "create",
29 "(Ljava/lang/String;Lorg/webrtc/EglBase$Context;)"
30 "Lorg/webrtc/SurfaceTextureHelper;"),
31 jni->NewStringUTF(thread_name), j_egl_context);
32 CHECK_EXCEPTION(jni)
33 << "error during initialization of Java SurfaceTextureHelper";
34 if (IsNull(jni, j_surface_texture_helper))
35 return nullptr;
36 return new rtc::RefCountedObject<SurfaceTextureHelper>(
37 jni, j_surface_texture_helper);
38 }
39
40 SurfaceTextureHelper::SurfaceTextureHelper(JNIEnv* jni,
41 jobject j_surface_texture_helper)
42 : j_surface_texture_helper_(jni, j_surface_texture_helper),
43 j_return_texture_method_(
44 GetMethodID(jni,
45 FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
46 "returnTextureFrame",
47 "()V")) {
48 CHECK_EXCEPTION(jni) << "error during initialization of SurfaceTextureHelper";
49 }
50
51 SurfaceTextureHelper::~SurfaceTextureHelper() {
52 LOG(LS_INFO) << "SurfaceTextureHelper dtor";
53 JNIEnv* jni = AttachCurrentThreadIfNeeded();
54 jni->CallVoidMethod(
55 *j_surface_texture_helper_,
56 GetMethodID(jni, FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
57 "dispose", "()V"));
58
59 CHECK_EXCEPTION(jni) << "error during SurfaceTextureHelper.dispose()";
60 }
61
62 jobject SurfaceTextureHelper::GetJavaSurfaceTextureHelper() const {
63 return *j_surface_texture_helper_;
64 }
65
66 void SurfaceTextureHelper::ReturnTextureFrame() const {
67 JNIEnv* jni = AttachCurrentThreadIfNeeded();
68 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_);
69
70 CHECK_EXCEPTION(
71 jni) << "error during SurfaceTextureHelper.returnTextureFrame";
72 }
73
74 rtc::scoped_refptr<webrtc::VideoFrameBuffer>
75 SurfaceTextureHelper::CreateTextureFrame(int width, int height,
76 const NativeHandleImpl& native_handle) {
77 return new rtc::RefCountedObject<AndroidTextureBuffer>(
78 width, height, native_handle, *j_surface_texture_helper_,
79 rtc::Bind(&SurfaceTextureHelper::ReturnTextureFrame, this));
80 }
81
82 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « webrtc/api/android/jni/surfacetexturehelper_jni.h ('k') | webrtc/api/test/androidtestinitializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698