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_verbatim.h" | 5 #include "remoting/base/encoder_verbatim.h" |
6 | 6 |
7 #include "gfx/rect.h" | 7 #include "gfx/rect.h" |
8 #include "media/base/data_buffer.h" | 8 #include "media/base/data_buffer.h" |
9 #include "remoting/base/capture_data.h" | 9 #include "remoting/base/capture_data.h" |
10 #include "remoting/base/protocol_util.h" | 10 #include "remoting/base/protocol_util.h" |
11 #include "remoting/base/protocol/chromotocol.pb.h" | 11 #include "remoting/base/protocol/chromotocol.pb.h" |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 | 14 |
15 using media::DataBuffer; | 15 using media::DataBuffer; |
16 | 16 |
17 void EncoderVerbatim::Encode(scoped_refptr<CaptureData> capture_data, | 17 void EncoderVerbatim::Encode(scoped_refptr<CaptureData> capture_data, |
18 bool key_frame, | 18 bool key_frame, |
19 DataAvailableCallback* data_available_callback) { | 19 DataAvailableCallback* data_available_callback) { |
20 const InvalidRects& rects = capture_data->dirty_rects(); | 20 const InvalidRects& rects = capture_data->dirty_rects(); |
21 int num_rects = rects.size(); | 21 int num_rects = rects.size(); |
22 int index = 0; | 22 int index = 0; |
23 for (InvalidRects::const_iterator r = rects.begin(); | 23 for (InvalidRects::const_iterator r = rects.begin(); |
24 r != rects.end(); ++r, ++index) { | 24 r != rects.end(); ++r, ++index) { |
25 const gfx::Rect& dirty_rect = *r; | 25 const gfx::Rect& dirty_rect = *r; |
26 HostMessage* msg = new HostMessage(); | 26 ChromotingHostMessage* msg = new ChromotingHostMessage(); |
27 UpdateStreamPacketMessage* packet = msg->mutable_update_stream_packet(); | 27 UpdateStreamPacketMessage* packet = msg->mutable_update_stream_packet(); |
28 | 28 |
29 if (EncodeRect(dirty_rect.x(), dirty_rect.y(), dirty_rect.width(), | 29 if (EncodeRect(dirty_rect.x(), dirty_rect.y(), dirty_rect.width(), |
30 dirty_rect.height(), capture_data, packet)) { | 30 dirty_rect.height(), capture_data, packet)) { |
31 // Prepare the end rect content. | 31 // Prepare the end rect content. |
32 packet->mutable_end_rect(); | 32 packet->mutable_end_rect(); |
33 | 33 |
34 EncodingState state = EncodingInProgress; | 34 EncodingState state = EncodingInProgress; |
35 if (index == 0) { | 35 if (index == 0) { |
36 state |= EncodingStarting; | 36 state |= EncodingStarting; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 DCHECK_LE(row_size, capture_data->data_planes().strides[i]); | 86 DCHECK_LE(row_size, capture_data->data_planes().strides[i]); |
87 memcpy(out, in, width * bytes_per_pixel); | 87 memcpy(out, in, width * bytes_per_pixel); |
88 in += capture_data->data_planes().strides[i]; | 88 in += capture_data->data_planes().strides[i]; |
89 out += row_size; | 89 out += row_size; |
90 } | 90 } |
91 } | 91 } |
92 return true; | 92 return true; |
93 } | 93 } |
94 | 94 |
95 } // namespace remoting | 95 } // namespace remoting |
OLD | NEW |