summaryrefslogtreecommitdiffstats
path: root/remoting/base/encoder_verbatim.cc
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/base/encoder_verbatim.cc')
-rw-r--r--remoting/base/encoder_verbatim.cc44
1 files changed, 29 insertions, 15 deletions
diff --git a/remoting/base/encoder_verbatim.cc b/remoting/base/encoder_verbatim.cc
index 0bbe4e8..8c59a7d 100644
--- a/remoting/base/encoder_verbatim.cc
+++ b/remoting/base/encoder_verbatim.cc
@@ -52,14 +52,15 @@ void EncoderVerbatim::EncodeRect(const gfx::Rect& rect, size_t rect_index) {
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() * stride +
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 total_bytes = 0;
for (int y = 0; y < rect.height(); y++) {
memcpy(out, in, row_size);
@@ -69,36 +70,49 @@ void EncoderVerbatim::EncodeRect(const gfx::Rect& rect, size_t rect_index) {
}
// We have reached the end of stream.
- 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.
- packet->mutable_data()->resize(total_bytes);
- SubmitMessage(packet, rect_index);
+ message->mutable_rectangle_update()->mutable_encoded_rect()->
+ resize(total_bytes);
+ SubmitMessage(message, rect_index);
}
void EncoderVerbatim::PrepareUpdateStart(const gfx::Rect& rect,
- VideoPacket* packet) {
+ RectangleUpdatePacket* update) {
- packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET);
- VideoPacketFormat* format = packet->mutable_format();
+ 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_VERBATIM);
+ format->set_encoding(EncodingNone);
format->set_pixel_format(capture_data_->pixel_format());
}
-uint8* EncoderVerbatim::GetOutputBuffer(VideoPacket* packet, size_t size) {
- packet->mutable_data()->resize(size);
+uint8* EncoderVerbatim::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 EncoderVerbatim::SubmitMessage(VideoPacket* packet, size_t rect_index) {
- callback_->Run(packet);
+void EncoderVerbatim::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