JNIEXPORT void JNICALL
Java_org_jitsi_impl_neomedia_codec_audio_g722_JNIEncoder_g722_1encoder_1close
    (JNIEnv *jniEnv, jclass clazz, jlong encoder)
{
    g722_encode_state_t *e = (g722_encode_state_t *) (intptr_t) encoder;

    g722_encode_release(e);
    g722_encode_free(e);
}
CTG722::~CTG722(){
   if(estate){
      g722_encode_release((g722_encode_state_t*)estate);
      g722_encode_free((g722_encode_state_t*)estate);
      estate=NULL;
   }
   if(dstate){
      g722_decode_release((g722_decode_state_t*)dstate);
      g722_decode_free((g722_decode_state_t*)dstate);
      dstate=NULL;
   }
}
static switch_status_t switch_g722_destroy(switch_codec_t *codec)
{
	struct g722_context *context = codec->private_info;

	codec->private_info = NULL;

	if (!context) {
		return SWITCH_STATUS_FALSE;
	}

	if (context->decoder_object)
		g722_decode_free(context->decoder_object);
	context->decoder_object = NULL;
	if (context->encoder_object)
		g722_encode_free(context->encoder_object);
	context->encoder_object = NULL;

	return SWITCH_STATUS_SUCCESS;
}