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

Unified Diff: webrtc/media/base/videocapturer.cc

Issue 1973873003: Delete AndroidVideoCapturer::FrameFactory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Move code to AndroidVideoCapturerJni. Make Matrix a class. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/media/base/videocapturer.cc
diff --git a/webrtc/media/base/videocapturer.cc b/webrtc/media/base/videocapturer.cc
index 084a9b913c7912f00e18647725dcb13c237a160d..283f768cb789b61a68d0868c2c7b3150ae50495d 100644
--- a/webrtc/media/base/videocapturer.cc
+++ b/webrtc/media/base/videocapturer.cc
@@ -214,25 +214,50 @@ void VideoCapturer::OnSinkWantsChanged(const rtc::VideoSinkWants& wants) {
}
}
-void VideoCapturer::OnFrameCaptured(VideoCapturer*,
- const CapturedFrame* captured_frame) {
+bool VideoCapturer::AdaptFrame(int width,
+ int height,
+ int* out_width,
+ int* out_height,
+ int* crop_width,
+ int* crop_height,
+ int* crop_x,
+ int* crop_y) {
if (!broadcaster_.frame_wanted()) {
- return;
+ return false;
}
- int cropped_width = captured_frame->width;
- int cropped_height = captured_frame->height;
- int out_width = captured_frame->width;
- int out_height = captured_frame->height;
if (enable_video_adapter_ && !IsScreencast()) {
- video_adapter_.AdaptFrameResolution(
- captured_frame->width, captured_frame->height,
- &cropped_width, &cropped_height,
- &out_width, &out_height);
- if (out_width == 0 || out_height == 0) {
+ if (!video_adapter_.AdaptFrameResolution(
+ width, height, crop_width, crop_height, out_width, out_height)) {
// VideoAdapter dropped the frame.
- return;
+ return false;
}
+ *crop_x = (width - *crop_width) / 2;
+ *crop_y = (height - *crop_height) / 2;
+ } else {
+ *out_width = width;
+ *out_height = height;
+ *crop_width = width;
+ *crop_height = height;
+ *crop_x = 0;
+ *crop_y = 0;
+ }
+ return true;
+}
+
+void VideoCapturer::OnFrameCaptured(VideoCapturer*,
+ const CapturedFrame* captured_frame) {
+ int out_width;
+ int out_height;
+ int crop_width;
+ int crop_height;
+ int crop_x;
+ int crop_y;
+
+ if (!AdaptFrame(captured_frame->width, captured_frame->height,
+ &out_width, &out_height,
+ &crop_width, &crop_height, &crop_x, &crop_y)) {
+ return;
}
if (!frame_factory_) {
@@ -240,9 +265,10 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
return;
}
- // TODO(nisse): Reorganize frame factory methods.
+ // TODO(nisse): Reorganize frame factory methods. crop_x and crop_y
+ // are ignored for now.
std::unique_ptr<VideoFrame> adapted_frame(frame_factory_->CreateAliasedFrame(
- captured_frame, cropped_width, cropped_height, out_width, out_height));
+ captured_frame, crop_width, crop_height, out_width, out_height));
if (!adapted_frame) {
// TODO(fbarchard): LOG more information about captured frame attributes.
@@ -252,12 +278,14 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
return;
}
- OnFrame(this, adapted_frame.get());
- UpdateInputSize(captured_frame);
+ OnFrame(*adapted_frame, captured_frame->width, captured_frame->height);
}
-void VideoCapturer::OnFrame(VideoCapturer* capturer, const VideoFrame* frame) {
- broadcaster_.OnFrame(*frame);
+void VideoCapturer::OnFrame(const VideoFrame& frame,
+ int orig_width,
+ int orig_height) {
+ broadcaster_.OnFrame(frame);
+ UpdateInputSize(orig_width, orig_height);
}
void VideoCapturer::SetCaptureState(CaptureState state) {
@@ -398,13 +426,13 @@ bool VideoCapturer::ShouldFilterFormat(const VideoFormat& format) const {
format.height > max_format_->height;
}
-void VideoCapturer::UpdateInputSize(const CapturedFrame* captured_frame) {
+void VideoCapturer::UpdateInputSize(int width, int height) {
// Update stats protected from fetches from different thread.
rtc::CritScope cs(&frame_stats_crit_);
input_size_valid_ = true;
- input_width_ = captured_frame->width;
- input_height_ = captured_frame->height;
+ input_width_ = width;
+ input_height_ = height;
}
} // namespace cricket

Powered by Google App Engine
This is Rietveld 408576698