FFmpeg
Loading...
Searching...
No Matches
ffplay_list.c File Reference
#include "config.h"
#include <limits.h>
#include <string.h>
#include "libavutil/avstring.h"
#include "libavutil/avutil.h"
#include "libavutil/bprint.h"
#include "libavutil/common.h"
#include "libavutil/error.h"
#include "libavutil/log.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/qsort.h"
#include "libavutil/time.h"
#include "ffplay_list.h"

Go to the source code of this file.

Data Structures

struct  ListSortKey
 
struct  ListHit
 
struct  ListCacheEntry
 
struct  ListStrip
 
struct  ListView
 
struct  ListLayout
 

Macros

#define LIST_FADE_TIME   250000
 
#define LIST_HOLD_TIME   500000
 
#define LIST_ROWS   7
 
#define CMP(a, b)
 
#define LIST_EVENT   "Dialogue: 0:00:00.00,9999:00:00.00,"
 
#define PANEL_COLOR   0xBF000000
 
#define HOVER_COLOR   0xCD444444
 
#define POPUP_COLOR   0xDF000000
 

Enumerations

enum  {
  LIST_SORT_NUMBER , LIST_SORT_ARTIST , LIST_SORT_TITLE , LIST_SORT_LENGTH ,
  LIST_SORT_SHUFFLE , LIST_SORT_NB
}
 

Functions

static double list_alpha (const ListView *lv, int64_t now)
 
static int compare_tags (const char *a, const char *b)
 
static uint32_t shuffle_rank (const ListView *lv, int index)
 
static int compare_rows (const ListView *lv, const int *a, const int *b)
 
static void list_sort_by (ListView *lv, int key, int seed_step)
 
static void list_update_rows (ListView *lv)
 
static void bprint_box (AVBPrint *script, const char *style, int x, int y, int w, int h)
 
static void bprint_cell (AVBPrint *script, const char *style, int x, int y, int right, int bottom, const char *text)
 
static ListLayout list_layout (const ListView *lv)
 
static ListHit list_hit (const ListLayout *l, int x, int y)
 
static void bprint_ring (AVBPrint *script, int cx, int cy, int r)
 
static void bprint_styles (AVBPrint *script, const ListLayout *l)
 
static void bprint_header_strip (const ListView *lv, AVBPrint *script, const ListLayout *l)
 
static void bprint_row_strip (const ListView *lv, AVBPrint *script, const ListLayout *l, int r)
 
static void cache_entry_free (ListCacheEntry **entry)
 
static void cache_make_room (ListView *lv, size_t bytes)
 
static int strip_render (ListView *lv, ListCacheEntry *entry)
 
static int cache_get (ListView *lv, const SDL_Rect *rect, uint32_t background, const AVBPrint *script, ListCacheEntry **entry)
 
static int strip_add (ListView *lv, ListStrip **strips, int *nb, SDL_Rect rect, uint32_t background, const AVBPrint *script)
 
static int list_strips (ListView *lv, const ListLayout *l, ListStrip **strips, int *nb)
 
static void list_discard (ListView *lv)
 
static int list_configure (ListView *lv, const ListLayout *l, const SDL_Rect *canvas)
 
static int list_render (ListView *lv)
 
static void list_select (ListView *lv, int row)
 
void list_view_text (ListView *lv, const char *text)
 Appends text typed while the list is pinned to the search, or erases its last character when text is NULL.
 
ListView * list_view_alloc (SDL_Renderer *renderer)
 
void list_view_free (ListView **plv)
 
int list_view_show (ListView *lv, const ListEntry *entries, int nb_entries, int selected)
 Replaces the entries and shows the list, fading it in.
 
void list_view_clear (ListView *lv)
 Removes the entries, which may be freed after this, and resets the sort and the search.
 
void list_view_pin (ListView *lv, int pinned)
 Keeps the list on screen and lets it take the keyboard and text input, or lets it fade out again.
 
int list_view_pinned (const ListView *lv)
 
int list_view_visible (const ListView *lv)
 
int list_view_selected (const ListView *lv)
 
void list_view_move (ListView *lv, int delta)
 Moves the selection by delta rows.
 
int list_view_key (ListView *lv, SDL_Keycode key)
 Handles a key while the list is pinned: escape unpins it, up/down move the selection, backspace erases from the search.
 
