7 #include <tapi-device.h>
12 struct agent
*agents
[2];
14 struct tapi_device
*tdev
;
16 void (*release
)(struct session
*);
21 struct session
*session_alloc(struct tapi_device
*dev
, struct agent
*caller
,
22 struct agent
*callee
, void (*release
)(struct session
*))
24 struct session
*session
;
27 session
= malloc(sizeof(*session
));
31 session
->agents
[0] = caller
;
32 session
->agents
[1] = callee
;
34 ret
= agent_invite(callee
, session
);
36 session_hangup(session
, callee
);
41 session
->release
= release
;
46 void session_accept(struct session
*session
, struct agent
*agent
)
50 printf("session_accept: %p %p\n", session
, agent
);
51 printf("session agents: %p %p\n", session
->agents
[0], session
->agents
[1]);
52 printf("session tdev: %p\n", session
->tdev
);
54 agent_accept(session
->agents
[0], session
);
56 ep
[0] = agent_get_endpoint(session
->agents
[0], session
);
57 ep
[1] = agent_get_endpoint(session
->agents
[1], session
);
58 session
->link
= tapi_link_alloc(session
->tdev
, ep
[0], ep
[1]);
60 printf("eps: %d %d\n", ep
[0], ep
[1]);
62 tapi_link_enable(session
->tdev
, session
->link
);
64 tapi_sync(session
->tdev
);
67 void session_hangup(struct session
*session
, struct agent
*agent
)
69 struct agent
*other_agent
;
71 if (session
->agents
[0] == agent
)
72 other_agent
= session
->agents
[1];
74 other_agent
= session
->agents
[0];
76 agent_hangup(other_agent
, session
);
78 tapi_link_disable(session
->tdev
, session
->link
);
79 tapi_link_free(session
->tdev
, session
->link
);
80 tapi_sync(session
->tdev
);
83 session
->release(session
);
This page took 0.059188 seconds and 5 git commands to generate.