| OLD | NEW |
| 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_ENCODER_H_ | 5 #ifndef REMOTING_BASE_ENCODER_H_ |
| 6 #define REMOTING_BASE_ENCODER_H_ | 6 #define REMOTING_BASE_ENCODER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "media/base/data_buffer.h" | 10 #include "media/base/data_buffer.h" |
| 11 // TODO(hclam): Should not depend on internal.pb.h. | 11 // TODO(hclam): Should not depend on internal.pb.h. |
| 12 #include "remoting/proto/internal.pb.h" | 12 #include "remoting/proto/internal.pb.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 class DataBuffer; | 15 class DataBuffer; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace remoting { | 18 namespace remoting { |
| 19 | 19 |
| 20 class CaptureData; | 20 class CaptureData; |
| 21 | 21 |
| 22 // A class to perform the task of encoding a continous stream of | 22 // A class to perform the task of encoding a continous stream of |
| 23 // images. | 23 // images. |
| 24 // This class operates asynchronously to enable maximum throughput. | 24 // This class operates asynchronously to enable maximum throughput. |
| 25 class Encoder { | 25 class Encoder { |
| 26 public: | 26 public: |
| 27 | 27 |
| 28 // EncodingState is a bitfield that tracks the state of the encoding. | |
| 29 // An encoding that consists of a single block could concievably be starting | |
| 30 // inprogress and ended at the same time. | |
| 31 enum { | |
| 32 EncodingStarting = 1 << 0, | |
| 33 EncodingInProgress = 1 << 1, | |
| 34 EncodingEnded = 1 << 2 | |
| 35 }; | |
| 36 typedef int EncodingState; | |
| 37 | |
| 38 // DataAvailableCallback is called as blocks of data are made available | 28 // DataAvailableCallback is called as blocks of data are made available |
| 39 // from the encoder. Data made available by the encoder is in the form | 29 // from the encoder. Data made available by the encoder is in the form |
| 40 // of HostMessage to reduce the amount of memory copies. | 30 // of HostMessage to reduce the amount of memory copies. |
| 41 // The callback takes ownership of the HostMessage and is responsible for | 31 // The callback takes ownership of the HostMessage and is responsible for |
| 42 // deleting it. | 32 // deleting it. |
| 43 typedef Callback2<ChromotingHostMessage*, | 33 typedef Callback1<VideoPacket*>::Type DataAvailableCallback; |
| 44 EncodingState>::Type DataAvailableCallback; | |
| 45 | 34 |
| 46 virtual ~Encoder() {} | 35 virtual ~Encoder() {} |
| 47 | 36 |
| 48 // Encode an image stored in |capture_data|. | 37 // Encode an image stored in |capture_data|. |
| 49 // | 38 // |
| 50 // If |key_frame| is true, the encoder should not reference | 39 // If |key_frame| is true, the encoder should not reference |
| 51 // previous encode and encode the full frame. | 40 // previous encode and encode the full frame. |
| 52 // | 41 // |
| 53 // When encoded data is available, partial or full |data_available_callback| | 42 // When encoded data is available, partial or full |data_available_callback| |
| 54 // is called. | 43 // is called. |
| 55 virtual void Encode(scoped_refptr<CaptureData> capture_data, | 44 virtual void Encode(scoped_refptr<CaptureData> capture_data, |
| 56 bool key_frame, | 45 bool key_frame, |
| 57 DataAvailableCallback* data_available_callback) = 0; | 46 DataAvailableCallback* data_available_callback) = 0; |
| 58 }; | 47 }; |
| 59 | 48 |
| 60 } // namespace remoting | 49 } // namespace remoting |
| 61 | 50 |
| 62 #endif // REMOTING_BASE_ENCODER_H_ | 51 #endif // REMOTING_BASE_ENCODER_H_ |
| OLD | NEW |