ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
mirror_h265_encoder.c File Reference

Go to the source code of this file.

Functions

asciichat_error_t h265_encode (h265_encoder_t *, uint16_t, uint16_t, const uint8_t *, uint8_t *, size_t *)
void h265_encoder_destroy (h265_encoder_t *)
asciichat_error_t h265_encoder_flush (h265_encoder_t *, uint8_t *, size_t *output_size)
void h265_encoder_request_keyframe (h265_encoder_t *)

Function Documentation

◆ h265_encode()

asciichat_error_t h265_encode ( h265_encoder_t * encoder,
uint16_t width,
uint16_t height,
const uint8_t * ascii_data,
uint8_t * output_buf,
size_t * output_size )

Encode an RGB24 upload frame

The encoder automatically detects size changes and reinitializes when needed. The output packet includes frame dimensions so decoder can reconfigure.

Parameters
encoderEncoder handle
widthCurrent frame width in pixels
heightCurrent frame height in pixels
ascii_dataRGB24 pixel data (width × height × 3 bytes)
output_bufBuffer for encoded output
output_sizeInput: buffer size, Output: actual encoded size
Returns
Error code (ASCIICHAT_OK on success)

OUTPUT PACKET FORMAT: [flags: u8][width: u16][height: u16][x265_data...]

Definition at line 3 of file mirror_h265_encoder.c.

3 {
4 return SET_ERRNO(ERROR_NOT_SUPPORTED, "H.265 encoding unavailable in the browser mirror");
5}
#define SET_ERRNO(code,...)
@ ERROR_NOT_SUPPORTED
Definition error_codes.h:74

References ERROR_NOT_SUPPORTED, and SET_ERRNO.

◆ h265_encoder_destroy()

void h265_encoder_destroy ( h265_encoder_t * encoder)

Destroy an x265 encoder

Parameters
encoderEncoder to destroy (may be NULL)

Definition at line 7 of file mirror_h265_encoder.c.

7{}

◆ h265_encoder_flush()

asciichat_error_t h265_encoder_flush ( h265_encoder_t * encoder,
uint8_t * output_buf,
size_t * output_size )

Flush remaining buffered frames from encoder

Sends a NULL frame to the encoder to flush all buffered frames. This should be called before destroying the encoder or when you need to ensure all encoded data is retrieved.

Parameters
encoderEncoder handle
output_bufBuffer for encoded output
output_sizeInput: buffer size, Output: actual encoded size
Returns
Error code (ASCIICHAT_OK on success, ASCIICHAT_OK with size=0 when no more data)

USAGE: // After final h265_encode() call, flush remaining frames while (size > 0) { size = max_size; h265_encoder_flush(encoder, buf, &size); if (size > 0) { // Send the flushed frame... } }

Definition at line 9 of file mirror_h265_encoder.c.

9 {
10 if (!output_size) {
11 return SET_ERRNO(ERROR_INVALID_PARAM, "H.265 encoder flush requires an output size");
12 }
13 *output_size = 0;
14 return ASCIICHAT_OK;
15}
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_INVALID_PARAM

References ASCIICHAT_OK, ERROR_INVALID_PARAM, and SET_ERRNO.

◆ h265_encoder_request_keyframe()

void h265_encoder_request_keyframe ( h265_encoder_t * encoder)

Request a keyframe on the next encode

Forces the encoder to produce an I-frame (keyframe) on the next call to h265_encoder_encode(). Useful for error recovery or stream synchronization.

Parameters
encoderEncoder handle

Definition at line 17 of file mirror_h265_encoder.c.

17{}