ref: 2809e5c22ca797313230f652eba645062f290994
parent: 51fc441fcdf5d97f15b73bccac45bb5fcf7f78f1
author: Jean-Marc Valin <[email protected]>
date: Mon May 1 12:59:52 EDT 2017
setting decision delay and muxing delay (untested)
--- a/include/opusenc.h
+++ b/include/opusenc.h
@@ -54,6 +54,18 @@
#define OPE_BAD_ARG -12
#define OPE_INTERNAL_ERROR -13
+/* These are the "raw" request values -- they should usually not be used. */
+#define OPE_SET_DECISION_DELAY_REQUEST 14000
+#define OPE_GET_DECISION_DELAY_REQUEST 14001
+#define OPE_SET_MUXING_DELAY_REQUEST 14002
+#define OPE_GET_MUXING_DELAY_REQUEST 14003
+
+#define OPE_SET_DECISION_DELAY(x) OPE_SET_DECISION_DELAY_REQUEST, __opus_check_int(x)
+#define OPE_GET_DECISION_DELAY(x) OPE_GET_DECISION_DELAY_REQUEST, __opus_check_int_ptr(x)
+#define OPE_SET_MUXING_DELAY(x) OPE_SET_MUXING_DELAY_REQUEST, __opus_check_int(x)
+#define OPE_GET_MUXING_DELAY(x) OPE_GET_MUXING_DELAY_REQUEST, __opus_check_int_ptr(x)
+
+
typedef int (*ope_write_func)(void *user_data, const unsigned char *ptr, int len);
typedef int (*ope_close_func)(void *user_data);
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -478,7 +478,7 @@
max_supported = OPUS_FRAMESIZE_120_MS;
#endif
if (value < OPUS_FRAMESIZE_2_5_MS || value > max_supported) {
- ret = OPE_UNIMPLEMENTED;
+ ret = OPUS_UNIMPLEMENTED;
break;
}
ret = opus_multistream_encoder_ctl(enc->st, request, value);
@@ -491,7 +491,7 @@
}
break;
default:
- ret = OPE_UNIMPLEMENTED;
+ ret = OPUS_UNIMPLEMENTED;
}
va_end(ap);
return ret;
@@ -499,9 +499,35 @@
/* ctl()-type call for the OggOpus layer. */
int ope_set_params(OggOpusEnc *enc, int request, ...) {
- (void)enc;
+ int ret;
+ va_list ap;
+ va_start(ap, request);
switch (request) {
+ case OPE_SET_DECISION_DELAY_REQUEST:
+ {
+ opus_int32 value = va_arg(ap, opus_int32);
+ if (value < 0) {
+ ret = OPE_BAD_ARG;
+ break;
+ }
+ enc->decision_delay = value;
+ ret = OPE_OK;
+ }
+ break;
+ case OPE_SET_MUXING_DELAY_REQUEST:
+ {
+ opus_int32 value = va_arg(ap, opus_int32);
+ if (value < 0) {
+ ret = OPE_BAD_ARG;
+ break;
+ }
+ enc->max_ogg_delay = value;
+ ret = OPE_OK;
+ }
+ break;
default:
return OPE_UNIMPLEMENTED;
}
+ va_end(ap);
+ return ret;
}