Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: talk/media/webrtc/webrtcvideoframe.cc

Issue 1304143003: VideoFrameBuffer: Make non-const data access explicit (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/common_video/i420_buffer_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 size_t WebRtcVideoFrame::GetWidth() const { 111 size_t WebRtcVideoFrame::GetWidth() const {
112 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; 112 return video_frame_buffer_ ? video_frame_buffer_->width() : 0;
113 } 113 }
114 114
115 size_t WebRtcVideoFrame::GetHeight() const { 115 size_t WebRtcVideoFrame::GetHeight() const {
116 return video_frame_buffer_ ? video_frame_buffer_->height() : 0; 116 return video_frame_buffer_ ? video_frame_buffer_->height() : 0;
117 } 117 }
118 118
119 const uint8* WebRtcVideoFrame::GetYPlane() const { 119 const uint8* WebRtcVideoFrame::GetYPlane() const {
120 // Const cast to call the correct const-version of data. 120 return video_frame_buffer_ ? video_frame_buffer_->data(kYPlane) : nullptr;
121 const webrtc::VideoFrameBuffer* const_ptr = video_frame_buffer_.get();
122 return const_ptr ? const_ptr->data(kYPlane) : nullptr;
123 } 121 }
124 122
125 const uint8* WebRtcVideoFrame::GetUPlane() const { 123 const uint8* WebRtcVideoFrame::GetUPlane() const {
126 // Const cast to call the correct const-version of data. 124 return video_frame_buffer_ ? video_frame_buffer_->data(kUPlane) : nullptr;
127 const webrtc::VideoFrameBuffer* const_ptr = video_frame_buffer_.get();
128 return const_ptr ? const_ptr->data(kUPlane) : nullptr;
129 } 125 }
130 126
131 const uint8* WebRtcVideoFrame::GetVPlane() const { 127 const uint8* WebRtcVideoFrame::GetVPlane() const {
132 // Const cast to call the correct const-version of data. 128 return video_frame_buffer_ ? video_frame_buffer_->data(kVPlane) : nullptr;
133 const webrtc::VideoFrameBuffer* const_ptr = video_frame_buffer_.get();
134 return const_ptr ? const_ptr->data(kVPlane) : nullptr;
135 } 129 }
136 130
137 uint8* WebRtcVideoFrame::GetYPlane() { 131 uint8* WebRtcVideoFrame::GetYPlane() {
138 return video_frame_buffer_ ? video_frame_buffer_->data(kYPlane) : nullptr; 132 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kYPlane)
133 : nullptr;
139 } 134 }
140 135
141 uint8* WebRtcVideoFrame::GetUPlane() { 136 uint8* WebRtcVideoFrame::GetUPlane() {
142 return video_frame_buffer_ ? video_frame_buffer_->data(kUPlane) : nullptr; 137 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kUPlane)
138 : nullptr;
143 } 139 }
144 140
145 uint8* WebRtcVideoFrame::GetVPlane() { 141 uint8* WebRtcVideoFrame::GetVPlane() {
146 return video_frame_buffer_ ? video_frame_buffer_->data(kVPlane) : nullptr; 142 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kVPlane)
143 : nullptr;
147 } 144 }
148 145
149 int32 WebRtcVideoFrame::GetYPitch() const { 146 int32 WebRtcVideoFrame::GetYPitch() const {
150 return video_frame_buffer_ ? video_frame_buffer_->stride(kYPlane) : 0; 147 return video_frame_buffer_ ? video_frame_buffer_->stride(kYPlane) : 0;
151 } 148 }
152 149
153 int32 WebRtcVideoFrame::GetUPitch() const { 150 int32 WebRtcVideoFrame::GetUPitch() const {
154 return video_frame_buffer_ ? video_frame_buffer_->stride(kUPlane) : 0; 151 return video_frame_buffer_ ? video_frame_buffer_->stride(kUPlane) : 0;
155 } 152 }
156 153
(...skipping 28 matching lines...) Expand all
185 return true; 182 return true;
186 183
187 // Not exclusive already, need to copy buffer. 184 // Not exclusive already, need to copy buffer.
188 rtc::scoped_refptr<webrtc::VideoFrameBuffer> new_buffer = 185 rtc::scoped_refptr<webrtc::VideoFrameBuffer> new_buffer =
189 new rtc::RefCountedObject<webrtc::I420Buffer>( 186 new rtc::RefCountedObject<webrtc::I420Buffer>(
190 video_frame_buffer_->width(), video_frame_buffer_->height(), 187 video_frame_buffer_->width(), video_frame_buffer_->height(),
191 video_frame_buffer_->stride(kYPlane), 188 video_frame_buffer_->stride(kYPlane),
192 video_frame_buffer_->stride(kUPlane), 189 video_frame_buffer_->stride(kUPlane),
193 video_frame_buffer_->stride(kVPlane)); 190 video_frame_buffer_->stride(kVPlane));
194 191
195 if (!CopyToPlanes(new_buffer->data(kYPlane), new_buffer->data(kUPlane), 192 if (!CopyToPlanes(
196 new_buffer->data(kVPlane), new_buffer->stride(kYPlane), 193 new_buffer->MutableData(kYPlane), new_buffer->MutableData(kUPlane),
197 new_buffer->stride(kUPlane), new_buffer->stride(kVPlane))) { 194 new_buffer->MutableData(kVPlane), new_buffer->stride(kYPlane),
195 new_buffer->stride(kUPlane), new_buffer->stride(kVPlane))) {
198 return false; 196 return false;
199 } 197 }
200 198
201 video_frame_buffer_ = new_buffer; 199 video_frame_buffer_ = new_buffer;
202 return true; 200 return true;
203 } 201 }
204 202
205 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer, 203 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer,
206 size_t size, int stride_rgb) const { 204 size_t size, int stride_rgb) const {
207 CHECK(video_frame_buffer_); 205 CHECK(video_frame_buffer_);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(), 325 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(),
328 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(), width, height, 326 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(), width, height,
329 static_cast<libyuv::RotationMode>(GetVideoRotation())); 327 static_cast<libyuv::RotationMode>(GetVideoRotation()));
330 if (ret == 0) { 328 if (ret == 0) {
331 return rotated_frame_.get(); 329 return rotated_frame_.get();
332 } 330 }
333 return nullptr; 331 return nullptr;
334 } 332 }
335 333
336 } // namespace cricket 334 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/common_video/i420_buffer_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698