mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed header protectors and cleaning up the msi
This commit is contained in:
parent
8c245affb1
commit
7329f3b3d4
|
@ -21,8 +21,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CODEC_H_
|
#ifndef CODEC_H
|
||||||
#define _CODEC_H_
|
#define CODEC_H
|
||||||
|
|
||||||
#include "toxav.h"
|
#include "toxav.h"
|
||||||
#include "rtp.h"
|
#include "rtp.h"
|
||||||
|
@ -186,4 +186,4 @@ void cs_disable_audio_receiving(CSSession* cs);
|
||||||
|
|
||||||
/* Internal. Called from rtp_handle_message */
|
/* Internal. Called from rtp_handle_message */
|
||||||
void queue_message(RTPSession *session, RTPMessage *msg);
|
void queue_message(RTPSession *session, RTPMessage *msg);
|
||||||
#endif /* _CODEC_H_ */
|
#endif /* CODEC_H */
|
||||||
|
|
867
toxav/msi.c
867
toxav/msi.c
File diff suppressed because it is too large
Load Diff
89
toxav/msi.h
89
toxav/msi.h
|
@ -19,8 +19,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __TOXMSI
|
#ifndef MSI_H
|
||||||
#define __TOXMSI
|
#define MSI_H
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
@ -40,6 +40,23 @@ typedef enum {
|
||||||
msi_TypeVideo
|
msi_TypeVideo
|
||||||
} MSICallType;
|
} MSICallType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error codes.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
msi_ErrUndisclosed,
|
||||||
|
} MSIError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supported capabilities
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
msi_CapSAudio = 1, /* sending audio */
|
||||||
|
msi_CapSVideo = 2, /* sending video */
|
||||||
|
msi_CapRAudio = 4, /* receiving audio */
|
||||||
|
msi_CapRVideo = 8, /* receiving video */
|
||||||
|
} MSICapabilities;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call state identifiers.
|
* Call state identifiers.
|
||||||
|
@ -70,16 +87,6 @@ typedef struct {
|
||||||
uint32_t audio_channels;
|
uint32_t audio_channels;
|
||||||
} MSICSettings;
|
} MSICSettings;
|
||||||
|
|
||||||
/**
|
|
||||||
* Active capabilities masks
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
msi_SendingAudio = 1,
|
|
||||||
msi_SendingVideo = 2,
|
|
||||||
msi_RecvingAudio = 4,
|
|
||||||
msi_RecvingVideo = 8,
|
|
||||||
} MSICapMask;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callbacks ids that handle the states
|
* Callbacks ids that handle the states
|
||||||
*/
|
*/
|
||||||
|
@ -87,9 +94,9 @@ typedef enum {
|
||||||
msi_OnInvite, /* Incoming call */
|
msi_OnInvite, /* Incoming call */
|
||||||
msi_OnRinging, /* When peer is ready to accept/reject the call */
|
msi_OnRinging, /* When peer is ready to accept/reject the call */
|
||||||
msi_OnStart, /* Call (RTP transmission) started */
|
msi_OnStart, /* Call (RTP transmission) started */
|
||||||
msi_OnCancel, /* The side that initiated call canceled invite */
|
|
||||||
msi_OnReject, /* The side that was invited rejected the call */
|
msi_OnReject, /* The side that was invited rejected the call */
|
||||||
msi_OnEnd, /* Call that was active ended */
|
msi_OnEnd, /* Call that was active ended */
|
||||||
|
msi_OnError, /* Call that was active ended */
|
||||||
msi_OnRequestTimeout, /* When the requested action didn't get response in specified time */
|
msi_OnRequestTimeout, /* When the requested action didn't get response in specified time */
|
||||||
msi_OnPeerTimeout, /* Peer timed out; stop the call */
|
msi_OnPeerTimeout, /* Peer timed out; stop the call */
|
||||||
msi_OnPeerCSChange, /* Peer requested Csettings change */
|
msi_OnPeerCSChange, /* Peer requested Csettings change */
|
||||||
|
@ -107,25 +114,30 @@ typedef enum {
|
||||||
} MSIError;
|
} MSIError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The call struct.
|
* The call struct. Please do not modify outside msi.c
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct MSICall_s {
|
||||||
struct MSISession_s *session; /* Session pointer */
|
struct MSISession_s *session; /* Session pointer */
|
||||||
|
|
||||||
MSICallState state;
|
MSICallState state;
|
||||||
uint8_t caps; /* Active capabilities */
|
uint8_t capabilities; /* Active capabilities */
|
||||||
|
|
||||||
uint32_t friend_id; /* Index of this call in MSISession */
|
uint32_t friend_id; /* Index of this call in MSISession */
|
||||||
|
|
||||||
|
struct MSICall_s* next;
|
||||||
|
struct MSICall_s* prev;
|
||||||
} MSICall;
|
} MSICall;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Control session struct
|
* Control session struct. Please do not modify outside msi.c
|
||||||
*/
|
*/
|
||||||
typedef struct MSISession_s {
|
typedef struct MSISession_s {
|
||||||
/* Call handlers */
|
/* Call handlers */
|
||||||
MSICall **calls;
|
MSICall **calls;
|
||||||
|
uint32_t calls_tail;
|
||||||
|
uint32_t calls_head;
|
||||||
|
|
||||||
void *agent_handler;
|
void *agent_handler;
|
||||||
Messenger *messenger_handle;
|
Messenger *messenger_handle;
|
||||||
|
|
||||||
|
@ -139,7 +151,7 @@ typedef struct MSISession_s {
|
||||||
MSISession *msi_new ( Messenger *messenger, int32_t max_calls );
|
MSISession *msi_new ( Messenger *messenger, int32_t max_calls );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminate control session.
|
* Terminate control session. NOTE: all calls will be freed
|
||||||
*/
|
*/
|
||||||
int msi_kill ( MSISession *session );
|
int msi_kill ( MSISession *session );
|
||||||
|
|
||||||
|
@ -151,45 +163,26 @@ void msi_register_callback(MSISession *session, MSICallbackType callback, MSICal
|
||||||
/**
|
/**
|
||||||
* Send invite request to friend_id.
|
* Send invite request to friend_id.
|
||||||
*/
|
*/
|
||||||
int msi_invite ( MSISession *session,
|
int msi_invite ( MSISession* session, MSICall** call, uint32_t friend_id, uint8_t capabilities );
|
||||||
int32_t *call_index,
|
|
||||||
const MSICSettings *csettings,
|
|
||||||
uint32_t rngsec,
|
|
||||||
uint32_t friend_id );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hangup active call.
|
* Hangup call. NOTE: 'call' will be freed
|
||||||
*/
|
*/
|
||||||
int msi_hangup ( MSISession *session, int32_t call_index );
|
int msi_hangup ( MSICall* call );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Answer active call request.
|
* Answer call request.
|
||||||
*/
|
*/
|
||||||
int msi_answer ( MSISession *session, int32_t call_index, const MSICSettings *csettings );
|
int msi_answer ( MSICall* call, uint8_t capabilities );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel request.
|
* Reject incoming call. NOTE: 'call' will be freed
|
||||||
*/
|
*/
|
||||||
int msi_cancel ( MSISession *session, int32_t call_index, uint32_t peer, const char *reason );
|
int msi_reject ( MSICall* call );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reject incoming call.
|
* Change capabilities of the call.
|
||||||
*/
|
*/
|
||||||
int msi_reject ( MSISession *session, int32_t call_index, const char *reason );
|
int msi_change_capabilities ( MSICall* call, uint8_t capabilities );
|
||||||
|
|
||||||
/**
|
#endif /* MSI_H */
|
||||||
* Terminate the call.
|
|
||||||
*/
|
|
||||||
int msi_stopcall ( MSISession *session, int32_t call_index );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change codec settings of the current call.
|
|
||||||
*/
|
|
||||||
int msi_change_csettings ( MSISession *session, int32_t call_index, const MSICSettings *csettings );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main msi loop
|
|
||||||
*/
|
|
||||||
void msi_do( MSISession *session );
|
|
||||||
|
|
||||||
#endif /* __TOXMSI */
|
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __TOXRTP
|
#ifndef RTP_H
|
||||||
#define __TOXRTP
|
#define RTP_H
|
||||||
|
|
||||||
#define RTP_VERSION 2
|
#define RTP_VERSION 2
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
@ -130,4 +130,4 @@ void rtp_free_msg ( RTPSession *session, RTPMessage *msg );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __TOXRTP */
|
#endif /* RTP_H */
|
||||||
|
|
|
@ -83,7 +83,6 @@ struct toxAV
|
||||||
void i_toxav_msi_callback_invite(void* toxav_inst, int32_t call_idx, void *data);
|
void i_toxav_msi_callback_invite(void* toxav_inst, int32_t call_idx, void *data);
|
||||||
void i_toxav_msi_callback_ringing(void* toxav_inst, int32_t call_idx, void *data);
|
void i_toxav_msi_callback_ringing(void* toxav_inst, int32_t call_idx, void *data);
|
||||||
void i_toxav_msi_callback_start(void* toxav_inst, int32_t call_idx, void *data);
|
void i_toxav_msi_callback_start(void* toxav_inst, int32_t call_idx, void *data);
|
||||||
void i_toxav_msi_callback_cancel(void* toxav_inst, int32_t call_idx, void *data);
|
|
||||||
void i_toxav_msi_callback_reject(void* toxav_inst, int32_t call_idx, void *data);
|
void i_toxav_msi_callback_reject(void* toxav_inst, int32_t call_idx, void *data);
|
||||||
void i_toxav_msi_callback_end(void* toxav_inst, int32_t call_idx, void *data);
|
void i_toxav_msi_callback_end(void* toxav_inst, int32_t call_idx, void *data);
|
||||||
void i_toxav_msi_callback_request_to(void* toxav_inst, int32_t call_idx, void *data); /* TODO remove */
|
void i_toxav_msi_callback_request_to(void* toxav_inst, int32_t call_idx, void *data); /* TODO remove */
|
||||||
|
@ -138,7 +137,6 @@ ToxAV* toxav_new(Tox* tox, TOXAV_ERR_NEW* error)
|
||||||
msi_register_callback(av->msi, i_toxav_msi_callback_invite, msi_OnInvite, NULL);
|
msi_register_callback(av->msi, i_toxav_msi_callback_invite, msi_OnInvite, NULL);
|
||||||
msi_register_callback(av->msi, i_toxav_msi_callback_ringing, msi_OnRinging, NULL);
|
msi_register_callback(av->msi, i_toxav_msi_callback_ringing, msi_OnRinging, NULL);
|
||||||
msi_register_callback(av->msi, i_toxav_msi_callback_start, msi_OnStart, NULL);
|
msi_register_callback(av->msi, i_toxav_msi_callback_start, msi_OnStart, NULL);
|
||||||
msi_register_callback(av->msi, i_toxav_msi_callback_cancel, msi_OnCancel, NULL);
|
|
||||||
msi_register_callback(av->msi, i_toxav_msi_callback_reject, msi_OnReject, NULL);
|
msi_register_callback(av->msi, i_toxav_msi_callback_reject, msi_OnReject, NULL);
|
||||||
msi_register_callback(av->msi, i_toxav_msi_callback_end, msi_OnEnd, NULL);
|
msi_register_callback(av->msi, i_toxav_msi_callback_end, msi_OnEnd, NULL);
|
||||||
msi_register_callback(av->msi, i_toxav_msi_callback_request_to, msi_OnRequestTimeout, NULL);
|
msi_register_callback(av->msi, i_toxav_msi_callback_request_to, msi_OnRequestTimeout, NULL);
|
||||||
|
@ -588,17 +586,6 @@ void i_toxav_msi_callback_start(void* toxav_inst, int32_t call_idx, void* data)
|
||||||
toxav->scb.first(toxav, call->friend_number, state, toxav->scb.second);
|
toxav->scb.first(toxav, call->friend_number, state, toxav->scb.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
void i_toxav_msi_callback_cancel(void* toxav_inst, int32_t call_idx, void* data)
|
|
||||||
{
|
|
||||||
ToxAV* toxav = toxav_inst;
|
|
||||||
|
|
||||||
i_toxav_remove_call(toxav, toxav->msi->calls[call_idx]->peers[0]);
|
|
||||||
|
|
||||||
if (toxav->scb.first)
|
|
||||||
toxav->scb.first(toxav, toxav->msi->calls[call_idx]->peers[0],
|
|
||||||
TOXAV_CALL_STATE_END, toxav->scb.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
void i_toxav_msi_callback_reject(void* toxav_inst, int32_t call_idx, void* data)
|
void i_toxav_msi_callback_reject(void* toxav_inst, int32_t call_idx, void* data)
|
||||||
{
|
{
|
||||||
ToxAV* toxav = toxav_inst;
|
ToxAV* toxav = toxav_inst;
|
||||||
|
@ -918,7 +905,6 @@ void i_toxav_kill_transmission(ToxAV* av, uint32_t friend_number)
|
||||||
|
|
||||||
if (!call->active) {
|
if (!call->active) {
|
||||||
pthread_mutex_unlock(call->mutex_control);
|
pthread_mutex_unlock(call->mutex_control);
|
||||||
LOGGER_WARNING("Action on inactive call: %d", call->call_idx);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#pragma once
|
#ifndef TOXAV_H
|
||||||
|
#define TOXAV_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -480,4 +482,6 @@ typedef void toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number,
|
||||||
/**
|
/**
|
||||||
* Set the callback for the `receive_audio_frame` event. Pass NULL to unset.
|
* Set the callback for the `receive_audio_frame` event. Pass NULL to unset.
|
||||||
*/
|
*/
|
||||||
void toxav_callback_receive_audio_frame(ToxAV *av, toxav_receive_audio_frame_cb *function, void *user_data);
|
void toxav_callback_receive_audio_frame(ToxAV *av, toxav_receive_audio_frame_cb *function, void *user_data);
|
||||||
|
|
||||||
|
#endif /* TOXAV_H */
|
Loading…
Reference in New Issue
Block a user