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+Private.h" | 11 #import "RTCVideoRendererAdapter+Private.h" |
12 | 12 |
13 #import "RTCVideoFrame+Private.h" | 13 #import "RTCVideoFrame+Private.h" |
14 | 14 |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 class VideoRendererAdapter | 19 class VideoRendererAdapter |
20 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { | 20 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { |
21 public: | 21 public: |
22 VideoRendererAdapter(RTCVideoRendererAdapter* adapter) { | 22 VideoRendererAdapter(RTCVideoRendererAdapter* adapter) { |
23 adapter_ = adapter; | 23 adapter_ = adapter; |
24 size_ = CGSizeZero; | 24 size_ = CGSizeZero; |
25 } | 25 } |
26 | 26 |
27 void OnFrame(const webrtc::VideoFrame& nativeVideoFrame) override { | 27 void OnFrame(const webrtc::VideoFrame& nativeVideoFrame) override { |
28 RTCVideoFrame* videoFrame = [[RTCVideoFrame alloc] | 28 RTCVideoFrame* videoFrame = [[RTCVideoFrame alloc] |
29 initWithVideoBuffer:nativeVideoFrame.video_frame_buffer() | 29 initWithVideoBuffer:nativeVideoFrame.video_frame_buffer() |
30 rotation:nativeVideoFrame.rotation() | 30 rotation:static_cast<RTCVideoRotation>( |
| 31 nativeVideoFrame.rotation()) |
31 timeStampNs:nativeVideoFrame.timestamp_us() * | 32 timeStampNs:nativeVideoFrame.timestamp_us() * |
32 rtc::kNumNanosecsPerMicrosec]; | 33 rtc::kNumNanosecsPerMicrosec]; |
33 CGSize current_size = (videoFrame.rotation % 180 == 0) | 34 CGSize current_size = (videoFrame.rotation % 180 == 0) |
34 ? CGSizeMake(videoFrame.width, videoFrame.height) | 35 ? CGSizeMake(videoFrame.width, videoFrame.height) |
35 : CGSizeMake(videoFrame.height, videoFrame.width); | 36 : CGSizeMake(videoFrame.height, videoFrame.width); |
36 | 37 |
37 if (!CGSizeEqualToSize(size_, current_size)) { | 38 if (!CGSizeEqualToSize(size_, current_size)) { |
38 size_ = current_size; | 39 size_ = current_size; |
39 [adapter_.videoRenderer setSize:size_]; | 40 [adapter_.videoRenderer setSize:size_]; |
40 } | 41 } |
41 [adapter_.videoRenderer renderFrame:videoFrame]; | 42 [adapter_.videoRenderer renderFrame:videoFrame]; |
42 } | 43 } |
(...skipping 17 matching lines...) Expand all Loading... |
60 _adapter.reset(new webrtc::VideoRendererAdapter(self)); | 61 _adapter.reset(new webrtc::VideoRendererAdapter(self)); |
61 } | 62 } |
62 return self; | 63 return self; |
63 } | 64 } |
64 | 65 |
65 - (rtc::VideoSinkInterface<webrtc::VideoFrame> *)nativeVideoRenderer { | 66 - (rtc::VideoSinkInterface<webrtc::VideoFrame> *)nativeVideoRenderer { |
66 return _adapter.get(); | 67 return _adapter.get(); |
67 } | 68 } |
68 | 69 |
69 @end | 70 @end |
OLD | NEW |