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

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

Issue 2849006: Chromoting unit test: Adding DecoderVerbatimTest (Closed)
Patch Set: add file 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 | « media/base/video_frame.cc ('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')
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 DecoderVerbatim::DecoderVerbatim() 9 DecoderVerbatim::DecoderVerbatim()
10 : updated_rects_(NULL) { 10 : updated_rects_(NULL) {
11 } 11 }
12 12
13 bool DecoderVerbatim::BeginDecode(scoped_refptr<media::VideoFrame> frame, 13 bool DecoderVerbatim::BeginDecode(scoped_refptr<media::VideoFrame> frame,
14 UpdatedRects* updated_rects, 14 UpdatedRects* updated_rects,
15 Task* partial_decode_done, 15 Task* partial_decode_done,
16 Task* decode_done) { 16 Task* decode_done) {
17 DCHECK(!partial_decode_done_.get()); 17 DCHECK(!partial_decode_done_.get());
18 DCHECK(!decode_done_.get()); 18 DCHECK(!decode_done_.get());
19 DCHECK(!updated_rects_); 19 DCHECK(!updated_rects_);
20 20
21 partial_decode_done_.reset(partial_decode_done); 21 partial_decode_done_.reset(partial_decode_done);
22 decode_done_.reset(decode_done); 22 decode_done_.reset(decode_done);
23 updated_rects_ = updated_rects; 23 updated_rects_ = updated_rects;
24 24
25 // TODO(hclam): Check if we can accept the color format of the video frame and 25 // TODO(hclam): Check if we can accept the color format of the video frame
26 // the codec. 26 // and the codec.
27 frame_ = frame; 27 frame_ = frame;
28 return true; 28 return true;
29 } 29 }
30 30
31 bool DecoderVerbatim::PartialDecode(HostMessage* message) { 31 bool DecoderVerbatim::PartialDecode(HostMessage* message) {
32 scoped_ptr<HostMessage> msg_deleter(message); 32 scoped_ptr<HostMessage> msg_deleter(message);
33 33
34 int width = message->update_stream_packet().header().width(); 34 int width = message->update_stream_packet().header().width();
35 int height = message->update_stream_packet().header().height(); 35 int height = message->update_stream_packet().header().height();
36 int x = message->update_stream_packet().header().x(); 36 int x = message->update_stream_packet().header().x();
37 int y = message->update_stream_packet().header().y(); 37 int y = message->update_stream_packet().header().y();
38 PixelFormat pixel_format = 38 PixelFormat pixel_format =
39 message->update_stream_packet().header().pixel_format(); 39 message->update_stream_packet().header().pixel_format();
40 int bytes_per_pixel = 0; 40 int bytes_per_pixel = 0;
41 41
42 // TODO(hclam): Extract the following to an util function. 42 // TODO(hclam): Extract the following to an util function.
43 if (pixel_format == PixelFormatRgb24) { 43 if (pixel_format == PixelFormatRgb24) {
44 bytes_per_pixel = 3; 44 bytes_per_pixel = 3;
45 } else if (pixel_format == PixelFormatRgb565) { 45 } else if (pixel_format == PixelFormatRgb565) {
46 bytes_per_pixel = 2; 46 bytes_per_pixel = 2;
47 } else if (pixel_format == PixelFormatRgb32) { 47 } else if (pixel_format == PixelFormatRgb32) {
48 bytes_per_pixel = 4; 48 bytes_per_pixel = 4;
49 } else if (pixel_format != PixelFormatAscii) { 49 } else if (pixel_format == PixelFormatAscii) {
50 bytes_per_pixel = 1; 50 bytes_per_pixel = 1;
51 } else { 51 } else {
52 NOTREACHED() << "Pixel format not supported"; 52 NOTREACHED() << "Pixel format not supported";
53 } 53 }
54 54
55 if (static_cast<PixelFormat>(frame_->format()) != pixel_format) { 55 if (static_cast<PixelFormat>(frame_->format()) != pixel_format) {
56 NOTREACHED() << "Pixel format of message doesn't match the video frame. " 56 NOTREACHED() << "Pixel format of message doesn't match the video frame. "
57 "Expected vs received = " 57 "Expected vs received = "
58 << frame_->format() << " vs " << pixel_format 58 << frame_->format() << " vs " << pixel_format
59 << " Color space conversion required."; 59 << " Color space conversion required.";
(...skipping 20 matching lines...) Expand all
80 void DecoderVerbatim::EndDecode() { 80 void DecoderVerbatim::EndDecode() {
81 decode_done_->Run(); 81 decode_done_->Run();
82 82
83 partial_decode_done_.reset(); 83 partial_decode_done_.reset();
84 decode_done_.reset(); 84 decode_done_.reset();
85 frame_ = NULL; 85 frame_ = NULL;
86 updated_rects_ = NULL; 86 updated_rects_ = NULL;
87 } 87 }
88 88
89 } // namespace remoting 89 } // namespace remoting
OLDNEW
« no previous file with comments | « media/base/video_frame.cc ('k') | remoting/client/decoder_verbatim_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698