| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #import "RTCVideoRendererAdapter.h" | 11 #import "RTCVideoRendererAdapter.h" |
| 12 | 12 |
| 13 #import "webrtc/api/objc/RTCVideoFrame+Private.h" | 13 #import "webrtc/api/objc/RTCVideoFrame+Private.h" |
| 14 #import "webrtc/api/objc/RTCVideoRendererAdapter+Private.h" | 14 #import "webrtc/api/objc/RTCVideoRendererAdapter+Private.h" |
| 15 | 15 |
| 16 namespace webrtc { | 16 namespace webrtc { |
| 17 | 17 |
| 18 class VideoRendererAdapter | 18 class VideoRendererAdapter |
| 19 : public rtc::VideoSinkInterface<cricket::VideoFrame> { | 19 : public rtc::VideoSinkInterface<cricket::VideoFrame> { |
| 20 public: | 20 public: |
| 21 VideoRendererAdapter(RTCVideoRendererAdapter* adapter) { | 21 VideoRendererAdapter(RTCVideoRendererAdapter* adapter) { |
| 22 adapter_ = adapter; | 22 adapter_ = adapter; |
| 23 size_ = CGSizeZero; | 23 size_ = CGSizeZero; |
| 24 } | 24 } |
| 25 | 25 |
| 26 void OnFrame(const cricket::VideoFrame& nativeVideoFrame) override { | 26 void OnFrame(const cricket::VideoFrame& nativeVideoFrame) override { |
| 27 const cricket::VideoFrame *frame = | 27 const cricket::VideoFrame *frame = |
| 28 nativeVideoFrame.GetCopyWithRotationApplied(); | 28 nativeVideoFrame.GetCopyWithRotationApplied(); |
| 29 CGSize current_size = CGSizeMake(frame->GetWidth(), frame->GetHeight()); | 29 CGSize current_size = CGSizeMake(frame->width(), frame->height()); |
| 30 if (!CGSizeEqualToSize(size_, current_size)) { | 30 if (!CGSizeEqualToSize(size_, current_size)) { |
| 31 size_ = current_size; | 31 size_ = current_size; |
| 32 [adapter_.videoRenderer setSize:size_]; | 32 [adapter_.videoRenderer setSize:size_]; |
| 33 } | 33 } |
| 34 RTCVideoFrame *videoFrame = | 34 RTCVideoFrame *videoFrame = |
| 35 [[RTCVideoFrame alloc] initWithNativeFrame:frame]; | 35 [[RTCVideoFrame alloc] initWithNativeFrame:frame]; |
| 36 [adapter_.videoRenderer renderFrame:videoFrame]; | 36 [adapter_.videoRenderer renderFrame:videoFrame]; |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 55 _adapter.reset(new webrtc::VideoRendererAdapter(self)); | 55 _adapter.reset(new webrtc::VideoRendererAdapter(self)); |
| 56 } | 56 } |
| 57 return self; | 57 return self; |
| 58 } | 58 } |
| 59 | 59 |
| 60 - (rtc::VideoSinkInterface<cricket::VideoFrame> *)nativeVideoRenderer { | 60 - (rtc::VideoSinkInterface<cricket::VideoFrame> *)nativeVideoRenderer { |
| 61 return _adapter.get(); | 61 return _adapter.get(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 @end | 64 @end |
| OLD | NEW |