| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/software_video_renderer.h" | 5 #include "remoting/client/software_video_renderer.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // This class wraps a VideoDecoder and byte-swaps the pixels for compatibility | 30 // This class wraps a VideoDecoder and byte-swaps the pixels for compatibility |
| 31 // with the android.graphics.Bitmap class. | 31 // with the android.graphics.Bitmap class. |
| 32 // TODO(lambroslambrou): Refactor so that the VideoDecoder produces data | 32 // TODO(lambroslambrou): Refactor so that the VideoDecoder produces data |
| 33 // in the right byte-order, instead of swapping it here. | 33 // in the right byte-order, instead of swapping it here. |
| 34 class RgbToBgrVideoDecoderFilter : public VideoDecoder { | 34 class RgbToBgrVideoDecoderFilter : public VideoDecoder { |
| 35 public: | 35 public: |
| 36 RgbToBgrVideoDecoderFilter(scoped_ptr<VideoDecoder> parent) | 36 RgbToBgrVideoDecoderFilter(scoped_ptr<VideoDecoder> parent) |
| 37 : parent_(parent.Pass()) { | 37 : parent_(parent.Pass()) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 void Initialize(const webrtc::DesktopSize& screen_size) override { | |
| 41 parent_->Initialize(screen_size); | |
| 42 } | |
| 43 | |
| 44 bool DecodePacket(const VideoPacket& packet) override { | 40 bool DecodePacket(const VideoPacket& packet) override { |
| 45 return parent_->DecodePacket(packet); | 41 return parent_->DecodePacket(packet); |
| 46 } | 42 } |
| 47 | 43 |
| 48 void Invalidate(const webrtc::DesktopSize& view_size, | 44 void Invalidate(const webrtc::DesktopSize& view_size, |
| 49 const webrtc::DesktopRegion& region) override { | 45 const webrtc::DesktopRegion& region) override { |
| 50 return parent_->Invalidate(view_size, region); | 46 return parent_->Invalidate(view_size, region); |
| 51 } | 47 } |
| 52 | 48 |
| 53 void RenderFrame(const webrtc::DesktopSize& view_size, | 49 void RenderFrame(const webrtc::DesktopSize& view_size, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 notify_size_or_dpi_change = true; | 183 notify_size_or_dpi_change = true; |
| 188 } | 184 } |
| 189 } | 185 } |
| 190 | 186 |
| 191 // If we've never seen a screen size, ignore the packet. | 187 // If we've never seen a screen size, ignore the packet. |
| 192 if (source_size_.is_empty()) { | 188 if (source_size_.is_empty()) { |
| 193 main_task_runner_->PostTask(FROM_HERE, base::Bind(done)); | 189 main_task_runner_->PostTask(FROM_HERE, base::Bind(done)); |
| 194 return; | 190 return; |
| 195 } | 191 } |
| 196 | 192 |
| 197 if (decoder_needs_reset) | |
| 198 decoder_->Initialize(source_size_); | |
| 199 if (notify_size_or_dpi_change) | 193 if (notify_size_or_dpi_change) |
| 200 consumer_->SetSourceSize(source_size_, source_dpi_); | 194 consumer_->SetSourceSize(source_size_, source_dpi_); |
| 201 | 195 |
| 202 if (decoder_->DecodePacket(*packet.get())) { | 196 if (decoder_->DecodePacket(*packet.get())) { |
| 203 SchedulePaint(); | 197 SchedulePaint(); |
| 204 } else { | 198 } else { |
| 205 LOG(ERROR) << "DecodePacket() failed."; | 199 LOG(ERROR) << "DecodePacket() failed."; |
| 206 } | 200 } |
| 207 | 201 |
| 208 main_task_runner_->PostTask(FROM_HERE, base::Bind(done)); | 202 main_task_runner_->PostTask(FROM_HERE, base::Bind(done)); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 DCHECK(CalledOnValidThread()); | 397 DCHECK(CalledOnValidThread()); |
| 404 | 398 |
| 405 // Record the latency between the packet being received and presented. | 399 // Record the latency between the packet being received and presented. |
| 406 base::TimeDelta decode_time = base::Time::Now() - decode_start; | 400 base::TimeDelta decode_time = base::Time::Now() - decode_start; |
| 407 stats_.RecordDecodeTime(decode_time.InMilliseconds()); | 401 stats_.RecordDecodeTime(decode_time.InMilliseconds()); |
| 408 | 402 |
| 409 decode_task_runner_->PostTask(FROM_HERE, done); | 403 decode_task_runner_->PostTask(FROM_HERE, done); |
| 410 } | 404 } |
| 411 | 405 |
| 412 } // namespace remoting | 406 } // namespace remoting |
| OLD | NEW |