Skip to content

Commit 389c708

Browse files
committed
libvncserver: add h264 support
1 parent 3c51569 commit 389c708

File tree

5 files changed

+1241
-3
lines changed

5 files changed

+1241
-3
lines changed

include/rfb/rfb.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ typedef UINT32 in_addr_t;
6666

6767
#include <rfb/threading.h>
6868

69+
#ifdef LIBVNCSERVER_HAVE_LIBAVCODEC
70+
struct AVCodecContext;
71+
struct AVFrame;
72+
struct AVPacket;
73+
#ifdef LIBVNCSERVER_HAVE_LIBSWSCALE
74+
struct SwsContext;
75+
#endif
76+
struct rfbH264EncoderContext;
77+
#endif
78+
6979
/* if you use pthreads, but don't define LIBVNCSERVER_HAVE_LIBPTHREAD, the structs
7080
get all mixed up. So this gives a linker error reminding you to compile
7181
the library and your application (at least the parts including rfb.h)
@@ -582,6 +592,15 @@ typedef struct _rfbClientRec {
582592
int rawBytesEquivalent;
583593
int bytesSent;
584594

595+
#ifdef LIBVNCSERVER_HAVE_LIBAVCODEC
596+
struct rfbH264EncoderContext *h264ContextsHead;
597+
struct rfbH264EncoderContext *h264ContextsTail;
598+
unsigned int h264ContextCount;
599+
rfbBool h264ForceKeyframe;
600+
rfbBool h264NeedsResetAll;
601+
int64_t h264BitRate;
602+
#endif
603+
585604
#ifdef LIBVNCSERVER_HAVE_LIBZ
586605
/* zlib encoding -- necessary compression state info per client */
587606

@@ -824,6 +843,12 @@ extern void rfbClientConnFailed(rfbClientPtr cl, const char *reason);
824843
extern void rfbNewUDPConnection(rfbScreenInfoPtr rfbScreen,rfbSocket sock);
825844
extern void rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen);
826845
extern rfbBool rfbSendFramebufferUpdate(rfbClientPtr cl, sraRegionPtr updateRegion);
846+
#ifdef LIBVNCSERVER_HAVE_LIBAVCODEC
847+
extern rfbBool rfbSendRectEncodingH264(rfbClientPtr cl, int x, int y, int w, int h);
848+
extern void rfbClientH264SetBitrate(rfbClientPtr cl, int64_t bitRate);
849+
void rfbClientH264ReleaseEncoder(rfbClientPtr cl);
850+
#endif
851+
827852
extern rfbBool rfbSendRectEncodingRaw(rfbClientPtr cl, int x,int y,int w,int h);
828853
extern rfbBool rfbSendUpdateBuf(rfbClientPtr cl);
829854
extern void rfbSendServerCutText(rfbScreenInfoPtr rfbScreen,char *str, int len);

include/rfb/rfbproto.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ typedef struct {
460460
#define rfbEncodingZRLE 16
461461
#define rfbEncodingZYWRLE 17
462462

463-
#define rfbEncodingH264 0x48323634
463+
#define rfbEncodingH264 50
464464

465465
/* Cache & XOR-Zlib - rdv@2002 */
466466
#define rfbEncodingCache 0xFFFF0000
@@ -891,6 +891,23 @@ typedef struct {
891891

892892
#endif
893893

894+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
895+
* h264 - h264 encoding. We have an rfbH264Header structure giving the number
896+
* of bytes following and control flags. Finally the data that follows is an
897+
* H.264 encoded frame stream for the rectangle.
898+
*/
899+
900+
typedef struct {
901+
uint32_t length;
902+
uint32_t flags;
903+
} rfbH264Header;
904+
905+
#define sz_rfbH264Header 8
906+
907+
#define rfbH264FlagNone 0u
908+
#define rfbH264FlagResetContext 1u /* reset the decoder for the matching rectangle */
909+
#define rfbH264FlagResetAllContexts 2u /* drop all cached H.264 decoder contexts */
910+
894911
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
895912
* XCursor encoding. This is a special encoding used to transmit X-style
896913
* cursor shapes from server to clients. Note that for this encoding,

0 commit comments

Comments
 (0)