| 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::OnCapturerStarted_w(bool success) { | 187 void AndroidVideoCapturerJni::OnCapturerStarted_w(bool success) { |
| 186 CHECK(thread_checker_.CalledOnValidThread()); | 188 CHECK(thread_checker_.CalledOnValidThread()); |
| 187 if (capturer_) { | 189 if (capturer_) { |
| 188 capturer_->OnCapturerStarted(success); | 190 capturer_->OnCapturerStarted(success); |
| 189 } else { | 191 } else { |
| 190 LOG(LS_WARNING) << "OnCapturerStarted_w is called for closed capturer."; | 192 LOG(LS_WARNING) << "OnCapturerStarted_w is called for closed capturer."; |
| 191 } | 193 } |
| 192 } | 194 } |
| 193 | 195 |
| 194 void AndroidVideoCapturerJni::OnIncomingFrame_w(void* video_frame, | 196 void AndroidVideoCapturerJni::OnIncomingFrame_w(void* video_frame, |
| 195 int length, | 197 int length, |
| 198 int width, |
| 199 int height, |
| 196 int rotation, | 200 int rotation, |
| 197 int64 time_stamp) { | 201 int64 time_stamp) { |
| 198 CHECK(thread_checker_.CalledOnValidThread()); | 202 CHECK(thread_checker_.CalledOnValidThread()); |
| 199 if (capturer_) { | 203 if (capturer_) { |
| 200 capturer_->OnIncomingFrame(video_frame, length, rotation, time_stamp); | 204 capturer_->OnIncomingFrame(video_frame, length, width, height, rotation, |
| 205 time_stamp); |
| 201 } else { | 206 } else { |
| 202 LOG(LS_INFO) << | 207 LOG(LS_INFO) << |
| 203 "Frame arrived after camera has been stopped: " << time_stamp << | 208 "Frame arrived after camera has been stopped: " << time_stamp << |
| 204 ". Valid global refs: " << valid_global_refs_; | 209 ". Valid global refs: " << valid_global_refs_; |
| 205 ReturnBuffer_w(time_stamp); | 210 ReturnBuffer_w(time_stamp); |
| 206 } | 211 } |
| 207 } | 212 } |
| 208 | 213 |
| 209 JNIEnv* AndroidVideoCapturerJni::jni() { return AttachCurrentThreadIfNeeded(); } | 214 JNIEnv* AndroidVideoCapturerJni::jni() { return AttachCurrentThreadIfNeeded(); } |
| 210 | 215 |
| 211 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnFrameCaptured) | 216 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnFrameCaptured) |
| 212 (JNIEnv* jni, jclass, jlong j_capturer, jbyteArray j_frame, jint length, | 217 (JNIEnv* jni, jclass, jlong j_capturer, jbyteArray j_frame, jint length, |
| 213 jint rotation, jlong ts) { | 218 jint width, jint height, jint rotation, jlong ts) { |
| 214 jboolean is_copy = true; | 219 jboolean is_copy = true; |
| 215 jbyte* bytes = jni->GetByteArrayElements(j_frame, &is_copy); | 220 jbyte* bytes = jni->GetByteArrayElements(j_frame, &is_copy); |
| 216 if (!is_copy) { | 221 if (!is_copy) { |
| 217 reinterpret_cast<AndroidVideoCapturerJni*>( | 222 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer) |
| 218 j_capturer)->OnIncomingFrame(bytes, length, rotation, ts); | 223 ->OnIncomingFrame(bytes, length, width, height, rotation, ts); |
| 219 } else { | 224 } else { |
| 220 // If this is a copy of the original frame, it means that the memory | 225 // 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 | 226 // is not direct memory and thus VideoCapturerAndroid does not guarantee |
| 222 // that the memory is valid when we have released |j_frame|. | 227 // that the memory is valid when we have released |j_frame|. |
| 223 LOG(LS_ERROR) << "NativeObserver_nativeOnFrameCaptured: frame is a copy"; | 228 LOG(LS_ERROR) << "NativeObserver_nativeOnFrameCaptured: frame is a copy"; |
| 224 CHECK(false) << "j_frame is a copy."; | 229 CHECK(false) << "j_frame is a copy."; |
| 225 } | 230 } |
| 226 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT); | 231 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT); |
| 227 } | 232 } |
| 228 | 233 |
| 229 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeCapturerStarted) | 234 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeCapturerStarted) |
| 230 (JNIEnv* jni, jclass, jlong j_capturer, jboolean j_success) { | 235 (JNIEnv* jni, jclass, jlong j_capturer, jboolean j_success) { |
| 231 LOG(LS_INFO) << "NativeObserver_nativeCapturerStarted"; | 236 LOG(LS_INFO) << "NativeObserver_nativeCapturerStarted"; |
| 232 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnCapturerStarted( | 237 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnCapturerStarted( |
| 233 j_success); | 238 j_success); |
| 234 } | 239 } |
| 235 | 240 |
| 236 } // namespace webrtc_jni | 241 } // namespace webrtc_jni |
| 237 | 242 |
| OLD | NEW |