| 1 | /* |
|---|
| 2 | * (C) 2011-2012 Michael 'Mickey' Lauer <mlauer@vanille-media.de> |
|---|
| 3 | */ |
|---|
| 4 | |
|---|
| 5 | [CCode (cprefix = "", lower_case_cprefix = "cmtspeech_")] |
|---|
| 6 | namespace CmtSpeech |
|---|
| 7 | { |
|---|
| 8 | /* Enums */ |
|---|
| 9 | |
|---|
| 10 | [CCode (cname = "gint", cprefix = "CMTSPEECH_STATE_", has_type_id = false, cheader_filename = "cmtspeech.h")] |
|---|
| 11 | public enum State |
|---|
| 12 | { |
|---|
| 13 | INVALID, |
|---|
| 14 | DISCONNECTED, |
|---|
| 15 | CONNECTED, |
|---|
| 16 | ACTIVE_DL, |
|---|
| 17 | ACTIVE_DLUL, |
|---|
| 18 | TEST_RAMP_PING_ACTIVE |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | [CCode (cname = "gint", cprefix = "CMTSPEECH_TR_", has_type_id = false, cheader_filename = "cmtspeech.h")] |
|---|
| 22 | public enum Transition |
|---|
| 23 | { |
|---|
| 24 | INVALID, |
|---|
| 25 | 0_NO_CHANGE, |
|---|
| 26 | 1_CONNECTED, |
|---|
| 27 | 2_DISCONNECTED, |
|---|
| 28 | 3_DL_START, |
|---|
| 29 | 4_DLUL_STOP, |
|---|
| 30 | 5_PARAM_UPDATE, |
|---|
| 31 | 6_TIMING_UPDATE, |
|---|
| 32 | 7_TIMING_UPDATE, |
|---|
| 33 | 10_RESET, |
|---|
| 34 | 11_UL_STOP, |
|---|
| 35 | 12_UL_START |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | [CCode (cname = "gint", cprefix = "CMTSPEECH_BUFFER_TYPE_", has_type_id = false, cheader_filename = "cmtspeech.h")] |
|---|
| 39 | public enum BufferType |
|---|
| 40 | { |
|---|
| 41 | PCM_S16_LE |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | [CCode (cname = "gint", cprefix = "CMTSPEECH_EVENT_", has_type_id = false, cheader_filename = "cmtspeech.h")] |
|---|
| 45 | public enum EventType |
|---|
| 46 | { |
|---|
| 47 | CONTROL, |
|---|
| 48 | DL_DATA, |
|---|
| 49 | XRUN |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | [CCode (cname = "gint", cprefix = "CMTSPEECH_DATA_TYPE_", has_type_id = false, cheader_filename = "cmtspeech.h")] |
|---|
| 53 | public enum FrameFlags |
|---|
| 54 | { |
|---|
| 55 | ZERO, |
|---|
| 56 | INVALID, |
|---|
| 57 | VALID |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | [CCode (cname = "gint", cprefix = "CMTSPEECH_SPC_FLAGS_", has_type_id = false, cheader_filename = "cmtspeech.h")] |
|---|
| 61 | public enum SpcFlags |
|---|
| 62 | { |
|---|
| 63 | SPEECH, |
|---|
| 64 | BFI, |
|---|
| 65 | ATTENUATE, |
|---|
| 66 | DEC_RESET, |
|---|
| 67 | MUTE, |
|---|
| 68 | PREV, |
|---|
| 69 | DTX_USED |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | [CCode (cname = "gint", cprefix = "CMTSPEECH_SAMPLE_RATE_", has_type_id = false, cheader_filename = "cmtspeech_msgs.h")] |
|---|
| 73 | public enum SampleRate |
|---|
| 74 | { |
|---|
| 75 | NONE, |
|---|
| 76 | 8KHZ, |
|---|
| 77 | 16KHZ |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | [CCode (cname = "gint", cprefix = "CMTSPEECH_TRACE_", has_type_id = false, cheader_filename = "cmtspeech_msgs.h")] |
|---|
| 81 | public enum TraceType |
|---|
| 82 | { |
|---|
| 83 | ERROR, |
|---|
| 84 | INFO, |
|---|
| 85 | STATE_CHANGE, |
|---|
| 86 | IO, |
|---|
| 87 | DEBUG, |
|---|
| 88 | INTERNAL |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | /* Structs */ |
|---|
| 92 | |
|---|
| 93 | [Compact] |
|---|
| 94 | [CCode (cname = "struct cmtspeech_buffer_s", free_function = "", cheader_filename = "cmtspeech.h")] |
|---|
| 95 | public class FrameBuffer |
|---|
| 96 | { |
|---|
| 97 | public BufferType type; /**< buffer type (CMTSPEECH_BUFFER_TYPE_*) */ |
|---|
| 98 | public int count; /**< octets of valid data (including header) */ |
|---|
| 99 | public int pcount; /**< octets of valid payload data */ |
|---|
| 100 | public int size; /**< octets of allocated space */ |
|---|
| 101 | public FrameFlags frame_flags; /**< frame flags; enum CMTSPEECH_DATATYPE_* */ |
|---|
| 102 | public SpcFlags spc_flags; /**< speech codec flags for the frame; |
|---|
| 103 | for UL: always set to zero, |
|---|
| 104 | for DL: bitmask of CMTSPEECH_SPC_FLAGS_* */ |
|---|
| 105 | public uint8* data; /**< pointer to a buffer of 'size' octets */ |
|---|
| 106 | public uint8* payload; /**< pointer to frame payload */ |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | [CCode (cname = "struct cmtspeech_event_s", destroy_function = "", cheader_filename = "cmtspeech.h,libcmtspeechdata.h")] |
|---|
| 110 | public struct Event |
|---|
| 111 | { |
|---|
| 112 | public State state; |
|---|
| 113 | public State prev_state; |
|---|
| 114 | public int msg_type; |
|---|
| 115 | public EventData msg; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | [CCode (cname = "CmtSpeechEventData", destroy_function = "", cheader_filename = "libcmtspeechdata.h")] |
|---|
| 119 | public struct EventData |
|---|
| 120 | { |
|---|
| 121 | public SsiConfigResp ssi_config_resp; |
|---|
| 122 | public SpeechConfigReq speech_config_req; |
|---|
| 123 | public TimingConfigNtf timing_config_ntf; |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | [CCode (cname = "CmtSpeechSsiConfigResp", destroy_function = "", cheader_filename = "libcmtspeechdata.h")] |
|---|
| 127 | public struct SsiConfigResp |
|---|
| 128 | { |
|---|
| 129 | public uint8 layout; |
|---|
| 130 | public uint8 version; |
|---|
| 131 | public uint8 result; |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | [CCode (cname = "CmtSpeechConfigReq", destroy_function = "", cheader_filename = "libcmtspeechdata.h")] |
|---|
| 135 | public struct SpeechConfigReq |
|---|
| 136 | { |
|---|
| 137 | public uint8 speech_data_stream; |
|---|
| 138 | public uint8 call_user_connect_ind; |
|---|
| 139 | public uint8 codec_info; |
|---|
| 140 | public uint8 cellular_info; |
|---|
| 141 | public uint8 sample_rate; |
|---|
| 142 | public uint8 data_format; |
|---|
| 143 | public bool layout_changed; |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | [CCode (cname = "CmtSpeechTimingConfigNtf", destroy_function = "", cheader_filename = "libcmtspeechdata.h")] |
|---|
| 147 | public struct TimingConfigNtf |
|---|
| 148 | { |
|---|
| 149 | uint16 msec; |
|---|
| 150 | uint16 usec; |
|---|
| 151 | Posix.timespec tstamp; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | /* Static */ |
|---|
| 155 | |
|---|
| 156 | public static string version_str(); |
|---|
| 157 | public static int protocol_version(); |
|---|
| 158 | public static void init(); |
|---|
| 159 | [CCode (has_target = false)] |
|---|
| 160 | public delegate void trace_handler_t( int priority, string message, va_list args ); |
|---|
| 161 | public static void trace_toggle( int priority, bool enabled ); |
|---|
| 162 | public static int set_trace_handler( trace_handler_t func ); |
|---|
| 163 | |
|---|
| 164 | /* Classes */ |
|---|
| 165 | |
|---|
| 166 | [Compact] |
|---|
| 167 | [CCode (cprefix = "cmtspeech_", cname = "cmtspeech_t", free_function = "cmtspeech_close", cheader_filename = "cmtspeech.h")] |
|---|
| 168 | public class Connection |
|---|
| 169 | { |
|---|
| 170 | [CCode (cname = "cmtspeech_open")] |
|---|
| 171 | public Connection(); |
|---|
| 172 | |
|---|
| 173 | //public int close(); |
|---|
| 174 | public int descriptor(); |
|---|
| 175 | public int check_pending( out EventType flags_mask ); |
|---|
| 176 | public int read_event( ref Event event ); |
|---|
| 177 | public Transition event_to_state_transition( Event event ); |
|---|
| 178 | |
|---|
| 179 | public int set_wb_preference( bool enabled ); |
|---|
| 180 | public State protocol_state(); |
|---|
| 181 | |
|---|
| 182 | public bool is_ssi_connection_enabled(); |
|---|
| 183 | public bool is_active(); |
|---|
| 184 | |
|---|
| 185 | public int state_change_call_status( bool state ); |
|---|
| 186 | public int state_change_call_connect( bool state ); |
|---|
| 187 | public int state_change_error(); |
|---|
| 188 | |
|---|
| 189 | public int ul_buffer_acquire( out FrameBuffer buffer ); |
|---|
| 190 | public int ul_buffer_release( FrameBuffer buffer ); |
|---|
| 191 | |
|---|
| 192 | public int dl_buffer_acquire( out FrameBuffer buffer ); |
|---|
| 193 | public int dl_buffer_release( FrameBuffer buffer ); |
|---|
| 194 | |
|---|
| 195 | public SampleRate buffer_codec_sample_rate(); |
|---|
| 196 | public SampleRate buffer_sample_rate(); |
|---|
| 197 | |
|---|
| 198 | public FrameBuffer dl_buffer_find_with_data( uint8* data); |
|---|
| 199 | |
|---|
| 200 | public string backend_name(); |
|---|
| 201 | public int backend_message( int type, int args, ... ); |
|---|
| 202 | public int send_timing_request(); |
|---|
| 203 | public int send_ssi_config_request( bool active ); |
|---|
| 204 | |
|---|
| 205 | public int test_data_ramp_req( uint8 rampstart, uint8 ramplen ); |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | } /* namespace CmtSpeech */ |
|---|
| 210 | |
|---|
| 211 | // vim:ts=4:sw=4:expandtab |
|---|