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