| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 for (int y = top; y <= bottom; ++y) { | 209 for (int y = top; y <= bottom; ++y) { |
| 210 for (int x = left; x <= right; ++x) | 210 for (int x = left; x <= right; ++x) |
| 211 map[x] = 1; | 211 map[x] = 1; |
| 212 map += active_map_width_; | 212 map += active_map_width_; |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data, | 217 void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data, |
| 218 bool key_frame, | 218 bool key_frame, |
| 219 DataAvailableCallback* data_available_callback) { | 219 const DataAvailableCallback& data_available_callback) { |
| 220 if (!initialized_ || (capture_data->size() != size_)) { | 220 if (!initialized_ || (capture_data->size() != size_)) { |
| 221 bool ret = Init(capture_data->size()); | 221 bool ret = Init(capture_data->size()); |
| 222 // TODO(hclam): Handle error better. | 222 // TODO(hclam): Handle error better. |
| 223 DCHECK(ret) << "Initialization of encoder failed"; | 223 DCHECK(ret) << "Initialization of encoder failed"; |
| 224 initialized_ = ret; | 224 initialized_ = ret; |
| 225 } | 225 } |
| 226 | 226 |
| 227 RectVector updated_rects; | 227 RectVector updated_rects; |
| 228 if (!PrepareImage(capture_data, &updated_rects)) { | 228 if (!PrepareImage(capture_data, &updated_rects)) { |
| 229 NOTREACHED() << "Can't image data for encoding"; | 229 NOTREACHED() << "Can't image data for encoding"; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 message->set_capture_time_ms(capture_data->capture_time_ms()); | 286 message->set_capture_time_ms(capture_data->capture_time_ms()); |
| 287 message->set_client_sequence_number(capture_data->client_sequence_number()); | 287 message->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 = message->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(message); |
| 297 delete data_available_callback; | |
| 298 } | 297 } |
| 299 | 298 |
| 300 } // namespace remoting | 299 } // namespace remoting |
| OLD | NEW |