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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 void AndroidVideoCapturerJni::OnIncomingFrame(void* video_frame, | 175 void AndroidVideoCapturerJni::OnIncomingFrame(void* video_frame, |
176 int length, | 176 int length, |
177 int rotation, | 177 int rotation, |
178 int64 time_stamp) { | 178 int64 time_stamp) { |
179 invoker_.AsyncInvoke<void>( | 179 invoker_.AsyncInvoke<void>( |
180 thread_, | 180 thread_, |
181 rtc::Bind(&AndroidVideoCapturerJni::OnIncomingFrame_w, | 181 rtc::Bind(&AndroidVideoCapturerJni::OnIncomingFrame_w, |
182 this, video_frame, length, rotation, time_stamp)); | 182 this, video_frame, length, rotation, time_stamp)); |
183 } | 183 } |
184 | 184 |
| 185 void AndroidVideoCapturerJni::OnOutputFormatRequest(int width, |
| 186 int height, |
| 187 int fps) { |
| 188 invoker_.AsyncInvoke<void>( |
| 189 thread_, |
| 190 rtc::Bind(&AndroidVideoCapturerJni::OnOutputFormatRequest_w, |
| 191 this, width, height, fps)); |
| 192 } |
| 193 |
185 void AndroidVideoCapturerJni::OnCapturerStarted_w(bool success) { | 194 void AndroidVideoCapturerJni::OnCapturerStarted_w(bool success) { |
186 CHECK(thread_checker_.CalledOnValidThread()); | 195 CHECK(thread_checker_.CalledOnValidThread()); |
187 if (capturer_) { | 196 if (capturer_) { |
188 capturer_->OnCapturerStarted(success); | 197 capturer_->OnCapturerStarted(success); |
189 } else { | 198 } else { |
190 LOG(LS_WARNING) << "OnCapturerStarted_w is called for closed capturer."; | 199 LOG(LS_WARNING) << "OnCapturerStarted_w is called for closed capturer."; |
191 } | 200 } |
192 } | 201 } |
193 | 202 |
194 void AndroidVideoCapturerJni::OnIncomingFrame_w(void* video_frame, | 203 void AndroidVideoCapturerJni::OnIncomingFrame_w(void* video_frame, |
195 int length, | 204 int length, |
196 int rotation, | 205 int rotation, |
197 int64 time_stamp) { | 206 int64 time_stamp) { |
198 CHECK(thread_checker_.CalledOnValidThread()); | 207 CHECK(thread_checker_.CalledOnValidThread()); |
199 if (capturer_) { | 208 if (capturer_) { |
200 capturer_->OnIncomingFrame(video_frame, length, rotation, time_stamp); | 209 capturer_->OnIncomingFrame(video_frame, length, rotation, time_stamp); |
201 } else { | 210 } else { |
202 LOG(LS_INFO) << | 211 LOG(LS_INFO) << |
203 "Frame arrived after camera has been stopped: " << time_stamp << | 212 "Frame arrived after camera has been stopped: " << time_stamp << |
204 ". Valid global refs: " << valid_global_refs_; | 213 ". Valid global refs: " << valid_global_refs_; |
205 ReturnBuffer_w(time_stamp); | 214 ReturnBuffer_w(time_stamp); |
206 } | 215 } |
207 } | 216 } |
208 | 217 |
| 218 void AndroidVideoCapturerJni::OnOutputFormatRequest_w(int width, |
| 219 int height, |
| 220 int fps) { |
| 221 CHECK(thread_checker_.CalledOnValidThread()); |
| 222 if (capturer_) { |
| 223 capturer_->OnOutputFormatRequest(width, height, fps); |
| 224 } else { |
| 225 LOG(LS_WARNING) << "OnOutputFormatRequest_w is called for closed capturer."; |
| 226 } |
| 227 } |
| 228 |
209 JNIEnv* AndroidVideoCapturerJni::jni() { return AttachCurrentThreadIfNeeded(); } | 229 JNIEnv* AndroidVideoCapturerJni::jni() { return AttachCurrentThreadIfNeeded(); } |
210 | 230 |
211 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnFrameCaptured) | 231 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnFrameCaptured) |
212 (JNIEnv* jni, jclass, jlong j_capturer, jbyteArray j_frame, jint length, | 232 (JNIEnv* jni, jclass, jlong j_capturer, jbyteArray j_frame, jint length, |
213 jint rotation, jlong ts) { | 233 jint rotation, jlong ts) { |
214 jboolean is_copy = true; | 234 jboolean is_copy = true; |
215 jbyte* bytes = jni->GetByteArrayElements(j_frame, &is_copy); | 235 jbyte* bytes = jni->GetByteArrayElements(j_frame, &is_copy); |
216 if (!is_copy) { | 236 if (!is_copy) { |
217 reinterpret_cast<AndroidVideoCapturerJni*>( | 237 reinterpret_cast<AndroidVideoCapturerJni*>( |
218 j_capturer)->OnIncomingFrame(bytes, length, rotation, ts); | 238 j_capturer)->OnIncomingFrame(bytes, length, rotation, ts); |
219 } else { | 239 } else { |
220 // If this is a copy of the original frame, it means that the memory | 240 // If this is a copy of the original frame, it means that the memory |
221 // is not direct memory and thus VideoCapturerAndroid does not guarantee | 241 // is not direct memory and thus VideoCapturerAndroid does not guarantee |
222 // that the memory is valid when we have released |j_frame|. | 242 // that the memory is valid when we have released |j_frame|. |
223 LOG(LS_ERROR) << "NativeObserver_nativeOnFrameCaptured: frame is a copy"; | 243 LOG(LS_ERROR) << "NativeObserver_nativeOnFrameCaptured: frame is a copy"; |
224 CHECK(false) << "j_frame is a copy."; | 244 CHECK(false) << "j_frame is a copy."; |
225 } | 245 } |
226 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT); | 246 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT); |
227 } | 247 } |
228 | 248 |
229 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeCapturerStarted) | 249 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeCapturerStarted) |
230 (JNIEnv* jni, jclass, jlong j_capturer, jboolean j_success) { | 250 (JNIEnv* jni, jclass, jlong j_capturer, jboolean j_success) { |
231 LOG(LS_INFO) << "NativeObserver_nativeCapturerStarted"; | 251 LOG(LS_INFO) << "NativeObserver_nativeCapturerStarted"; |
232 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnCapturerStarted( | 252 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnCapturerStarted( |
233 j_success); | 253 j_success); |
234 } | 254 } |
235 | 255 |
| 256 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnOutputFormatRequest) |
| 257 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, |
| 258 jint j_fps) { |
| 259 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; |
| 260 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( |
| 261 j_width, j_height, j_fps); |
| 262 } |
| 263 |
236 } // namespace webrtc_jni | 264 } // namespace webrtc_jni |
237 | 265 |
OLD | NEW |