summaryrefslogtreecommitdiffstats
blob: 0a343bbf9219a6370d9e0677b3825620f31516bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright (c) 2012 Yoann Blein
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#pragma once

#include <Swiften/ScreenSharing/VideoEncoder.h>

#define VPX_CODEC_DISABLE_COMPAT 1 // Recomended
#include "vpx/vpx_encoder.h"


namespace Swift {
	class Image;
	class VP8RTPPacketizer;

	class VP8Encoder : public VideoEncoder {
		public:
			VP8Encoder(VP8RTPPacketizer* packetizer, unsigned int width, unsigned int height);
			virtual ~VP8Encoder();

			void updateCodecConfig();

			virtual void encodeImage(const Image& frame);

		private:
			bool convertRGB24toYV12inBuffer(const Image& frame);

		private:
			VP8RTPPacketizer* packetizer;
			vpx_codec_iface_t* codecInterface;
			vpx_codec_ctx_t codecContext;
			vpx_codec_enc_cfg_t codecConfig;
			vpx_image_t* imageBuffer;
			vpx_codec_flags_t codecFlags;
			vpx_enc_frame_flags_t frameFlags;
			int frameNumber;
	};

}