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

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

Issue 9827006: Refactor VideoStub interface to accept ownership of video packets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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/rectangle_update_decoder.h ('k') | remoting/host/chromoting_host_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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/rectangle_update_decoder.h" 5 #include "remoting/client/rectangle_update_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 decoder_.reset(DecoderRowBased::CreateVerbatimDecoder()); 45 decoder_.reset(DecoderRowBased::CreateVerbatimDecoder());
46 } else if (codec == ChannelConfig::CODEC_ZIP) { 46 } else if (codec == ChannelConfig::CODEC_ZIP) {
47 decoder_.reset(DecoderRowBased::CreateZlibDecoder()); 47 decoder_.reset(DecoderRowBased::CreateZlibDecoder());
48 } else if (codec == ChannelConfig::CODEC_VP8) { 48 } else if (codec == ChannelConfig::CODEC_VP8) {
49 decoder_.reset(new DecoderVp8()); 49 decoder_.reset(new DecoderVp8());
50 } else { 50 } else {
51 NOTREACHED() << "Invalid Encoding found: " << codec; 51 NOTREACHED() << "Invalid Encoding found: " << codec;
52 } 52 }
53 } 53 }
54 54
55 void RectangleUpdateDecoder::DecodePacket(const VideoPacket* packet, 55 void RectangleUpdateDecoder::DecodePacket(scoped_ptr<VideoPacket> packet,
56 const base::Closure& done) { 56 const base::Closure& done) {
57 if (!message_loop_->BelongsToCurrentThread()) { 57 if (!message_loop_->BelongsToCurrentThread()) {
58 message_loop_->PostTask( 58 message_loop_->PostTask(
59 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DecodePacket, 59 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DecodePacket,
60 this, packet, done)); 60 this, base::Passed(&packet), done));
61 return; 61 return;
62 } 62 }
63 63
64 base::ScopedClosureRunner done_runner(done); 64 base::ScopedClosureRunner done_runner(done);
65 bool decoder_needs_reset = false; 65 bool decoder_needs_reset = false;
66 66
67 // If the packet includes a screen size, store it. 67 // If the packet includes a screen size, store it.
68 if (packet->format().has_screen_width() && 68 if (packet->format().has_screen_width() &&
69 packet->format().has_screen_height()) { 69 packet->format().has_screen_height()) {
70 SkISize source_size = SkISize::Make(packet->format().screen_width(), 70 SkISize source_size = SkISize::Make(packet->format().screen_width(),
(...skipping 13 matching lines...) Expand all
84 decoder_->Initialize(source_size_); 84 decoder_->Initialize(source_size_);
85 consumer_->SetSourceSize(source_size_); 85 consumer_->SetSourceSize(source_size_);
86 } 86 }
87 87
88 if (!decoder_->IsReadyForData()) { 88 if (!decoder_->IsReadyForData()) {
89 // TODO(ajwong): This whole thing should move into an invalid state. 89 // TODO(ajwong): This whole thing should move into an invalid state.
90 LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; 90 LOG(ERROR) << "Decoder is unable to process data. Dropping packet.";
91 return; 91 return;
92 } 92 }
93 93
94 if (decoder_->DecodePacket(packet) == Decoder::DECODE_DONE) 94 if (decoder_->DecodePacket(packet.get()) == Decoder::DECODE_DONE)
95 SchedulePaint(); 95 SchedulePaint();
96 } 96 }
97 97
98 void RectangleUpdateDecoder::SchedulePaint() { 98 void RectangleUpdateDecoder::SchedulePaint() {
99 if (paint_scheduled_) 99 if (paint_scheduled_)
100 return; 100 return;
101 paint_scheduled_ = true; 101 paint_scheduled_ = true;
102 message_loop_->PostTask( 102 message_loop_->PostTask(
103 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DoPaint, this)); 103 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DoPaint, this));
104 } 104 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } else { 209 } else {
210 ++i; 210 ++i;
211 } 211 }
212 } 212 }
213 213
214 SchedulePaint(); 214 SchedulePaint();
215 } 215 }
216 } 216 }
217 217
218 } // namespace remoting 218 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/rectangle_update_decoder.h ('k') | remoting/host/chromoting_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698