Index: remoting/client/rectangle_update_decoder.cc |
diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc |
index 106c9934bbec89ea5361db5b3629fd61bf70540c..95f46d78849b52d67bc1b7f2208c9997ca8d7fd0 100644 |
--- a/remoting/client/rectangle_update_decoder.cc |
+++ b/remoting/client/rectangle_update_decoder.cc |
@@ -18,12 +18,74 @@ |
#include "remoting/protocol/session_config.h" |
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
+#if defined(OS_ANDROID) |
Sergey Ulanov
2013/09/20 18:35:15
No need to wrap this include in ifdefs (even if yo
Lambros
2013/09/25 18:40:41
Done.
|
+#include "third_party/libyuv/include/libyuv/convert_argb.h" |
+#endif // OS_ANDROID |
+ |
using base::Passed; |
using remoting::protocol::ChannelConfig; |
using remoting::protocol::SessionConfig; |
namespace remoting { |
+#if defined(OS_ANDROID) |
Sergey Ulanov
2013/09/20 18:35:15
Can we make this more generic so it's easier to re
Lambros
2013/09/25 18:40:41
Done.
|
+class VideoDecoderWrapper : public VideoDecoder { |
Sergey Ulanov
2013/09/20 18:35:15
Maybe call it RgbToBgrVideoDecoderFilter?
Lambros
2013/09/25 18:40:41
Done.
|
+ public: |
+ VideoDecoderWrapper(scoped_ptr<VideoDecoder> parent) |
+ : parent_(parent.Pass()) { |
+ } |
+ |
+ virtual void Initialize(const SkISize& screen_size) OVERRIDE { |
+ parent_->Initialize(screen_size); |
+ } |
+ |
+ virtual DecodeResult DecodePacket(const VideoPacket* packet) |
+ OVERRIDE { |
Sergey Ulanov
2013/09/20 18:35:15
nit: OVERRIDE must be on one line with the last pa
Lambros
2013/09/25 18:40:41
Hmm.. wrapping wasn't needed anyway.
|
+ return parent_->DecodePacket(packet); |
+ } |
+ |
+ virtual bool IsReadyForData() OVERRIDE { |
Sergey Ulanov
2013/09/20 18:35:15
VideoDecoder interface has rotten over time. There
Lambros
2013/09/25 18:40:41
Done.
|
+ return parent_->IsReadyForData(); |
+ } |
+ |
+ virtual VideoPacketFormat::Encoding Encoding() OVERRIDE { |
+ return parent_->Encoding(); |
+ } |
+ |
+ virtual void Invalidate(const SkISize& view_size, |
+ const SkRegion& region) OVERRIDE { |
+ return parent_->Invalidate(view_size, region); |
+ } |
+ |
+ virtual void RenderFrame(const SkISize& view_size, |
+ const SkIRect& clip_area, |
+ uint8* image_buffer, |
+ int image_stride, |
+ SkRegion* output_region) OVERRIDE { |
+ parent_->RenderFrame(view_size, clip_area, image_buffer, image_stride, |
+ output_region); |
+ |
+ // Byte-swap the pixels for compatibility with the android.graphics.Bitmap |
+ // class. |
+ static const int kBytesPerPixelRGB32 = 4; |
Sergey Ulanov
2013/09/20 18:35:15
Please add this const in VideoDecoder interface an
Lambros
2013/09/25 18:40:41
Done.
|
+ for (SkRegion::Iterator i(*output_region); !i.done(); i.next()) { |
+ SkIRect rect = i.rect(); |
+ uint8* pixels = image_buffer + (rect.top() * image_stride) + |
+ (rect.left() * kBytesPerPixelRGB32); |
+ libyuv::ABGRToARGB(pixels, image_stride, pixels, image_stride, |
Sergey Ulanov
2013/09/20 18:35:15
It would be great if we could get data in the righ
fbarchard
2013/09/20 21:50:58
If this is coming from the codec as I420, libyuv c
Sergey Ulanov
2013/09/20 21:56:03
Decoder uses media::ScaleYUVToRGB32WithRect() for
Lambros
2013/09/25 18:40:41
Added TODO.
|
+ rect.width(), rect.height()); |
+ } |
+ } |
+ |
+ virtual const SkRegion* GetImageShape() OVERRIDE { |
+ return parent_->GetImageShape(); |
+ } |
+ |
+ private: |
+ scoped_ptr<VideoDecoder> parent_; |
+}; |
+#endif // OS_ANDROID |
+ |
RectangleUpdateDecoder::RectangleUpdateDecoder( |
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, |
@@ -52,6 +114,11 @@ void RectangleUpdateDecoder::Initialize(const SessionConfig& config) { |
} else { |
NOTREACHED() << "Invalid Encoding found: " << codec; |
} |
+ |
+#if defined (OS_ANDROID) |
Sergey Ulanov
2013/09/20 18:35:15
I think it's better to make this more generic. The
Lambros
2013/09/25 18:40:41
Done - added output format getter to FrameConsumer
|
+ scoped_ptr<VideoDecoder> wrapper(new VideoDecoderWrapper(decoder_.Pass())); |
+ decoder_ = wrapper.Pass(); |
+#endif // OS_ANDROID |
} |
void RectangleUpdateDecoder::DecodePacket(scoped_ptr<VideoPacket> packet, |