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 18 matching lines...) Expand all Loading... |
29 #ifndef TALK_APP_WEBRTC_JAVA_JNI_NATIVE_HANDLE_IMPL_H_ | 29 #ifndef TALK_APP_WEBRTC_JAVA_JNI_NATIVE_HANDLE_IMPL_H_ |
30 #define TALK_APP_WEBRTC_JAVA_JNI_NATIVE_HANDLE_IMPL_H_ | 30 #define TALK_APP_WEBRTC_JAVA_JNI_NATIVE_HANDLE_IMPL_H_ |
31 | 31 |
32 #include <jni.h> | 32 #include <jni.h> |
33 | 33 |
34 #include "webrtc/common_video/include/video_frame_buffer.h" | 34 #include "webrtc/common_video/include/video_frame_buffer.h" |
35 | 35 |
36 namespace webrtc_jni { | 36 namespace webrtc_jni { |
37 | 37 |
38 // Wrapper for texture object. | 38 // Wrapper for texture object. |
39 struct NativeTextureHandleImpl { | 39 struct NativeHandleImpl { |
40 NativeTextureHandleImpl(JNIEnv* jni, | 40 NativeHandleImpl(JNIEnv* jni, |
41 jint j_oes_texture_id, | 41 jint j_oes_texture_id, |
42 jfloatArray j_transform_matrix); | 42 jfloatArray j_transform_matrix); |
43 | 43 |
44 const int oes_texture_id; | 44 const int oes_texture_id; |
45 float sampling_matrix[16]; | 45 float sampling_matrix[16]; |
46 }; | 46 }; |
47 | 47 |
48 // Native handle for SurfaceTexture + texture id. | |
49 class NativeHandleImpl { | |
50 public: | |
51 NativeHandleImpl(); | |
52 | |
53 void* GetHandle(); | |
54 int GetTextureId(); | |
55 void SetTextureObject(void* texture_object, int texture_id); | |
56 | |
57 private: | |
58 jobject texture_object_; | |
59 int32_t texture_id_; | |
60 }; | |
61 | |
62 class JniNativeHandleBuffer : public webrtc::NativeHandleBuffer { | |
63 public: | |
64 JniNativeHandleBuffer(void* native_handle, int width, int height); | |
65 | |
66 // TODO(pbos): Override destructor to release native handle, at the moment the | |
67 // native handle is not released based on refcount. | |
68 | |
69 private: | |
70 rtc::scoped_refptr<webrtc::VideoFrameBuffer> NativeToI420Buffer() override; | |
71 }; | |
72 | |
73 class AndroidTextureBuffer : public webrtc::NativeHandleBuffer { | 48 class AndroidTextureBuffer : public webrtc::NativeHandleBuffer { |
74 public: | 49 public: |
75 AndroidTextureBuffer(int width, | 50 AndroidTextureBuffer(int width, |
76 int height, | 51 int height, |
77 const NativeTextureHandleImpl& native_handle, | 52 const NativeHandleImpl& native_handle, |
78 const rtc::Callback0<void>& no_longer_used); | 53 const rtc::Callback0<void>& no_longer_used); |
79 ~AndroidTextureBuffer(); | 54 ~AndroidTextureBuffer(); |
80 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; | 55 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; |
81 | 56 |
82 private: | 57 private: |
83 NativeTextureHandleImpl native_handle_; | 58 NativeHandleImpl native_handle_; |
84 rtc::Callback0<void> no_longer_used_cb_; | 59 rtc::Callback0<void> no_longer_used_cb_; |
85 }; | 60 }; |
86 | 61 |
87 } // namespace webrtc_jni | 62 } // namespace webrtc_jni |
88 | 63 |
89 #endif // TALK_APP_WEBRTC_JAVA_JNI_NATIVE_HANDLE_IMPL_H_ | 64 #endif // TALK_APP_WEBRTC_JAVA_JNI_NATIVE_HANDLE_IMPL_H_ |
OLD | NEW |