1/* 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11#include "sdk/objc/native/src/objc_video_renderer.h" 12 13#import "base/RTCMacros.h" 14#import "base/RTCVideoFrame.h" 15#import "base/RTCVideoRenderer.h" 16 17#include "sdk/objc/native/src/objc_video_frame.h" 18 19namespace webrtc { 20 21ObjCVideoRenderer::ObjCVideoRenderer(id<RTC_OBJC_TYPE(RTCVideoRenderer)> renderer) 22 : renderer_(renderer), size_(CGSizeZero) {} 23 24void ObjCVideoRenderer::OnFrame(const VideoFrame& nativeVideoFrame) { 25 RTC_OBJC_TYPE(RTCVideoFrame)* videoFrame = ToObjCVideoFrame(nativeVideoFrame); 26 27 CGSize current_size = (videoFrame.rotation % 180 == 0) ? 28 CGSizeMake(videoFrame.width, videoFrame.height) : 29 CGSizeMake(videoFrame.height, videoFrame.width); 30 31 if (!CGSizeEqualToSize(size_, current_size)) { 32 size_ = current_size; 33 [renderer_ setSize:size_]; 34 } 35 [renderer_ renderFrame:videoFrame]; 36} 37 38} // namespace webrtc 39