| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #if !defined(__has_feature) || !__has_feature(objc_arc) | 28 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 29 #error "This file requires ARC support." | 29 #error "This file requires ARC support." |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #import "RTCI420Frame+Internal.h" | 32 #import "RTCI420Frame+Internal.h" |
| 33 #import "RTCVideoRendererAdapter.h" | 33 #import "RTCVideoRendererAdapter.h" |
| 34 | 34 |
| 35 #include <memory> |
| 36 |
| 35 namespace webrtc { | 37 namespace webrtc { |
| 36 | 38 |
| 37 class RTCVideoRendererNativeAdapter : public VideoRendererInterface { | 39 class RTCVideoRendererNativeAdapter : public VideoRendererInterface { |
| 38 public: | 40 public: |
| 39 RTCVideoRendererNativeAdapter(RTCVideoRendererAdapter* adapter) { | 41 RTCVideoRendererNativeAdapter(RTCVideoRendererAdapter* adapter) { |
| 40 _adapter = adapter; | 42 _adapter = adapter; |
| 41 _size = CGSizeZero; | 43 _size = CGSizeZero; |
| 42 } | 44 } |
| 43 | 45 |
| 44 void RenderFrame(const cricket::VideoFrame* videoFrame) override { | 46 void RenderFrame(const cricket::VideoFrame* videoFrame) override { |
| 45 const cricket::VideoFrame* frame = videoFrame->GetCopyWithRotationApplied(); | 47 const cricket::VideoFrame* frame = videoFrame->GetCopyWithRotationApplied(); |
| 46 CGSize currentSize = CGSizeMake(frame->GetWidth(), frame->GetHeight()); | 48 CGSize currentSize = CGSizeMake(frame->GetWidth(), frame->GetHeight()); |
| 47 if (!CGSizeEqualToSize(_size, currentSize)) { | 49 if (!CGSizeEqualToSize(_size, currentSize)) { |
| 48 _size = currentSize; | 50 _size = currentSize; |
| 49 [_adapter.videoRenderer setSize:_size]; | 51 [_adapter.videoRenderer setSize:_size]; |
| 50 } | 52 } |
| 51 RTCI420Frame* i420Frame = [[RTCI420Frame alloc] initWithVideoFrame:frame]; | 53 RTCI420Frame* i420Frame = [[RTCI420Frame alloc] initWithVideoFrame:frame]; |
| 52 [_adapter.videoRenderer renderFrame:i420Frame]; | 54 [_adapter.videoRenderer renderFrame:i420Frame]; |
| 53 } | 55 } |
| 54 | 56 |
| 55 private: | 57 private: |
| 56 __weak RTCVideoRendererAdapter* _adapter; | 58 __weak RTCVideoRendererAdapter* _adapter; |
| 57 CGSize _size; | 59 CGSize _size; |
| 58 }; | 60 }; |
| 59 } | 61 } |
| 60 | 62 |
| 61 @implementation RTCVideoRendererAdapter { | 63 @implementation RTCVideoRendererAdapter { |
| 62 id<RTCVideoRenderer> _videoRenderer; | 64 id<RTCVideoRenderer> _videoRenderer; |
| 63 rtc::scoped_ptr<webrtc::RTCVideoRendererNativeAdapter> _adapter; | 65 std::unique_ptr<webrtc::RTCVideoRendererNativeAdapter> _adapter; |
| 64 } | 66 } |
| 65 | 67 |
| 66 - (instancetype)initWithVideoRenderer:(id<RTCVideoRenderer>)videoRenderer { | 68 - (instancetype)initWithVideoRenderer:(id<RTCVideoRenderer>)videoRenderer { |
| 67 NSParameterAssert(videoRenderer); | 69 NSParameterAssert(videoRenderer); |
| 68 if (self = [super init]) { | 70 if (self = [super init]) { |
| 69 _videoRenderer = videoRenderer; | 71 _videoRenderer = videoRenderer; |
| 70 _adapter.reset(new webrtc::RTCVideoRendererNativeAdapter(self)); | 72 _adapter.reset(new webrtc::RTCVideoRendererNativeAdapter(self)); |
| 71 } | 73 } |
| 72 return self; | 74 return self; |
| 73 } | 75 } |
| 74 | 76 |
| 75 - (webrtc::VideoRendererInterface*)nativeVideoRenderer { | 77 - (webrtc::VideoRendererInterface*)nativeVideoRenderer { |
| 76 return _adapter.get(); | 78 return _adapter.get(); |
| 77 } | 79 } |
| 78 | 80 |
| 79 @end | 81 @end |
| OLD | NEW |