Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: remoting/base/decoder.h

Issue 4476003: Add VideoPacket struct for video packets. Refactor Decode interface to use it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/base/capture_data.cc ('k') | remoting/base/decoder_row_based.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <vector>
9
8 #include "base/task.h" 10 #include "base/task.h"
9 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
10 #include "gfx/rect.h" 12 #include "gfx/rect.h"
11 #include "media/base/video_frame.h" 13 #include "media/base/video_frame.h"
12 #include "remoting/proto/video.pb.h" 14 #include "remoting/proto/video.pb.h"
13 15
14 namespace remoting { 16 namespace remoting {
15 17
16 typedef std::vector<gfx::Rect> UpdatedRects; 18 typedef std::vector<gfx::Rect> UpdatedRects;
17 19
18 // Interface for a decoder that takes a stream of bytes from the network and 20 // Interface for a decoder that takes a stream of bytes from the network and
19 // outputs frames of data. 21 // outputs frames of data.
20 // 22 //
21 // TODO(ajwong): Beef up this documentation once the API stablizes. 23 // TODO(ajwong): Beef up this documentation once the API stablizes.
22 class Decoder { 24 class Decoder {
23 public: 25 public:
26 // DecodeResult is returned from DecodePacket() and indicates current state
27 // of the decoder. DECODE_DONE means that last packet for the frame was
28 // processed, and the frame can be displayed now. DECODE_IN_PROGRESS
29 // indicates that the decoder must receive more data before the frame can be
30 // displayed. DECODE_ERROR is returned if there was an error in the stream.
31 enum DecodeResult {
32 DECODE_ERROR = -1,
33 DECODE_IN_PROGRESS,
34 DECODE_DONE,
35 };
36
24 Decoder() {} 37 Decoder() {}
25 virtual ~Decoder() {} 38 virtual ~Decoder() {}
26 39
27 // TODO(ajwong): This API is incorrect in the face of a streaming decode
28 // protocol like VP8. However, it breaks the layering abstraction by
29 // depending on the network packet protocol buffer type. I'm going to go
30 // forward with it as is, and then refactor again to support streaming
31 // decodes.
32
33 // Initializes the decoder to draw into the given |frame|. The |clip| 40 // Initializes the decoder to draw into the given |frame|. The |clip|
34 // specifies the region to draw into. The clip region must fit inside 41 // specifies the region to draw into. The clip region must fit inside
35 // the dimensions of frame. Failure to do so will CHECK Fail. 42 // the dimensions of frame. Failure to do so will CHECK fail.
36 // 43 virtual void Initialize(scoped_refptr<media::VideoFrame> frame) = 0;
37 // TODO(ajwong): Should this take the source pixel format? 44
38 // TODO(ajwong): Should the protocol be split into basic-types followed 45 // Feeds more data into the decoder.
39 // by packet types? Basic types might include the format enum below. 46 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0;
40 virtual void Initialize(scoped_refptr<media::VideoFrame> frame, 47
41 const gfx::Rect& clip, int bytes_per_src_pixel) = 0; 48 // Returns rects that were updated in the last frame. Can be called only
49 // after DecodePacket returned DECODE_DONE. Caller keeps ownership of
50 // |rects|. |rects| is kept empty if whole screen needs to be updated.
51 virtual void GetUpdatedRects(UpdatedRects* rects) = 0;
42 52
43 // Reset the decoder to an uninitialized state. Release all references to 53 // Reset the decoder to an uninitialized state. Release all references to
44 // the initialized |frame|. Initialize() must be called before the decoder 54 // the initialized |frame|. Initialize() must be called before the decoder
45 // is used again. 55 // is used again.
46 virtual void Reset() = 0; 56 virtual void Reset() = 0;
47 57
48 // Feeds more data into the decoder. 58 // Returns true if decoder is ready to accept data via DecodePacket.
49 virtual void DecodeBytes(const std::string& encoded_bytes) = 0;
50
51 // Returns true if decoder is ready to accept data via ProcessRectangleData.
52 virtual bool IsReadyForData() = 0; 59 virtual bool IsReadyForData() = 0;
53 60
54 virtual VideoPacketFormat::Encoding Encoding() = 0; 61 virtual VideoPacketFormat::Encoding Encoding() = 0;
55 }; 62 };
56 63
57 } // namespace remoting 64 } // namespace remoting
58 65
59 #endif // REMOTING_BASE_DECODER_H_ 66 #endif // REMOTING_BASE_DECODER_H_
OLDNEW
« no previous file with comments | « remoting/base/capture_data.cc ('k') | remoting/base/decoder_row_based.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698