本文整理汇总了C++中TSK_DEBUG_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ TSK_DEBUG_ERROR函数的具体用法?C++ TSK_DEBUG_ERROR怎么用?C++ TSK_DEBUG_ERROR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TSK_DEBUG_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tcomp_udvm_runByteCode
/**Executes the bytecode.
*/
static tsk_bool_t tcomp_udvm_runByteCode(tcomp_udvm_t *udvm)
{
uint16_t operand_1, operand_2, operand_3, operand_4, operand_5, operand_6, operand_7;
tsk_bool_t excution_failed = tsk_false, end_message = tsk_false;
if(!udvm->isOK) {
TSK_DEBUG_ERROR("Cannot run()/execute() invalid bytecode");
return tsk_false;
}
// LOOP - EXCUTE all bytecode
while( !excution_failed && !end_message )
{
uint8_t udvm_instruction = * (TCOMP_UDVM_GET_BUFFER_AT(udvm->executionPointer));
udvm->last_memory_address_of_instruction = udvm->executionPointer;
udvm->executionPointer++; /* Skip the 1-byte [INSTRUCTION]. */
switch(udvm_instruction)
{
case TCOMP_UDVM_INST__DECOMPRESSION_FAILURE:
{
TCOMP_UDVM_EXEC_INST__DECOMPRESSION_FAILURE(udvm);
excution_failed = tsk_true;
break;
}
case TCOMP_UDVM_INST__AND:
{
operand_1 = tcomp_udvm_opget_reference_param(udvm);
operand_2 = tcomp_udvm_opget_multitype_param(udvm);
excution_failed = !TCOMP_UDVM_EXEC_INST__AND(udvm, operand_1, operand_2);
break;
}
case TCOMP_UDVM_INST__OR:
{
operand_1 = tcomp_udvm_opget_reference_param(udvm);
operand_2 = tcomp_udvm_opget_multitype_param(udvm);
excution_failed = !TCOMP_UDVM_EXEC_INST__OR(udvm, operand_1, operand_2);
break;
}
case TCOMP_UDVM_INST__NOT:
{
operand_1 = tcomp_udvm_opget_reference_param(udvm);
excution_failed = !TCOMP_UDVM_EXEC_INST__NOT(udvm, operand_1);
break;
}
case TCOMP_UDVM_INST__LSHIFT:
{
operand_1 = tcomp_udvm_opget_reference_param(udvm);
operand_2 = tcomp_udvm_opget_multitype_param(udvm);
excution_failed = !TCOMP_UDVM_EXEC_INST__LSHIFT(udvm, operand_1, operand_2);
break;
}
case TCOMP_UDVM_INST__RSHIFT:
{
operand_1 = tcomp_udvm_opget_reference_param(udvm);
operand_2 = tcomp_udvm_opget_multitype_param(udvm);
excution_failed = !TCOMP_UDVM_EXEC_INST__RSHIFT(udvm, operand_1, operand_2);
break;
}
case TCOMP_UDVM_INST__ADD:
{
operand_1 = tcomp_udvm_opget_reference_param(udvm);
operand_2 = tcomp_udvm_opget_multitype_param(udvm);
excution_failed = !TCOMP_UDVM_EXEC_INST__ADD(udvm, operand_1, operand_2);
break;
}
case TCOMP_UDVM_INST__SUBTRACT:
{
operand_1 = tcomp_udvm_opget_reference_param(udvm);
operand_2 = tcomp_udvm_opget_multitype_param(udvm);
excution_failed = !TCOMP_UDVM_EXEC_INST__SUBTRACT(udvm, operand_1, operand_2);
break;
}
case TCOMP_UDVM_INST__MULTIPLY:
{
operand_1 = tcomp_udvm_opget_reference_param(udvm);
operand_2 = tcomp_udvm_opget_multitype_param(udvm);
excution_failed = !TCOMP_UDVM_EXEC_INST__MULTIPLY(udvm, operand_1, operand_2);
break;
}
case TCOMP_UDVM_INST__DIVIDE:
{
operand_1 = tcomp_udvm_opget_reference_param(udvm);
operand_2 = tcomp_udvm_opget_multitype_param(udvm);
excution_failed = !TCOMP_UDVM_EXEC_INST__DIVIDE(udvm, operand_1, operand_2);
break;
}
case TCOMP_UDVM_INST__REMAINDER:
{
//.........这里部分代码省略.........
示例2: tipsec_run_command
int tipsec_run_command(TCHAR *args)
{
#define TIPSEC_PIPE_BUFFER 1024
DWORD bread=0,tid=0;
int ret = -1;
struct handleInfo hInfo;
TCHAR _args[MAX_PATH];
HANDLE writePipe, readPipe, hThread;
SECURITY_ATTRIBUTES secAttr = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
char buffer[TIPSEC_PIPE_BUFFER];
/* Create pipes */
if((ret = CreatePipe(&readPipe, &writePipe, &secAttr, 0)) == 0) {
TSK_DEBUG_ERROR("CreatePipe failed with error code [%d].", GetLastError());
ret = -5;
goto bail;
}
wsprintf(_args, TEXT("\"%s\" %s"), TEXT("ipsec6.exe"), args );
memset(buffer, 0, TIPSEC_PIPE_BUFFER);
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = NULL;
si.hStdOutput = writePipe;
si.hStdError = NULL;
/* Create process */
if (CreateProcess(NULL, _args, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi) == 0){
TSK_DEBUG_ERROR("CreateProcess failed with error code [%d].", GetLastError());
ret = -3;
goto bail;
}
hInfo.process = pi.hProcess;
hInfo.pipe = writePipe;
/* Create thread */
if((hThread = CreateThread(NULL, 0, tipsec_waitForExit, &hInfo, 0, &tid)) == NULL) {
TSK_DEBUG_ERROR("CreateThread failed with error code [%d].", GetLastError());
ret = -4;
goto bail;
}
/* For debugging */
#if defined(DEBUG) || defined(_DEBUG)
while (ReadFile(readPipe, buffer, TIPSEC_PIPE_BUFFER-2, &bread, NULL))
{
if(bread > 0){
TSK_DEBUG_INFO("IPSEC6 ==> %s\n-------------\n", buffer);
memset(buffer, 0, TIPSEC_PIPE_BUFFER); /* reset the buffer. */
}
}
#endif
ret = 0;
bail:
return ret;
}
示例3: tmedia_codec_init
/**@ingroup tmedia_codec_group
* Initialize a Codec
* @param self The codec to initialize. Could be any type of codec (e.g. @ref tmedia_codec_audio_t or @ref tmedia_codec_video_t).
* @param type
* @param name the name of the codec. e.g. "G.711u" or "G.711a" etc used in the sdp.
* @param desc full description.
* @param format the format. e.g. "0" for G.711.u or "8" for G.711a or "*" for MSRP.
* @retval Zero if succeed and non-zero error code otherwise.
*/
int tmedia_codec_init(tmedia_codec_t* self, tmedia_type_t type, const char* name, const char* desc, const char* format)
{
if(!self || tsk_strnullORempty(name)) {
TSK_DEBUG_ERROR("Invalid parameter");
return -1;
}
self->type = type;
tsk_strupdate(&self->name, name);
tsk_strupdate(&self->desc,desc);
tsk_strupdate(&self->format, format);
if(!self->bandwidth_max_upload) {
self->bandwidth_max_upload = (type == tmedia_video ? tmedia_defaults_get_bandwidth_video_upload_max() : INT_MAX); // INT_MAX or <=0 means undefined
}
if(!self->bandwidth_max_download) {
self->bandwidth_max_download = (type == tmedia_video ? tmedia_defaults_get_bandwidth_video_download_max() : INT_MAX); // INT_MAX or <=0 means undefined
}
if(!self->in.rate) {
self->in.rate = self->plugin->rate;
}
if(!self->out.rate) {
self->out.rate = self->plugin->rate;
}
if(type & tmedia_audio) {
tmedia_codec_audio_t* audio = TMEDIA_CODEC_AUDIO(self);
if(!audio->in.ptime) {
audio->in.ptime = (self->plugin->audio.ptime ? self->plugin->audio.ptime : tmedia_defaults_get_audio_ptime());
}
if(!audio->out.ptime) {
audio->out.ptime = (self->plugin->audio.ptime ? self->plugin->audio.ptime : tmedia_defaults_get_audio_ptime());
}
if(!audio->in.channels) {
audio->in.channels = self->plugin->audio.channels;
}
if(!audio->out.channels) {
audio->out.channels = self->plugin->audio.channels;
}
if(!audio->in.timestamp_multiplier) {
audio->in.timestamp_multiplier = tmedia_codec_audio_get_timestamp_multiplier(self->id, self->in.rate);
}
if(!audio->out.timestamp_multiplier) {
audio->out.timestamp_multiplier = tmedia_codec_audio_get_timestamp_multiplier(self->id, self->out.rate);
}
}
// Video flipping: For backward compatibility we have to initialize the default values
// according to the CFLAGS: 'FLIP_ENCODED_PICT' and 'FLIP_DECODED_PICT'. At any time you
// can update thse values (e.g. when the device switch from landscape to portrait) using video_session->set();
else if(type & tmedia_video) {
tmedia_codec_video_t* video = TMEDIA_CODEC_VIDEO(self);
#if FLIP_ENCODED_PICT
video->out.flip = tsk_true;
#endif
#if FLIP_DECODED_PICT
video->in.flip = tsk_true;
#endif
if(!video->in.fps) {
video->in.fps = self->plugin->video.fps ? self->plugin->video.fps : tmedia_defaults_get_video_fps();
}
if(!video->out.fps) {
video->out.fps = self->plugin->video.fps ? self->plugin->video.fps : tmedia_defaults_get_video_fps();
}
if(video->in.chroma == tmedia_chroma_none) {
video->in.chroma = tmedia_chroma_yuv420p;
}
if(video->out.chroma == tmedia_chroma_none) {
video->out.chroma = tmedia_chroma_yuv420p;
}
if(0) { // @deprecated
if(!video->in.width) {
video->in.width = video->out.width = self->plugin->video.width;
}
if(!video->in.height) {
video->in.height = video->out.height = self->plugin->video.height;
}
}
else {
int ret;
unsigned width, height;
video->pref_size = tmedia_defaults_get_pref_video_size();
if((ret = tmedia_video_get_size(video->pref_size, &width, &height)) != 0) {
width = self->plugin->video.width;
height = self->plugin->video.height;
}
if(!video->in.width) {
video->in.width = video->out.width = width;
}
if(!video->in.height) {
video->in.height = video->out.height = height;
}
}
//.........这里部分代码省略.........
示例4: tmsrp_receiver_recv
int tmsrp_receiver_recv(tmsrp_receiver_t* self, const void* data, tsk_size_t size)
{
tmsrp_message_t* message;
if(!self || !data || !size){
TSK_DEBUG_ERROR("Invalid parameter");
return -1;
}
// put the data
tmsrp_data_in_put(self->data_in, data, size);
// get msrp messages
while((message = tmsrp_data_in_get(self->data_in))){
/* alert that we have received a message (Request or Response) */
_tmsrp_receiver_alert_user(self, tsk_false, message);
//
// REQUEST
//
if(TMSRP_MESSAGE_IS_REQUEST(message)){
/* ============= SEND =============== */
if(TMSRP_REQUEST_IS_SEND(message)){
tmsrp_response_t* r2xx;
tmsrp_request_t* REPORT;
// send 200 OK
if((r2xx = tmsrp_create_response(message, 200, "OK"))){
if(tmsrp_message_serialize(r2xx, self->buffer) == 0 && self->buffer->data){
tnet_sockfd_send(self->fd, self->buffer->data, self->buffer->size, 0);
}
tsk_buffer_cleanup(self->buffer);
TSK_OBJECT_SAFE_FREE(r2xx);
}
// send REPORT
if(tmsrp_isReportRequired(message, tsk_false)){
if((REPORT = tmsrp_create_report(message, 200, "OK"))){
if(tmsrp_message_serialize(REPORT, self->buffer) == 0 && self->buffer->data){
tnet_sockfd_send(self->fd, self->buffer->data, self->buffer->size, 0);
}
tsk_buffer_cleanup(self->buffer);
TSK_OBJECT_SAFE_FREE(REPORT);
}
}
}
/* ============= REPORT =============== */
if(TMSRP_REQUEST_IS_REPORT(message)){
tmsrp_response_t* r2xx;
// send 200 OK
if((r2xx = tmsrp_create_response(message, 200, "Report received"))){
if(tmsrp_message_serialize(r2xx, self->buffer) == 0 && self->buffer->data){
tnet_sockfd_send(self->fd, self->buffer->data, self->buffer->size, 0);
}
tsk_buffer_cleanup(self->buffer);
TSK_OBJECT_SAFE_FREE(r2xx);
}
}
/* ============= AUTH =============== */
/* ============= METHOD =============== */
}
//
// RESPONSE
//
else{
//short code = TMSRP_RESPONSE_CODE(message);
//TSK_DEBUG_INFO("code=%u, tid=%s, phrase=%s", code, message->tid, TMSRP_RESPONSE_PHRASE(message));
}
// alert user layer
TSK_OBJECT_SAFE_FREE(message);
}
return 0;
}
示例5: tipsec_set_SPDs
int tipsec_set_SPDs(tipsec_context_xp_t* ctx_xp)
{
int ret = -1;
FILE* file = NULL;
char* str = NULL;
if(!ctx_xp){
goto bail;
}
if(TIPSEC_CONTEXT(ctx_xp)->state != state_full){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -3;
goto bail;
}
if(!(file = fopen(TINYIPSEC_IPSEC6_FILE_SPD, "wb+"))){
TSK_DEBUG_ERROR("Failed to open file [%s].", TINYIPSEC_IPSEC6_FILE_SPD);
ret = -4;
goto bail;
}
tsk_sprintf(&str, TINYIPSEC_IPSEC6_TEMPLATE_POLICY,
/* UC -> PS */
TINYIPSEC_IPSEC6_UCPS_POLICY,
TIPSEC_CONTEXT(ctx_xp)->addr_remote,
TIPSEC_CONTEXT(ctx_xp)->addr_local,
TINYIPSEC_XP_GET_IPPROTO(TIPSEC_CONTEXT(ctx_xp)->ipproto),
TIPSEC_CONTEXT(ctx_xp)->port_ps,
TIPSEC_CONTEXT(ctx_xp)->port_uc,
TINYIPSEC_XP_GET_PROTO(TIPSEC_CONTEXT(ctx_xp)->protocol),
TINYIPSEC_XP_GET_MODE(TIPSEC_CONTEXT(ctx_xp)->mode),
"*", /* RemoteGWIPAddr */
"NONE", /* SABundleIndex */
"BIDIRECT", /* Direction */
"APPLY", /* Action */
"0", /* InterfaceIndex */
/* US -> PC */
TINYIPSEC_IPSEC6_USPC_POLICY,
TIPSEC_CONTEXT(ctx_xp)->addr_remote,
TIPSEC_CONTEXT(ctx_xp)->addr_local,
TINYIPSEC_XP_GET_IPPROTO(TIPSEC_CONTEXT(ctx_xp)->ipproto),
TIPSEC_CONTEXT(ctx_xp)->port_pc,
TIPSEC_CONTEXT(ctx_xp)->port_us,
TINYIPSEC_XP_GET_PROTO(TIPSEC_CONTEXT(ctx_xp)->protocol),
TINYIPSEC_XP_GET_MODE(TIPSEC_CONTEXT(ctx_xp)->mode),
"*", /* RemoteGWIPAddr */
"NONE", /* SABundleIndex */
"BIDIRECT", /* Direction */
"APPLY", /* Action */
"0" /* InterfaceIndex */
);
fwrite(str, tsk_strlen(str), sizeof(uint8_t), file);
ret = 0;
bail:
if(file){
fclose(file);
}
if(str){
TSK_FREE(str);
}
return ret;
}
示例6: tnet_dtls_socket_do_handshake
int tnet_dtls_socket_do_handshake(tnet_dtls_socket_handle_t* handle, const struct sockaddr_storage* remote_addr)
{
#if !HAVE_OPENSSL || !HAVE_OPENSSL_DTLS
TSK_DEBUG_ERROR("OpenSSL or DTLS not enabled");
return -1;
#else
tnet_dtls_socket_t *socket = handle;
int ret = 0, len;
void* out_data;
if (!socket) {
TSK_DEBUG_ERROR("Invalid parameter");
return -1;
}
tsk_safeobj_lock(socket);
// update remote address even if handshaking is completed
if (remote_addr) {
socket->remote.addr = *remote_addr;
}
if (socket->handshake_completed) {
TSK_DEBUG_INFO("Handshake completed");
ret = 0;
goto bail;
}
if (!socket->handshake_started) {
if ((ret = SSL_do_handshake(socket->ssl)) != 1) {
switch ((ret = SSL_get_error(socket->ssl, ret))) {
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_NONE:
break;
default:
TSK_DEBUG_ERROR("DTLS handshake failed [%s]", ERR_error_string(ERR_get_error(), tsk_null));
_tnet_dtls_socket_raise_event_dataless(socket, tnet_dtls_socket_event_type_handshake_failed);
ret = -2;
goto bail;
}
}
socket->handshake_started = (ret == SSL_ERROR_NONE); // TODO: reset for renegotiation
}
if ((len = (int)BIO_get_mem_data(socket->wbio, &out_data)) > 0 && out_data) {
if (socket->handshake_storedata) { // e.g. when TURN is enabled we have to query handshaking data and sent it via the negotiated channel
if ((int)socket->handshake_data.size < len) {
if (!(socket->handshake_data.ptr = tsk_realloc(socket->handshake_data.ptr, len))) {
socket->handshake_data.size = 0;
socket->handshake_data.count = 0;
ret = -5;
goto bail;
}
socket->handshake_data.size = len;
}
socket->handshake_data.count = len;
memcpy(socket->handshake_data.ptr, out_data, len);
}
else {
int sentlen = 0;
tnet_port_t port;
tnet_ip_t ip;
tsk_bool_t is_dgram = TNET_SOCKET_TYPE_IS_DGRAM(socket->wrapped_sock->type);
const uint8_t *record_ptr, *records_ptr = out_data;
tsk_size_t record_size;
int records_len = len;
tnet_get_sockip_n_port((const struct sockaddr *)&socket->remote.addr, &ip, &port);
TSK_DEBUG_INFO("DTLS data handshake to send with len = %d, from(%.*s/%d) to(%.*s/%d)", len, (int)sizeof(socket->wrapped_sock->ip), socket->wrapped_sock->ip, socket->wrapped_sock->port, (int)sizeof(ip), ip, port);
//!\ IP fragmentation issues must be avoided even if the local transport is TCP/TLS because the relayed (TURN) transport could be UDP
while (records_len > 0 && (ret = tnet_dtls_socket_get_record_first(records_ptr, (tsk_size_t)records_len, &record_ptr, &record_size)) == 0) {
if (is_dgram) {
sentlen += tnet_sockfd_sendto(socket->wrapped_sock->fd, (const struct sockaddr *)&socket->remote.addr, record_ptr, record_size);
}
else {
sentlen += tnet_socket_send_stream(socket->wrapped_sock, record_ptr, record_size);
}
records_len -= (int)record_size;
records_ptr += record_size;
}
TSK_DEBUG_INFO("DTLS data handshake sent len = %d", sentlen);
}
}
BIO_reset(socket->rbio);
BIO_reset(socket->wbio);
if ((socket->handshake_completed = SSL_is_init_finished(socket->ssl))) {
TSK_DEBUG_INFO("DTLS handshake completed");
#if HAVE_OPENSSL_DTLS_SRTP
if (socket->use_srtp){
#if !defined(SRTP_MAX_KEY_LEN)
# define cipher_key_length (128 >> 3) // rfc5764 4.1.2. SRTP Protection Profiles
# define cipher_salt_length (112 >> 3) // rfc5764 4.1.2. SRTP Protection Profiles
// "cipher_key_length" is also equal to srtp_profile_get_master_key_length(srtp_profile_aes128_cm_sha1_80)
// "cipher_salt_length" is also srtp_profile_get_master_salt_length(srtp_profile_aes128_cm_sha1_80)
//.........这里部分代码省略.........
示例7: tnet_transport_tls_set_certs
int tnet_transport_tls_set_certs(tnet_transport_handle_t *handle, const char* ca, const char* pbk, const char* pvk, tsk_bool_t verify)
{
tnet_transport_t *transport = handle;
static const char* ssl_password = tsk_null;
if(!transport){
TSK_DEBUG_ERROR("Invalid parameter");
return -1;
}
tsk_strupdate(&transport->tls.ca, ca);
tsk_strupdate(&transport->tls.pvk, pvk);
tsk_strupdate(&transport->tls.pbk, pbk);
transport->tls.verify = verify;
#if HAVE_OPENSSL
{
int32_t i, ret;
SSL_CTX* contexts[3] = { tsk_null };
/* init DTLS/TLS contexts */
if((ret = _tnet_transport_ssl_init(transport))){
return ret;
}
if(transport->tls.enabled){
contexts[0] = transport->tls.ctx_client;
contexts[1] = transport->tls.ctx_server;
}
if(transport->dtls.enabled){
contexts[2] = transport->dtls.ctx;
/* Reset fingerprints */
memset(transport->dtls.fingerprints, 0, sizeof(transport->dtls.fingerprints));
}
for(i = 0; i < sizeof(contexts)/sizeof(contexts[0]); ++i){
if(!contexts[i]){
continue;
}
SSL_CTX_set_verify(contexts[i], transport->tls.verify ? (SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT) : SSL_VERIFY_NONE, tsk_null);
if(!tsk_strnullORempty(transport->tls.pbk) || !tsk_strnullORempty(transport->tls.pvk) || !tsk_strnullORempty(transport->tls.ca)){
/* Sets Public key (cert) */
if(!tsk_strnullORempty(transport->tls.pbk) && (ret = SSL_CTX_use_certificate_file(contexts[i], transport->tls.pbk, SSL_FILETYPE_PEM)) != 1) {
TSK_DEBUG_ERROR("SSL_CTX_use_certificate_file failed [%d,%s]", ret, ERR_error_string(ERR_get_error(), tsk_null));
return -3;
}
/*Sets the password of the private key*/
if(!tsk_strnullORempty(ssl_password)){
SSL_CTX_set_default_passwd_cb_userdata(contexts[i], (void*)ssl_password);
}
/* Sets Private key (cert) */
if (!tsk_strnullORempty(transport->tls.pvk) && (ret = SSL_CTX_use_PrivateKey_file(contexts[i], transport->tls.pvk, SSL_FILETYPE_PEM)) != 1) {
TSK_DEBUG_ERROR("SSL_CTX_use_PrivateKey_file failed [%d,%s]", ret, ERR_error_string(ERR_get_error(), tsk_null));
return -4;
}
/* Checks private key */
if(!tsk_strnullORempty(transport->tls.pvk) && SSL_CTX_check_private_key(contexts[i]) == 0) {
TSK_DEBUG_ERROR("SSL_CTX_check_private_key failed [%d,%s]", ret, ERR_error_string(ERR_get_error(), tsk_null));
return -5;
}
/* Sets trusted CAs and CA file */
if(!tsk_strnullORempty(transport->tls.ca) && (ret = SSL_CTX_load_verify_locations(contexts[i], transport->tls.ca, /*tlsdir_cas*/tsk_null)) != 1) {
TSK_DEBUG_ERROR("SSL_CTX_load_verify_locations failed [%d, %s]", ret, ERR_error_string(ERR_get_error(), tsk_null));
return -5;
}
}
}
}
#endif /* HAVE_OPENSSL */
return 0;
}
示例8: tnet_transport_connectto_3
tnet_fd_t tnet_transport_connectto_3(const tnet_transport_handle_t *handle, struct tnet_socket_s* socket, const char* host, tnet_port_t port, tnet_socket_type_t type)
{
tnet_transport_t *transport = (tnet_transport_t*)handle;
struct sockaddr_storage to;
int status = -1;
tnet_fd_t fd = socket ? socket->fd : TNET_INVALID_FD;
tnet_tls_socket_handle_t* tls_handle = tsk_null;
tsk_bool_t owe_socket = socket ? tsk_false : tsk_true;
tsk_bool_t use_proxy = TNET_SOCKET_TYPE_IS_STREAM(type);
const char* to_host = host;
tnet_port_t to_port = port;
tnet_socket_type_t to_type = type;
tnet_proxyinfo_t* proxy_info = tsk_null;
if (!transport || !transport->master) {
TSK_DEBUG_ERROR("Invalid transport handle");
goto bail;
}
if ((TNET_SOCKET_TYPE_IS_STREAM(transport->master->type) && !TNET_SOCKET_TYPE_IS_STREAM(type)) ||
(TNET_SOCKET_TYPE_IS_DGRAM(transport->master->type) && !TNET_SOCKET_TYPE_IS_DGRAM(type))) {
TSK_DEBUG_ERROR("Master/destination types mismatch [%u/%u]", transport->master->type, type);
goto bail;
}
if (use_proxy) {
// auto-detect the proxy
if (transport->proxy.auto_detect) {
char* url = tsk_null;
// The proxy detection implementations are designed for a browser and expect a "http://" or "https://" schemes (will work with socks).
tsk_sprintf(&url, "%s://%s:%d", TNET_SOCKET_TYPE_IS_TLS(to_type) ? "https" : "http", to_host, to_port);
proxy_info = tnet_proxydetect_get_info_fast(url, to_type);
TSK_FREE(url);
}
// fall-back to the hard proxy if auto-detection failed
if (!tnet_proxyinfo_is_valid(proxy_info) && tnet_proxyinfo_is_valid(transport->proxy.info)) {
proxy_info = tsk_object_ref(transport->proxy.info);
}
}
use_proxy &= tnet_proxyinfo_is_valid(proxy_info);
if (use_proxy) {
if (tnet_proxy_node_is_nettransport_supported(proxy_info->type, type)) {
to_host = proxy_info->hostname;
to_port = proxy_info->port;
// SOCKS still doesn't define RFC for SSL security (https://tools.ietf.org/html/draft-ietf-aft-socks-ssl-00) but Kerberos6 authentication is supported
if (proxy_info->type == tnet_proxy_type_http || proxy_info->type == tnet_proxy_type_socks4 || proxy_info->type == tnet_proxy_type_socks4a || proxy_info->type == tnet_proxy_type_socks5) {
// Send CONNET to the proxy using unsecure connection then begin SSL handshaking if needed
TNET_SOCKET_TYPE_UNSET(to_type, TLS); // Make the type unsecure (will keep other flags-e.g. IP version-)
TNET_SOCKET_TYPE_SET(to_type, TCP); // Use plain TCP
}
}
else {
// Not an error.
TSK_DEBUG_INFO("No proxy plugin to handle network transport type = %d", type);
use_proxy = tsk_false;
}
}
TSK_DEBUG_INFO("tnet_transport_connectto_3(host=%s, port=%d, type=%d, fd=%d, use_proxy=%d, to_host=%s, to_port=%d, to_type=%d, proxy_type=%d)" , host, port, type, fd, use_proxy, to_host, to_port, to_type, proxy_info ? proxy_info->type : 0);
/* Init destination sockaddr fields */
if ((status = tnet_sockaddr_init(to_host, to_port, to_type, &to))) {
TSK_DEBUG_ERROR("Invalid HOST/PORT [%s/%u]", host, port);
goto bail;
}
if (TNET_SOCKET_TYPE_IS_IPV46(type)) {
/* Update the type (unambiguously) */
if (to.ss_family == AF_INET6) {
TNET_SOCKET_TYPE_SET_IPV6Only(type);
}
else {
TNET_SOCKET_TYPE_SET_IPV4Only(type);
}
}
/*
* STREAM ==> create new socket and connect it to the remote host.
* DGRAM ==> connect the master to the remote host.
*/
if (fd == TNET_INVALID_FD) {
// Create client socket descriptor.
if ((status = tnet_sockfd_init(transport->local_host, TNET_SOCKET_PORT_ANY, to_type, &fd))) {
TSK_DEBUG_ERROR("Failed to create new sockfd.");
goto bail;
}
}
if ((status = tnet_sockfd_connectto(fd, (const struct sockaddr_storage *)&to))) {
if (fd != transport->master->fd) {
tnet_sockfd_close(&fd);
}
goto bail;
}
else {
static const tsk_bool_t __isClient = tsk_true;
if (TNET_SOCKET_TYPE_IS_TLS(to_type) || TNET_SOCKET_TYPE_IS_WSS(to_type)) {
#if HAVE_OPENSSL
tls_handle = tnet_tls_socket_create(fd, transport->tls.ctx_client);
if (socket) {
//.........这里部分代码省略.........
示例9: tnet_stun_attribute_deserialize
/**@ingroup tnet_stun_group
* Creates @ref tnet_stun_attribute_t from raw buffer.
* @param data Raw buffer from which to create the STUN attribute.*
* @param size The size of the eaw buffer.
* @retval @ref tnet_stun_attribute_t object if succeed and NULL other wise.
*/
tnet_stun_attribute_t* tnet_stun_attribute_deserialize(const void* data, tsk_size_t size)
{
tnet_stun_attribute_t *attribute = 0;
const uint8_t* dataPtr = data;
tnet_stun_attribute_type_t type = (tnet_stun_attribute_type_t)tnet_ntohs_2(dataPtr);
uint16_t length = tnet_ntohs_2(&dataPtr[2]);
/* Check validity */
if(!data || size<=4/* Type(2-bytes) plus Length (2-bytes) */)
{
return 0;
}
dataPtr += (2 /* Type */+ 2/* Length */);
/* Attribute Value
*/
switch(type)
{
/* RFC 5389 - 15.1. MAPPED-ADDRESS */
case stun_mapped_address:
{
attribute = (tnet_stun_attribute_t *)tnet_stun_attribute_mapped_address_create(dataPtr, length);
break;
}
/* RFC 5389 - 15.2. XOR-MAPPED-ADDRESS*/
case stun_xor_mapped_address:
{
attribute = (tnet_stun_attribute_t *)tnet_stun_attribute_xmapped_address_create(dataPtr, length);
break;
}
/* RFC 5389 - 15.3. USERNAME*/
case stun_username:
{
attribute = (tnet_stun_attribute_t *)tnet_stun_attribute_username_create(dataPtr, length);
break;
}
/* RFC 5389 - MESSAGE-INTEGRITY*/
case stun_message_integrity:
{
if(length == TSK_SHA1_DIGEST_SIZE){
attribute = (tnet_stun_attribute_t *)tnet_stun_attribute_integrity_create(dataPtr, length);
}
break;
}
/* RFC 5389 - 15.5. FINGERPRINT*/
case stun_fingerprint:
{
uint32_t fingerprint = tnet_htonl_2(dataPtr);
attribute = (tnet_stun_attribute_t *)tnet_stun_attribute_fingerprint_create(fingerprint);
break;
}
/* RFC 5389 - 15.6. ERROR-CODE*/
case stun_error_code:
{
attribute = (tnet_stun_attribute_t *)tnet_stun_attribute_errorcode_create(dataPtr, length);
break;
}
/* RFC 5389 - 15.7. REALM*/
case stun_realm:
{
attribute = (tnet_stun_attribute_t *)tnet_stun_attribute_realm_create(dataPtr, length);
break;
}
/* RFC 5389 - 15.8. NONCE*/
case stun_nonce:
{
attribute = (tnet_stun_attribute_t *)tnet_stun_attribute_nonce_create(dataPtr, length);
break;
}
/* RFC 5389 - 15.9. UNKNOWN-ATTRIBUTES*/
case stun_unknown_attributes:
{
TSK_DEBUG_ERROR("DESERIALIZE:UNKNOWN-ATTRIBUTES ==> NOT IMPLEMENTED");
attribute = tnet_stun_attribute_create();
break;
}
/* RFC 5389 - 15.10. SOFTWARE */
case stun_software:
{
attribute = (tnet_stun_attribute_t *)tnet_stun_attribute_software_create(dataPtr, length);
break;
//.........这里部分代码省略.........
示例10: tdav_codec_mp4ves_encap
static void tdav_codec_mp4ves_encap(tdav_codec_mp4ves_t* mp4v, const uint8_t* pdata, tsk_size_t size)
{
uint32_t scode; // start code
if(size <= 4/*32bits: start code size*/){
TSK_DEBUG_ERROR("Too short");
return;
}
// first 32bits
scode = tnet_htonl_2(pdata);
/* RFC 3016 - 3.3 Examples of packetized MPEG-4 Visual bitstream
VS= Visual Object Sequence
VO= Visual Object
VOL= Visual Object Layer
VOP= Visual Object Plane
GOV= Group of Visual Object Plane
VP= Video Plane
+------+------+------+------+
(a) | RTP | VS | VO | VOL |
|header|header|header|header|
+------+------+------+------+
+------+------+------+------+------------+
(b) | RTP | VS | VO | VOL |Video Packet|
|header|header|header|header| |
+------+------+------+------+------------+
+------+-----+------------------+
(c) | RTP | GOV |Video Object Plane|
|header| | |
+------+-----+------------------+
+------+------+------------+ +------+------+------------+
(d) | RTP | VOP |Video Packet| | RTP | VP |Video Packet|
|header|header| (1) | |header|header| (2) |
+------+------+------------+ +------+------+------------+
+------+------+------------+------+------------+------+------------+
(e) | RTP | VP |Video Packet| VP |Video Packet| VP |Video Packet|
|header|header| (1) |header| (2) |header| (3) |
+------+------+------------+------+------------+------+------------+
+------+------+------------+ +------+------------+
(f) | RTP | VOP |VOP fragment| | RTP |VOP fragment|
|header|header| (1) | |header| (2) | ___
+------+------+------------+ +------+------------+
Figure 2 - Examples of RTP packetized MPEG-4 Visual bitstream
*/
/* RFC 3016 - 3.2 Fragmentation of MPEG-4 Visual bitstream
A fragmented MPEG-4 Visual bitstream is mapped directly onto the RTP
payload without any addition of extra header fields or any removal of
Visual syntax elements. The Combined Configuration/Elementary
streams mode is used.
In the following, header means one of the following:
- Configuration information (Visual Object Sequence Header, Visual
Object Header and Video Object Layer Header)
- visual_object_sequence_end_code
- The header of the entry point function for an elementary stream
(Group_of_VideoObjectPlane() or the header of VideoObjectPlane(),
video_plane_with_short_header(), MeshObject() or FaceObject())
- The video packet header (video_packet_header() excluding
next_resync_marker())
- The header of gob_layer()
See 6.2.1 "Start codes" of ISO/IEC 14496-2 [2][9][4] for the
definition of the configuration information and the entry point
functions.
*/
switch(scode){
case visual_object_sequence_start_code:
case visual_object_start_code:
case user_data_start_code:
case video_object_layer_start_code:
case group_of_vop_start_code:
case vop_start_code:
{
register uint32_t i, last_index = 0;
int startcode = 0xffffffff;
if(scode == visual_object_sequence_start_code && size >=5){
//uint8_t profile_and_level_indication = pdata[4]; /* IEC 14496-2: 6.3.2 Visual Object Sequence and Visual Object */
// TSK_DEBUG_INFO("profile_and_level_indication=%d", profile_and_level_indication);
}
if(size < MP4V_RTP_PAYLOAD_SIZE){
goto last;
}
for(i = 4; i<(size - 4); i++){
startcode = (startcode <<8) | pdata[i];
switch(startcode){
case visual_object_sequence_start_code:
//.........这里部分代码省略.........
示例11: _tnet_transport_ssl_init
static int _tnet_transport_ssl_init(tnet_transport_t* transport)
{
if (!transport){
TSK_DEBUG_ERROR("Invalid parameter");
return -1;
}
#if HAVE_OPENSSL
{
tnet_socket_type_t type = tnet_transport_get_type(transport);
tsk_bool_t is_tls = (TNET_SOCKET_TYPE_IS_TLS(type) || TNET_SOCKET_TYPE_IS_WSS(type));
tsk_bool_t is_dtls = transport->dtls.enabled/* TNET_SOCKET_TYPE_IS_DTLS(type)*/; // DTLS-RTP, not raw DTLS
if (is_dtls && !tnet_dtls_is_supported()){
TSK_DEBUG_ERROR("Requesting to create DTLS transport but source code not built with support for this feature");
return -1;
}
if (is_tls && !tnet_tls_is_supported()){
TSK_DEBUG_ERROR("Requesting to create TLS transport but source code not built with support for this feature");
return -1;
}
if ((transport->tls.enabled = is_tls)){
if (!transport->tls.ctx_client && !(transport->tls.ctx_client = SSL_CTX_new(SSLv23_client_method()))){
TSK_DEBUG_ERROR("Failed to create SSL client context");
return -2;
}
if (!transport->tls.ctx_server && !(transport->tls.ctx_server = SSL_CTX_new(SSLv23_server_method()))){
TSK_DEBUG_ERROR("Failed to create SSL server context");
return -3;
}
SSL_CTX_set_mode(transport->tls.ctx_client, SSL_MODE_AUTO_RETRY);
SSL_CTX_set_mode(transport->tls.ctx_server, SSL_MODE_AUTO_RETRY);
SSL_CTX_set_verify(transport->tls.ctx_server, SSL_VERIFY_NONE, tsk_null); // to be updated by tnet_transport_tls_set_certs()
SSL_CTX_set_verify(transport->tls.ctx_client, SSL_VERIFY_NONE, tsk_null); // to be updated by tnet_transport_tls_set_certs()
if (SSL_CTX_set_cipher_list(transport->tls.ctx_client, TNET_CIPHER_LIST) <= 0 || SSL_CTX_set_cipher_list(transport->tls.ctx_server, TNET_CIPHER_LIST) <= 0){
TSK_DEBUG_ERROR("SSL_CTX_set_cipher_list failed [%s]", ERR_error_string(ERR_get_error(), tsk_null));
return -4;
}
}
#if HAVE_OPENSSL_DTLS
if ((transport->dtls.enabled = is_dtls)){
if (!transport->dtls.ctx && !(transport->dtls.ctx = SSL_CTX_new(DTLSv1_method()))){
TSK_DEBUG_ERROR("Failed to create DTLSv1 context");
TSK_OBJECT_SAFE_FREE(transport);
return -5;
}
SSL_CTX_set_read_ahead(transport->dtls.ctx, 1);
// SSL_CTX_set_options(transport->dtls.ctx, SSL_OP_ALL);
// SSL_CTX_set_mode(transport->dtls.ctx, SSL_MODE_AUTO_RETRY);
SSL_CTX_set_verify(transport->dtls.ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, tsk_null); // to be updated by tnet_transport_tls_set_certs()
if (SSL_CTX_set_cipher_list(transport->dtls.ctx, TNET_CIPHER_LIST) <= 0){
TSK_DEBUG_ERROR("SSL_CTX_set_cipher_list failed [%s]", ERR_error_string(ERR_get_error(), tsk_null));
return -6;
}
//!\ This is required even if the local transport is TCP/TLS because the relayed (TURN) transport could be UDP
// Up to the DTLS socket to set the default MTU value
SSL_CTX_set_options(transport->dtls.ctx, SSL_OP_NO_QUERY_MTU);
SSL_CTX_ctrl(transport->dtls.ctx, SSL_CTRL_SET_MTU, TNET_DTLS_MTU - 28, NULL);
transport->dtls.activated = tsk_true;
}
#endif /* HAVE_OPENSSL_DTLS */
}
#endif /* HAVE_OPENSSL */
return 0;
}
示例12: tdav_codec_mp4ves_open_encoder
/* ============ Internal functions ================= */
int tdav_codec_mp4ves_open_encoder(tdav_codec_mp4ves_t* self)
{
int ret, size;
int32_t max_bw_kpbs;
if(!self->encoder.codec && !(self->encoder.codec = avcodec_find_encoder(CODEC_ID_MPEG4))){
TSK_DEBUG_ERROR("Failed to find mp4v encoder");
return -1;
}
if(self->encoder.context){
TSK_DEBUG_ERROR("Encoder already opened");
return -1;
}
self->encoder.context = avcodec_alloc_context();
avcodec_get_context_defaults(self->encoder.context);
self->encoder.context->pix_fmt = PIX_FMT_YUV420P;
self->encoder.context->time_base.num = 1;
self->encoder.context->time_base.den = TMEDIA_CODEC_VIDEO(self)->in.fps;
self->encoder.context->width = (self->encoder.rotation == 90 || self->encoder.rotation == 270) ? TMEDIA_CODEC_VIDEO(self)->out.height : TMEDIA_CODEC_VIDEO(self)->out.width;
self->encoder.context->height = (self->encoder.rotation == 90 || self->encoder.rotation == 270) ? TMEDIA_CODEC_VIDEO(self)->out.width : TMEDIA_CODEC_VIDEO(self)->out.height;
self->encoder.context->mb_decision = FF_MB_DECISION_RD;
self->encoder.context->noise_reduction = 250;
self->encoder.context->flags |= CODEC_FLAG_QSCALE;
self->encoder.context->global_quality = FF_QP2LAMBDA * self->encoder.quality;
max_bw_kpbs = TSK_CLAMP(
0,
tmedia_get_video_bandwidth_kbps_2(TMEDIA_CODEC_VIDEO(self)->out.width, TMEDIA_CODEC_VIDEO(self)->out.height, TMEDIA_CODEC_VIDEO(self)->out.fps),
self->encoder.max_bw_kpbs
);
self->encoder.context->bit_rate = (max_bw_kpbs * 1024);// bps
self->encoder.context->rtp_payload_size = MP4V_RTP_PAYLOAD_SIZE;
self->encoder.context->opaque = tsk_null;
self->encoder.context->profile = self->profile>>4;
self->encoder.context->level = self->profile & 0x0F;
self->encoder.context->gop_size = (TMEDIA_CODEC_VIDEO(self)->in.fps * MP4V_GOP_SIZE_IN_SECONDS);
self->encoder.context->max_b_frames = 0;
self->encoder.context->b_frame_strategy = 1;
self->encoder.context->flags |= CODEC_FLAG_AC_PRED;
// Picture (YUV 420)
if(!(self->encoder.picture = avcodec_alloc_frame())){
TSK_DEBUG_ERROR("Failed to create MP4V-ES encoder picture");
return -2;
}
avcodec_get_frame_defaults(self->encoder.picture);
size = avpicture_get_size(PIX_FMT_YUV420P, self->encoder.context->width, self->encoder.context->height);
if(!(self->encoder.buffer = tsk_calloc(size, sizeof(uint8_t)))){
TSK_DEBUG_ERROR("Failed to allocate MP4V-ES encoder buffer");
return -2;
}
// Open encoder
if((ret = avcodec_open(self->encoder.context, self->encoder.codec)) < 0){
TSK_DEBUG_ERROR("Failed to open MP4V-ES encoder");
return ret;
}
TSK_DEBUG_INFO("[MP4V-ES] bitrate=%d bps", self->encoder.context->bit_rate);
return ret;
}
示例13: tdav_codec_mp4ves_decode
tsk_size_t tdav_codec_mp4ves_decode(tmedia_codec_t* _self, const void* in_data, tsk_size_t in_size, void** out_data, tsk_size_t* out_max_size, const tsk_object_t* proto_hdr)
{
tdav_codec_mp4ves_t* self = (tdav_codec_mp4ves_t*)_self;
const trtp_rtp_header_t* rtp_hdr = proto_hdr;
tsk_size_t xsize, retsize = 0;
int got_picture_ptr;
int ret;
if(!self || !in_data || !in_size || !out_data || !self->decoder.context){
TSK_DEBUG_ERROR("Invalid parameter");
return 0;
}
// get expected size
xsize = avpicture_get_size(self->decoder.context->pix_fmt, self->decoder.context->width, self->decoder.context->height);
/* Packet lost? */
if(self->decoder.last_seq != (rtp_hdr->seq_num - 1) && self->decoder.last_seq){
if(self->decoder.last_seq == rtp_hdr->seq_num){
// Could happen on some stupid emulators
TSK_DEBUG_INFO("Packet duplicated, seq_num=%d", rtp_hdr->seq_num);
return 0;
}
TSK_DEBUG_INFO("Packet lost, seq_num=%d", rtp_hdr->seq_num);
}
self->decoder.last_seq = rtp_hdr->seq_num;
if((self->decoder.accumulator_pos + in_size) <= xsize){
memcpy(&((uint8_t*)self->decoder.accumulator)[self->decoder.accumulator_pos], in_data, in_size);
self->decoder.accumulator_pos += in_size;
}
else{
TSK_DEBUG_WARN("Buffer overflow");
self->decoder.accumulator_pos = 0;
return 0;
}
if(rtp_hdr->marker){
AVPacket packet;
/* allocate destination buffer */
if(*out_max_size <xsize){
if(!(*out_data = tsk_realloc(*out_data, xsize))){
TSK_DEBUG_ERROR("Failed to allocate new buffer");
self->decoder.accumulator_pos = 0;
*out_max_size = 0;
return 0;
}
*out_max_size = xsize;
}
av_init_packet(&packet);
packet.size = (int)self->decoder.accumulator_pos;
packet.data = self->decoder.accumulator;
ret = avcodec_decode_video2(self->decoder.context, self->decoder.picture, &got_picture_ptr, &packet);
if(ret < 0){
TSK_DEBUG_WARN("Failed to decode the buffer with error code = %d", ret);
if(TMEDIA_CODEC_VIDEO(self)->in.callback){
TMEDIA_CODEC_VIDEO(self)->in.result.type = tmedia_video_decode_result_type_error;
TMEDIA_CODEC_VIDEO(self)->in.result.proto_hdr = proto_hdr;
TMEDIA_CODEC_VIDEO(self)->in.callback(&TMEDIA_CODEC_VIDEO(self)->in.result);
}
}
else if(got_picture_ptr){
retsize = xsize;
TMEDIA_CODEC_VIDEO(self)->in.width = self->decoder.context->width;
TMEDIA_CODEC_VIDEO(self)->in.height = self->decoder.context->height;
/* copy picture into a linear buffer */
avpicture_layout((AVPicture *)self->decoder.picture, self->decoder.context->pix_fmt, (int)self->decoder.context->width, (int)self->decoder.context->height,
*out_data, (int)retsize);
}
/* in all cases: reset accumulator */
self->decoder.accumulator_pos = 0;
}
return retsize;
}
示例14: tdav_speex_denoise_open
static int tdav_speex_denoise_open(tmedia_denoise_t* self, uint32_t frame_size, uint32_t sampling_rate)
{
tdav_speex_denoise_t *denoiser = (tdav_speex_denoise_t *)self;
float f;
int i;
if(!denoiser->echo_state && TMEDIA_DENOISE(denoiser)->echo_supp_enabled){
TSK_DEBUG_INFO("Init Aec frame_size[%u] filter_length[%u] SampleRate[%u]",
(uint32_t)(frame_size* sizeof(spx_int16_t)),TMEDIA_DENOISE(denoiser)->echo_tail*frame_size,sampling_rate);
if((denoiser->echo_state = speex_echo_state_init(frame_size, TMEDIA_DENOISE(denoiser)->echo_tail))){
speex_echo_ctl(denoiser->echo_state, SPEEX_ECHO_SET_SAMPLING_RATE, &sampling_rate);
}
}
if(!denoiser->preprocess_state_record && !denoiser->preprocess_state_playback){
denoiser->frame_size = frame_size;
if((denoiser->preprocess_state_record = speex_preprocess_state_init(frame_size, sampling_rate))
&& (denoiser->preprocess_state_playback = speex_preprocess_state_init(frame_size, sampling_rate))
){
// Echo suppression
if(denoiser->echo_state){
int echo_supp , echo_supp_active = 0;
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_ECHO_STATE, denoiser->echo_state);
TSK_FREE(denoiser->echo_output_frame);
denoiser->echo_output_frame = tsk_calloc(denoiser->frame_size, sizeof(spx_int16_t));
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_GET_ECHO_SUPPRESS , &echo_supp );
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE , &echo_supp_active );
TSK_DEBUG_INFO("AEC echo_supp level [%d] echo_supp_active level[%d] ", echo_supp , echo_supp_active);
echo_supp = -60 ;
echo_supp_active = -60 ;
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS , &echo_supp );
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE , &echo_supp_active );
// TRACES
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_GET_ECHO_SUPPRESS , &echo_supp );
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE , &echo_supp_active );
TSK_DEBUG_INFO("New aec echo_supp level [%d] echo_supp_active level[%d] ", echo_supp , echo_supp_active);
}
// Noise suppression
if(TMEDIA_DENOISE(denoiser)->noise_supp_enabled){
TSK_DEBUG_INFO("SpeexDSP: Noise supp enabled");
i = 1;
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_DENOISE, &i);
speex_preprocess_ctl(denoiser->preprocess_state_playback, SPEEX_PREPROCESS_SET_DENOISE, &i);
i = TMEDIA_DENOISE(denoiser)->noise_supp_level;
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &i);
speex_preprocess_ctl(denoiser->preprocess_state_playback, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &i);
}
else{
i = 0;
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_DENOISE, &i);
speex_preprocess_ctl(denoiser->preprocess_state_playback, SPEEX_PREPROCESS_SET_DENOISE, &i);
}
// Automatic gain control
if(TMEDIA_DENOISE(denoiser)->agc_enabled){
float agc_level = TMEDIA_DENOISE(denoiser)->agc_level;
TSK_DEBUG_INFO("SpeexDSP: AGC enabled");
i = 1;
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_AGC, &i);
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_AGC_LEVEL, &agc_level);
}
else{
i = 0, f = 8000.0f;
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_AGC, &i);
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_AGC_LEVEL, &f);
}
// Voice Activity detection
i = TMEDIA_DENOISE(denoiser)->vad_enabled ? 1 : 0;
speex_preprocess_ctl(denoiser->preprocess_state_record, SPEEX_PREPROCESS_SET_VAD, &i);
return 0;
}
else{
TSK_DEBUG_ERROR("Failed to create Speex preprocessor state");
return -2;
}
}
return 0;
}
示例15: tdav_speex_jitterbuffer_set
static int tdav_speex_jitterbuffer_set(tmedia_jitterbuffer_t *self, const tmedia_param_t* param)
{
TSK_DEBUG_ERROR("Not implemented");
return -2;
}