blob: da2c5c09fca263c911a9123e4e84dcf3567b24c5 [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>
DRCffe09d62011-08-17 02:27:59 +000024#include <rfb/TransImageGetter.h>
DRCb4a83232011-08-19 04:57:18 +000025#include <rfb/JpegCompressor.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000026
27namespace rfb {
28 class SMsgWriter;
29 class Encoder;
30 class ImageGetter;
31 typedef Encoder* (*EncoderCreateFnType)(SMsgWriter*);
32
33 class Encoder {
34 public:
35 virtual ~Encoder();
36
37 virtual void setCompressLevel(int level) {};
38 virtual void setQualityLevel(int level) {};
DRCb4a83232011-08-19 04:57:18 +000039 virtual void setFineQualityLevel(int quality, JPEG_SUBSAMP subsampling) {};
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000040 virtual int getNumRects(const Rect &r) { return 1; }
41
42 // writeRect() tries to write the given rectangle. If it is unable to
43 // write the whole rectangle it returns false and sets actual to the actual
44 // rectangle which was updated.
DRCffe09d62011-08-17 02:27:59 +000045 virtual bool writeRect(const Rect& r, TransImageGetter* ig,
46 Rect* actual)=0;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000047
Peter Åstrand98fe98c2010-02-10 07:43:02 +000048 static bool supported(int encoding);
49 static Encoder* createEncoder(int encoding, SMsgWriter* writer);
50 static void registerEncoder(int encoding,
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000051 EncoderCreateFnType createFn);
Peter Åstrand98fe98c2010-02-10 07:43:02 +000052 static void unregisterEncoder(int encoding);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000053 private:
54 static EncoderCreateFnType createFns[encodingMax+1];
55 };
56
57 class EncoderInit {
58 static int count;
59 public:
60 EncoderInit();
61 };
62
63 static EncoderInit encoderInitObj;
64}
65
66#endif