Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1213)

Side by Side Diff: media/capture/content/android/screen_capture_machine_android.cc

Issue 2364413002: Screen Video Capture: Implement suspend optimization. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "media/capture/content/video_capture_oracle.h" 11 #include "media/capture/content/video_capture_oracle.h"
12 #include "third_party/libyuv/include/libyuv.h" 12 #include "third_party/libyuv/include/libyuv.h"
13 13
14 using base::android::AttachCurrentThread; 14 using base::android::AttachCurrentThread;
15 using base::android::ScopedJavaLocalRef; 15 using base::android::ScopedJavaLocalRef;
16 16
17 namespace media { 17 namespace media {
18 18
19 // static 19 // static
20 bool ScreenCaptureMachineAndroid::RegisterScreenCaptureMachine(JNIEnv* env) { 20 bool ScreenCaptureMachineAndroid::RegisterScreenCaptureMachine(JNIEnv* env) {
21 return RegisterNativesImpl(env); 21 return RegisterNativesImpl(env);
22 } 22 }
23 23
24 ScreenCaptureMachineAndroid::ScreenCaptureMachineAndroid() {} 24 ScreenCaptureMachineAndroid::ScreenCaptureMachineAndroid()
25 : suspend_frame_capture_(false) {}
25 26
26 ScreenCaptureMachineAndroid::~ScreenCaptureMachineAndroid() {} 27 ScreenCaptureMachineAndroid::~ScreenCaptureMachineAndroid() {}
27 28
28 // static 29 // static
29 ScopedJavaLocalRef<jobject> 30 ScopedJavaLocalRef<jobject>
30 ScreenCaptureMachineAndroid::createScreenCaptureMachineAndroid( 31 ScreenCaptureMachineAndroid::createScreenCaptureMachineAndroid(
31 jlong nativeScreenCaptureMachineAndroid) { 32 jlong nativeScreenCaptureMachineAndroid) {
32 return (Java_ScreenCapture_createScreenCaptureMachine( 33 return (Java_ScreenCapture_createScreenCaptureMachine(
33 AttachCurrentThread(), base::android::GetApplicationContext(), 34 AttachCurrentThread(), base::android::GetApplicationContext(),
34 nativeScreenCaptureMachineAndroid)); 35 nativeScreenCaptureMachineAndroid));
35 } 36 }
36 37
37 void ScreenCaptureMachineAndroid::OnRGBAFrameAvailable(JNIEnv* env, 38 void ScreenCaptureMachineAndroid::OnRGBAFrameAvailable(JNIEnv* env,
38 jobject obj, 39 jobject obj,
39 jobject buf, 40 jobject buf,
40 jint row_stride, 41 jint row_stride,
41 jint left, 42 jint left,
42 jint top, 43 jint top,
43 jint width, 44 jint width,
44 jint height, 45 jint height,
45 jlong timestamp) { 46 jlong timestamp) {
47 if (suspend_frame_capture_)
48 return;
49
46 const VideoCaptureOracle::Event event = VideoCaptureOracle::kCompositorUpdate; 50 const VideoCaptureOracle::Event event = VideoCaptureOracle::kCompositorUpdate;
47 const uint64_t absolute_micro = 51 const uint64_t absolute_micro =
48 timestamp / base::Time::kNanosecondsPerMicrosecond; 52 timestamp / base::Time::kNanosecondsPerMicrosecond;
49 const base::TimeTicks start_time = 53 const base::TimeTicks start_time =
50 base::TimeTicks() + base::TimeDelta::FromMicroseconds(absolute_micro); 54 base::TimeTicks() + base::TimeDelta::FromMicroseconds(absolute_micro);
51 scoped_refptr<VideoFrame> frame; 55 scoped_refptr<VideoFrame> frame;
52 ThreadSafeCaptureOracle::CaptureFrameCallback capture_frame_cb; 56 ThreadSafeCaptureOracle::CaptureFrameCallback capture_frame_cb;
53 57
54 if (!oracle_proxy_->ObserveEventAndDecideCapture( 58 if (!oracle_proxy_->ObserveEventAndDecideCapture(
55 event, gfx::Rect(), start_time, &frame, &capture_frame_cb)) { 59 event, gfx::Rect(), start_time, &frame, &capture_frame_cb)) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 jint y_stride, 115 jint y_stride,
112 jobject u_buffer, 116 jobject u_buffer,
113 jobject v_buffer, 117 jobject v_buffer,
114 jint uv_row_stride, 118 jint uv_row_stride,
115 jint uv_pixel_stride, 119 jint uv_pixel_stride,
116 jint left, 120 jint left,
117 jint top, 121 jint top,
118 jint width, 122 jint width,
119 jint height, 123 jint height,
120 jlong timestamp) { 124 jlong timestamp) {
125 if (suspend_frame_capture_)
126 return;
127
121 const VideoCaptureOracle::Event event = VideoCaptureOracle::kCompositorUpdate; 128 const VideoCaptureOracle::Event event = VideoCaptureOracle::kCompositorUpdate;
122 const uint64_t absolute_micro = 129 const uint64_t absolute_micro =
123 timestamp / base::Time::kNanosecondsPerMicrosecond; 130 timestamp / base::Time::kNanosecondsPerMicrosecond;
124 const base::TimeTicks start_time = 131 const base::TimeTicks start_time =
125 base::TimeTicks() + base::TimeDelta::FromMicroseconds(absolute_micro); 132 base::TimeTicks() + base::TimeDelta::FromMicroseconds(absolute_micro);
126 scoped_refptr<VideoFrame> frame; 133 scoped_refptr<VideoFrame> frame;
127 ThreadSafeCaptureOracle::CaptureFrameCallback capture_frame_cb; 134 ThreadSafeCaptureOracle::CaptureFrameCallback capture_frame_cb;
128 135
129 if (!oracle_proxy_->ObserveEventAndDecideCapture( 136 if (!oracle_proxy_->ObserveEventAndDecideCapture(
130 event, gfx::Rect(), start_time, &frame, &capture_frame_cb)) { 137 event, gfx::Rect(), start_time, &frame, &capture_frame_cb)) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 frame->visible_data(VideoFrame::kUPlane), 274 frame->visible_data(VideoFrame::kUPlane),
268 frame->stride(VideoFrame::kUPlane), 275 frame->stride(VideoFrame::kUPlane),
269 frame->visible_data(VideoFrame::kVPlane), 276 frame->visible_data(VideoFrame::kVPlane),
270 frame->stride(VideoFrame::kVPlane), frame->visible_rect().width(), 277 frame->stride(VideoFrame::kVPlane), frame->visible_rect().width(),
271 frame->visible_rect().height(), libyuv::kFilterBilinear); 278 frame->visible_rect().height(), libyuv::kFilterBilinear);
272 279
273 capture_frame_cb.Run(frame, start_time, true); 280 capture_frame_cb.Run(frame, start_time, true);
274 } 281 }
275 282
276 } // namespace media 283 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698