| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // Helper class to create and synchronize access to an Android SurfaceTexture. | 42 // Helper class to create and synchronize access to an Android SurfaceTexture. |
| 43 // It is used for creating webrtc::VideoFrameBuffers from a SurfaceTexture when | 43 // It is used for creating webrtc::VideoFrameBuffers from a SurfaceTexture when |
| 44 // the SurfaceTexture has been updated. | 44 // the SurfaceTexture has been updated. |
| 45 // When the VideoFrameBuffer is released, this class returns the buffer to the | 45 // When the VideoFrameBuffer is released, this class returns the buffer to the |
| 46 // java SurfaceTextureHelper so it can be updated safely. The VideoFrameBuffer | 46 // java SurfaceTextureHelper so it can be updated safely. The VideoFrameBuffer |
| 47 // can be released on an arbitrary thread. | 47 // can be released on an arbitrary thread. |
| 48 // SurfaceTextureHelper is reference counted to make sure that it is not | 48 // SurfaceTextureHelper is reference counted to make sure that it is not |
| 49 // destroyed while a VideoFrameBuffer is in use. | 49 // destroyed while a VideoFrameBuffer is in use. |
| 50 // This class is the C++ counterpart of the java class SurfaceTextureHelper. | 50 // This class is the C++ counterpart of the java class SurfaceTextureHelper. |
| 51 // Usage: | 51 // Usage: |
| 52 // 1. Create an instance of this class. | 52 // 1. Create an java instance of SurfaceTextureHelper. |
| 53 // 2. Call GetJavaSurfaceTextureHelper to get the Java SurfaceTextureHelper. | 53 // 2. Create an instance of this class. |
| 54 // 3. Register a listener to the Java SurfaceListener and start producing | 54 // 3. Register a listener to the Java SurfaceListener and start producing |
| 55 // new buffers. | 55 // new buffers. |
| 56 // 3. Call CreateTextureFrame to wrap the Java texture in a VideoFrameBuffer. | 56 // 4. Call CreateTextureFrame to wrap the Java texture in a VideoFrameBuffer. |
| 57 class SurfaceTextureHelper : public rtc::RefCountInterface { | 57 class SurfaceTextureHelper : public rtc::RefCountInterface { |
| 58 public: | 58 public: |
| 59 SurfaceTextureHelper(JNIEnv* jni, jobject shared_egl_context); | 59 SurfaceTextureHelper(JNIEnv* jni, jobject surface_texture_helper); |
| 60 | |
| 61 // Returns the Java SurfaceTextureHelper. | |
| 62 jobject GetJavaSurfaceTextureHelper() const { | |
| 63 return *j_surface_texture_helper_; | |
| 64 } | |
| 65 | 60 |
| 66 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateTextureFrame( | 61 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateTextureFrame( |
| 67 int width, | 62 int width, |
| 68 int height, | 63 int height, |
| 69 const NativeHandleImpl& native_handle); | 64 const NativeHandleImpl& native_handle); |
| 70 | 65 |
| 71 protected: | 66 protected: |
| 72 ~SurfaceTextureHelper(); | 67 ~SurfaceTextureHelper(); |
| 73 | 68 |
| 74 private: | 69 private: |
| 75 // May be called on arbitrary thread. | 70 // May be called on arbitrary thread. |
| 76 void ReturnTextureFrame() const; | 71 void ReturnTextureFrame() const; |
| 77 | 72 |
| 78 const ScopedGlobalRef<jclass> j_surface_texture_helper_class_; | |
| 79 const ScopedGlobalRef<jobject> j_surface_texture_helper_; | 73 const ScopedGlobalRef<jobject> j_surface_texture_helper_; |
| 80 const jmethodID j_return_texture_method_; | 74 const jmethodID j_return_texture_method_; |
| 81 }; | 75 }; |
| 82 | 76 |
| 83 } // namespace webrtc_jni | 77 } // namespace webrtc_jni |
| 84 | 78 |
| 85 #endif // TALK_APP_WEBRTC_JAVA_JNI_SURFACETEXTUREHELPER_JNI_H_ | 79 #endif // TALK_APP_WEBRTC_JAVA_JNI_SURFACETEXTUREHELPER_JNI_H_ |
| OLD | NEW |