18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#ifndef REMOTING_CODEC_VIDEO_DECODER_VPX_H_ 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#define REMOTING_CODEC_VIDEO_DECODER_VPX_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "remoting/codec/scoped_vpx_codec.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "remoting/codec/video_decoder.h" 12d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 13d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "third_party/webrtc/modules/desktop_capture/desktop_region.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct vpx_image vpx_image_t; 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace remoting { 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class VideoDecoderVpx : public VideoDecoder { 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Create decoders for the specified protocol. 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) static scoped_ptr<VideoDecoderVpx> CreateForVP8(); 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) static scoped_ptr<VideoDecoderVpx> CreateForVP9(); 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~VideoDecoderVpx(); 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // VideoDecoder interface. 28d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) virtual void Initialize(const webrtc::DesktopSize& screen_size) OVERRIDE; 2968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) virtual bool DecodePacket(const VideoPacket& packet) OVERRIDE; 30d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) virtual void Invalidate(const webrtc::DesktopSize& view_size, 31d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const webrtc::DesktopRegion& region) OVERRIDE; 32d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) virtual void RenderFrame(const webrtc::DesktopSize& view_size, 33d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const webrtc::DesktopRect& clip_area, 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint8* image_buffer, 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int image_stride, 36d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) webrtc::DesktopRegion* output_region) OVERRIDE; 37d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) virtual const webrtc::DesktopRegion* GetImageShape() OVERRIDE; 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) explicit VideoDecoderVpx(ScopedVpxCodec codec); 41eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 42eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Calculates the difference between the desktop shape regions in two 43eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // consecutive frames and updates |updated_region_| and |transparent_region_| 44eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // accordingly. 45d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void UpdateImageShapeRegion(webrtc::DesktopRegion* new_desktop_shape); 46eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ScopedVpxCodec codec_; 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Pointer to the last decoded image. 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) vpx_image_t* last_image_; 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The region updated that hasn't been copied to the screen yet. 53d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) webrtc::DesktopRegion updated_region_; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Output dimensions. 56d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) webrtc::DesktopSize screen_size_; 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 58eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // The region occupied by the top level windows. 59d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) webrtc::DesktopRegion desktop_shape_; 60eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 61eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // The region that should be make transparent. 62d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) webrtc::DesktopRegion transparent_region_; 63eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(VideoDecoderVpx); 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace remoting 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // REMOTING_CODEC_VIDEO_DECODER_VP8_H_ 70