summaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 03:17:41 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 07:48:31 +0200
commit3cb3bbbddc1d09dab1471a3630f1a9aa4392ed50 (patch)
tree4989a29dbae266e0bb83bddca9fcdef1058c4a17 /command.c
parent2be10f22b24712b959fa2883a4dcfa7caf72ab79 (diff)
downloadmpv-3cb3bbbddc1d09dab1471a3630f1a9aa4392ed50.tar.bz2
mpv-3cb3bbbddc1d09dab1471a3630f1a9aa4392ed50.tar.xz
Add a simple capture feature (-capture)
If a specified key is pressed during playback, the current stream is captured to a file, similar to what -dumpstream achieves. original patch by Pásztor Szilárd, don tricon hu Taken from the following svn commits, but with several fixes and modifications (one obvious user-visible difference is that the default key binding is 'C', not 'c'): git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32524 b3059339-0415-0410-9bf9-f77b7e298cf2 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32529 b3059339-0415-0410-9bf9-f77b7e298cf2 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32530 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'command.c')
-rw-r--r--command.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/command.c b/command.c
index 60d04d4248..e367687c5a 100644
--- a/command.c
+++ b/command.c
@@ -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},