2 The objective of the media_api is to construct and run the necessary processing
\r
3 on audio and video data flows for a given call (two party call) or conference.
\r
4 Copyright (C) 2001 Sharath Udupa skuds@gmx.net
\r
6 This library is free software; you can redistribute it and/or
\r
7 modify it under the terms of the GNU Lesser General Public
\r
8 License as published by the Free Software Foundation; either
\r
9 version 2.1 of the License, or (at your option) any later version.
\r
11 This library is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
14 Lesser General Public License for more details.
\r
16 You should have received a copy of the GNU Lesser General Public
\r
17 License along with this library; if not, write to the Free Software
\r
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
22 #include "callmember.h"
\r
23 #include "mediaflow.h"
\r
26 CallMember *call_member_new(char *name){
\r
27 CallMember *member = (CallMember*) g_malloc(sizeof(CallMember));
\r
28 api_trace("call_member_new: creating %s", name);
\r
29 member->name = name;
\r
30 member->flows = NULL;
\r
31 member->profile = NULL;
\r
35 int call_member_set_rtp_profile(CallMember *member, RtpProfile *profile){
\r
36 member->profile = profile;
\r
40 int call_member_setup_flow(CallMember *member, MediaFlow *flow, char* rx, char *tx){
\r
41 Members *mem = (Members*) g_malloc(sizeof(Members));
\r
42 Flows *flows = (Flows*) g_malloc(sizeof(Flows));
\r
43 api_trace("call_member_setup_flow: setting up flow for: CallMember->%s , MediaFlow->%s", member->name, flow->id);
\r
44 mem->member = member;
\r
45 mem->rx_endpoint = parse_end_point(rx);
\r
46 mem->tx_endpoint = parse_end_point(tx);
\r
47 flow->members = g_list_append(flow->members, mem);
\r
50 flows->rx_endpoint = parse_end_point(rx);
\r
51 flows->tx_endpoint = parse_end_point(tx);
\r
52 member->flows = g_list_append(member->flows, flows);
\r
56 EndPoint *parse_end_point(char *endpoint){
\r
57 EndPoint *result = (EndPoint*) g_malloc(sizeof(EndPoint));
\r
58 int i=0,len1,len2,len, tlen;
\r
59 char *str2, temp[30], *host_str;
\r
60 //api_trace("parse_end_point: parsing %s\n", endpoint);
\r
63 str2 = (char*) strpbrk(endpoint, ":");
\r
65 str2 = (char*) strpbrk(endpoint, ";");
\r
67 len = strlen(endpoint);
\r
70 len1 = strlen(endpoint);
\r
71 len2 = strlen(str2);
\r
76 len1 = strlen(endpoint);
\r
77 len2 = strlen(str2);
\r
80 strncpy(temp,endpoint,len);
\r
82 tlen = strlen(temp);
\r
83 if((tlen >= 2)&&(temp[0] == '/')&&(temp[1] == '/')){
\r
84 host_str = remove_slash(temp);
\r
87 case 0: if(strcmp(temp,"rtp")==0){
\r
88 result->protocol=MEDIA_RTP;
\r
90 else if(strcmp(temp,"oss")==0){
\r
91 result->protocol=MEDIA_OSS;
\r
93 else if(strcmp(temp,"alsa")==0){
\r
94 result->protocol=MEDIA_ALSA;
\r
96 else if(strcmp(temp,"file")==0){
\r
97 result->protocol=MEDIA_FILE;
\r
100 case 1: if(result->protocol==MEDIA_FILE){
\r
101 result->file=host_str;
\r
104 result->host = host_str;
\r
107 case 2: result->port = to_digits(temp);
\r
109 case 3: result->pt = pt_digits(temp);
\r
111 default://result->options[result->nOptions++] = temp;
\r
114 if(str2 != NULL) endpoint = str2+1;
\r
121 int to_digits(char *str){
\r
124 for(i=0;i<len;i++){
\r
132 int pt_digits(char *str){
\r
135 if((len>3)&&(str[0]=='p')&&(str[1]=='t')&&(str[2]=='=')){
\r
136 return to_digits(str+3);
\r
139 api_warn("Wrong parameters passed in the endpoints");
\r
144 char *remove_slash(char var[]){
\r
145 char *temp = (char*) g_malloc(10*sizeof(char));
\r
148 for(i=2;i<len;i++){
\r