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

Side by Side Diff: webrtc/sdk/android/src/jni/surfacetexturehelper_jni.h

Issue 3009613002: Android: Replace webrtc_jni namespace with nested jni namespace (Closed)
Patch Set: Rebase Created 3 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_SURFACETEXTUREHELPER_JNI_H_ 11 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_SURFACETEXTUREHELPER_JNI_H_
12 #define WEBRTC_SDK_ANDROID_SRC_JNI_SURFACETEXTUREHELPER_JNI_H_ 12 #define WEBRTC_SDK_ANDROID_SRC_JNI_SURFACETEXTUREHELPER_JNI_H_
13 13
14 #include <jni.h> 14 #include <jni.h>
15 15
16 #include "webrtc/api/video/video_frame_buffer.h" 16 #include "webrtc/api/video/video_frame_buffer.h"
17 #include "webrtc/rtc_base/refcount.h" 17 #include "webrtc/rtc_base/refcount.h"
18 #include "webrtc/rtc_base/scoped_ref_ptr.h" 18 #include "webrtc/rtc_base/scoped_ref_ptr.h"
19 #include "webrtc/sdk/android/src/jni/jni_helpers.h" 19 #include "webrtc/sdk/android/src/jni/jni_helpers.h"
20 #include "webrtc/sdk/android/src/jni/native_handle_impl.h" 20 #include "webrtc/sdk/android/src/jni/native_handle_impl.h"
21 21
22 namespace webrtc_jni { 22 namespace webrtc {
23 namespace jni {
23 24
24 // Helper class to create and synchronize access to an Android SurfaceTexture. 25 // Helper class to create and synchronize access to an Android SurfaceTexture.
25 // It is used for creating webrtc::VideoFrameBuffers from a SurfaceTexture when 26 // It is used for creating VideoFrameBuffers from a SurfaceTexture when
26 // the SurfaceTexture has been updated. 27 // the SurfaceTexture has been updated.
27 // When the VideoFrameBuffer is released, this class returns the buffer to the 28 // When the VideoFrameBuffer is released, this class returns the buffer to the
28 // java SurfaceTextureHelper so it can be updated safely. The VideoFrameBuffer 29 // java SurfaceTextureHelper so it can be updated safely. The VideoFrameBuffer
29 // can be released on an arbitrary thread. 30 // can be released on an arbitrary thread.
30 // SurfaceTextureHelper is reference counted to make sure that it is not 31 // SurfaceTextureHelper is reference counted to make sure that it is not
31 // destroyed while a VideoFrameBuffer is in use. 32 // destroyed while a VideoFrameBuffer is in use.
32 // This class is the C++ counterpart of the java class SurfaceTextureHelper. 33 // This class is the C++ counterpart of the java class SurfaceTextureHelper.
33 // It owns the corresponding java object, and calls the java dispose 34 // It owns the corresponding java object, and calls the java dispose
34 // method when destroyed. 35 // method when destroyed.
35 // Usage: 36 // Usage:
36 // 1. Create an instance of this class. 37 // 1. Create an instance of this class.
37 // 2. Get the Java SurfaceTextureHelper with GetJavaSurfaceTextureHelper(). 38 // 2. Get the Java SurfaceTextureHelper with GetJavaSurfaceTextureHelper().
38 // 3. Register a listener to the Java SurfaceListener and start producing 39 // 3. Register a listener to the Java SurfaceListener and start producing
39 // new buffers. 40 // new buffers.
40 // 4. Call CreateTextureFrame to wrap the Java texture in a VideoFrameBuffer. 41 // 4. Call CreateTextureFrame to wrap the Java texture in a VideoFrameBuffer.
41 class SurfaceTextureHelper : public rtc::RefCountInterface { 42 class SurfaceTextureHelper : public rtc::RefCountInterface {
42 public: 43 public:
43 // Might return null if creating the Java SurfaceTextureHelper fails. 44 // Might return null if creating the Java SurfaceTextureHelper fails.
44 static rtc::scoped_refptr<SurfaceTextureHelper> create( 45 static rtc::scoped_refptr<SurfaceTextureHelper> create(
45 JNIEnv* jni, const char* thread_name, jobject j_egl_context); 46 JNIEnv* jni, const char* thread_name, jobject j_egl_context);
46 47
47 jobject GetJavaSurfaceTextureHelper() const; 48 jobject GetJavaSurfaceTextureHelper() const;
48 49
49 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateTextureFrame( 50 rtc::scoped_refptr<VideoFrameBuffer> CreateTextureFrame(
50 int width, 51 int width,
51 int height, 52 int height,
52 const NativeHandleImpl& native_handle); 53 const NativeHandleImpl& native_handle);
53 54
54 // May be called on arbitrary thread. 55 // May be called on arbitrary thread.
55 void ReturnTextureFrame() const; 56 void ReturnTextureFrame() const;
56 57
57 protected: 58 protected:
58 ~SurfaceTextureHelper(); 59 ~SurfaceTextureHelper();
59 SurfaceTextureHelper(JNIEnv* jni, jobject j_surface_texture_helper); 60 SurfaceTextureHelper(JNIEnv* jni, jobject j_surface_texture_helper);
60 61
61 private: 62 private:
62 const ScopedGlobalRef<jobject> j_surface_texture_helper_; 63 const ScopedGlobalRef<jobject> j_surface_texture_helper_;
63 const jmethodID j_return_texture_method_; 64 const jmethodID j_return_texture_method_;
64 }; 65 };
65 66
66 } // namespace webrtc_jni 67 } // namespace jni
68 } // namespace webrtc
67 69
68 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_SURFACETEXTUREHELPER_JNI_H_ 70 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_SURFACETEXTUREHELPER_JNI_H_
OLDNEW
« no previous file with comments | « webrtc/sdk/android/src/jni/pc/video_jni.cc ('k') | webrtc/sdk/android/src/jni/surfacetexturehelper_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698