FFmpeg
Loading...
Searching...
No Matches
iterm2enc.c File Reference
#include <string.h>
#include "libavutil/base64.h"
#include "libavutil/macros.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "avformat.h"
#include "mux.h"

Go to the source code of this file.

Data Structures

struct  ITerm2Context
 

Macros

#define ESC   "\033"
 
#define SYNC_BEGIN   ESC "[?2026h"
 
#define SYNC_END   ESC "[?2026l"
 
#define CURSOR_SAVE   ESC "7"
 
#define CURSOR_RESTORE   ESC "8"
 
#define CURSOR_HOME   ESC "[H"
 
#define CURSOR_BOTTOM   ESC "[999H"
 
#define OSC_START   ESC "]1337;"
 
#define BEL   "\a"
 
#define ST   ESC "\\"
 
#define TMUX_DCS   ESC "Ptmux;"
 
#define FILEPART_CHUNK   ((1 << 20) - 4096)
 
#define WRITE_LITERAL(pb, str)
 
#define OFFSET(x)
 
#define ENC   AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static void osc_open (ITerm2Context *c, AVIOContext *pb)
 
static void osc_close (ITerm2Context *c, AVIOContext *pb)
 
static void write_image (ITerm2Context *c, AVIOContext *pb, int size)
 
static int iterm2_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static int iterm2_write_trailer (AVFormatContext *s)
 
static av_cold void iterm2_deinit (AVFormatContext *s)
 

Variables

static const AVOption options []
 
static const AVClass iterm2_class
 
const FFOutputFormat ff_iterm2_muxer
 

Macro Definition Documentation

◆ ESC

#define ESC   "\033"

Definition at line 32 of file iterm2enc.c.

Referenced by osc_open().

◆ SYNC_BEGIN

#define SYNC_BEGIN   ESC "[?2026h"

Definition at line 34 of file iterm2enc.c.

Referenced by iterm2_write_packet().

◆ SYNC_END

#define SYNC_END   ESC "[?2026l"

Definition at line 35 of file iterm2enc.c.

Referenced by iterm2_write_packet().

◆ CURSOR_SAVE

#define CURSOR_SAVE   ESC "7"

Definition at line 36 of file iterm2enc.c.

Referenced by iterm2_write_packet().

◆ CURSOR_RESTORE

#define CURSOR_RESTORE   ESC "8"

Definition at line 37 of file iterm2enc.c.

Referenced by iterm2_write_packet().

◆ CURSOR_HOME

#define CURSOR_HOME   ESC "[H"

Definition at line 38 of file iterm2enc.c.

Referenced by iterm2_write_packet().

◆ CURSOR_BOTTOM

#define CURSOR_BOTTOM   ESC "[999H"

Definition at line 39 of file iterm2enc.c.

Referenced by iterm2_write_trailer().

◆ OSC_START

#define OSC_START   ESC "]1337;"

Definition at line 41 of file iterm2enc.c.

Referenced by osc_open().

◆ BEL

#define BEL   "\a"

Definition at line 42 of file iterm2enc.c.

Referenced by osc_close().

◆ ST

#define ST   ESC "\\"

Definition at line 43 of file iterm2enc.c.

Referenced by get_tlm(), and osc_close().

◆ TMUX_DCS

#define TMUX_DCS   ESC "Ptmux;"

Definition at line 46 of file iterm2enc.c.

Referenced by osc_open().

◆ FILEPART_CHUNK

#define FILEPART_CHUNK   ((1 << 20) - 4096)

Definition at line 52 of file iterm2enc.c.

Referenced by write_image().

◆ WRITE_LITERAL

#define WRITE_LITERAL ( pb,
str )
Value:
avio_write(pb, (const unsigned char *)(str), \
sizeof(str) - 1)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition aviobuf.c:206

Definition at line 54 of file iterm2enc.c.

Referenced by iterm2_write_packet(), iterm2_write_trailer(), osc_close(), osc_open(), and write_image().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 145 of file iterm2enc.c.

◆ ENC

#define ENC   AV_OPT_FLAG_ENCODING_PARAM

Definition at line 146 of file iterm2enc.c.

Function Documentation

◆ osc_open()

static void osc_open ( ITerm2Context * c,
AVIOContext * pb )
static

Definition at line 67 of file iterm2enc.c.

Referenced by write_image().

◆ osc_close()

static void osc_close ( ITerm2Context * c,
AVIOContext * pb )
static

Definition at line 74 of file iterm2enc.c.

Referenced by write_image().

◆ write_image()

static void write_image ( ITerm2Context * c,
AVIOContext * pb,
int size )
static

Definition at line 81 of file iterm2enc.c.

Referenced by iterm2_write_packet().

◆ iterm2_write_packet()

static int iterm2_write_packet ( AVFormatContext * s,
AVPacket * pkt )
static

Definition at line 110 of file iterm2enc.c.

◆ iterm2_write_trailer()

static int iterm2_write_trailer ( AVFormatContext * s)
static

Definition at line 132 of file iterm2enc.c.

◆ iterm2_deinit()

static av_cold void iterm2_deinit ( AVFormatContext * s)
static

Definition at line 139 of file iterm2enc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "display_width", "on-screen width (auto, N cells, Npx, N%%)",
OFFSET(display_width), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC },
{ "display_height", "on-screen height (auto, N cells, Npx, N%%)",
OFFSET(display_height), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC },
{ "keep_aspect", "preserve aspect ratio when scaling",
OFFSET(keep_aspect), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, ENC },
{ "tmux", "wrap image in tmux DCS passthrough, requires tmux set -g allow-passthrough on",
OFFSET(tmux), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
{ NULL },
}
#define ENC
Definition caca.c:198
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 148 of file iterm2enc.c.

◆ iterm2_class

const AVClass iterm2_class
static
Initial value:
= {
.class_name = "iTerm2 muxer",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
@ AV_CLASS_CATEGORY_MUXER
Definition log.h:32

Definition at line 160 of file iterm2enc.c.

◆ ff_iterm2_muxer

const FFOutputFormat ff_iterm2_muxer
Initial value:
= {
.p.name = "iterm2",
.p.long_name = NULL_IF_CONFIG_SMALL("iTerm2 inline image protocol"),
.priv_data_size = sizeof(ITerm2Context),
.p.audio_codec = AV_CODEC_ID_NONE,
.p.video_codec = AV_CODEC_ID_MJPEG,
.write_packet = iterm2_write_packet,
.write_trailer = iterm2_write_trailer,
.deinit = iterm2_deinit,
.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH,
.p.priv_class = &iterm2_class,
}
#define AVFMT_NODIMENSIONS
Format does not need width/height.
Definition avformat.h:502
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition avformat.h:498
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_MJPEG
Definition codec_id.h:57
static int iterm2_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition iterm2enc.c:110
static av_cold void iterm2_deinit(AVFormatContext *s)
Definition iterm2enc.c:139
static const AVClass iterm2_class
Definition iterm2enc.c:160
static int iterm2_write_trailer(AVFormatContext *s)
Definition iterm2enc.c:132
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
#define FF_OFMT_FLAG_MAX_ONE_OF_EACH
If this flag is set, it indicates that for each codec type whose corresponding default codec (i....
Definition mux.h:50

Definition at line 168 of file iterm2enc.c.