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

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

Issue 2357113002: Revert of Delete VideoFrameFactory, CapturedFrame, and related code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 3 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
« no previous file with comments | « webrtc/media/base/videoframefactory.h ('k') | webrtc/media/engine/webrtcvideocapturer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/base/videoframefactory.cc
diff --git a/webrtc/media/base/videoframefactory.cc b/webrtc/media/base/videoframefactory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a4eeece148c9cb49294c4334767ddb1e6fc5f30c
--- /dev/null
+++ b/webrtc/media/base/videoframefactory.cc
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/media/base/videoframefactory.h"
+
+#include <algorithm>
+#include "webrtc/media/base/videocapturer.h"
+
+namespace cricket {
+
+VideoFrame* VideoFrameFactory::CreateAliasedFrame(
+ const CapturedFrame* input_frame,
+ int cropped_input_width,
+ int cropped_input_height,
+ int output_width,
+ int output_height) const {
+ std::unique_ptr<VideoFrame> cropped_input_frame(CreateAliasedFrame(
+ input_frame, cropped_input_width, cropped_input_height));
+ if (!cropped_input_frame)
+ return nullptr;
+
+ if (cropped_input_width == output_width &&
+ cropped_input_height == output_height) {
+ // No scaling needed.
+ return cropped_input_frame.release();
+ }
+
+ // If the frame is rotated, we need to switch the width and height.
+ if (apply_rotation_ &&
+ (input_frame->rotation == webrtc::kVideoRotation_90 ||
+ input_frame->rotation == webrtc::kVideoRotation_270)) {
+ std::swap(output_width, output_height);
+ }
+
+ rtc::scoped_refptr<webrtc::I420Buffer> scaled_buffer(
+ pool_.CreateBuffer(output_width, output_height));
+ scaled_buffer->CropAndScaleFrom(cropped_input_frame->video_frame_buffer());
+
+ return new WebRtcVideoFrame(scaled_buffer, cropped_input_frame->rotation(),
+ cropped_input_frame->timestamp_us(),
+ cropped_input_frame->transport_frame_id());
+}
+
+} // namespace cricket
« no previous file with comments | « webrtc/media/base/videoframefactory.h ('k') | webrtc/media/engine/webrtcvideocapturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698