void list_view_clear_search (ListView *lv)
 Clears the search, listing all entries.
 
void list_view_hover (ListView *lv, int x, int y)
 Keeps the mouse position, in window coordinates, -1 when the mouse left the window.
 
int list_view_click (ListView *lv, int x, int y, int *chosen)
 Handles a left click at window coordinates: a click on an entry chooses it, a click on a column button sorts by it.
 
void list_view_set_size (ListView *lv, int width, int height)
 Sets the size of the window the list is drawn into.
 
void list_view_set_playing (ListView *lv, int entry)
 Marks the entry as playing, -1 for none.
 
int list_view_update (ListView *lv)
 Brings the list up to date for the next frame, once the pending input is handled.
 
void list_view_draw (ListView *lv)
 Draws the list onto the window, between its other content and the present.
 

Variables

struct { 
 
   const char *   label 
 
   int   width 
 
} sort_buttons [LIST_SORT_NB] 
 

Macro Definition Documentation

◆ LIST_FADE_TIME

#define LIST_FADE_TIME   250000

Definition at line 41 of file ffplay_list.c.

Referenced by list_alpha(), and list_select().

◆ LIST_HOLD_TIME

#define LIST_HOLD_TIME   500000

Definition at line 42 of file ffplay_list.c.

Referenced by list_alpha(), and list_view_pin().

◆ LIST_ROWS

#define LIST_ROWS   7

Definition at line 43 of file ffplay_list.c.

Referenced by list_layout().

◆ CMP

#define CMP ( a,
b )
Value:
static int compare_rows(const ListView *lv, const int *a, const int *b)
int a
#define b
Definition input.c:43

Referenced by list_update_rows(), and load_rgb_float32_frame().

◆ LIST_EVENT

#define LIST_EVENT   "Dialogue: 0:00:00.00,9999:00:00.00,"

◆ PANEL_COLOR

#define PANEL_COLOR   0xBF000000

Definition at line 327 of file ffplay_list.c.

Referenced by list_strips().

◆ HOVER_COLOR

#define HOVER_COLOR   0xCD444444

Definition at line 328 of file ffplay_list.c.

Referenced by list_strips().

◆ POPUP_COLOR

#define POPUP_COLOR   0xDF000000

Definition at line 329 of file ffplay_list.c.

Referenced by list_strips().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LIST_SORT_NUMBER 
LIST_SORT_ARTIST 
LIST_SORT_TITLE 
LIST_SORT_LENGTH 
LIST_SORT_SHUFFLE 
LIST_SORT_NB 

Definition at line 45 of file ffplay_list.c.

Function Documentation

◆ list_alpha()

static double list_alpha ( const ListView * lv,
int64_t now )
static

Definition at line 128 of file ffplay_list.c.

Referenced by list_select(), list_view_draw(), list_view_update(), and list_view_visible().

◆ compare_tags()

static int compare_tags ( const char * a,
const char * b )
static

Definition at line 140 of file ffplay_list.c.

Referenced by compare_rows().

◆ shuffle_rank()

static uint32_t shuffle_rank ( const ListView * lv,
int index )
static

Definition at line 148 of file ffplay_list.c.

Referenced by compare_rows().

◆ compare_rows()

static int compare_rows ( const ListView * lv,
const int * a,
const int * b )
static

Definition at line 157 of file ffplay_list.c.

◆ list_sort_by()

static void list_sort_by ( ListView * lv,
int key,
int seed_step )
static

Definition at line 179 of file ffplay_list.c.

Referenced by list_view_click().

◆ list_update_rows()

static void list_update_rows ( ListView * lv)
static

◆ bprint_box()

static void bprint_box ( AVBPrint * script,
const char * style,
int x,
int y,
int w,
int h )
static

Definition at line 227 of file ffplay_list.c.

Referenced by bprint_header_strip(), and bprint_row_strip().

◆ bprint_cell()

static void bprint_cell ( AVBPrint * script,
const char * style,
int x,
int y,
int right,
int bottom,
const char * text )
static

Definition at line 233 of file ffplay_list.c.

Referenced by bprint_header_strip(), bprint_row_strip(), and list_strips().

◆ list_layout()

static ListLayout list_layout ( const ListView * lv)
static

Definition at line 248 of file ffplay_list.c.

Referenced by list_render(), list_view_click(), and list_view_hover().

◆ list_hit()

