Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/capture/content/android/screen_capture_machine_android.h" | 5 #include "media/capture/content/android/screen_capture_machine_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "jni/ScreenCapture_jni.h" | 10 #include "jni/ScreenCapture_jni.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 } | 189 } |
| 190 | 190 |
| 191 void ScreenCaptureMachineAndroid::OnActivityResult(JNIEnv* env, | 191 void ScreenCaptureMachineAndroid::OnActivityResult(JNIEnv* env, |
| 192 jobject obj, | 192 jobject obj, |
| 193 jboolean result) { | 193 jboolean result) { |
| 194 if (!result) { | 194 if (!result) { |
| 195 oracle_proxy_->ReportError(FROM_HERE, "The user denied screen capture"); | 195 oracle_proxy_->ReportError(FROM_HERE, "The user denied screen capture"); |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 Java_ScreenCapture_startCapture(env, obj); | 199 if (Java_ScreenCapture_startCapture(env, obj)) |
| 200 oracle_proxy_->ReportStarted(); | |
| 201 else | |
| 202 oracle_proxy_->ReportError(FROM_HERE, "Failed to start Screen Capture"); | |
| 200 } | 203 } |
| 201 | 204 |
| 202 void ScreenCaptureMachineAndroid::OnOrientationChange(JNIEnv* env, | 205 void ScreenCaptureMachineAndroid::OnOrientationChange(JNIEnv* env, |
| 203 jobject obj, | 206 jobject obj, |
| 204 jint rotation) { | 207 jint rotation) { |
| 205 DeviceOrientation orientation = kDefault; | 208 DeviceOrientation orientation = kDefault; |
| 206 switch (rotation) { | 209 switch (rotation) { |
| 207 case 0: | 210 case 0: |
| 208 case 180: | 211 case 180: |
| 209 orientation = kPortrait; | 212 orientation = kPortrait; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 Java_ScreenCapture_allocate(AttachCurrentThread(), j_capture_, | 254 Java_ScreenCapture_allocate(AttachCurrentThread(), j_capture_, |
| 252 params.requested_format.frame_size.width(), | 255 params.requested_format.frame_size.width(), |
| 253 params.requested_format.frame_size.height()); | 256 params.requested_format.frame_size.height()); |
| 254 if (!ret) { | 257 if (!ret) { |
| 255 DLOG(ERROR) << "Failed to init ScreenCaptureAndroid"; | 258 DLOG(ERROR) << "Failed to init ScreenCaptureAndroid"; |
| 256 callback.Run(ret); | 259 callback.Run(ret); |
| 257 return; | 260 return; |
| 258 } | 261 } |
| 259 | 262 |
| 260 ret = Java_ScreenCapture_startPrompt(AttachCurrentThread(), j_capture_); | 263 ret = Java_ScreenCapture_startPrompt(AttachCurrentThread(), j_capture_); |
| 261 | 264 // On Android, we must wait for user input to start capturing before we can |
| 262 callback.Run(ret); | 265 // report back device started state. |
|
miu
2017/02/09 22:21:49
Maybe add: However, if the user-prompt failed to s
braveyao
2017/02/14 01:05:49
Done.
| |
| 266 if (!ret) | |
| 267 callback.Run(ret); | |
| 263 } | 268 } |
| 264 | 269 |
| 265 void ScreenCaptureMachineAndroid::Stop(const base::Closure& callback) { | 270 void ScreenCaptureMachineAndroid::Stop(const base::Closure& callback) { |
| 266 if (j_capture_.obj() != nullptr) { | 271 if (j_capture_.obj() != nullptr) { |
| 267 Java_ScreenCapture_stopCapture(AttachCurrentThread(), j_capture_); | 272 Java_ScreenCapture_stopCapture(AttachCurrentThread(), j_capture_); |
| 268 } | 273 } |
| 269 | 274 |
| 270 callback.Run(); | 275 callback.Run(); |
| 271 } | 276 } |
| 272 | 277 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 frame->visible_data(VideoFrame::kUPlane), | 309 frame->visible_data(VideoFrame::kUPlane), |
| 305 frame->stride(VideoFrame::kUPlane), | 310 frame->stride(VideoFrame::kUPlane), |
| 306 frame->visible_data(VideoFrame::kVPlane), | 311 frame->visible_data(VideoFrame::kVPlane), |
| 307 frame->stride(VideoFrame::kVPlane), frame->visible_rect().width(), | 312 frame->stride(VideoFrame::kVPlane), frame->visible_rect().width(), |
| 308 frame->visible_rect().height(), libyuv::kFilterBilinear); | 313 frame->visible_rect().height(), libyuv::kFilterBilinear); |
| 309 | 314 |
| 310 capture_frame_cb.Run(frame, start_time, true); | 315 capture_frame_cb.Run(frame, start_time, true); |
| 311 } | 316 } |
| 312 | 317 |
| 313 } // namespace media | 318 } // namespace media |
| OLD | NEW |