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 "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 "net/base/io_buffer.h" |
10 #include "remoting/base/capture_data.h" | 10 #include "remoting/base/capture_data.h" |
11 #include "remoting/base/util.h" | 11 #include "remoting/base/util.h" |
| 12 #include "remoting/proto/video.pb.h" |
12 | 13 |
13 namespace remoting { | 14 namespace remoting { |
14 | 15 |
15 // TODO(garykac): Move up into shared location. Share value with encoder_zlib. | 16 // TODO(garykac): Move up into shared location. Share value with encoder_zlib. |
16 // TODO(garykac): 10* is added to ensure that rects fit in a single packet. | 17 // TODO(garykac): 10* is added to ensure that rects fit in a single packet. |
17 // Add support for splitting across packets and remove the 10*. | 18 // Add support for splitting across packets and remove the 10*. |
18 static const int kPacketSize = 10 * 1024 * 1024; | 19 static const int kPacketSize = 10 * 1024 * 1024; |
19 | 20 |
20 using media::DataBuffer; | |
21 | |
22 EncoderVerbatim::EncoderVerbatim() | 21 EncoderVerbatim::EncoderVerbatim() |
23 : packet_size_(kPacketSize) { | 22 : packet_size_(kPacketSize) { |
24 } | 23 } |
25 | 24 |
26 EncoderVerbatim::EncoderVerbatim(int packet_size) | 25 EncoderVerbatim::EncoderVerbatim(int packet_size) |
27 : packet_size_(packet_size) { | 26 : packet_size_(packet_size) { |
28 } | 27 } |
29 | 28 |
30 void EncoderVerbatim::Encode(scoped_refptr<CaptureData> capture_data, | 29 void EncoderVerbatim::Encode(scoped_refptr<CaptureData> capture_data, |
31 bool key_frame, | 30 bool key_frame, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 VideoPacket* packet) { | 79 VideoPacket* packet) { |
81 | 80 |
82 packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET); | 81 packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET); |
83 VideoPacketFormat* format = packet->mutable_format(); | 82 VideoPacketFormat* format = packet->mutable_format(); |
84 | 83 |
85 format->set_x(rect.x()); | 84 format->set_x(rect.x()); |
86 format->set_y(rect.y()); | 85 format->set_y(rect.y()); |
87 format->set_width(rect.width()); | 86 format->set_width(rect.width()); |
88 format->set_height(rect.height()); | 87 format->set_height(rect.height()); |
89 format->set_encoding(VideoPacketFormat::ENCODING_VERBATIM); | 88 format->set_encoding(VideoPacketFormat::ENCODING_VERBATIM); |
90 format->set_pixel_format(capture_data_->pixel_format()); | |
91 } | 89 } |
92 | 90 |
93 uint8* EncoderVerbatim::GetOutputBuffer(VideoPacket* packet, size_t size) { | 91 uint8* EncoderVerbatim::GetOutputBuffer(VideoPacket* packet, size_t size) { |
94 packet->mutable_data()->resize(size); | 92 packet->mutable_data()->resize(size); |
95 // TODO(ajwong): Is there a better way to do this at all??? | 93 // TODO(ajwong): Is there a better way to do this at all??? |
96 return const_cast<uint8*>(reinterpret_cast<const uint8*>( | 94 return const_cast<uint8*>(reinterpret_cast<const uint8*>( |
97 packet->mutable_data()->data())); | 95 packet->mutable_data()->data())); |
98 } | 96 } |
99 | 97 |
100 void EncoderVerbatim::SubmitMessage(VideoPacket* packet, size_t rect_index) { | 98 void EncoderVerbatim::SubmitMessage(VideoPacket* packet, size_t rect_index) { |
101 callback_->Run(packet); | 99 callback_->Run(packet); |
102 } | 100 } |
103 | 101 |
104 } // namespace remoting | 102 } // namespace remoting |
OLD | NEW |