Index: content/renderer/media_recorder/video_track_recorder.cc |
diff --git a/content/renderer/media_recorder/video_track_recorder.cc b/content/renderer/media_recorder/video_track_recorder.cc |
index bc6b59e5cff01e2f3eb3ba7f981c28dc0f4e3afc..48f56ceb57bb31e239d2c4812966b29d62da905c 100644 |
--- a/content/renderer/media_recorder/video_track_recorder.cc |
+++ b/content/renderer/media_recorder/video_track_recorder.cc |
@@ -52,6 +52,21 @@ namespace content { |
namespace { |
+libyuv::RotationMode MediaVideoRotationToRotationMode( |
+ media::VideoRotation rotation) { |
+ switch (rotation) { |
+ case media::VIDEO_ROTATION_0: |
+ return libyuv::kRotate0; |
+ case media::VIDEO_ROTATION_90: |
+ return libyuv::kRotate90; |
+ case media::VIDEO_ROTATION_180: |
+ return libyuv::kRotate180; |
+ case media::VIDEO_ROTATION_270: |
+ return libyuv::kRotate270; |
+ } |
emircan
2017/04/07 19:50:55
Add "NOTREACHED();". It makes sure that we will be
Chandan
2017/04/10 10:36:15
Done.
|
+ return libyuv::kRotate0; |
+} |
+ |
// HW encoders expect a nonzero bitrate, so |kVEADefaultBitratePerPixel| is used |
// to estimate bits per second for ~30 fps with ~1/16 compression rate. |
const int kVEADefaultBitratePerPixel = 2; |
@@ -303,10 +318,24 @@ void VideoTrackRecorder::Encoder::RetrieveFrameOnMainThread( |
DCHECK(video_frame->HasTextures()); |
DCHECK_EQ(media::PIXEL_FORMAT_ARGB, video_frame->format()); |
- frame = media::VideoFrame::CreateFrame( |
- media::PIXEL_FORMAT_I420, video_frame->coded_size(), |
- video_frame->visible_rect(), video_frame->natural_size(), |
- video_frame->timestamp()); |
+ gfx::Size coded_size = video_frame->coded_size(), |
+ natural_size = video_frame->natural_size(); |
+ gfx::Rect visible_rect = video_frame->visible_rect(); |
emircan
2017/04/07 19:50:55
You can do all these calculations based on visible
Chandan
2017/04/10 10:36:15
Done.
|
+ media::VideoRotation video_rotation = media::VIDEO_ROTATION_0; |
+ if (video_frame->metadata()->GetRotation( |
+ media::VideoFrameMetadata::ROTATION, &video_rotation)) { |
emircan
2017/04/07 19:50:55
Merge two if statements with &&.
Chandan
2017/04/10 10:36:15
Done.
|
+ if (video_rotation == media::VIDEO_ROTATION_90 || |
+ video_rotation == media::VIDEO_ROTATION_270) { |
+ coded_size.SetSize(coded_size.height(), coded_size.width()); |
+ natural_size.SetSize(natural_size.height(), natural_size.width()); |
+ visible_rect.set_width(visible_rect.height()); |
+ visible_rect.set_height(visible_rect.width()); |
Chandan
2017/04/07 13:21:55
I am not too confident of this change. Please sugg
emircan
2017/04/07 19:50:55
I can totally understand, sorry for my late respon
Chandan
2017/04/10 10:36:15
Thanks!
|
+ } |
+ } |
+ |
+ frame = media::VideoFrame::CreateFrame(media::PIXEL_FORMAT_I420, coded_size, |
+ visible_rect, natural_size, |
+ video_frame->timestamp()); |
const SkImageInfo info = SkImageInfo::MakeN32( |
frame->visible_rect().width(), frame->visible_rect().height(), |
@@ -331,9 +360,11 @@ void VideoTrackRecorder::Encoder::RetrieveFrameOnMainThread( |
DLOG(ERROR) << "Error trying to map PaintSurface's pixels"; |
return; |
} |
- // TODO(mcasas): Use the incoming frame's rotation when |
- // https://bugs.chromium.org/p/webrtc/issues/detail?id=6069 is closed. |
- const libyuv::RotationMode source_rotation = libyuv::kRotate0; |
+ |
+ libyuv::RotationMode source_rotation = libyuv::kRotate0; |
+ if (video_rotation != media::VIDEO_ROTATION_0) |
+ source_rotation = MediaVideoRotationToRotationMode(video_rotation); |
+ |
const uint32 source_pixel_format = |
(kN32_SkColorType == kRGBA_8888_SkColorType) ? libyuv::FOURCC_ABGR |
: libyuv::FOURCC_ARGB; |