hi, everyone.
Is there anyone who has succeeded in multicast
programming using ortp under windows.
i came cross some problems.
this is my test code .
#include <ortp/ortp.h>
#include <windows.h>
int main(int argc, char **argv)
{
if(argc!=2)
{
printf("usage: %s multicast_address \n",argv[0]);
return -1;
}
ortp_init();
ortp_scheduler_init();
ortp_set_log_level_mask(ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
uint8_t buf[100];
RtpSession *pRtpSession=NULL;
pRtpSession = rtp_session_new(RTP_SESSION_RECVONLY);
if(!pRtpSession)
{
printf("can't create rtp session\n");
return -1;
}
rtp_session_set_scheduling_mode(pRtpSession, 0);
rtp_session_set_blocking_mode(pRtpSession, 0);
rtp_session_set_local_addr(pRtpSession, argv[1], 9000); //argv[1]
224.1.2.3
rtp_session_set_multicast_ttl(pRtpSession, 1);
mblk_t *pMblk = NULL;
int ts = 0;
while((pMblk = rtp_session_recvm_with_ts(pRtpSession, ts))!= NULL)
{
int seq_no = rtp_get_seqnumber(pMblk);
int timestamp = rtp_get_timestamp(pMblk);
memcpy(buf, pMblk->b_rptr+12, 100);
printf("seq_no is %d , timestamp is %d , buf is %s \n",seq_no, timestamp,
buf);
ts+=20;
}
ortp_exit();
ortp_global_stats_display();
system("pause");
return 0;
}
when i debuged into this test code , i found that this function
rtp_session_set_local_addr(pRtpSession,
argv[1], 9000) returns -1;
argv[1] is the multicast address i specify ,which is 224.1.2.3 . I debug
into the function .when it came to create_and_bind(const char *addr, int
port, int *sock_family, bool_t reuse_addr). it shows that the windows native
bind() fails .
msdn shows that we can't bind an address that is not one of the local
interface .
so what is the solution .
Do I miss anything ?
thanks in advance.