Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 #import "RTCVideoRendererAdapter.h" | |
| 12 | |
| 13 #import "webrtc/api/objc/RTCVideoFrame+Private.h" | |
| 14 #import "webrtc/api/objc/RTCVideoRendererAdapter+Private.h" | |
| 15 | |
| 16 namespace webrtc { | |
| 17 | |
| 18 class VideoRendererAdapter : public VideoRendererInterface { | |
| 19 public: | |
| 20 VideoRendererAdapter(RTCVideoRendererAdapter* adapter) { | |
| 21 adapter_ = adapter; | |
| 22 size_ = CGSizeZero; | |
| 23 } | |
| 24 | |
| 25 void RenderFrame(const cricket::VideoFrame *nativeVideoFrame) override { | |
| 26 const cricket::VideoFrame *frame = | |
| 27 nativeVideoFrame->GetCopyWithRotationApplied(); | |
| 28 CGSize currentsize_ = CGSizeMake(frame->GetWidth(), frame->GetHeight()); | |
|
tkchin_webrtc
2016/01/20 22:14:16
current_size
hjon_webrtc
2016/01/20 22:28:00
Done.
| |
| 29 if (!CGSizeEqualToSize(size_, currentsize_)) { | |
| 30 size_ = currentsize_; | |
| 31 [adapter_.videoRenderer setSize:size_]; | |
| 32 } | |
| 33 RTCVideoFrame *videoFrame = | |
| 34 [[RTCVideoFrame alloc] initWithNativeFrame:frame]; | |
| 35 [adapter_.videoRenderer renderFrame:videoFrame]; | |
| 36 } | |
| 37 | |
| 38 private: | |
| 39 __weak RTCVideoRendererAdapter *adapter_; | |
| 40 CGSize size_; | |
| 41 }; | |
| 42 } | |
| 43 | |
| 44 @implementation RTCVideoRendererAdapter { | |
| 45 rtc::scoped_ptr<webrtc::VideoRendererAdapter> _adapter; | |
| 46 } | |
| 47 | |
| 48 @synthesize videoRenderer = _videoRenderer; | |
| 49 | |
| 50 - (instancetype)initWithNativeRenderer:(id<RTCVideoRenderer>)videoRenderer { | |
| 51 NSParameterAssert(videoRenderer); | |
| 52 if (self = [super init]) { | |
| 53 _videoRenderer = videoRenderer; | |
| 54 _adapter.reset(new webrtc::VideoRendererAdapter(self)); | |
| 55 } | |
| 56 return self; | |
| 57 } | |
| 58 | |
| 59 - (webrtc::VideoRendererInterface *)nativeVideoRenderer { | |
| 60 return _adapter.get(); | |
| 61 } | |
| 62 | |
| 63 @end | |
| OLD | NEW |