OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef REMOTING_BASE_DECODER_H_ | 5 #ifndef REMOTING_BASE_DECODER_H_ |
6 #define REMOTING_BASE_DECODER_H_ | 6 #define REMOTING_BASE_DECODER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "media/base/video_frame.h" | |
10 #include "remoting/proto/video.pb.h" | 10 #include "remoting/proto/video.pb.h" |
11 #include "third_party/skia/include/core/SkRect.h" | |
11 #include "third_party/skia/include/core/SkRegion.h" | 12 #include "third_party/skia/include/core/SkRegion.h" |
13 #include "third_party/skia/include/core/SkSize.h" | |
12 | 14 |
13 namespace remoting { | 15 namespace remoting { |
14 | 16 |
15 // Interface for a decoder that takes a stream of bytes from the network and | 17 // Interface for a decoder that takes a stream of bytes from the network and |
16 // outputs frames of data. | 18 // outputs frames of data. |
17 // | 19 // |
18 // TODO(ajwong): Beef up this documentation once the API stablizes. | 20 // TODO(ajwong): Beef up this documentation once the API stablizes. |
19 class Decoder { | 21 class Decoder { |
20 public: | 22 public: |
21 // DecodeResult is returned from DecodePacket() and indicates current state | 23 // DecodeResult is returned from DecodePacket() and indicates current state |
22 // of the decoder. DECODE_DONE means that last packet for the frame was | 24 // of the decoder. DECODE_DONE means that last packet for the frame was |
23 // processed, and the frame can be displayed now. DECODE_IN_PROGRESS | 25 // processed, and the frame can be displayed now. DECODE_IN_PROGRESS |
24 // indicates that the decoder must receive more data before the frame can be | 26 // indicates that the decoder must receive more data before the frame can be |
25 // displayed. DECODE_ERROR is returned if there was an error in the stream. | 27 // displayed. DECODE_ERROR is returned if there was an error in the stream. |
26 enum DecodeResult { | 28 enum DecodeResult { |
27 DECODE_ERROR = -1, | 29 DECODE_ERROR = -1, |
28 DECODE_IN_PROGRESS, | 30 DECODE_IN_PROGRESS, |
29 DECODE_DONE, | 31 DECODE_DONE, |
30 }; | 32 }; |
31 | 33 |
32 Decoder() {} | 34 Decoder() {} |
33 virtual ~Decoder() {} | 35 virtual ~Decoder() {} |
34 | 36 |
35 // Initializes the decoder to draw into the given |frame|. | 37 // Initializes the decoder and sets the output dimensions for the decoder. |
Wez
2012/02/07 01:56:31
nit: no need for "for the decoder".
alexeypa (please no reviews)
2012/02/15 23:06:22
Done.
| |
36 virtual void Initialize(scoped_refptr<media::VideoFrame> frame) = 0; | 38 virtual void Initialize(const SkISize& screen_size) = 0; |
Wez
2012/02/07 01:56:31
Why do you need |screen_size| here?
alexeypa (please no reviews)
2012/02/15 23:06:22
For scaling. It is passed this way because Rectang
| |
37 | 39 |
38 // Feeds more data into the decoder. | 40 // Feeds more data into the decoder. |
39 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; | 41 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; |
40 | 42 |
41 // Returns the region affected by the most recent frame. Can be called only | 43 // Reset the decoder to an uninitialized state. Initialize() must be called |
42 // after DecodePacket returned DECODE_DONE. Caller keeps ownership of | 44 // before the decoder is used again. |
43 // |region|. | |
44 virtual void GetUpdatedRegion(SkRegion* region) = 0; | |
45 | |
46 // Reset the decoder to an uninitialized state. Release all references to | |
47 // the initialized |frame|. Initialize() must be called before the decoder | |
48 // is used again. | |
49 virtual void Reset() = 0; | 45 virtual void Reset() = 0; |
50 | 46 |
51 // Returns true if decoder is ready to accept data via DecodePacket. | 47 // Returns true if decoder is ready to accept data via DecodePacket. |
52 virtual bool IsReadyForData() = 0; | 48 virtual bool IsReadyForData() = 0; |
53 | 49 |
54 virtual VideoPacketFormat::Encoding Encoding() = 0; | 50 virtual VideoPacketFormat::Encoding Encoding() = 0; |
55 | 51 |
56 // Set the output dimensions for the decoder. If the dimensions are empty | |
57 // then the source is rendered without scaling. | |
58 // Output dimensions are ignored if the decoder doesn't support scaling. | |
59 virtual void SetOutputSize(const SkISize& size) {} | |
60 | |
61 // Set the clipping rectangle to the decoder. Decoder should respect this and | |
62 // only output changes in this rectangle. The new clipping rectangle will be | |
63 // effective on the next decoded video frame. | |
64 virtual void SetClipRect(const SkIRect& clip_rect) {} | |
65 | |
66 // Force decoder to output a frame based on the specified |region| of the | 52 // Force decoder to output a frame based on the specified |region| of the |
67 // most recently decoded video frame. |region| is expressed in video frame | 53 // most recently decoded video frame. |region| is expressed in video frame |
68 // rather than output coordinates. | 54 // rather than output coordinates. |
69 virtual void RefreshRegion(const SkRegion& region) {} | 55 virtual void UpdateRegion(const SkRegion& region) = 0; |
Wez
2012/02/07 01:56:31
This should be called ForceUpdate(), Invalidate(),
alexeypa (please no reviews)
2012/02/15 23:06:22
It is Invalidate() now.
| |
56 | |
57 // Outputs pixels within |region| of the video frame to |image_buffer| | |
58 // performing necessary conversion and scaling. | |
Wez
2012/02/07 01:56:31
The routine actually refreshes the portions of the
alexeypa (please no reviews)
2012/02/15 23:06:22
Both.
| |
59 // | |
60 // The routine produces |output_region| to indicate the updated areas of | |
Wez
2012/02/07 01:56:31
produces ... -> sets ...
alexeypa (please no reviews)
2012/02/15 23:06:22
Done.
| |
61 // |image_buffer|. |output_region| is in output buffer coordinates. | |
62 // | |
63 // |image_buffer| is assumed to be large enough to hold entire |clip_area| | |
64 // (RGBA32). The top left corner of the buffer corresponds to the top left | |
Wez
2012/02/07 01:56:31
What coordinate scheme does |clip_area| apply to?
alexeypa (please no reviews)
2012/02/15 23:06:22
Consumer's. Done.
| |
65 // corner of |clip_area|. |image_stride| specifies the size of a single row | |
66 // of the buffer in bytes. | |
67 virtual void Draw(const SkISize& view_size, | |
Wez
2012/02/07 01:56:31
I think it's cleaner to set the output size explic
alexeypa (please no reviews)
2012/02/15 23:06:22
This call does not set the output size. |view_size
| |
68 const SkIRect& clip_area, | |
69 uint8* image_buffer, | |
70 int image_stride, | |
71 SkRegion* output_region) = 0; | |
Wez
2012/02/07 01:56:31
Consider renaming this RefreshFrame(), UpdateFrame
alexeypa (please no reviews)
2012/02/15 23:06:22
RenderFrame(). Done.
| |
70 }; | 72 }; |
71 | 73 |
72 } // namespace remoting | 74 } // namespace remoting |
73 | 75 |
74 #endif // REMOTING_BASE_DECODER_H_ | 76 #endif // REMOTING_BASE_DECODER_H_ |
OLD | NEW |