Browse code

avfilter/af_rubberband: add process_command()

Signed-off-by: Paul B Mahol <onemda@gmail.com>

Paul B Mahol authored on 2015/10/01 04:40:54
Showing 1 changed files
... ...
@@ -207,6 +207,38 @@ static int request_frame(AVFilterLink *outlink)
207 207
     return ret;
208 208
 }
209 209
 
210
+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
211
+                           char *res, int res_len, int flags)
212
+{
213
+    RubberBandContext *s = ctx->priv;
214
+
215
+    if (!strcmp(cmd, "tempo")) {
216
+        double arg;
217
+
218
+        sscanf(args, "%lf", &arg);
219
+        if (arg < 0.01 || arg > 100) {
220
+            av_log(ctx, AV_LOG_ERROR,
221
+                   "Tempo scale factor '%f' out of range\n", arg);
222
+            return AVERROR(EINVAL);
223
+        }
224
+        rubberband_set_time_ratio(s->rbs, 1. / arg);
225
+    }
226
+
227
+    if (!strcmp(cmd, "pitch")) {
228
+        double arg;
229
+
230
+        sscanf(args, "%lf", &arg);
231
+        if (arg < 0.01 || arg > 100) {
232
+            av_log(ctx, AV_LOG_ERROR,
233
+                   "Pitch scale factor '%f' out of range\n", arg);
234
+            return AVERROR(EINVAL);
235
+        }
236
+        rubberband_set_pitch_scale(s->rbs, arg);
237
+    }
238
+
239
+    return 0;
240
+}
241
+
210 242
 static const AVFilterPad rubberband_inputs[] = {
211 243
     {
212 244
         .name          = "default",
... ...
@@ -235,4 +267,5 @@ AVFilter ff_af_rubberband = {
235 235
     .uninit        = uninit,
236 236
     .inputs        = rubberband_inputs,
237 237
     .outputs       = rubberband_outputs,
238
+    .process_command = process_command,
238 239
 };