Move the function added in 3ea8d751f5 to misc.c because command.c is too big. The circle definitions are also moved to core.h
Unified · Split
| @@ -76,6 +76,8 @@ · 75 unmodified lines | |||
| 76 | #include "osdep/subprocess.h" | 76 | #include "osdep/subprocess.h" |
| 77 | #include "osdep/terminal.h" | 77 | #include "osdep/terminal.h" |
| 78 | 78 | ||
| 79 | #include "core.h" | ||
| 80 | |||
| 79 | #ifdef _WIN32 | 81 | #ifdef _WIN32 |
| 80 | #include <windows.h> | 82 | #include <windows.h> |
| 81 | #endif | 83 | #endif |
| @@ -2099,67 +2101,6 @@ static char *append_track_info(char *res, struct track *track) · 2017 unmodified lines | |||
| 2099 | return res; | 2101 | return res; |
| 2100 | } | 2102 | } |
| 2101 | 2103 | ||
| 2102 | #define bstr_xappend0(ctx, dst, s) bstr_xappend(ctx, dst, bstr0(s)) | ||
| 2103 | #define ADD_FLAG(ctx, dst, flag, first) do { \ | ||
| 2104 | bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \ | ||
| 2105 | first = false; \ | ||
| 2106 | } while(0) | ||
| 2107 | |||
| 2108 | char *mp_format_track_metadata(void *ctx, struct track *t, bool add_lang) | ||
| 2109 | { | ||
| 2110 | struct sh_stream *s = t->stream; | ||
| 2111 | bstr dst = {0}; | ||
| 2112 | |||
| 2113 | if (t->title) | ||
| 2114 | bstr_xappend_asprintf(ctx, &dst, "'%s' ", t->title); | ||
| 2115 | |||
| 2116 | const char *codec = s ? s->codec->codec : NULL; | ||
| 2117 | |||
| 2118 | bstr_xappend0(ctx, &dst, "("); | ||
| 2119 | |||
| 2120 | if (add_lang && t->lang) | ||
| 2121 | bstr_xappend_asprintf(ctx, &dst, "%s ", t->lang); | ||
| 2122 | |||
| 2123 | bstr_xappend0(ctx, &dst, codec ? codec : "<unknown>"); | ||
| 2124 | |||
| 2125 | if (s && s->codec->codec_profile) | ||
| 2126 | bstr_xappend_asprintf(ctx, &dst, " [%s]", s->codec->codec_profile); | ||
| 2127 | if (s && s->codec->disp_w) | ||
| 2128 | bstr_xappend_asprintf(ctx, &dst, " %dx%d", s->codec->disp_w, s->codec->disp_h); | ||
| 2129 | if (s && s->codec->fps && !t->image) { | ||
| 2130 | char *fps = mp_format_double(ctx, s->codec->fps, 4, false, false, true); | ||
| 2131 | bstr_xappend_asprintf(ctx, &dst, " %s fps", fps); | ||
| 2132 | } | ||
| 2133 | if (s && s->codec->channels.num) | ||
| 2134 | bstr_xappend_asprintf(ctx, &dst, " %dch", s->codec->channels.num); | ||
| 2135 | if (s && s->codec->samplerate) | ||
| 2136 | bstr_xappend_asprintf(ctx, &dst, " %d Hz", s->codec->samplerate); | ||
| 2137 | if (s && s->codec->bitrate) { | ||
| 2138 | bstr_xappend_asprintf(ctx, &dst, " %d kbps", (s->codec->bitrate + 500) / 1000); | ||
| 2139 | } else if (s && s->hls_bitrate) { | ||
| 2140 | bstr_xappend_asprintf(ctx, &dst, " %d kbps", (s->hls_bitrate + 500) / 1000); | ||
| 2141 | } | ||
| 2142 | bstr_xappend0(ctx, &dst, ")"); | ||
| 2143 | |||
| 2144 | bool first = true; | ||
| 2145 | if (t->default_track) | ||
| 2146 | ADD_FLAG(ctx, dst, "default", first); | ||
| 2147 | if (t->forced_track) | ||
| 2148 | ADD_FLAG(ctx, dst, "forced", first); | ||
| 2149 | if (t->dependent_track) | ||
| 2150 | ADD_FLAG(ctx, dst, "dependent", first); | ||
| 2151 | if (t->visual_impaired_track) | ||
| 2152 | ADD_FLAG(ctx, dst, "visual-impaired", first); | ||
| 2153 | if (t->hearing_impaired_track) | ||
| 2154 | ADD_FLAG(ctx, dst, "hearing-impaired", first); | ||
| 2155 | if (t->is_external) | ||
| 2156 | ADD_FLAG(ctx, dst, "external", first); | ||
| 2157 | if (!first) | ||
| 2158 | bstr_xappend0(ctx, &dst, "]"); | ||
| 2159 | |||
| 2160 | return bstrto0(ctx, dst); | ||
| 2161 | } | ||
| 2162 | |||
| 2163 | static int property_list_tracks(void *ctx, struct m_property *prop, | 2104 | static int property_list_tracks(void *ctx, struct m_property *prop, |
| 2164 | int action, void *arg) | 2105 | int action, void *arg) |
| 2165 | { | 2106 | { |
| @@ -20,7 +20,6 @@ · 19 unmodified lines | |||
| 20 | 20 | ||
| 21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
| 22 | 22 | ||
| 23 | #include "core.h" | ||
| 24 | #include "libmpv/client.h" | 23 | #include "libmpv/client.h" |
| 25 | #include "osdep/compiler.h" | 24 | #include "osdep/compiler.h" |
| 26 | 25 | ||
| @@ -122,10 +121,4 @@ void mark_seek(struct MPContext *mpctx); · 95 unmodified lines | |||
| 122 | 121 | ||
| 123 | void mp_abort_cache_dumping(struct MPContext *mpctx); | 122 | void mp_abort_cache_dumping(struct MPContext *mpctx); |
| 124 | 123 | ||
| 125 | // U+25CB WHITE CIRCLE | ||
| 126 | // U+25CF BLACK CIRCLE | ||
| 127 | #define WHITE_CIRCLE "\xe2\x97\x8b" | ||
| 128 | #define BLACK_CIRCLE "\xe2\x97\x8f" | ||
| 129 | char *mp_format_track_metadata(void *ctx, struct track *t, bool add_lang); | ||
| 130 | |||
| 131 | #endif /* MPLAYER_COMMAND_H */ | 124 | #endif /* MPLAYER_COMMAND_H */ |
| @@ -481,6 +481,11 @@ struct mp_abort_entry { · 480 unmodified lines | |||
| 481 | // (only valid if client_work_type set) | 481 | // (only valid if client_work_type set) |
| 482 | }; | 482 | }; |
| 483 | 483 | ||
| 484 | // U+25CB WHITE CIRCLE | ||
| 485 | // U+25CF BLACK CIRCLE | ||
| 486 | #define WHITE_CIRCLE "\xe2\x97\x8b" | ||
| 487 | #define BLACK_CIRCLE "\xe2\x97\x8f" | ||
| 488 | |||
| 484 | // audio.c | 489 | // audio.c |
| 485 | void reset_audio_state(struct MPContext *mpctx); | 490 | void reset_audio_state(struct MPContext *mpctx); |
| 486 | void reinit_audio_chain(struct MPContext *mpctx); | 491 | void reinit_audio_chain(struct MPContext *mpctx); |
| @@ -566,6 +571,7 @@ void error_on_track(struct MPContext *mpctx, struct track *track); · 79 unmodified lines | |||
| 566 | int stream_dump(struct MPContext *mpctx, const char *source_filename); | 571 | int stream_dump(struct MPContext *mpctx, const char *source_filename); |
| 567 | double get_track_seek_offset(struct MPContext *mpctx, struct track *track); | 572 | double get_track_seek_offset(struct MPContext *mpctx, struct track *track); |
| 568 | bool str_in_list(bstr str, char **list); | 573 | bool str_in_list(bstr str, char **list); |
| 574 | char *mp_format_track_metadata(void *ctx, struct track *t, bool add_lang); | ||
| 569 | 575 | ||
| 570 | // osd.c | 576 | // osd.c |
| 571 | void set_osd_bar(struct MPContext *mpctx, int type, | 577 | void set_osd_bar(struct MPContext *mpctx, int type, |
| @@ -353,3 +353,64 @@ bool str_in_list(bstr str, char **list) · 352 unmodified lines | |||
| 353 | } | 353 | } |
| 354 | return false; | 354 | return false; |
| 355 | } | 355 | } |
| 356 | |||
| 357 | #define ADD_FLAG(ctx, dst, flag, first) do { \ | ||
| 358 | bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \ | ||
| 359 | first = false; \ | ||
| 360 | } while(0) | ||
| 361 | #define bstr_xappend0(ctx, dst, s) bstr_xappend(ctx, dst, bstr0(s)) | ||
| 362 | |||
| 363 | char *mp_format_track_metadata(void *ctx, struct track *t, bool add_lang) | ||
| 364 | { | ||
| 365 | struct sh_stream *s = t->stream; | ||
| 366 | bstr dst = {0}; | ||
| 367 | |||
| 368 | if (t->title) | ||
| 369 | bstr_xappend_asprintf(ctx, &dst, "'%s' ", t->title); | ||
| 370 | |||
| 371 | const char *codec = s ? s->codec->codec : NULL; | ||
| 372 | |||
| 373 | bstr_xappend0(ctx, &dst, "("); | ||
| 374 | |||
| 375 | if (add_lang && t->lang) | ||
| 376 | bstr_xappend_asprintf(ctx, &dst, "%s ", t->lang); | ||
| 377 | |||
| 378 | bstr_xappend0(ctx, &dst, codec ? codec : "<unknown>"); | ||
| 379 | |||
| 380 | if (s && s->codec->codec_profile) | ||
| 381 | bstr_xappend_asprintf(ctx, &dst, " [%s]", s->codec->codec_profile); | ||
| 382 | if (s && s->codec->disp_w) | ||
| 383 | bstr_xappend_asprintf(ctx, &dst, " %dx%d", s->codec->disp_w, s->codec->disp_h); | ||
| 384 | if (s && s->codec->fps && !t->image) { | ||
| 385 | char *fps = mp_format_double(ctx, s->codec->fps, 4, false, false, true); | ||
| 386 | bstr_xappend_asprintf(ctx, &dst, " %s fps", fps); | ||
| 387 | } | ||
| 388 | if (s && s->codec->channels.num) | ||
| 389 | bstr_xappend_asprintf(ctx, &dst, " %dch", s->codec->channels.num); | ||
| 390 | if (s && s->codec->samplerate) | ||
| 391 | bstr_xappend_asprintf(ctx, &dst, " %d Hz", s->codec->samplerate); | ||
| 392 | if (s && s->codec->bitrate) { | ||
| 393 | bstr_xappend_asprintf(ctx, &dst, " %d kbps", (s->codec->bitrate + 500) / 1000); | ||
| 394 | } else if (s && s->hls_bitrate) { | ||
| 395 | bstr_xappend_asprintf(ctx, &dst, " %d kbps", (s->hls_bitrate + 500) / 1000); | ||
| 396 | } | ||
| 397 | bstr_xappend0(ctx, &dst, ")"); | ||
| 398 | |||
| 399 | bool first = true; | ||
| 400 | if (t->default_track) | ||
| 401 | ADD_FLAG(ctx, dst, "default", first); | ||
| 402 | if (t->forced_track) | ||
| 403 | ADD_FLAG(ctx, dst, "forced", first); | ||
| 404 | if (t->dependent_track) | ||
| 405 | ADD_FLAG(ctx, dst, "dependent", first); | ||
| 406 | if (t->visual_impaired_track) | ||
| 407 | ADD_FLAG(ctx, dst, "visual-impaired", first); | ||
| 408 | if (t->hearing_impaired_track) | ||
| 409 | ADD_FLAG(ctx, dst, "hearing-impaired", first); | ||
| 410 | if (t->is_external) | ||
| 411 | ADD_FLAG(ctx, dst, "external", first); | ||
| 412 | if (!first) | ||
| 413 | bstr_xappend0(ctx, &dst, "]"); | ||
| 414 | |||
| 415 | return bstrto0(ctx, dst); | ||
| 416 | } | ||