OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 int y = window_bounds.bottom - CGImageGetHeight(image_ref); | 85 int y = window_bounds.bottom - CGImageGetHeight(image_ref); |
86 CGRect dst_rect = CGRectMake(x, y, CGImageGetWidth(image_ref), | 86 CGRect dst_rect = CGRectMake(x, y, CGImageGetWidth(image_ref), |
87 CGImageGetHeight(image_ref)); | 87 CGImageGetHeight(image_ref)); |
88 CGContextDrawImage(context, dst_rect, image_ref); | 88 CGContextDrawImage(context, dst_rect, image_ref); |
89 CGContextFlush(context); | 89 CGContextFlush(context); |
90 QDEndCGContext(GetWindowPort(window_ref_), &context); | 90 QDEndCGContext(GetWindowPort(window_ref_), &context); |
91 CGImageRelease(image_ref); | 91 CGImageRelease(image_ref); |
92 return true; | 92 return true; |
93 } | 93 } |
94 | 94 |
95 bool CarbonVideoRenderer::SetSize(int width, int height, int reserved) { | 95 bool CarbonVideoRenderer::SetSize(int width, int height) { |
96 if (width != image_width_ || height != image_height_) { | 96 if (width != image_width_ || height != image_height_) { |
97 // Grab the image lock while changing its size. | 97 // Grab the image lock while changing its size. |
98 rtc::CritScope cs(&image_crit_); | 98 rtc::CritScope cs(&image_crit_); |
99 image_width_ = width; | 99 image_width_ = width; |
100 image_height_ = height; | 100 image_height_ = height; |
101 image_.reset(new uint8_t[width * height * 4]); | 101 image_.reset(new uint8_t[width * height * 4]); |
102 memset(image_.get(), 255, width * height * 4); | 102 memset(image_.get(), 255, width * height * 4); |
103 } | 103 } |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 bool CarbonVideoRenderer::RenderFrame(const VideoFrame* video_frame) { | 107 void CarbonVideoRenderer::OnFrame(const VideoFrame& video_frame) { |
108 if (!video_frame) { | |
109 return false; | |
110 } | |
111 { | 108 { |
112 const VideoFrame* frame = video_frame->GetCopyWithRotationApplied(); | 109 const VideoFrame* frame = video_frame->GetCopyWithRotationApplied(); |
113 | 110 |
114 if (!SetSize(frame->GetWidth(), frame->GetHeight(), 0)) { | 111 if (!SetSize(frame->GetWidth(), frame->GetHeight(), 0)) { |
115 return false; | 112 return false; |
116 } | 113 } |
117 | 114 |
118 // Grab the image lock so we are not trashing up the image being drawn. | 115 // Grab the image lock so we are not trashing up the image being drawn. |
119 rtc::CritScope cs(&image_crit_); | 116 rtc::CritScope cs(&image_crit_); |
120 frame->ConvertToRgbBuffer(cricket::FOURCC_ABGR, | 117 frame->ConvertToRgbBuffer(cricket::FOURCC_ABGR, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 if (err != noErr) { | 160 if (err != noErr) { |
164 LOG(LS_ERROR) << "Failed to install event handler, error code: " << err; | 161 LOG(LS_ERROR) << "Failed to install event handler, error code: " << err; |
165 return false; | 162 return false; |
166 } | 163 } |
167 SelectWindow(window_ref_); | 164 SelectWindow(window_ref_); |
168 ShowWindow(window_ref_); | 165 ShowWindow(window_ref_); |
169 return true; | 166 return true; |
170 } | 167 } |
171 | 168 |
172 } // namespace cricket | 169 } // namespace cricket |
OLD | NEW |