Changeset 296:dc30103742b9
- Timestamp:
- 10/08/08 15:31:23 (3 months ago)
- Files:
-
- phapi/phapi.c (modified) (9 diffs)
- phapi/phapi.h (modified) (2 diffs)
- phapi/phmedia-audio.c (modified) (4 diffs)
- phapi/phmedia.c (modified) (1 diff)
- phapi/phmedia.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
phapi/phapi.c
r286 r296 137 137 138 138 static char* _get_public_sip_port(); 139 139 140 140 141 … … 193 194 ph_build_cname(char *buf, int n, struct vline *vl); 194 195 196 197 static 198 void ph_msession_free(struct ph_msession_s *s); 195 199 196 200 int phvlRegister(int vlid); … … 1017 1021 phLinePlaceCall4(int vlid, const char *uri, void *userdata, int rcid, int streams, const char *adev, const char *audio_addr, const char *video_addr) 1018 1022 { 1019 return phLinePlaceCall_withCa(vlid, uri, userdata, rcid, streams, 0, 0, adev, 0, 0); 1023 return phLinePlaceCall_withCa(vlid, uri, userdata, rcid, streams, 0, adev, audio_addr, video_addr); 1024 } 1025 1026 1027 1028 MY_DLLEXPORT int 1029 phLinePlaceMcCall(int vlid, const char *uri, void *userdata, int streams, const char *adev) 1030 { 1031 return phLinePlaceCall_withCa(vlid, uri, userdata, 0, 1032 streams|PH_STREAM_MCRECV, 0, adev, 0, 0); 1020 1033 } 1021 1034 1035 1036 1022 1037 1023 1038 #define optional(x) (x[0] ? x : 0) … … 1092 1107 else 1093 1108 { 1094 1095 1109 #ifdef STUN_ENABLE 1096 1110 … … 1098 1112 { 1099 1113 1100 int ret = getPublicPort(local_voice_port, local_video_port, public_voice_port, public_video_port ); 1114 int ret = 0; 1115 1116 ret = getPublicPort(local_voice_port, local_video_port, public_voice_port, public_video_port ); 1101 1117 1118 1102 1119 if (ret <1) 1103 1120 { … … 1595 1612 } 1596 1613 1614 MY_DLLEXPORT int 1615 phAcceptMcCall(int cid, const char *adev, const char *audioaddr, int port) 1616 { 1617 phcall_t *ca = ph_locate_call_by_cid(cid); 1618 char local_voice_port[16] = "0"; 1619 int streams = PH_STREAM_AUDIO; 1620 phCallStateInfo_t info; 1621 int i; 1622 char *remoteUri; 1623 1624 snprintf(local_voice_port,16, "%d", port); 1625 eXosip_lock(); 1626 1627 i = eXosip_answer_call(ca->did, 200, local_voice_port, ph_get_call_contact(ca), 1628 NULL,NULL,NULL, 1629 audioaddr, NULL); 1630 1631 1632 1633 if (i == 0) 1634 { 1635 char tmp[16]; 1636 1637 i = ph_call_retrieve_payloads(ca, NULL, streams); 1638 1639 _get_local_audio_sdp_port(tmp); 1640 ca->local_sdp_audio_port = atoi(tmp); 1641 ca->remote_sdp_audio_port = port; 1642 strncpy(ca->remote_sdp_audio_ip, audioaddr, sizeof(ca->remote_sdp_audio_ip)); 1643 1644 } 1645 1646 eXosip_unlock(); 1647 1648 if (adev) 1649 { 1650 if (ca->audiodev) free(ca->audiodev); 1651 ca->audiodev = strdup(adev); 1652 } 1653 1654 ph_call_media_start(ca, NULL, streams|PH_STREAM_MCSEND, 0); 1655 1656 eXosip_lock(); 1657 eXosip_retrieve_from(ca->did, &remoteUri); 1658 eXosip_unlock(); 1659 1660 clear(info); 1661 1662 info.u.remoteUri = remoteUri; 1663 info.event = phCALLOK; 1664 phcb->callProgress(cid, &info); 1665 1666 if (remoteUri) 1667 osip_free(remoteUri); 1668 1669 return 0; 1670 1671 1672 } 1673 1674 phAcceptMcastCall2(int cid, int mcid) 1675 { 1676 1677 } 1597 1678 1598 1679 static void … … 3930 4011 3931 4012 if (ca->mses) 3932 { 3933 if (!ca->audiodev) 3934 ca->audiodev = phcfg.audio_dev; 3935 3936 if (!ph_msession_stopped(ca->mses)) 3937 { 3938 ph_msession_stop(ca->mses, ca->audiodev); 3939 } 3940 3941 // cf allocation sequence for the ph_msession_s in phmedia.h 3942 g_mutex_free(ca->mses->critsec_mstream_init); 3943 free(ca->mses); 3944 3945 ca->mses = 0; 3946 } 4013 { 4014 if (ca->mses->refcnt == 1) 4015 { 4016 if (!ca->audiodev) 4017 ca->audiodev = phcfg.audio_dev; 4018 4019 if (!ph_msession_stopped(ca->mses)) 4020 { 4021 ph_msession_stop(ca->mses, ca->audiodev); 4022 } 4023 } 4024 ph_msession_free(ca->mses); 4025 ca->mses = 0; 4026 } 4027 4028 return 0; 3947 4029 3948 4030 } … … 3979 4061 3980 4062 } 4063 4064 4065 4066 static 4067 struct ph_msession_s *ph_msession_new() 4068 { 4069 struct ph_msession_s *s = (struct ph_msession_s *)calloc(sizeof(struct ph_msession_s), 1); 4070 s->critsec_mstream_init = g_mutex_new(); 4071 s->refcnt = 1; 4072 } 4073 4074 4075 static 4076 void ph_msession_free(struct ph_msession_s *s) 4077 { 4078 if (s) 4079 { 4080 g_mutex_lock(s->critsec_mstream_init); 4081 if (s->refcnt-- == 1) 4082 { 4083 g_mutex_unlock(s->critsec_mstream_init); 4084 free(s); 4085 return; 4086 } 4087 g_mutex_unlock(s->critsec_mstream_init); 4088 } 4089 } 4090 3981 4091 3982 4092 … … 4000 4110 if (!s) 4001 4111 { 4002 s = ca->mses = (struct ph_msession_s *)calloc(sizeof(struct ph_msession_s), 1); 4003 s->critsec_mstream_init = g_mutex_new(); 4112 s = ca->mses = ph_msession_new(); 4004 4113 } 4005 4114 phapi/phapi.h
r250 r296 173 173 #define PH_NOMEDIA_STREAMS (1 << 5) 174 174 #define PH_STREAM_DATA (1 << 6) 175 #define PH_STREAM_MCSEND (1 << 7) 176 #define PH_STREAM_MCRECV (1 << 8) 177 175 178 176 179 /********************TELEPHONY*********************/ … … 258 261 MY_DLLEXPORT int phAcceptCall4(int cid, void *userData, int streams, const char *audio_addr, const char *video_addr); 259 262 MY_DLLEXPORT int phAcceptCall5(int cid, void *userData, int streams, ...); 263 264 MY_DLLEXPORT int phAcceptMcCall(int cid, const char *adev, const char *audioaddr, int port); 265 MY_DLLEXPORT int phLinePlaceMcCall(int vlid, const char *uri, void *userdata, int streams, const char *adev); 266 260 267 261 268 #define phAcceptCall(cid) phAcceptCall2(cid, 0) phapi/phmedia-audio.c
r272 r296 2218 2218 } 2219 2219 2220 2221 int ph_media_setup_mcast_send(int fd, ph_mstream_params_t *sp) 2222 { 2223 return 0; 2224 } 2225 2226 2227 int ph_media_setup_mcast_recv(int fd, ph_mstream_params_t *sp) 2228 { 2229 struct ip_mreq mreq; 2230 2231 memset(&mreq, 0, sizeof(mreq)); 2232 mreq.imr_multiaddr.s_addr=inet_addr(sp->remoteaddr); 2233 mreq.imr_interface.s_addr=htonl(INADDR_ANY); 2234 if (setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq)) < 0) 2235 return -1; 2236 2237 return 0; 2238 2239 } 2220 2240 2221 2241 … … 2336 2356 else 2337 2357 #endif 2338 rtp_session_set_remote_addr(stream->ms.rtp_session, 2358 { 2359 2360 rtp_session_set_remote_addr(stream->ms.rtp_session, 2339 2361 stream->ms.remote_ip, 2340 2362 stream->ms.remote_port); 2363 2364 if (s->mcast_send) 2365 { 2366 ph_media_setup_mcast_send(stream->ms.rtp_session->rtp.socket, sp); 2367 } 2368 else if (s->mcast_recv) 2369 { 2370 ph_media_setup_mcast_recv(stream->ms.rtp_session->rtp.socket, sp); 2371 } 2372 2373 2374 2375 } 2341 2376 2342 2377 DBG1_MEDIA_ENGINE("ph_msession_audio_start: audio stream reset done\n"); … … 2432 2467 2433 2468 2434 2435 session = rtp_session_new(RTP_SESSION_SENDRECV); 2469 if (s->mcast_send) 2470 session = rtp_session_new(RTP_SESSION_SENDONLY); 2471 else if (s->mcast_recv) 2472 session = rtp_session_new(RTP_SESSION_RECVONLY); 2473 else 2474 session = rtp_session_new(RTP_SESSION_SENDRECV); 2436 2475 2437 2476 DBG2_MEDIA_ENGINE("ph_msession_audio_start: rtpsession's qos: %d\n", s->qos); … … 2502 2541 stream->ms.running = 1; 2503 2542 stream->ms.rtp_session = session; 2543 2544 if (s->mcast_send) 2545 { 2546 ph_media_setup_mcast_send(stream->ms.rtp_session->rtp.socket, sp); 2547 } 2548 else if (s->mcast_recv) 2549 { 2550 ph_media_setup_mcast_recv(stream->ms.rtp_session->rtp.socket, sp); 2551 } 2552 2504 2553 2505 2554 phapi/phmedia.c
r278 r296 72 72 73 73 g_mutex_lock(s->critsec_mstream_init); 74 if (s->refcnt != 1) 75 { 76 g_mutex_unlock(s->critsec_mstream_init); 77 return 0; 78 } 79 74 80 75 81 ret1 = ph_msession_audio_start(s, deviceid); phapi/phmedia.h
r279 r296 133 133 struct ph_msession_s 134 134 { 135 int refcnt; /* reference count */ 136 int mcast_send; 137 int mcast_recv; 135 138 int activestreams; /* bit mask of active streams */ 136 139 int newstreams; /* bit mask of new streams to be activated */
