Home | History | Annotate | Download | only in codec
      1 // Copyright (c) 2011 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.
      4 
      5 #ifndef REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_
      6 #define REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_
      7 
      8 #include "base/time/time.h"
      9 #include "remoting/codec/video_encoder.h"
     10 #include "remoting/proto/video.pb.h"
     11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
     12 
     13 namespace remoting {
     14 
     15 // VideoEncoderVerbatim implements a VideoEncoder that sends image data as a
     16 // sequence of RGB values, without compression.
     17 class VideoEncoderVerbatim : public VideoEncoder {
     18  public:
     19   VideoEncoderVerbatim();
     20   virtual ~VideoEncoderVerbatim();
     21 
     22   // Sets maximum size of data in video packets. Used by unittests.
     23   void SetMaxPacketSize(int size);
     24 
     25   // VideoEncoder interface.
     26   virtual void Encode(
     27       const webrtc::DesktopFrame* frame,
     28       const DataAvailableCallback& data_available_callback) OVERRIDE;
     29 
     30  private:
     31   // Encode a single dirty |rect|.
     32   void EncodeRect(const webrtc::DesktopFrame* frame,
     33                   const webrtc::DesktopRect& rect,
     34                   bool last);
     35 
     36   // Initializes first packet in a sequence of video packets to update screen
     37   // rectangle |rect|.
     38   void PrepareUpdateStart(const webrtc::DesktopFrame* frame,
     39                           const webrtc::DesktopRect& rect,
     40                           VideoPacket* packet);
     41 
     42   // Allocates a buffer of the specified |size| inside |packet| and returns the
     43   // pointer to it.
     44   uint8* GetOutputBuffer(VideoPacket* packet, size_t size);
     45 
     46   // Submit |packet| to |callback_|.
     47   void SubmitMessage(VideoPacket* packet, size_t rect_index);
     48 
     49   DataAvailableCallback callback_;
     50   base::Time encode_start_time_;
     51 
     52   // The most recent screen size.
     53   webrtc::DesktopSize screen_size_;
     54 
     55   int max_packet_size_;
     56 };
     57 
     58 }  // namespace remoting
     59 
     60 #endif  // REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_
     61