[MPlayer-users] RTP multicast error

Ruslan Araslanov aruslan at chat.ru
Sun May 26 14:25:02 CEST 2002


Hello!

for working mplayer with rtp://multicast_ip
need change rtp.c module as is:

/* create a receiver socket, i.e. join the multicast group. */
int makeclientsocket(char *szAddr, unsigned short port, int TTL, 
struct sockaddr_in *sSockAddr)
{
    int socket = makesocket(szAddr, port, TTL, sSockAddr);
    struct ip_mreqn blub; // arn00
    struct sockaddr_in sin;
    unsigned int tempaddr;
    char localhost[1024]; // ++arn00
    struct in_addr local; 
    struct hostent *host; 

    gethostname(localhost, sizeof localhost);
    host = gethostbyname(localhost);
    if (host != NULL)
        local = *((struct in_addr **) host->h_addr_list)[0];
    else
    {
        perror("unknown local host address");
        return -1;
    } // --arn00

    sin.sin_family=AF_INET;
    sin.sin_port=htons(port);
    sin.sin_addr.s_addr=inet_addr(szAddr);
  
    if (bind(socket,(struct sockaddr *) &sin,sizeof(sin)))
    {
        perror("bind failed");
        return -1;
    }
    tempaddr=inet_addr(szAddr);
    if ((ntohl(tempaddr) >> 28) == 0xe)
    {
        blub.imr_multiaddr.s_addr = inet_addr(szAddr);
        blub.imr_address.s_addr = local.s_addr; // arn00
        blub.imr_ifindex = 0;   // arn00
        if (setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, 
&blub, sizeof(blub)))
        {
            perror("setsockopt IP_ADD_MEMBERSHIP failed (multicast 
kernel?)");
            return -1;
        }
    }
    return socket;
}


Best regards,
Ruslan Araslanov




More information about the MPlayer-users mailing list