static ListHit list_hit ( const ListLayout * l,
int x,
int y )
static

Definition at line 293 of file ffplay_list.c.

Referenced by list_render(), list_view_click(), and list_view_hover().

◆ bprint_ring()

static void bprint_ring ( AVBPrint * script,
int cx,
int cy,
int r )
static

Definition at line 316 of file ffplay_list.c.

Referenced by bprint_row_strip().

◆ bprint_styles()

static void bprint_styles ( AVBPrint * script,
const ListLayout * l )
static

Definition at line 331 of file ffplay_list.c.

Referenced by list_configure().

◆ bprint_header_strip()

static void bprint_header_strip ( const ListView * lv,
AVBPrint * script,
const ListLayout * l )
static

Definition at line 353 of file ffplay_list.c.

Referenced by list_strips().

◆ bprint_row_strip()

static void bprint_row_strip ( const ListView * lv,
AVBPrint * script,
const ListLayout * l,
int r )
static

Definition at line 374 of file ffplay_list.c.

Referenced by list_strips().

◆ cache_entry_free()

static void cache_entry_free ( ListCacheEntry ** entry)
static

Definition at line 399 of file ffplay_list.c.

Referenced by cache_get(), cache_make_room(), and list_discard().

◆ cache_make_room()

static void cache_make_room ( ListView * lv,
size_t bytes )
static

Definition at line 409 of file ffplay_list.c.

Referenced by cache_get().

◆ strip_render()

static int strip_render ( ListView * lv,
ListCacheEntry * entry )
static

Definition at line 614 of file ffplay_list.c.

Referenced by cache_get().

◆ cache_get()

static int cache_get ( ListView * lv,
const SDL_Rect * rect,
uint32_t background,
const AVBPrint * script,
ListCacheEntry ** entry )
static

Definition at line 428 of file ffplay_list.c.

Referenced by strip_add().

◆ strip_add()

static int strip_add ( ListView * lv,
ListStrip ** strips,
int * nb,
SDL_Rect rect,
uint32_t background,
const AVBPrint * script )
static

Definition at line 458 of file ffplay_list.c.

Referenced by list_strips().

◆ list_strips()

static int list_strips ( ListView * lv,
const ListLayout * l,
ListStrip ** strips,
int * nb )
static

Definition at line 478 of file ffplay_list.c.

Referenced by list_render().

◆ list_discard()

static void list_discard ( ListView * lv)
static

◆ list_configure()

static int list_configure ( ListView * lv,
const ListLayout * l,
const SDL_Rect * canvas )
static

Definition at line 552 of file ffplay_list.c.

Referenced by list_render().

◆ list_render()

static int list_render ( ListView * lv)
static

Definition at line 648 of file ffplay_list.c.

Referenced by list_view_update().

◆ list_select()

static void list_select ( ListView * lv,
int row )
static

Definition at line 707 of file ffplay_list.c.

Referenced by list_view_click(), list_view_move(), and list_view_show().

◆ list_view_text()

void list_view_text ( ListView * lv,
const char * text )

Appends text typed while the list is pinned to the search, or erases its last character when text is NULL.

Definition at line 717 of file ffplay_list.c.

Referenced by event_loop(), and list_view_key().

◆ list_view_alloc()

ListView * list_view_alloc ( SDL_Renderer * renderer)
Parameters
rendererNULL when there is none, which leaves the list unable to show
Returns
the list, hidden, or NULL on allocation failure

Definition at line 733 of file ffplay_list.c.

Referenced by main().

◆ list_view_free()

void list_view_free ( ListView ** plv)

Definition at line 750 of file ffplay_list.c.

Referenced by do_exit().

◆ list_view_show()

int list_view_show ( ListView * lv,
const ListEntry * entries,
int nb_entries,
int selected )

Replaces the entries and shows the list, fading it in.

Parameters
entriesnumbered from 1 in the list; their strings and dictionaries must stay valid until the next call or list_view_free()
selectedentry to select, the selection is kept when it is -1 or not listed
Returns
0 or a negative error code

Definition at line 767 of file ffplay_list.c.

Referenced by chapter_list_show(), and file_list_show().

◆ list_view_clear()

void list_view_clear ( ListView * lv)

Removes the entries, which may be freed after this, and resets the sort and the search.

Definition at line 802 of file ffplay_list.c.

Referenced by chapter_list_show(), file_list_show(), list_view_alloc(), and stream_replace().

