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

Unified Diff: remoting/base/encoder_zlib.cc

Issue 4255001: Revert 64672 - Cleanups in the video encoding decoding code. Reenable VP8.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/base/encoder_zlib.h ('k') | remoting/base/multiple_array_input_stream_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/encoder_zlib.cc
===================================================================
--- remoting/base/encoder_zlib.cc (revision 64676)
+++ remoting/base/encoder_zlib.cc (working copy)
@@ -26,7 +26,7 @@
void EncoderZlib::Encode(scoped_refptr<CaptureData> capture_data,
bool key_frame,
DataAvailableCallback* data_available_callback) {
- CHECK(capture_data->pixel_format() == PIXEL_FORMAT_RGB32)
+ CHECK(capture_data->pixel_format() == PixelFormatRgb32)
<< "Zlib Encoder only works with RGB32. Got "
<< capture_data->pixel_format();
capture_data_ = capture_data;
@@ -51,22 +51,24 @@
const int bytes_per_pixel = GetBytesPerPixel(capture_data_->pixel_format());
const int row_size = bytes_per_pixel * rect.width();
- VideoPacket* packet = new VideoPacket();
- PrepareUpdateStart(rect, packet);
+ ChromotingHostMessage* message = new ChromotingHostMessage();
+ RectangleUpdatePacket* update = message->mutable_rectangle_update();
+ PrepareUpdateStart(rect, update);
const uint8* in = capture_data_->data_planes().data[0] +
rect.y() * strides +
rect.x() * bytes_per_pixel;
// TODO(hclam): Fill in the sequence number.
- uint8* out = GetOutputBuffer(packet, packet_size_);
+ uint8* out = GetOutputBuffer(update, packet_size_);
int filled = 0;
int row_x = 0;
int row_y = 0;
bool compress_again = true;
while (compress_again) {
// Prepare a message for sending out.
- if (!packet) {
- packet = new VideoPacket();
- out = GetOutputBuffer(packet, packet_size_);
+ if (!message) {
+ message = new ChromotingHostMessage();
+ update = message->mutable_rectangle_update();
+ out = GetOutputBuffer(update, packet_size_);
filled = 0;
}
@@ -89,14 +91,15 @@
// We have reached the end of stream.
if (!compress_again) {
- packet->set_flags(packet->flags() | VideoPacket::LAST_PACKET);
+ update->set_flags(update->flags() | RectangleUpdatePacket::LAST_PACKET);
}
// If we have filled the message or we have reached the end of stream.
if (filled == packet_size_ || !compress_again) {
- packet->mutable_data()->resize(filled);
- SubmitMessage(packet, rect_index);
- packet = NULL;
+ message->mutable_rectangle_update()->mutable_encoded_rect()->
+ resize(filled);
+ SubmitMessage(message, rect_index);
+ message = NULL;
}
// Reached the end of input row and we're not at the last row.
@@ -109,27 +112,40 @@
}
void EncoderZlib::PrepareUpdateStart(const gfx::Rect& rect,
- VideoPacket* packet) {
- packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET);
- VideoPacketFormat* format = packet->mutable_format();
+ RectangleUpdatePacket* update) {
+ update->set_flags(update->flags() | RectangleUpdatePacket::FIRST_PACKET);
+ RectangleFormat* format = update->mutable_format();
+
format->set_x(rect.x());
format->set_y(rect.y());
format->set_width(rect.width());
format->set_height(rect.height());
- format->set_encoding(VideoPacketFormat::ENCODING_ZLIB);
+ format->set_encoding(EncodingZlib);
format->set_pixel_format(capture_data_->pixel_format());
}
-uint8* EncoderZlib::GetOutputBuffer(VideoPacket* packet, size_t size) {
- packet->mutable_data()->resize(size);
+uint8* EncoderZlib::GetOutputBuffer(RectangleUpdatePacket* update,
+ size_t size) {
+ update->mutable_encoded_rect()->resize(size);
// TODO(ajwong): Is there a better way to do this at all???
return const_cast<uint8*>(reinterpret_cast<const uint8*>(
- packet->mutable_data()->data()));
+ update->mutable_encoded_rect()->data()));
}
-void EncoderZlib::SubmitMessage(VideoPacket* packet, size_t rect_index) {
- callback_->Run(packet);
+void EncoderZlib::SubmitMessage(ChromotingHostMessage* message,
+ size_t rect_index) {
+ EncodingState state = EncodingInProgress;
+ const RectangleUpdatePacket& update = message->rectangle_update();
+ if (rect_index == 0 &&
+ (update.flags() | RectangleUpdatePacket::FIRST_PACKET)) {
+ state |= EncodingStarting;
+ }
+ if (rect_index == capture_data_->dirty_rects().size() - 1 &&
+ (update.flags() | RectangleUpdatePacket::LAST_PACKET)) {
+ state |= EncodingEnded;
+ }
+ callback_->Run(message, state);
}
} // namespace remoting
« no previous file with comments | « remoting/base/encoder_zlib.h ('k') | remoting/base/multiple_array_input_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698