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

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

Issue 2745006: Implement a chromoting client using X11 (Closed)
Patch Set: removed all.gyp 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
« no previous file with comments | « remoting/client/decoder_verbatim.h ('k') | remoting/client/host_connection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/client/decoder_verbatim.h" 5 #include "remoting/client/decoder_verbatim.h"
6 6
7 namespace remoting { 7 namespace remoting {
8 8
9 bool DecoderVerbatim::BeginDecode(scoped_refptr<media::VideoFrame> frame) { 9 bool DecoderVerbatim::BeginDecode(scoped_refptr<media::VideoFrame> frame,
10 // TODO(hclam): Check if we can accept the codec. 10 UpdatedRects* updated_rects,
11 Task* partial_decode_done,
12 Task* decode_done) {
13 DCHECK(!partial_decode_done_.get());
14 DCHECK(!decode_done_.get());
15 DCHECK(!updated_rects_);
16
17 partial_decode_done_.reset(partial_decode_done);
18 decode_done_.reset(decode_done);
19 updated_rects_ = updated_rects;
20
21 // TODO(hclam): Check if we can accept the color format of the video frame and
22 // the codec.
11 frame_ = frame; 23 frame_ = frame;
12 return true; 24 return true;
13 } 25 }
14 26
15 bool DecoderVerbatim::PartialDecode(chromotocol_pb::HostMessage* message) { 27 bool DecoderVerbatim::PartialDecode(HostMessage* message) {
16 scoped_ptr<chromotocol_pb::HostMessage> msg_deleter(message); 28 scoped_ptr<HostMessage> msg_deleter(message);
17 29
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(); 30 int width = message->update_stream_packet().header().width();
24 int height = message->update_stream_packet().header().height(); 31 int height = message->update_stream_packet().header().height();
25 int x = message->update_stream_packet().header().x(); 32 int x = message->update_stream_packet().header().x();
26 int y = message->update_stream_packet().header().y(); 33 int y = message->update_stream_packet().header().y();
27 chromotocol_pb::PixelFormat pixel_format = 34 PixelFormat pixel_format =
28 message->update_stream_packet().header().pixel_format(); 35 message->update_stream_packet().header().pixel_format();
29 int bytes_per_pixel = 0; 36 int bytes_per_pixel = 0;
30 37
31 // TODO(hclam): Extract the following to an util function. 38 // TODO(hclam): Extract the following to an util function.
32 if (pixel_format == chromotocol_pb::PixelFormatRgb24) { 39 if (pixel_format == PixelFormatRgb24) {
33 bytes_per_pixel = 3; 40 bytes_per_pixel = 3;
34 } else if (pixel_format == chromotocol_pb::PixelFormatRgb565) { 41 } else if (pixel_format == PixelFormatRgb565) {
35 bytes_per_pixel = 2; 42 bytes_per_pixel = 2;
36 } else if (pixel_format == chromotocol_pb::PixelFormatRgb32) { 43 } else if (pixel_format == PixelFormatRgb32) {
37 bytes_per_pixel = 4; 44 bytes_per_pixel = 4;
38 } else if (pixel_format != chromotocol_pb::PixelFormatAscii) { 45 } else if (pixel_format != PixelFormatAscii) {
39 bytes_per_pixel = 1; 46 bytes_per_pixel = 1;
40 } else { 47 } else {
41 NOTREACHED() << "Pixel format not supported"; 48 NOTREACHED() << "Pixel format not supported";
42 } 49 }
43 50
51 if (static_cast<PixelFormat>(frame_->format()) != pixel_format) {
52 NOTREACHED() << "Pixel format of message doesn't match the video frame. "
53 "Expected vs received = "
54 << frame_->format() << " vs " << pixel_format
55 << " Color space conversion required.";
56 }
57
44 // Copy the data line by line. 58 // Copy the data line by line.
45 const int src_stride = bytes_per_pixel * width; 59 const int src_stride = bytes_per_pixel * width;
46 const char* src = message->update_stream_packet().data().c_str(); 60 const char* src = message->update_stream_packet().data().c_str();
47 const int dest_stride = frame_->stride(media::VideoFrame::kRGBPlane); 61 const int dest_stride = frame_->stride(media::VideoFrame::kRGBPlane);
48 uint8* dest = frame_->data(media::VideoFrame::kRGBPlane) + 62 uint8* dest = frame_->data(media::VideoFrame::kRGBPlane) +
49 dest_stride * y + bytes_per_pixel * x; 63 dest_stride * y + bytes_per_pixel * x;
50 for (int i = 0; i < height; ++i) { 64 for (int i = 0; i < height; ++i) {
51 memcpy(dest, src, src_stride); 65 memcpy(dest, src, src_stride);
52 dest += dest_stride; 66 dest += dest_stride;
53 src += src_stride; 67 src += src_stride;
54 } 68 }
55 69
56 UpdatedRects rects; 70 updated_rects_->clear();
57 rects.push_back(gfx::Rect(x, y, width, height)); 71 updated_rects_->push_back(gfx::Rect(x, y, width, height));
58 partial_decode_done()->Run(frame_, rects); 72 partial_decode_done_->Run();
59 return true; 73 return true;
60 } 74 }
61 75
62 void DecoderVerbatim::EndDecode() { 76 void DecoderVerbatim::EndDecode() {
63 decode_done()->Run(frame_); 77 decode_done_->Run();
78
79 partial_decode_done_.reset();
80 decode_done_.reset();
64 frame_ = NULL; 81 frame_ = NULL;
82 updated_rects_ = NULL;
65 } 83 }
66 84
67 } // namespace remoting 85 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/decoder_verbatim.h ('k') | remoting/client/host_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698