| 153 | } |
| 154 | |
| 155 | static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) |
| 156 | { |
| 157 | int ret; |
| 158 | AVDictionary *options = NULL, *bsf_options = NULL; |
| 159 | const AVDictionaryEntry *entry; |
| 160 | char *filename; |
| 161 | char *format = NULL, *select = NULL; |
| 162 | AVFormatContext *avf2 = NULL; |
| 163 | int stream_count; |
| 164 | int fullret; |
| 165 | char *subselect = NULL, *next_subselect = NULL, *first_subselect = NULL, *tmp_select = NULL; |
| 166 | |
| 167 | if ((ret = ff_tee_parse_slave_options(avf, slave, &options, &filename)) < 0) |
| 168 | return ret; |
| 169 | |
| 170 | tee_slave->on_fail = DEFAULT_SLAVE_FAILURE_POLICY; |
| 171 | |
| 172 | #define CONSUME_OPTION(option, field, action) do { \ |
| 173 | AVDictionaryEntry *en = av_dict_get(options, option, NULL, 0); \ |
| 174 | if (en) { \ |
| 175 | field = en->value; \ |
| 176 | { action } \ |
| 177 | av_dict_set(&options, option, NULL, 0); \ |
| 178 | } \ |
| 179 | } while (0) |
| 180 | #define STEAL_OPTION(option, field) \ |
| 181 | CONSUME_OPTION(option, field, \ |
| 182 | en->value = NULL; /* prevent it from being freed */) |
| 183 | #define PROCESS_OPTION(option, function, on_error) do { \ |
| 184 | const char *value; \ |
| 185 | CONSUME_OPTION(option, value, if ((ret = function) < 0) \ |
| 186 | { { on_error } goto end; }); \ |
| 187 | } while (0) |
| 188 | |
| 189 | STEAL_OPTION("f", format); |
| 190 | STEAL_OPTION("select", select); |
| 191 | PROCESS_OPTION("onfail", |
| 192 | parse_slave_failure_policy_option(value, tee_slave), |
| 193 | av_log(avf, AV_LOG_ERROR, "Invalid onfail option value, " |
| 194 | "valid options are 'abort' and 'ignore'\n");); |
| 195 | PROCESS_OPTION("use_fifo", |
| 196 | parse_slave_fifo_policy(value, tee_slave), |
| 197 | av_log(avf, AV_LOG_ERROR, "Error parsing fifo options: %s\n", |
| 198 | av_err2str(ret));); |
| 199 | PROCESS_OPTION("fifo_options", |
| 200 | parse_slave_fifo_options(value, tee_slave), ;); |
| 201 | entry = NULL; |
| 202 | while ((entry = av_dict_get(options, "bsfs", NULL, AV_DICT_IGNORE_SUFFIX))) { |
| 203 | /* trim out strlen("bsfs") characters from key */ |
| 204 | av_dict_set(&bsf_options, entry->key + 4, entry->value, 0); |
| 205 | av_dict_set(&options, entry->key, NULL, 0); |
| 206 | } |
| 207 | |
| 208 | if (tee_slave->use_fifo) { |
| 209 | |
| 210 | if (options) { |
| 211 | char *format_options_str = NULL; |
| 212 | ret = av_dict_get_string(options, &format_options_str, '=', ':'); |
no test coverage detected