video_decoder.h revision 68043e1e95eeb07d5cae7aca370b26518b0867d6
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 3// found in the LICENSE file. 4 5#ifndef REMOTING_CODEC_VIDEO_DECODER_H_ 6#define REMOTING_CODEC_VIDEO_DECODER_H_ 7 8#include "base/basictypes.h" 9#include "remoting/proto/video.pb.h" 10 11namespace webrtc { 12class DesktopRect; 13class DesktopRegion; 14class DesktopSize; 15} // namespace webrtc 16 17namespace remoting { 18 19// Interface for a decoder that takes a stream of bytes from the network and 20// outputs frames of data. 21class VideoDecoder { 22 public: 23 static const int kBytesPerPixel = 4; 24 25 VideoDecoder() {} 26 virtual ~VideoDecoder() {} 27 28 // Initializes the decoder and sets the output dimensions. 29 // |screen size| must not be empty. 30 virtual void Initialize(const webrtc::DesktopSize& screen_size) = 0; 31 32 // Feeds more data into the decoder. Returns true if |packet| was processed 33 // and the frame can be displayed now. 34 virtual bool DecodePacket(const VideoPacket& packet) = 0; 35 36 // Marks the specified |region| of the view for update the next time 37 // RenderFrame() is called. |region| is expressed in |view_size| coordinates. 38 // |view_size| must not be empty. 39 virtual void Invalidate(const webrtc::DesktopSize& view_size, 40 const webrtc::DesktopRegion& region) = 0; 41 42 // Copies invalidated pixels within |clip_area| to |image_buffer|. Pixels are 43 // invalidated either by new data received in DecodePacket(), or by explicit 44 // calls to Invalidate(). |clip_area| is specified in |view_size| coordinates. 45 // If |view_size| differs from the source size then the copied pixels will be 46 // scaled accordingly. |view_size| cannot be empty. 47 // 48 // |image_buffer|'s origin must correspond to the top-left of |clip_area|, 49 // and the buffer must be large enough to hold |clip_area| RGBA32 pixels. 50 // |image_stride| gives the output buffer's stride in pixels. 51 // 52 // On return, |output_region| contains the updated area, in |view_size| 53 // coordinates. 54 virtual void RenderFrame(const webrtc::DesktopSize& view_size, 55 const webrtc::DesktopRect& clip_area, 56 uint8* image_buffer, 57 int image_stride, 58 webrtc::DesktopRegion* output_region) = 0; 59 60 // Returns the "shape", if any, of the most recently rendered frame. 61 // The shape is returned in source dimensions. 62 virtual const webrtc::DesktopRegion* GetImageShape() = 0; 63}; 64 65} // namespace remoting 66 67#endif // REMOTING_CODEC_VIDEO_DECODER_H_ 68