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

Unified Diff: webrtc/media/engine/webrtcvideoframe.cc

Issue 2091983002: Revert of Cleanups in cricket::VideoFrame and cricket::WebRtcVideoFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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/engine/webrtcvideoframe.h ('k') | webrtc/media/engine/webrtcvideoframe_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvideoframe.cc
diff --git a/webrtc/media/engine/webrtcvideoframe.cc b/webrtc/media/engine/webrtcvideoframe.cc
index 2ff4042c525b2e56394976fe176ef8897d74ee31..4f89c8b85d100562d14cb891c6b11e8f67f247d1 100644
--- a/webrtc/media/engine/webrtcvideoframe.cc
+++ b/webrtc/media/engine/webrtcvideoframe.cc
@@ -149,8 +149,23 @@
return true;
}
+VideoFrame* WebRtcVideoFrame::CreateEmptyFrame(int w,
+ int h,
+ int64_t timestamp_us) const {
+ WebRtcVideoFrame* frame = new WebRtcVideoFrame();
+ frame->InitToEmptyBuffer(w, h, rtc::kNumNanosecsPerMicrosec * timestamp_us);
+ return frame;
+}
+
void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h) {
video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h);
+ rotation_ = webrtc::kVideoRotation_0;
+}
+
+void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h,
+ int64_t time_stamp_ns) {
+ video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h);
+ SetTimeStamp(time_stamp_ns);
rotation_ = webrtc::kVideoRotation_0;
}
@@ -170,19 +185,19 @@
return rotated_frame_.get();
}
- int current_width = width();
- int current_height = height();
-
- int rotated_width = current_width;
- int rotated_height = current_height;
+ int orig_width = width();
+ int orig_height = height();
+
+ int rotated_width = orig_width;
+ int rotated_height = orig_height;
if (rotation() == webrtc::kVideoRotation_90 ||
rotation() == webrtc::kVideoRotation_270) {
- std::swap(rotated_width, rotated_height);
- }
-
- rtc::scoped_refptr<webrtc::I420Buffer> buffer =
- new rtc::RefCountedObject<webrtc::I420Buffer>(rotated_width,
- rotated_height);
+ rotated_width = orig_height;
+ rotated_height = orig_width;
+ }
+
+ rotated_frame_.reset(
+ CreateEmptyFrame(rotated_width, rotated_height, timestamp_us_));
// TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from
// VideoRotation to libyuv::RotationMode.
@@ -190,16 +205,18 @@
video_frame_buffer_->DataY(), video_frame_buffer_->StrideY(),
video_frame_buffer_->DataU(), video_frame_buffer_->StrideU(),
video_frame_buffer_->DataV(), video_frame_buffer_->StrideV(),
- buffer->MutableDataY(), buffer->StrideY(), buffer->MutableDataU(),
- buffer->StrideU(), buffer->MutableDataV(), buffer->StrideV(),
- current_width, current_height,
+ rotated_frame_->video_frame_buffer()->MutableDataY(),
+ rotated_frame_->video_frame_buffer()->StrideY(),
+ rotated_frame_->video_frame_buffer()->MutableDataU(),
+ rotated_frame_->video_frame_buffer()->StrideU(),
+ rotated_frame_->video_frame_buffer()->MutableDataV(),
+ rotated_frame_->video_frame_buffer()->StrideV(),
+ orig_width, orig_height,
static_cast<libyuv::RotationMode>(rotation()));
if (ret == 0) {
- rotated_frame_.reset(
- new WebRtcVideoFrame(buffer, webrtc::kVideoRotation_0, timestamp_us_));
- }
-
- return rotated_frame_.get();
+ return rotated_frame_.get();
+ }
+ return nullptr;
}
} // namespace cricket
« no previous file with comments | « webrtc/media/engine/webrtcvideoframe.h ('k') | webrtc/media/engine/webrtcvideoframe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698