diff options
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -1178,6 +1178,40 @@ static int mp_property_yuv_colorspace(m_option_t *prop, int action, return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_capture(m_option_t *prop, int action, + void *arg, MPContext *mpctx) +{ + struct MPOpts *opts = &mpctx->opts; + + if (!mpctx->stream) + return M_PROPERTY_UNAVAILABLE; + + if (!opts->capture_dump) { + mp_tmsg(MSGT_GLOBAL, MSGL_ERR, + "Capturing not enabled (forgot -capture parameter?)\n"); + return M_PROPERTY_ERROR; + } + + int capturing = !!mpctx->stream->capture_file; + + int ret = m_property_flag(prop, action, arg, &capturing); + if (ret == M_PROPERTY_OK && capturing != !!mpctx->stream->capture_file) { + if (capturing) { + mpctx->stream->capture_file = fopen(opts->stream_dump_name, "wb"); + if (!mpctx->stream->capture_file) { + mp_tmsg(MSGT_GLOBAL, MSGL_ERR, + "Error opening capture file: %s\n", strerror(errno)); + ret = M_PROPERTY_ERROR; + } + } else { + fclose(mpctx->stream->capture_file); + mpctx->stream->capture_file = NULL; + } + } + + return ret; +} + /// Panscan (RW) static int mp_property_panscan(m_option_t *prop, int action, void *arg, MPContext *mpctx) @@ -2158,6 +2192,8 @@ static const m_option_t mp_properties[] = { 0, 0, 0, NULL }, { "pause", mp_property_pause, CONF_TYPE_FLAG, M_OPT_RANGE, 0, 1, NULL }, + { "capturing", mp_property_capture, CONF_TYPE_FLAG, + M_OPT_RANGE, 0, 1, NULL }, // Audio { "volume", mp_property_volume, CONF_TYPE_FLOAT, @@ -2330,6 +2366,7 @@ static struct property_osd_display { // general { "loop", 0, -1, _("Loop: %s") }, { "chapter", -1, -1, NULL }, + { "capturing", 0, -1, _("Capturing: %s") }, // audio { "volume", OSD_VOLUME, -1, _("Volume") }, { "mute", 0, -1, _("Mute: %s") }, @@ -2456,6 +2493,7 @@ static struct { { "chapter", MP_CMD_SEEK_CHAPTER, 0}, { "angle", MP_CMD_SWITCH_ANGLE, 0}, { "pause", MP_CMD_PAUSE, 0}, + { "capturing", MP_CMD_CAPTURING, 1}, // audio { "volume", MP_CMD_VOLUME, 0}, { "mute", MP_CMD_MUTE, 1}, |