sipomatic.h 2.62 KB
Newer Older
aymeric's avatar
aymeric committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
/***************************************************************************
                          linphone  - sipomatic.c
This is a test program for linphone. It acts as a sip server and answers to linphone's
call.
                             -------------------
    begin                : ven mar  30
    copyright            : (C) 2001 by Simon MORLAT
    email                : simon.morlat@free.fr
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/


#include "../coreapi/linphonecore.h"
#include "../coreapi/sdphandler.h"
#include <eXosip2/eXosip.h>
#undef PACKAGE
#undef VERSION
#include "mediastreamer2/mediastream.h"

#include <ortp/ortp.h>
#include <ortp/telephonyevents.h>


#define ANNOUCE_FILE8000HZ	"hello8000.wav"
#define ANNOUCE_FILE16000HZ	"hello16000.wav"

struct _Sipomatic
{
	ms_mutex_t lock;
	MSList *calls;
	double acceptance_time;
	double max_call_time;
	char *file_path8000hz;
	char *file_path16000hz;
	bool_t ipv6;
};

typedef struct _Sipomatic Sipomatic;
	
void sipomatic_init(Sipomatic *obj, char *url, bool_t ipv6);
void sipomatic_uninit(Sipomatic *obj);
void sipomatic_iterate(Sipomatic *obj);
#define sipomatic_lock(obj) ms_mutex_lock(&(obj)->lock);
#define sipomatic_unlock(obj) ms_mutex_unlock(&(obj)->lock);

void sipomatic_set_annouce_file(Sipomatic *obj, char *file);

struct stream_params{
	int ncodecs;
	int line;
	int localport;
	int remoteport;
	int pt;
	char *remaddr;
};

struct _Call
{
	Sipomatic *root;
	sdp_context_t *sdpc;
	int time;
	int did;
	int tid;
	AudioStream *audio_stream;
#ifdef VIDEO_ENABLED
	VideoStream *video_stream;
#endif
	int state;
	struct _CallParams *params;
	int eof;
	RtpProfile *profile;
	struct stream_params audio;
	struct stream_params video;
};

#define CALL_STATE_INIT 0
#define CALL_STATE_RUNNING 1
#define CALL_STATE_FINISHED 2

typedef struct _Call Call;

	
Call * call_new(Sipomatic *obj, eXosip_event_t *ev);
void call_accept(Call *call);
void call_release(Call *call);
void call_destroy(Call *call);

Call* sipomatic_find_call(Sipomatic *obj,int cid);