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

Unified Diff: content/renderer/media/webrtc/media_stream_remote_video_source.cc

Issue 2150203002: Apply rotation for texture backed VideoFrames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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: content/renderer/media/webrtc/media_stream_remote_video_source.cc
diff --git a/content/renderer/media/webrtc/media_stream_remote_video_source.cc b/content/renderer/media/webrtc/media_stream_remote_video_source.cc
index 78ac79672cf1d70b841131a631380774e37387cd..57e8f94994baee9fa3fab185d9fc1a2098e22b7d 100644
--- a/content/renderer/media/webrtc/media_stream_remote_video_source.cc
+++ b/content/renderer/media/webrtc/media_stream_remote_video_source.cc
@@ -21,6 +21,25 @@
namespace content {
+namespace {
+
+media::VideoRotation WebRTCToMediaVideoRotation(
+ webrtc::VideoRotation rotation) {
+ switch (rotation) {
+ case webrtc::kVideoRotation_0:
+ return media::VIDEO_ROTATION_0;
+ case webrtc::kVideoRotation_90:
+ return media::VIDEO_ROTATION_90;
+ case webrtc::kVideoRotation_180:
+ return media::VIDEO_ROTATION_180;
+ case webrtc::kVideoRotation_270:
+ return media::VIDEO_ROTATION_270;
+ }
+ return media::VIDEO_ROTATION_0;
+}
+
+} // anonymous namespace
+
// Internal class used for receiving frames from the webrtc track on a
// libjingle thread and forward it to the IO-thread.
class MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate
@@ -97,9 +116,13 @@ void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::OnFrame(
incoming_frame.video_frame_buffer());
if (buffer->native_handle() != NULL) {
- video_frame =
- static_cast<media::VideoFrame*>(buffer->native_handle());
+ video_frame = static_cast<media::VideoFrame*>(buffer->native_handle());
video_frame->set_timestamp(elapsed_timestamp);
+ if (incoming_frame.rotation() != webrtc::kVideoRotation_0) {
+ video_frame->metadata()->SetRotation(
+ media::VideoFrameMetadata::ROTATION,
+ WebRTCToMediaVideoRotation(incoming_frame.rotation()));
+ }
} else {
// Note that the GetCopyWithRotationApplied returns a pointer to a
// frame owned by incoming_frame.

Powered by Google App Engine
This is Rietveld 408576698