OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 paint_scheduled_(false) { | 36 paint_scheduled_(false) { |
37 } | 37 } |
38 | 38 |
39 RectangleUpdateDecoder::~RectangleUpdateDecoder() { | 39 RectangleUpdateDecoder::~RectangleUpdateDecoder() { |
40 } | 40 } |
41 | 41 |
42 void RectangleUpdateDecoder::Initialize(const SessionConfig& config) { | 42 void RectangleUpdateDecoder::Initialize(const SessionConfig& config) { |
43 // Initialize decoder based on the selected codec. | 43 // Initialize decoder based on the selected codec. |
44 ChannelConfig::Codec codec = config.video_config().codec; | 44 ChannelConfig::Codec codec = config.video_config().codec; |
45 if (codec == ChannelConfig::CODEC_VERBATIM) { | 45 if (codec == ChannelConfig::CODEC_VERBATIM) { |
46 decoder_.reset(DecoderRowBased::CreateVerbatimDecoder()); | 46 decoder_.reset(VideoDecoderRowBased::CreateVerbatimDecoder()); |
47 } else if (codec == ChannelConfig::CODEC_ZIP) { | 47 } else if (codec == ChannelConfig::CODEC_ZIP) { |
48 decoder_.reset(DecoderRowBased::CreateZlibDecoder()); | 48 decoder_.reset(VideoDecoderRowBased::CreateZlibDecoder()); |
49 } else if (codec == ChannelConfig::CODEC_VP8) { | 49 } else if (codec == ChannelConfig::CODEC_VP8) { |
50 decoder_.reset(new DecoderVp8()); | 50 decoder_.reset(new VideoDecoderVp8()); |
51 } else { | 51 } else { |
52 NOTREACHED() << "Invalid Encoding found: " << codec; | 52 NOTREACHED() << "Invalid Encoding found: " << codec; |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 void RectangleUpdateDecoder::DecodePacket(scoped_ptr<VideoPacket> packet, | 56 void RectangleUpdateDecoder::DecodePacket(scoped_ptr<VideoPacket> packet, |
57 const base::Closure& done) { | 57 const base::Closure& done) { |
58 if (!task_runner_->BelongsToCurrentThread()) { | 58 if (!task_runner_->BelongsToCurrentThread()) { |
59 task_runner_->PostTask( | 59 task_runner_->PostTask( |
60 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DecodePacket, | 60 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DecodePacket, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 decoder_->Initialize(source_size_); | 94 decoder_->Initialize(source_size_); |
95 if (notify_size_or_dpi_change) | 95 if (notify_size_or_dpi_change) |
96 consumer_->SetSourceSize(source_size_, source_dpi_); | 96 consumer_->SetSourceSize(source_size_, source_dpi_); |
97 | 97 |
98 if (!decoder_->IsReadyForData()) { | 98 if (!decoder_->IsReadyForData()) { |
99 // TODO(ajwong): This whole thing should move into an invalid state. | 99 // TODO(ajwong): This whole thing should move into an invalid state. |
100 LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; | 100 LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; |
101 return; | 101 return; |
102 } | 102 } |
103 | 103 |
104 if (decoder_->DecodePacket(packet.get()) == Decoder::DECODE_DONE) | 104 if (decoder_->DecodePacket(packet.get()) == VideoDecoder::DECODE_DONE) |
105 SchedulePaint(); | 105 SchedulePaint(); |
106 } | 106 } |
107 | 107 |
108 void RectangleUpdateDecoder::SchedulePaint() { | 108 void RectangleUpdateDecoder::SchedulePaint() { |
109 if (paint_scheduled_) | 109 if (paint_scheduled_) |
110 return; | 110 return; |
111 paint_scheduled_ = true; | 111 paint_scheduled_ = true; |
112 task_runner_->PostTask( | 112 task_runner_->PostTask( |
113 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DoPaint, this)); | 113 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DoPaint, this)); |
114 } | 114 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } else { | 219 } else { |
220 ++i; | 220 ++i; |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 SchedulePaint(); | 224 SchedulePaint(); |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 } // namespace remoting | 228 } // namespace remoting |
OLD | NEW |