OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/base/encoder_vp8.h" | 5 #include "remoting/base/encoder_vp8.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
9 #include "media/base/yuv_convert.h" | 9 #include "media/base/yuv_convert.h" |
10 #include "remoting/base/capture_data.h" | 10 #include "remoting/base/capture_data.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 // TODO(hclam): Apply the proper timestamp here. | 253 // TODO(hclam): Apply the proper timestamp here. |
254 last_timestamp_ += 50; | 254 last_timestamp_ += 50; |
255 | 255 |
256 // Read the encoded data. | 256 // Read the encoded data. |
257 vpx_codec_iter_t iter = NULL; | 257 vpx_codec_iter_t iter = NULL; |
258 bool got_data = false; | 258 bool got_data = false; |
259 | 259 |
260 // TODO(hclam): Make sure we get exactly one frame from the packet. | 260 // TODO(hclam): Make sure we get exactly one frame from the packet. |
261 // TODO(hclam): We should provide the output buffer to avoid one copy. | 261 // TODO(hclam): We should provide the output buffer to avoid one copy. |
262 VideoPacket* message = new VideoPacket(); | 262 scoped_ptr<VideoPacket> packet(new VideoPacket()); |
263 | 263 |
264 while (!got_data) { | 264 while (!got_data) { |
265 const vpx_codec_cx_pkt_t* packet = vpx_codec_get_cx_data(codec_.get(), | 265 const vpx_codec_cx_pkt_t* vpx_packet = vpx_codec_get_cx_data(codec_.get(), |
266 &iter); | 266 &iter); |
267 if (!packet) | 267 if (!vpx_packet) |
268 continue; | 268 continue; |
269 | 269 |
270 switch (packet->kind) { | 270 switch (vpx_packet->kind) { |
271 case VPX_CODEC_CX_FRAME_PKT: | 271 case VPX_CODEC_CX_FRAME_PKT: |
272 got_data = true; | 272 got_data = true; |
273 // TODO(sergeyu): Split each frame into multiple partitions. | 273 // TODO(sergeyu): Split each frame into multiple partitions. |
274 message->set_data(packet->data.frame.buf, packet->data.frame.sz); | 274 packet->set_data(vpx_packet->data.frame.buf, vpx_packet->data.frame.sz); |
275 break; | 275 break; |
276 default: | 276 default: |
277 break; | 277 break; |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 message->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); | 281 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); |
282 message->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET | | 282 packet->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET | |
283 VideoPacket::LAST_PARTITION); | 283 VideoPacket::LAST_PARTITION); |
284 message->mutable_format()->set_screen_width(capture_data->size().width()); | 284 packet->mutable_format()->set_screen_width(capture_data->size().width()); |
285 message->mutable_format()->set_screen_height(capture_data->size().height()); | 285 packet->mutable_format()->set_screen_height(capture_data->size().height()); |
286 message->set_capture_time_ms(capture_data->capture_time_ms()); | 286 packet->set_capture_time_ms(capture_data->capture_time_ms()); |
287 message->set_client_sequence_number(capture_data->client_sequence_number()); | 287 packet->set_client_sequence_number(capture_data->client_sequence_number()); |
288 for (size_t i = 0; i < updated_rects.size(); ++i) { | 288 for (size_t i = 0; i < updated_rects.size(); ++i) { |
289 Rect* rect = message->add_dirty_rects(); | 289 Rect* rect = packet->add_dirty_rects(); |
290 rect->set_x(updated_rects[i].fLeft); | 290 rect->set_x(updated_rects[i].fLeft); |
291 rect->set_y(updated_rects[i].fTop); | 291 rect->set_y(updated_rects[i].fTop); |
292 rect->set_width(updated_rects[i].width()); | 292 rect->set_width(updated_rects[i].width()); |
293 rect->set_height(updated_rects[i].height()); | 293 rect->set_height(updated_rects[i].height()); |
294 } | 294 } |
295 | 295 |
296 data_available_callback.Run(message); | 296 data_available_callback.Run(packet.Pass()); |
297 } | 297 } |
298 | 298 |
299 } // namespace remoting | 299 } // namespace remoting |
OLD | NEW |