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.
5 #ifndef REMOTING_CODEC_VIDEO_DECODER_H_
6 #define REMOTING_CODEC_VIDEO_DECODER_H_
8 #include "base/basictypes.h"
9 #include "remoting/proto/video.pb.h"
10 #include "third_party/skia/include/core/SkRect.h"
11 #include "third_party/skia/include/core/SkRegion.h"
12 #include "third_party/skia/include/core/SkSize.h"
16 // Interface for a decoder that takes a stream of bytes from the network and
17 // outputs frames of data.
19 // TODO(ajwong): Beef up this documentation once the API stablizes.
22 // DecodeResult is returned from DecodePacket() and indicates current state
23 // of the decoder. DECODE_DONE means that last packet for the frame was
24 // processed, and the frame can be displayed now. DECODE_IN_PROGRESS
25 // indicates that the decoder must receive more data before the frame can be
26 // displayed. DECODE_ERROR is returned if there was an error in the stream.
34 virtual ~VideoDecoder() {}
36 // Initializes the decoder and sets the output dimensions.
37 // |screen size| must not be empty.
38 virtual void Initialize(const SkISize
& screen_size
) = 0;
40 // Feeds more data into the decoder.
41 virtual DecodeResult
DecodePacket(const VideoPacket
* packet
) = 0;
43 // Returns true if decoder is ready to accept data via DecodePacket.
44 virtual bool IsReadyForData() = 0;
46 virtual VideoPacketFormat::Encoding
Encoding() = 0;
48 // Marks the specified |region| of the view for update the next time
49 // RenderFrame() is called. |region| is expressed in |view_size| coordinates.
50 // |view_size| must not be empty.
51 virtual void Invalidate(const SkISize
& view_size
,
52 const SkRegion
& region
) = 0;
54 // Copies invalidated pixels within |clip_area| to |image_buffer|. Pixels are
55 // invalidated either by new data received in DecodePacket(), or by explicit
56 // calls to Invalidate(). |clip_area| is specified in |view_size| coordinates.
57 // If |view_size| differs from the source size then the copied pixels will be
58 // scaled accordingly. |view_size| cannot be empty.
60 // |image_buffer|'s origin must correspond to the top-left of |clip_area|,
61 // and the buffer must be large enough to hold |clip_area| RGBA32 pixels.
62 // |image_stride| gives the output buffer's stride in pixels.
64 // On return, |output_region| contains the updated area, in |view_size|
66 virtual void RenderFrame(const SkISize
& view_size
,
67 const SkIRect
& clip_area
,
70 SkRegion
* output_region
) = 0;
72 // Returns the "shape", if any, of the most recently rendered frame.
73 // The shape is returned in source dimensions.
74 virtual const SkRegion
* GetImageShape() = 0;
77 } // namespace remoting
79 #endif // REMOTING_CODEC_VIDEO_DECODER_H_