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