blob: 1a7935de19a20b5c0969f72c452ff4ee3dd6ebe2 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
DRCb4a83232011-08-19 04:57:18 +00002 * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00003 *
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>
DRCb4a83232011-08-19 04:57:18 +000024#include <rfb/JpegCompressor.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000025
26namespace rfb {
27 class SMsgWriter;
28 class Encoder;
Pierre Ossman456b2c22014-01-15 13:22:03 +010029 class TransImageGetter;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000030 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) {};
DRCb4a83232011-08-19 04:57:18 +000038 virtual void setFineQualityLevel(int quality, JPEG_SUBSAMP subsampling) {};
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000039 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.
DRCffe09d62011-08-17 02:27:59 +000044 virtual bool writeRect(const Rect& r, TransImageGetter* ig,
45 Rect* actual)=0;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000046
Peter Åstrand98fe98c2010-02-10 07:43:02 +000047 static bool supported(int encoding);
48 static Encoder* createEncoder(int encoding, SMsgWriter* writer);
49 static void registerEncoder(int encoding,
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000050 EncoderCreateFnType createFn);
Peter Åstrand98fe98c2010-02-10 07:43:02 +000051 static void unregisterEncoder(int encoding);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000052 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