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