comparison command.c @ 32438:faefba58f413

Implement a basic capture feature, available through -capture. If a specified key is pressed during playback, the current stream is captured to a file, similar to what -dumpstream achieves. patch by P«”sztor Szil«”rd, don tricon hu
author diego
date Thu, 21 Oct 2010 18:19:30 +0000
parents 8f35fc25523f
children bf593e3827d9
comparison
equal deleted inserted replaced
32437:8d6bd95d0009 32438:faefba58f413
1105 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDDeinterlace, 1105 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDDeinterlace,
1106 deinterlace ? MSGTR_Enabled : MSGTR_Disabled); 1106 deinterlace ? MSGTR_Enabled : MSGTR_Disabled);
1107 return M_PROPERTY_OK; 1107 return M_PROPERTY_OK;
1108 } 1108 }
1109 return M_PROPERTY_NOT_IMPLEMENTED; 1109 return M_PROPERTY_NOT_IMPLEMENTED;
1110 }
1111
1112 static int mp_property_capture(m_option_t *prop, int action,
1113 void *arg, MPContext *mpctx)
1114 {
1115 int ret;
1116 int capturing = !!mpctx->stream->capture_file;
1117
1118 if (!mpctx->stream)
1119 return M_PROPERTY_UNAVAILABLE;
1120
1121 ret = m_property_flag(prop, action, arg, &capturing);
1122 if (ret == M_PROPERTY_OK && capturing != !!mpctx->stream->capture_file) {
1123 if (capturing) {
1124 if (capture_dump && !(mpctx->stream->capture_file = fopen(stream_dump_name, "wb"))) {
1125 mp_msg(MSGT_GLOBAL, MSGL_ERR,
1126 "Error opening capture file: %s\n", strerror(errno));
1127 ret = M_PROPERTY_ERROR;
1128 } else {
1129 mp_msg(MSGT_GLOBAL, MSGL_ERR,
1130 "Capturing not enabled (forgot -capture parameter?)\n");
1131 ret = M_PROPERTY_ERROR;
1132 }
1133 } else {
1134 fclose(mpctx->stream->capture_file);
1135 mpctx->stream->capture_file = NULL;
1136 }
1137 }
1138
1139 switch (ret) {
1140 case M_PROPERTY_ERROR:
1141 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDCapturingFailure);
1142 break;
1143 case M_PROPERTY_OK:
1144 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDCapturing,
1145 mpctx->stream->capture_file ? MSGTR_Enabled : MSGTR_Disabled);
1146 break;
1147 default:
1148 break;
1149 }
1150
1151 return ret;
1110 } 1152 }
1111 1153
1112 /// Panscan (RW) 1154 /// Panscan (RW)
1113 static int mp_property_panscan(m_option_t *prop, int action, void *arg, 1155 static int mp_property_panscan(m_option_t *prop, int action, void *arg,
1114 MPContext *mpctx) 1156 MPContext *mpctx)
2094 { "angle", mp_property_angle, CONF_TYPE_INT, 2136 { "angle", mp_property_angle, CONF_TYPE_INT,
2095 CONF_RANGE, -2, 10, NULL }, 2137 CONF_RANGE, -2, 10, NULL },
2096 { "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST, 2138 { "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST,
2097 0, 0, 0, NULL }, 2139 0, 0, 0, NULL },
2098 { "pause", mp_property_pause, CONF_TYPE_FLAG, 2140 { "pause", mp_property_pause, CONF_TYPE_FLAG,
2141 M_OPT_RANGE, 0, 1, NULL },
2142 { "capturing", mp_property_capture, CONF_TYPE_FLAG,
2099 M_OPT_RANGE, 0, 1, NULL }, 2143 M_OPT_RANGE, 0, 1, NULL },
2100 2144
2101 // Audio 2145 // Audio
2102 { "volume", mp_property_volume, CONF_TYPE_FLOAT, 2146 { "volume", mp_property_volume, CONF_TYPE_FLOAT,
2103 M_OPT_RANGE, 0, 100, NULL }, 2147 M_OPT_RANGE, 0, 100, NULL },
2284 } set_prop_cmd[] = { 2328 } set_prop_cmd[] = {
2285 // general 2329 // general
2286 { "loop", MP_CMD_LOOP, 0, 0, -1, MSGTR_LoopStatus }, 2330 { "loop", MP_CMD_LOOP, 0, 0, -1, MSGTR_LoopStatus },
2287 { "chapter", MP_CMD_SEEK_CHAPTER, 0, 0, -1, NULL }, 2331 { "chapter", MP_CMD_SEEK_CHAPTER, 0, 0, -1, NULL },
2288 { "angle", MP_CMD_SWITCH_ANGLE, 0, 0, -1, NULL }, 2332 { "angle", MP_CMD_SWITCH_ANGLE, 0, 0, -1, NULL },
2333 { "capturing", MP_CMD_CAPTURING, 1, 0, -1, NULL },
2289 // audio 2334 // audio
2290 { "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume }, 2335 { "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume },
2291 { "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus }, 2336 { "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus },
2292 { "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, MSGTR_AVDelayStatus }, 2337 { "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, MSGTR_AVDelayStatus },
2293 { "switch_audio", MP_CMD_SWITCH_AUDIO, 1, 0, -1, MSGTR_OSDAudio }, 2338 { "switch_audio", MP_CMD_SWITCH_AUDIO, 1, 0, -1, MSGTR_OSDAudio },