Implements OPUS_MULTISTREAM_{EN|DE}CODER_GET_STATE

Untested
diff --git a/src/opus_multistream.c b/src/opus_multistream.c
index 16c1118..c1238ae 100644
--- a/src/opus_multistream.c
+++ b/src/opus_multistream.c
@@ -443,6 +443,25 @@
       }
    }
    break;
+   case OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST:
+   {
+      int s;
+      opus_int32 stream_id;
+      OpusEncoder **value;
+      stream_id = va_arg(ap, opus_int32);
+      if (stream_id<0 || stream_id >= st->layout.nb_streams)
+         ret = OPUS_BAD_ARG;
+      value = va_arg(ap, OpusEncoder**);
+      for (s=0;s<stream_id;s++)
+      {
+         if (s < st->layout.nb_coupled_streams)
+            ptr += align(coupled_size);
+         else
+            ptr += align(mono_size);
+      }
+      *value = (OpusEncoder*)ptr;
+   }
+      break;
    default:
       ret = OPUS_UNIMPLEMENTED;
       break;
@@ -728,7 +747,6 @@
        case OPUS_GET_FINAL_RANGE_REQUEST:
        {
           int s;
-          /* This only works for int32* params, but that's all we have right now */
           opus_uint32 *value = va_arg(ap, opus_uint32*);
           for (s=0;s<st->layout.nb_streams;s++)
           {
@@ -748,7 +766,6 @@
        case OPUS_RESET_STATE:
        {
           int s;
-          /* This only works for int32* params, but that's all we have right now */
           for (s=0;s<st->layout.nb_streams;s++)
           {
              OpusDecoder *dec;
@@ -764,6 +781,25 @@
           }
        }
        break;
+       case OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST:
+       {
+          int s;
+          opus_int32 stream_id;
+          OpusDecoder **value;
+          stream_id = va_arg(ap, opus_int32);
+          if (stream_id<0 || stream_id >= st->layout.nb_streams)
+             ret = OPUS_BAD_ARG;
+          value = va_arg(ap, OpusDecoder**);
+          for (s=0;s<stream_id;s++)
+          {
+             if (s < st->layout.nb_coupled_streams)
+                ptr += align(coupled_size);
+             else
+                ptr += align(mono_size);
+          }
+          *value = (OpusDecoder*)ptr;
+       }
+          break;
        default:
           ret = OPUS_UNIMPLEMENTED;
        break;
diff --git a/src/opus_multistream.h b/src/opus_multistream.h
index c68ecd6..2723154 100644
--- a/src/opus_multistream.h
+++ b/src/opus_multistream.h
@@ -38,6 +38,15 @@
 typedef struct OpusMSEncoder OpusMSEncoder;
 typedef struct OpusMSDecoder OpusMSDecoder;
 
+#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr)))
+#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr)))
+
+#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120
+#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122
+
+#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y)
+#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y)
+
 OPUS_EXPORT OpusMSEncoder *opus_multistream_encoder_create(
       opus_int32 Fs,                     /**< Sampling rate of input signal (Hz) */
       int channels,               /**< Number of channels (1/2) in input signal */