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

Unified Diff: webrtc/api/objc/RTCVideoRendererAdapter.mm

Issue 1894873002: Fix crash when receiving a texture frame with rotation bit set. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/objc/RTCVideoRendererAdapter.mm
diff --git a/webrtc/api/objc/RTCVideoRendererAdapter.mm b/webrtc/api/objc/RTCVideoRendererAdapter.mm
index 81e7888f3bcd4bfa5fc128717c59e280da2208d5..af41a6307eae74aa92ca61dd0f9c0968b595dfb1 100644
--- a/webrtc/api/objc/RTCVideoRendererAdapter.mm
+++ b/webrtc/api/objc/RTCVideoRendererAdapter.mm
@@ -10,6 +10,8 @@
#import "RTCVideoRendererAdapter.h"
+#include "webrtc/media/engine/webrtcvideoframe.h"
+
#import "webrtc/api/objc/RTCVideoFrame+Private.h"
#import "webrtc/api/objc/RTCVideoRendererAdapter+Private.h"
@@ -24,15 +26,31 @@ class VideoRendererAdapter
}
void OnFrame(const cricket::VideoFrame& nativeVideoFrame) override {
- const cricket::VideoFrame *frame =
- nativeVideoFrame.GetCopyWithRotationApplied();
- CGSize current_size = CGSizeMake(frame->width(), frame->height());
+ RTCVideoFrame *videoFrame = nil;
+ // Rotation of native handles is unsupported right now. Convert to CPU
+ // I420 buffer for rotation before calling the rotation method otherwise
+ // it will hit a DCHECK.
+ if (nativeVideoFrame.rotation() != webrtc::kVideoRotation_0 &&
+ nativeVideoFrame.GetNativeHandle()) {
+ rtc::scoped_refptr<webrtc::VideoFrameBuffer> i420Buffer =
+ nativeVideoFrame.video_frame_buffer()->NativeToI420Buffer();
+ std::unique_ptr<cricket::VideoFrame> cpuFrame(
+ new cricket::WebRtcVideoFrame(i420Buffer,
+ nativeVideoFrame.rotation(),
+ nativeVideoFrame.timestamp_us()));
+ const cricket::VideoFrame *rotatedFrame =
+ cpuFrame->GetCopyWithRotationApplied();
+ videoFrame = [[RTCVideoFrame alloc] initWithNativeFrame:rotatedFrame];
+ } else {
+ const cricket::VideoFrame *rotatedFrame =
+ nativeVideoFrame.GetCopyWithRotationApplied();
+ videoFrame = [[RTCVideoFrame alloc] initWithNativeFrame:rotatedFrame];
+ }
+ CGSize current_size = CGSizeMake(videoFrame.width, videoFrame.height);
if (!CGSizeEqualToSize(size_, current_size)) {
size_ = current_size;
[adapter_.videoRenderer setSize:size_];
}
- RTCVideoFrame *videoFrame =
- [[RTCVideoFrame alloc] initWithNativeFrame:frame];
[adapter_.videoRenderer renderFrame:videoFrame];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698