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

Side by Side Diff: remoting/client/decoder_verbatim.cc

Issue 2690003: Copy the (early prototype of) remoting in Chrome into the public tree.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/client/decoder_verbatim.h ('k') | remoting/client/decoder_verbatim_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/client/decoder_verbatim.h"
6
7 namespace remoting {
8
9 bool DecoderVerbatim::BeginDecode(scoped_refptr<media::VideoFrame> frame) {
10 // TODO(hclam): Check if we can accept the codec.
11 frame_ = frame;
12 return true;
13 }
14
15 bool DecoderVerbatim::PartialDecode(chromotocol_pb::HostMessage* message) {
16 scoped_ptr<chromotocol_pb::HostMessage> msg_deleter(message);
17
18 // TODO(hclam): Support YUV.
19 if (static_cast<int>(message->update_stream_packet().header().pixel_format())
20 != static_cast<int>(frame_->format())) {
21 return false;
22 }
23 int width = message->update_stream_packet().header().width();
24 int height = message->update_stream_packet().header().height();
25 int x = message->update_stream_packet().header().x();
26 int y = message->update_stream_packet().header().y();
27 chromotocol_pb::PixelFormat pixel_format =
28 message->update_stream_packet().header().pixel_format();
29 int bytes_per_pixel = 0;
30
31 // TODO(hclam): Extract the following to an util function.
32 if (pixel_format == chromotocol_pb::PixelFormatRgb24) {
33 bytes_per_pixel = 3;
34 } else if (pixel_format == chromotocol_pb::PixelFormatRgb565) {
35 bytes_per_pixel = 2;
36 } else if (pixel_format == chromotocol_pb::PixelFormatRgb32) {
37 bytes_per_pixel = 4;
38 } else if (pixel_format != chromotocol_pb::PixelFormatAscii) {
39 bytes_per_pixel = 1;
40 } else {
41 NOTREACHED() << "Pixel format not supported";
42 }
43
44 // Copy the data line by line.
45 const int src_stride = bytes_per_pixel * width;
46 const char* src = message->update_stream_packet().data().c_str();
47 const int dest_stride = frame_->stride(media::VideoFrame::kRGBPlane);
48 uint8* dest = frame_->data(media::VideoFrame::kRGBPlane) +
49 dest_stride * y + bytes_per_pixel * x;
50 for (int i = 0; i < height; ++i) {
51 memcpy(dest, src, src_stride);
52 dest += dest_stride;
53 src += src_stride;
54 }
55
56 UpdatedRects rects;
57 rects.push_back(gfx::Rect(x, y, width, height));
58 partial_decode_done()->Run(frame_, rects);
59 return true;
60 }
61
62 void DecoderVerbatim::EndDecode() {
63 decode_done()->Run(frame_);
64 frame_ = NULL;
65 }
66
67 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/decoder_verbatim.h ('k') | remoting/client/decoder_verbatim_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698