◆ list_view_pin()

void list_view_pin ( ListView * lv,
int pinned )

Keeps the list on screen and lets it take the keyboard and text input, or lets it fade out again.

Definition at line 812 of file ffplay_list.c.

Referenced by chapter_list_pin(), file_list_listed(), file_list_open(), list_view_key(), and stream_replace().

◆ list_view_pinned()

int list_view_pinned ( const ListView * lv)

Definition at line 825 of file ffplay_list.c.

Referenced by event_loop().

◆ list_view_visible()

int list_view_visible ( const ListView * lv)
Returns
whether the list is on screen or about to be

Definition at line 830 of file ffplay_list.c.

Referenced by event_loop(), list_view_hover(), list_view_set_size(), and refresh_loop_wait_event().

◆ list_view_selected()

int list_view_selected ( const ListView * lv)
Returns
the selected entry, -1 when none is listed

Definition at line 835 of file ffplay_list.c.

Referenced by event_loop(), list_update_rows(), list_view_key(), and list_view_show().

◆ list_view_move()

void list_view_move ( ListView * lv,
int delta )

Moves the selection by delta rows.

Definition at line 840 of file ffplay_list.c.

Referenced by event_loop(), and list_view_key().

◆ list_view_key()

int list_view_key ( ListView * lv,
SDL_Keycode key )

Handles a key while the list is pinned: escape unpins it, up/down move the selection, backspace erases from the search.

Returns
the entry chosen by enter, -1 otherwise

Definition at line 846 of file ffplay_list.c.

Referenced by event_loop().

◆ list_view_clear_search()

void list_view_clear_search ( ListView * lv)

Clears the search, listing all entries.

Definition at line 859 of file ffplay_list.c.

Referenced by file_list_listed().

◆ list_view_hover()

void list_view_hover ( ListView * lv,
int x,
int y )

Keeps the mouse position, in window coordinates, -1 when the mouse left the window.

Definition at line 868 of file ffplay_list.c.

Referenced by event_loop().

◆ list_view_click()

int list_view_click ( ListView * lv,
int x,
int y,
int * chosen )

Handles a left click at window coordinates: a click on an entry chooses it, a click on a column button sorts by it.

Parameters
chosenset to the entry clicked, -1 when none was
Returns
whether the click hit the list

Definition at line 883 of file ffplay_list.c.

Referenced by event_loop().

◆ list_view_set_size()

void list_view_set_size ( ListView * lv,
int width,
int height )

Sets the size of the window the list is drawn into.

Definition at line 899 of file ffplay_list.c.

Referenced by event_loop(), and video_open().

◆ list_view_set_playing()

void list_view_set_playing ( ListView * lv,
int entry )

Marks the entry as playing, -1 for none.

Definition at line 911 of file ffplay_list.c.

Referenced by refresh_loop_wait_event().

◆ list_view_update()

int list_view_update ( ListView * lv)

Brings the list up to date for the next frame, once the pending input is handled.

Returns
whether the window needs to be drawn again

Definition at line 919 of file ffplay_list.c.

Referenced by refresh_loop_wait_event().

◆ list_view_draw()

void list_view_draw ( ListView * lv)

Draws the list onto the window, between its other content and the present.

Definition at line 937 of file ffplay_list.c.

Referenced by video_display().

Variable Documentation

◆ label

◆ width

int width

Definition at line 216 of file ffplay_list.c.

◆ [struct]

const struct { ... } sort_buttons[LIST_SORT_NB]
Initial value:
= {
[LIST_SORT_NUMBER] = { "#", 5 },
[LIST_SORT_ARTIST] = { "Artist", 8 },
[LIST_SORT_TITLE] = { "Title", 7 },
[LIST_SORT_LENGTH] = { "Duration", 10 },
[LIST_SORT_SHUFFLE] = { "Shuffle", 14 },
}
@ LIST_SORT_NUMBER
Definition ffplay_list.c:46
@ LIST_SORT_TITLE
Definition ffplay_list.c:48
@ LIST_SORT_LENGTH
Definition ffplay_list.c:49
@ LIST_SORT_ARTIST
Definition ffplay_list.c:47
@ LIST_SORT_SHUFFLE
Definition ffplay_list.c:50

Referenced by bprint_header_strip(), list_hit(), list_layout(), and list_view_click().