toxcore/toxmsi/phone.h

63 lines
1.5 KiB
C
Raw Normal View History

2013-10-13 22:16:47 +08:00
#ifndef _PHONE_H_
#define _PHONE_H_
#include "toxmsi.h"
#include "../toxrtp/toxrtp.h"
#include "toxmsi_message.h"
#include "../toxrtp/toxrtp_message.h"
#include "../toxrtp/tests/test_helper.h"
#include <assert.h>
#include <pthread.h>
2013-10-28 21:19:38 +08:00
#include "toxmedia.h"
2013-10-13 22:16:47 +08:00
/* Define client version */
#define _USERAGENT "tox_phone-v.0.2.1"
static pthread_mutex_t _mutex;
#define THREADLOCK() \
pthread_mutex_lock ( &_mutex );
#define THREADUNLOCK() \
pthread_mutex_unlock ( &_mutex );
typedef struct phone_s {
msi_session_t* _msi;
rtp_session_t* _rtp_audio;
rtp_session_t* _rtp_video;
uint32_t _frame_rate;
uint16_t _send_port, _recv_port;
int _tox_sock;
pthread_t _medialoop_id;
codec_state *cs;
Networking_Core* _networking;
} phone_t;
phone_t* initPhone(uint16_t _listen_port, uint16_t _send_port);
int quitPhone(phone_t* _phone);
/* My recv functions */
int rtp_handlepacket ( void* _object, tox_IP_Port ip_port, uint8_t* data, uint32_t length );
int msi_handlepacket ( void* _object, tox_IP_Port ip_port, uint8_t* data, uint32_t length );
/* This is basically representation of networking_poll of toxcore */
void* phone_receivepacket ( void* _phone );
/* Phones main loop */
void* phone_poll ( void* _phone );
pthread_t phone_startmain_loop(phone_t* _phone);
pthread_t phone_startmedia_loop ( phone_t* _phone );
/* Thread handlers */
void* phone_handle_receive_callback ( void* _p );
void* phone_handle_media_transport_poll ( void* _hmtc_args_p );
#endif /* _PHONE_H_ */