| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_zlib.h" | 5 #include "remoting/base/encoder_zlib.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "gfx/rect.h" | 8 #include "gfx/rect.h" |
| 9 #include "media/base/data_buffer.h" | 9 #include "media/base/data_buffer.h" |
| 10 #include "remoting/base/capture_data.h" | 10 #include "remoting/base/capture_data.h" |
| 11 #include "remoting/base/compressor_zlib.h" | 11 #include "remoting/base/compressor_zlib.h" |
| 12 #include "remoting/base/util.h" | 12 #include "remoting/base/util.h" |
| 13 #include "remoting/base/protocol/chromotocol.pb.h" | 13 #include "remoting/base/protocol/chromotocol.pb.h" |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 | 16 |
| 17 static const int kPacketSize = 1024 * 1024; | 17 static const int kPacketSize = 1024 * 1024; |
| 18 | 18 |
| 19 EncoderZlib::EncoderZlib() : packet_size_(kPacketSize) { | 19 EncoderZlib::EncoderZlib() : packet_size_(kPacketSize) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 EncoderZlib::EncoderZlib(int packet_size) : packet_size_(packet_size) { | 22 EncoderZlib::EncoderZlib(int packet_size) : packet_size_(packet_size) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 EncoderZlib::~EncoderZlib() {} |
| 26 |
| 25 void EncoderZlib::Encode(scoped_refptr<CaptureData> capture_data, | 27 void EncoderZlib::Encode(scoped_refptr<CaptureData> capture_data, |
| 26 bool key_frame, | 28 bool key_frame, |
| 27 DataAvailableCallback* data_available_callback) { | 29 DataAvailableCallback* data_available_callback) { |
| 28 CHECK(capture_data->pixel_format() == PixelFormatRgb32) | 30 CHECK(capture_data->pixel_format() == PixelFormatRgb32) |
| 29 << "Zlib Encoder only works with RGB32"; | 31 << "Zlib Encoder only works with RGB32"; |
| 30 capture_data_ = capture_data; | 32 capture_data_ = capture_data; |
| 31 callback_.reset(data_available_callback); | 33 callback_.reset(data_available_callback); |
| 32 | 34 |
| 33 CompressorZlib compressor; | 35 CompressorZlib compressor; |
| 34 const InvalidRects& rects = capture_data->dirty_rects(); | 36 const InvalidRects& rects = capture_data->dirty_rects(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 state |= EncodingStarting; | 142 state |= EncodingStarting; |
| 141 } | 143 } |
| 142 if (rect_index == capture_data_->dirty_rects().size() - 1 && | 144 if (rect_index == capture_data_->dirty_rects().size() - 1 && |
| 143 (update.flags() | RectangleUpdatePacket::LAST_PACKET)) { | 145 (update.flags() | RectangleUpdatePacket::LAST_PACKET)) { |
| 144 state |= EncodingEnded; | 146 state |= EncodingEnded; |
| 145 } | 147 } |
| 146 callback_->Run(message, state); | 148 callback_->Run(message, state); |
| 147 } | 149 } |
| 148 | 150 |
| 149 } // namespace remoting | 151 } // namespace remoting |
| OLD | NEW |