Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
DRC | b4a8323 | 2011-08-19 04:57:18 +0000 | [diff] [blame] | 2 | * Copyright (C) 2011 D. R. Commander. All Rights Reserved. |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
| 19 | #ifndef __RFB_ENCODER_H__ |
| 20 | #define __RFB_ENCODER_H__ |
| 21 | |
| 22 | #include <rfb/Rect.h> |
| 23 | #include <rfb/encodings.h> |
DRC | b4a8323 | 2011-08-19 04:57:18 +0000 | [diff] [blame] | 24 | #include <rfb/JpegCompressor.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 25 | |
| 26 | namespace rfb { |
| 27 | class SMsgWriter; |
| 28 | class Encoder; |
Pierre Ossman | 456b2c2 | 2014-01-15 13:22:03 +0100 | [diff] [blame^] | 29 | class TransImageGetter; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 30 | typedef Encoder* (*EncoderCreateFnType)(SMsgWriter*); |
| 31 | |
| 32 | class Encoder { |
| 33 | public: |
| 34 | virtual ~Encoder(); |
| 35 | |
| 36 | virtual void setCompressLevel(int level) {}; |
| 37 | virtual void setQualityLevel(int level) {}; |
DRC | b4a8323 | 2011-08-19 04:57:18 +0000 | [diff] [blame] | 38 | virtual void setFineQualityLevel(int quality, JPEG_SUBSAMP subsampling) {}; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 39 | virtual int getNumRects(const Rect &r) { return 1; } |
| 40 | |
| 41 | // writeRect() tries to write the given rectangle. If it is unable to |
| 42 | // write the whole rectangle it returns false and sets actual to the actual |
| 43 | // rectangle which was updated. |
DRC | ffe09d6 | 2011-08-17 02:27:59 +0000 | [diff] [blame] | 44 | virtual bool writeRect(const Rect& r, TransImageGetter* ig, |
| 45 | Rect* actual)=0; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 46 | |
Peter Åstrand | 98fe98c | 2010-02-10 07:43:02 +0000 | [diff] [blame] | 47 | static bool supported(int encoding); |
| 48 | static Encoder* createEncoder(int encoding, SMsgWriter* writer); |
| 49 | static void registerEncoder(int encoding, |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 50 | EncoderCreateFnType createFn); |
Peter Åstrand | 98fe98c | 2010-02-10 07:43:02 +0000 | [diff] [blame] | 51 | static void unregisterEncoder(int encoding); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 52 | private: |
| 53 | static EncoderCreateFnType createFns[encodingMax+1]; |
| 54 | }; |
| 55 | |
| 56 | class EncoderInit { |
| 57 | static int count; |
| 58 | public: |
| 59 | EncoderInit(); |
| 60 | }; |
| 61 | |
| 62 | static EncoderInit encoderInitObj; |
| 63 | } |
| 64 | |
| 65 | #endif |