1 /+
2 +            Copyright 2023 – 2024 Aya Partridge
3 + Distributed under the Boost Software License, Version 1.0.
4 +     (See accompanying file LICENSE_1_0.txt or copy at
5 +           http://www.boost.org/LICENSE_1_0.txt)
6 +/
7 module opus.custom;
8 
9 version(Opus_Custom):
10 import bindbc.opus.config;
11 import bindbc.opus.codegen;
12 
13 struct OpusCustomEncoder;
14 
15 struct OpusCustomDecoder;
16 
17 struct OpusCustomMode;
18 
19 pragma(inline,true) nothrow @nogc{
20 	auto OPUS_SET_COMPLEXITY(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_COMPLEXITY_REQUEST, x); }
21 	auto OPUS_GET_COMPLEXITY(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_COMPLEXITY_REQUEST, x); }
22 	auto OPUS_SET_BITRATE(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_BITRATE_REQUEST, x); }
23 	auto OPUS_GET_BITRATE(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_BITRATE_REQUEST, x); }
24 	auto OPUS_SET_VBR(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_VBR_REQUEST, x); }
25 	auto OPUS_GET_VBR(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_VBR_REQUEST, x); }
26 	auto OPUS_SET_VBR_CONSTRAINT(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_VBR_CONSTRAINT_REQUEST, x); }
27 	auto OPUS_GET_VBR_CONSTRAINT(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_VBR_CONSTRAINT_REQUEST, x); }
28 	auto OPUS_SET_FORCE_CHANNELS(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_FORCE_CHANNELS_REQUEST, x); }
29 	auto OPUS_GET_FORCE_CHANNELS(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_FORCE_CHANNELS_REQUEST, x); }
30 	auto OPUS_SET_MAX_BANDWIDTH(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_MAX_BANDWIDTH_REQUEST, x); }
31 	auto OPUS_GET_MAX_BANDWIDTH(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_MAX_BANDWIDTH_REQUEST, x); }
32 	auto OPUS_SET_BANDWIDTH(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_BANDWIDTH_REQUEST, x); }
33 	auto OPUS_SET_SIGNAL(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_SIGNAL_REQUEST, x); }
34 	auto OPUS_GET_SIGNAL(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_SIGNAL_REQUEST, x); }
35 	auto OPUS_SET_APPLICATION(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_APPLICATION_REQUEST, x); }
36 	auto OPUS_GET_APPLICATION(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_APPLICATION_REQUEST, x); }
37 	auto OPUS_GET_LOOKAHEAD(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_LOOKAHEAD_REQUEST, x); }
38 	auto OPUS_SET_INBAND_FEC(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_INBAND_FEC_REQUEST, x); }
39 	auto OPUS_GET_INBAND_FEC(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_INBAND_FEC_REQUEST, x); }
40 	auto OPUS_SET_PACKET_LOSS_PERC(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_PACKET_LOSS_PERC_REQUEST, x); }
41 	auto OPUS_GET_PACKET_LOSS_PERC(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_PACKET_LOSS_PERC_REQUEST, x); }
42 	auto OPUS_SET_DTX(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_DTX_REQUEST, x); }
43 	auto OPUS_GET_DTX(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_DTX_REQUEST, x); }
44 	auto OPUS_SET_LSB_DEPTH(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_LSB_DEPTH_REQUEST, x); }
45 	auto OPUS_GET_LSB_DEPTH(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_LSB_DEPTH_REQUEST, x); }
46 	auto OPUS_SET_EXPERT_FRAME_DURATION(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, x); }
47 	auto OPUS_GET_EXPERT_FRAME_DURATION(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, x); }
48 	auto OPUS_SET_PREDICTION_DISABLED(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_PREDICTION_DISABLED_REQUEST, x); }
49 	auto OPUS_GET_PREDICTION_DISABLED(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_PREDICTION_DISABLED_REQUEST, x); }
50 	
51 	auto OPUS_GET_FINAL_RANGE(OpusEncoder* st, uint* x){ return opus_custom_encoder_ctl(st, OPUS_GET_FINAL_RANGE_REQUEST, x); }
52 	auto OPUS_GET_FINAL_RANGE(OpusDecoder* st, uint* x){ return opus_custom_decoder_ctl(st, OPUS_GET_FINAL_RANGE_REQUEST, x); }
53 	auto OPUS_GET_BANDWIDTH(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_BANDWIDTH_REQUEST, x); }
54 	auto OPUS_GET_BANDWIDTH(OpusDecoder* st, int* x){ return opus_custom_decoder_ctl(st, OPUS_GET_BANDWIDTH_REQUEST, x); }
55 	auto OPUS_GET_SAMPLE_RATE(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_SAMPLE_RATE_REQUEST, x); }
56 	auto OPUS_GET_SAMPLE_RATE(OpusDecoder* st, int* x){ return opus_custom_decoder_ctl(st, OPUS_GET_SAMPLE_RATE_REQUEST, x); }
57 	auto OPUS_SET_PHASE_INVERSION_DISABLED(OpusEncoder* st, int x){ return opus_custom_encoder_ctl(st, OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, x); }
58 	auto OPUS_SET_PHASE_INVERSION_DISABLED(OpusDecoder* st, int x){ return opus_custom_decoder_ctl(st, OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, x); }
59 	auto OPUS_GET_PHASE_INVERSION_DISABLED(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, x); }
60 	auto OPUS_GET_PHASE_INVERSION_DISABLED(OpusDecoder* st, int* x){ return opus_custom_decoder_ctl(st, OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, x); }
61 	auto OPUS_GET_IN_DTX(OpusEncoder* st, int* x){ return opus_custom_encoder_ctl(st, OPUS_GET_IN_DTX_REQUEST, x); }
62 	auto OPUS_GET_IN_DTX(OpusDecoder* st, int* x){ return opus_custom_decoder_ctl(st, OPUS_GET_IN_DTX_REQUEST, x); }
63 	
64 	auto OPUS_SET_GAIN(OpusDecoder* st, int x){ return opus_custom_decoder_ctl(st, OPUS_SET_GAIN_REQUEST, x); }
65 	auto OPUS_GET_GAIN(OpusDecoder* st, int* x){ return opus_custom_decoder_ctl(st, OPUS_GET_GAIN_REQUEST, x); }
66 	auto OPUS_GET_LAST_PACKET_DURATION(OpusDecoder* st, int* x){ return opus_custom_decoder_ctl(st, OPUS_GET_LAST_PACKET_DURATION_REQUEST, x); }
67 	auto OPUS_GET_PITCH(OpusDecoder* st, int* x){ return opus_custom_decoder_ctl(st, OPUS_GET_PITCH_REQUEST, x); }
68 }
69 
70 mixin(joinFnBinds((){
71 	FnBind[] ret = [
72 		{q{OpusCustomMode*}, q{opus_custom_mode_create}, q{int fs, int frameSize, int* error}},
73 		{q{void}, q{opus_custom_mode_destroy}, q{OpusCustomMode* mode}},
74 		{q{int}, q{opus_custom_encoder_get_size}, q{const(OpusCustomMode)* mode, int channels}},
75 		{q{int}, q{opus_custom_encoder_init}, q{OpusCustomEncoder* st, const(OpusCustomMode)* mode, int channels}},
76 		{q{OpusCustomEncoder*}, q{opus_custom_encoder_create}, q{const(OpusCustomMode)* mode, int channels, int* error}},
77 		{q{void}, q{opus_custom_encoder_destroy}, q{OpusCustomEncoder* st}},
78 		{q{int}, q{opus_custom_encode_float}, q{OpusCustomEncoder* st, const(float)* pcm, int frameSize, ubyte* compressed, int maxCompressedBytes}},
79 		{q{int}, q{opus_custom_encode}, q{OpusCustomEncoder* st, const(short)* pcm, int frameSize, ubyte* compressed, int maxCompressedBytes}},
80 		{q{int}, q{opus_custom_encoder_ctl}, q{OpusCustomEncoder* st, int request, ...}},
81 		{q{int}, q{opus_custom_decoder_get_size}, q{const(OpusCustomMode)* mode, int channels}},
82 		{q{int}, q{opus_custom_decoder_init}, q{OpusCustomDecoder* st, const(OpusCustomMode)* mode, int channels}},
83 		{q{OpusCustomDecoder*}, q{opus_custom_decoder_create}, q{const(OpusCustomMode)* mode, int channels, int* error}},
84 		{q{void}, q{opus_custom_decoder_destroy}, q{OpusCustomDecoder* st}},
85 		{q{int}, q{opus_custom_decode_float}, q{OpusCustomDecoder* st, const(ubyte)* data, int len, float* pcm, int frameSize}},
86 		{q{int}, q{opus_custom_decode}, q{OpusCustomDecoder* st, const(ubyte)* data, int len, short* pcm, int frameSize}},
87 		{q{int}, q{opus_custom_decoder_ctl}, q{OpusCustomDecoder* st, int request, ...}},
88 	];
89 	return ret;
90 }()));