As the sender of multicast data, adding arm_linux to multicast groups is not required. You can add or not.
Arm_linux data sending program: (only functional functions are provided)
Void multicast_thread ()
{
Rtpsession sess;
Int portbase = 6000;
Int status;
// Int length;
Int loop;
Bool iscast;
Unsigned long destip;
Unsigned long localip;
Char * buff = "multicasting test ";
Int length = strlen (buff );
Destip = inet_addr ("233.0.0.1 ");
Localip = inet_addr ("172.29.26.101 ");
If (destip = inaddr_none | localip = inaddr_none)
{
Printf ("Bad IP address specfied/N ");
Return;
}
Destip = ntohl (destip );
Localip = ntohl (localip );
Status = sess. Create (portbase, localip );
Checkerror (Status );
Iscast = sess. supportsmulticasting ();
If (! Iscast)
{
Sess. Destroy ();
Printf ("the RTP Library was not complied with multicasting support/N ");
Return;
}
/*************************************** **********************
* As a sender to a multicastgroup, it doesn' t have to add *
* The group. Both can send the data successfully .*
**************************************** **********************/
// Sess. joinmulticastgroup (destip );
Status = sess. adddestination (destip, portbase );
Checkerror (Status );
For (loop = 0; loop <1000; loop ++)
{
Status = sess. sendpacket (buff, length, 1, false, 25 );
Printf ("Send packet: % d/N", loop + 1 );
Sleep (1 );
}
Sess. cleardestinations ();
// Sess. leavemulticastgroup (destip );
Sess. Destroy ();
Return;
}
To receive data programs on Windows, you must add them to multicast groups:
Uint multicast_thread (lpvoid)
{
Cadmintooldlg * DLG = (cadmintooldlg *) afxgetapp ()-> getmainwnd ();
Rtpsession sess;
Int portbase, status, length;
Unsigned long destip;
Unsigned char * rawdata;
Bool iscast;
// Cstring STR;
Portbase = 6000;
Destip = inet_addr (Multicast );
If (destip = inaddr_none)
{
Afxmessagebox ("invalid multicast address ");
Return-1;
}
Destip = ntohl (destip );
Status = sess. Create (portbase );
DLG-> checkerror (Status );
Iscast = sess. supportsmulticasting ();
If (! Iscast)
{
Sess. Destroy ();
Afxmessagebox ("multicasting is not supported ");
Return-1;
}
If (sess. joinmulticastgroup (destip) <0)
{
Afxmessagebox ("failed to join multicast group ");
Return-1;
}
// Sess. setreceivemode (receivemode_acceptsome );
// Sess. addtoacceptlist (destip, 1, portbase );
DLG-> recvbytes = 0;
DLG-> COUNT = 0;
While (1)
{
Sess. polldata ();
If (sess. gotofirstsourcewithdata ())
{
// Afxmessagebox ("receive data ");
Rtppacket * pack;
While (pack = sess. getnextpacket ())! = NULL)
{
Length = pack-> getpayloadlength ();
Rawdata = pack-> getpayload ();
For (INT I = 0; I <length; I ++)
{
DLG-> data [DLG-> recvbytes] = rawdata [I];
DLG-> recvbytes ++;
}
DLG-> count ++;
}
}
If (DLG-> exitflag = 1 | purview = 0)
{
DLG-> m_brtprunning = false;
Sess. Destroy ();
Exitthread (-1 );
}
}
Sess. leavemulticastgroup (destip );
Sess. Destroy ();
Afxmessagebox ("session end/N ");
DLG-> m_brtprunning = false;
Return 0;
}