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 18 matching lines...) Expand all Loading... |
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> | 35 #include <memory> |
36 | 36 |
37 namespace webrtc { | 37 namespace webrtc { |
38 | 38 |
39 class RTCVideoRendererNativeAdapter : public VideoRendererInterface { | 39 class RTCVideoRendererNativeAdapter |
| 40 : public rtc::VideoSinkInterface<cricket::VideoFrame> { |
40 public: | 41 public: |
41 RTCVideoRendererNativeAdapter(RTCVideoRendererAdapter* adapter) { | 42 RTCVideoRendererNativeAdapter(RTCVideoRendererAdapter* adapter) { |
42 _adapter = adapter; | 43 _adapter = adapter; |
43 _size = CGSizeZero; | 44 _size = CGSizeZero; |
44 } | 45 } |
45 | 46 |
46 void RenderFrame(const cricket::VideoFrame* videoFrame) override { | 47 void OnFrame(const cricket::VideoFrame& videoFrame) override { |
47 const cricket::VideoFrame* frame = videoFrame->GetCopyWithRotationApplied(); | 48 const cricket::VideoFrame* frame = videoFrame.GetCopyWithRotationApplied(); |
48 CGSize currentSize = CGSizeMake(frame->GetWidth(), frame->GetHeight()); | 49 CGSize currentSize = CGSizeMake(frame->GetWidth(), frame->GetHeight()); |
49 if (!CGSizeEqualToSize(_size, currentSize)) { | 50 if (!CGSizeEqualToSize(_size, currentSize)) { |
50 _size = currentSize; | 51 _size = currentSize; |
51 [_adapter.videoRenderer setSize:_size]; | 52 [_adapter.videoRenderer setSize:_size]; |
52 } | 53 } |
53 RTCI420Frame* i420Frame = [[RTCI420Frame alloc] initWithVideoFrame:frame]; | 54 RTCI420Frame* i420Frame = [[RTCI420Frame alloc] initWithVideoFrame:frame]; |
54 [_adapter.videoRenderer renderFrame:i420Frame]; | 55 [_adapter.videoRenderer renderFrame:i420Frame]; |
55 } | 56 } |
56 | 57 |
57 private: | 58 private: |
58 __weak RTCVideoRendererAdapter* _adapter; | 59 __weak RTCVideoRendererAdapter* _adapter; |
59 CGSize _size; | 60 CGSize _size; |
60 }; | 61 }; |
61 } | 62 } |
62 | 63 |
63 @implementation RTCVideoRendererAdapter { | 64 @implementation RTCVideoRendererAdapter { |
64 id<RTCVideoRenderer> _videoRenderer; | 65 id<RTCVideoRenderer> _videoRenderer; |
65 std::unique_ptr<webrtc::RTCVideoRendererNativeAdapter> _adapter; | 66 std::unique_ptr<webrtc::RTCVideoRendererNativeAdapter> _adapter; |
66 } | 67 } |
67 | 68 |
68 - (instancetype)initWithVideoRenderer:(id<RTCVideoRenderer>)videoRenderer { | 69 - (instancetype)initWithVideoRenderer:(id<RTCVideoRenderer>)videoRenderer { |
69 NSParameterAssert(videoRenderer); | 70 NSParameterAssert(videoRenderer); |
70 if (self = [super init]) { | 71 if (self = [super init]) { |
71 _videoRenderer = videoRenderer; | 72 _videoRenderer = videoRenderer; |
72 _adapter.reset(new webrtc::RTCVideoRendererNativeAdapter(self)); | 73 _adapter.reset(new webrtc::RTCVideoRendererNativeAdapter(self)); |
73 } | 74 } |
74 return self; | 75 return self; |
75 } | 76 } |
76 | 77 |
77 - (webrtc::VideoRendererInterface*)nativeVideoRenderer { | 78 - (rtc::VideoSinkInterface<cricket::VideoFrame> *)nativeVideoRenderer { |
78 return _adapter.get(); | 79 return _adapter.get(); |
79 } | 80 } |
80 | 81 |
81 @end | 82 @end |
OLD | NEW |