2
The objective of the media_api is to construct and run the necessary processing
3
on audio and video data flows for a given call (two party call) or conference.
4
Copyright (C) 2001 Sharath Udupa skuds@gmx.net
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#include "basiccall.h"
22
#include "../mediastreamer/mscodec.h"
27
BasicCall *basic_call_new(){
28
BasicCall *bc = (BasicCall*) g_malloc(sizeof(BasicCall));
29
api_trace("basic_call_new: creating a basic call");
30
bc->memberA = call_member_new("memberA");
31
bc->memberB = call_member_new("memberB");
35
CallMember *basic_call_get_member(BasicCall *call, int member_nu){
36
api_trace("basic_call_get_member: called for %d",member_nu);
37
if(member_nu == MemberA){
40
else if(member_nu == MemberB){
45
void basic_call_add_flow(BasicCall *call, MediaFlow *flow){
46
api_trace("basic_call_add_flow: called for %s",flow->id);
47
call->flows = g_list_append( call->flows, flow);
51
int find_mediaflow(gconstpointer llist, gconstpointer flow){
52
//MediaFlow *mf = (MediaFlow *) ((BasicCallFlow*)llist)->mediaFlow;
53
if(((MediaFlow*)flow)->id == ((MediaFlow*)llist)->id){
59
int basic_call_start_flow(BasicCall *call, MediaFlow *flow){
64
Members *source, *destination;
67
GList *snd_read = NULL, *snd_write = NULL, *filter = NULL;
70
//This is initialized in media_api.c
71
//when should these functions be really called?
75
api_trace("basic_call_start_flow: called for flow %s", flow->id);
77
elem = g_list_find_custom( call->flows, flow, &find_mediaflow);
79
api_error("basic_call_start_flow: Called for unregistered mediaflow %s", flow->id);
82
nFlowDirections = g_list_length(flow->flowDirections);
83
if(flow->type == MEDIA_FLOW_VOICE){
85
sync = ms_timer_new();
91
for(i=0;i< nFlowDirections; i++){
93
if(syncFlag == MULTISYNC){
94
sync = ms_timer_new();
96
fd = (FlowDirections*)g_list_nth_data(flow->flowDirections,i);
98
destination = fd->destination;
100
media_flow_start_fd(fd, sync);
101
if(fd->type == MEDIA_FLOW_DUPLEX){
102
switch(source->tx_endpoint->protocol){
105
snd_read = g_list_append(snd_read, fd->recv);
107
switch(destination->rx_endpoint->protocol){
110
snd_write = g_list_append(snd_write, fd->play);
113
switch(destination->tx_endpoint->protocol){
116
snd_read = g_list_append(snd_read, fd->read);
119
switch(source->rx_endpoint->protocol){
122
snd_write = g_list_append(snd_write, fd->send);
126
else if(fd->type == MEDIA_FLOW_HALF_DUPLEX){
128
switch(source->tx_endpoint->protocol){
131
snd_read = g_list_append(snd_read, fd->recv);
133
switch(destination->rx_endpoint->protocol){
136
snd_write = g_list_append(snd_write, fd->play);
139
if(syncFlag == MULTISYNC){
140
flow->sync = g_list_append(flow->sync, sync);
143
if(syncFlag == ONESYNC){
145
flow->sync = g_list_append(flow->sync, sync);
147
if(syncFlag == MULTISYNC){
149
while(selem != NULL){
150
ms_start(selem->data);
151
selem = g_list_next(selem);
155
while(filter != NULL){
156
ms_sound_read_start(MS_SOUND_READ((MSFilter*)filter->data));
157
filter = g_list_next(filter);
161
while(filter != NULL){
162
ms_sound_write_start(MS_SOUND_WRITE((MSFilter*)filter->data));
163
filter = g_list_next(filter);
168
int basic_call_stop_flow(BasicCall *call, MediaFlow *flow){