Implement OPE_GET_* ctl() calls
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Fri, 19 May 2017 04:30:19 +0000 (00:30 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Fri, 19 May 2017 04:30:19 +0000 (00:30 -0400)
include/opusenc.h
src/opusenc.c

index a1b7e3e..66867f8 100644 (file)
@@ -112,7 +112,7 @@ extern "C" {
 #define OPE_SET_SERIALNO_REQUEST            14006
 #define OPE_GET_SERIALNO_REQUEST            14007
 #define OPE_SET_PACKET_CALLBACK_REQUEST     14008
-#define OPE_GET_PACKET_CALLBACK_REQUEST     14009
+/*#define OPE_GET_PACKET_CALLBACK_REQUEST     14009*/
 #define OPE_SET_HEADER_GAIN_REQUEST         14010
 #define OPE_GET_HEADER_GAIN_REQUEST         14011
 
@@ -134,7 +134,7 @@ extern "C" {
 #define OPE_GET_SERIALNO(x) OPE_GET_SERIALNO_REQUEST, __opus_check_int_ptr(x)
 /* FIXME: Add type-checking macros to these. */
 #define OPE_SET_PACKET_CALLBACK(x,u) OPE_SET_PACKET_CALLBACK_REQUEST, (x), (u)
-#define OPE_GET_PACKET_CALLBACK(x,u) OPE_GET_PACKET_CALLBACK_REQUEST, (x), (u)
+/*#define OPE_GET_PACKET_CALLBACK(x,u) OPE_GET_PACKET_CALLBACK_REQUEST, (x), (u)*/
 #define OPE_SET_HEADER_GAIN(x,u) OPE_SET_HEADER_GAIN_REQUEST, __opus_check_int(x)
 #define OPE_GET_HEADER_GAIN(x,u) OPE_GET_HEADER_GAIN_REQUEST, __opus_check_int_ptr(x)
 /*@}*/
index 109f4bf..21a550f 100644 (file)
@@ -663,6 +663,7 @@ int ope_encoder_ctl(OggOpusEnc *enc, int request, ...) {
   va_list ap;
   if (enc->unrecoverable) return OPE_UNRECOVERABLE;
   va_start(ap, request);
+  ret = OPE_OK;
   switch (request) {
     case OPUS_SET_APPLICATION_REQUEST:
     case OPUS_SET_BITRATE_REQUEST:
@@ -753,7 +754,12 @@ int ope_encoder_ctl(OggOpusEnc *enc, int request, ...) {
         break;
       }
       enc->decision_delay = value;
-      ret = OPE_OK;
+    }
+    break;
+    case OPE_GET_DECISION_DELAY_REQUEST:
+    {
+      opus_int32 *value = va_arg(ap, opus_int32*);
+      *value = enc->decision_delay;
     }
     break;
     case OPE_SET_MUXING_DELAY_REQUEST:
@@ -765,7 +771,12 @@ int ope_encoder_ctl(OggOpusEnc *enc, int request, ...) {
       }
       enc->max_ogg_delay = value;
       oggp_set_muxing_delay(enc->oggp, enc->max_ogg_delay);
-      ret = OPE_OK;
+    }
+    break;
+    case OPE_GET_MUXING_DELAY_REQUEST:
+    {
+      opus_int32 *value = va_arg(ap, opus_int32*);
+      *value = enc->max_ogg_delay;
     }
     break;
     case OPE_SET_COMMENT_PADDING_REQUEST:
@@ -779,6 +790,12 @@ int ope_encoder_ctl(OggOpusEnc *enc, int request, ...) {
       ret = OPE_OK;
     }
     break;
+    case OPE_GET_COMMENT_PADDING_REQUEST:
+    {
+      opus_int32 *value = va_arg(ap, opus_int32*);
+      *value = enc->comment_padding;
+    }
+    break;
     case OPE_SET_SERIALNO_REQUEST:
     {
       opus_int32 value = va_arg(ap, opus_int32);
@@ -791,6 +808,12 @@ int ope_encoder_ctl(OggOpusEnc *enc, int request, ...) {
       ret = OPE_OK;
     }
     break;
+    case OPE_GET_SERIALNO_REQUEST:
+    {
+      opus_int32 *value = va_arg(ap, opus_int32*);
+      *value = enc->last_stream->serialno;
+    }
+    break;
     case OPE_SET_PACKET_CALLBACK_REQUEST:
     {
       ope_packet_func value = va_arg(ap, ope_packet_func);
@@ -811,6 +834,12 @@ int ope_encoder_ctl(OggOpusEnc *enc, int request, ...) {
       ret = OPE_OK;
     }
     break;
+    case OPE_GET_HEADER_GAIN_REQUEST:
+    {
+      opus_int32 *value = va_arg(ap, opus_int32*);
+      *value = enc->header.gain;
+    }
+    break;
     default:
       ret = OPE_UNIMPLEMENTED;
   }