HP-UX Multimedia Streaming Protocols (MSP) Programmer's Guide
}
else
printf(“ tDestination %s:%d addded to RTCP SENDTO list n”
,destaddr
,remRTCPport
);
/*
* The library automatically generates RTCP packets.
*/
/* poll for an RTP packet */
printf(“polling for an RTP packet... n”);
rfds[0].rd=rd;
rfds[0].events=RTP_PIN;
if((ret=rtp_poll(rfds,1,-1))<0)
{
fprintf(stderr,”rtp_poll() failed n”);
exit(1);
}
printf(“An RTP packet is ready to be received n”
“Receive it now?”);
fflush(stdin);
scanf(“%c”,&ec);
i=0;
int buflen;
while((ec!=’n’)&&(ec!=’N’))
{
i++;
buflen=sizeof buf;
/*
* receiving an RTP packet
* if ptr points to NULL instead of buf the
* library would automatically allocate the
* required memory for the RTP packet.
*/
if((ret= rtp_recv(rd,(rtp_pkt_t *)NULL,&ptr,&buflen))<0) break;
printf(“receive another packet? “);
fflush(stdin);
scanf(“%c”,&ec);
}
if(ret<0)
{
/*
* if memory were requested from the library
* a check for RTP_EMOREDATA would have been
* redundant
*/
if(ret==RTP_EMOREDATA)
fprintf(stderr,”The buffer passed to rtp_recv() was small n”);
else
fprintf(stderr,”rtp_recv() failed n”);
}
else
printf(“%d RTP packet(s) received n”,i);
}
RTP Sample Program 91