38 #ifndef CCRTP_CHANNEL_H_
39 #define CCRTP_CHANNEL_H_
44 #include <sys/ioctl.h>
46 { return ::ioctl(so,request,&len); }
52 ::ioctlsocket(so,request,&l);
58 #ifdef CCXX_NAMESPACES
118 recv(
unsigned char* buffer,
size_t len)
156 send(
const unsigned char*
const buffer,
size_t len)
188 template<
class BaseSocket>
194 recvSocket =
new BaseSocket(ia,port);
195 sendSocket =
new BaseSocket;
199 {
delete sendSocket;
delete recvSocket; }
203 {
return recvSocket->isPendingRecv(timeout); }
207 {
return recvSocket->getSender(port); }
210 recv(
unsigned char* buffer,
size_t len)
211 {
return recvSocket->recv(buffer, len); }
215 {
return recvSocket->getNextPacketSize(); }
220 if (error)
return error;
221 return sendSocket->setMulticast(enable); }
225 {
return recvSocket->join(ia,iface); }
229 {
return recvSocket->drop(ia); }
233 {
return sendSocket->setTimeToLive(ttl); }
237 { sendSocket->setPeer(host,port); }
240 send(
const unsigned char*
const buffer,
size_t len)
241 {
return sendSocket->send(buffer, len); }
244 {
return recvSocket->getRecvSocket(); }
249 { sendSocket->endSocket(); recvSocket->endSocket(); }
279 class RTPBaseUDPIPv6Socket :
private UDPSocket
285 RTPBaseUDPIPv6Socket(
const IPV6Address& ia,
tpport_t port) :
289 inline ~RTPBaseUDPIPv6Socket()
298 {
return UDPSocket::getIPV6Sender(&port); }
301 recv(
unsigned char* buffer,
size_t len)
308 getNextPacketSize()
const
312 setMulticast(
bool enable)
316 join(
const IPV6Multicast& ia, uint32 iface)
320 drop(
const IPV6Multicast& ia)
324 setTimeToLive(
unsigned char ttl)
330 RTPBaseUDPIPv6Socket() :
335 setPeer(
const IPV6Host &ia,
tpport_t port)
339 send(
const unsigned char*
const buffer,
size_t len)
342 inline SOCKET getRecvSocket()
const
371 template<
class BaseSocket>
372 class DualRTPChannelIPV6
375 DualRTPChannelIPV6(
const IPV6Host& ia,
tpport_t port)
377 recvSocket =
new BaseSocket(ia,port);
378 sendSocket =
new BaseSocket;
381 inline ~DualRTPChannelIPV6()
382 {
delete sendSocket;
delete recvSocket; }
386 {
return recvSocket->isPendingRecv(timeout); }
390 {
return recvSocket->getIPV6Sender(port); }
393 recv(
unsigned char* buffer,
size_t len)
394 {
return recvSocket->recv(buffer, len); }
397 getNextPacketSize()
const
398 {
return recvSocket->getNextPacketSize(); }
401 setMulticast(
bool enable)
403 if (error)
return error;
404 return sendSocket->setMulticast(enable); }
407 join(
const IPV6Multicast& ia, uint32 iface)
408 {
return recvSocket->join(ia,iface); }
411 drop(
const IPV6Multicast& ia)
412 {
return recvSocket->drop(ia); }
415 setTimeToLive(
unsigned char ttl)
416 {
return sendSocket->setTimeToLive(ttl); }
419 setPeer(
const IPV6Host& host,
tpport_t port)
420 { sendSocket->setPeer(host,port); }
423 send(
const unsigned char*
const buffer,
size_t len)
424 {
return sendSocket->send(buffer, len); }
426 inline SOCKET getRecvSocket()
const
427 {
return recvSocket->getRecvSocket(); }
432 { sendSocket->endSocket(); recvSocket->endSocket(); }
435 BaseSocket* sendSocket;
436 BaseSocket* recvSocket;
440 typedef DualRTPChannelIPV6<RTPBaseUDPIPv6Socket> DualRTPUDPIPv6Channel;
441 typedef RTPBaseUDPIPv6Socket SingleRTPChannelIPV6;
442 typedef SingleRTPChannelIPV6 SymmetricRTPChannelIPV6;
461 #ifdef CCXX_NAMESPACES
465 #endif //CCRTP_CHANNEL_H_
virtual bool isPending(Pending pend, timeout_t timeout=TIMEOUT_INF)
Get the status of pending operations.
Socket::Error setTimeToLive(unsigned char ttl)
RTPBaseUDPIPv4Socket()
Constructor for transmitter.
Socket::Error join(const IPV4Multicast &ia, int InterfaceIndex)
join a multicast group on a particular interface
UDP sockets implement the TCP SOCK_DGRAM UDP protocol.
Socket::Error drop(const InetMcastAddress &ia)
Error join(const IPV4Multicast &ia)
Join a multicast group.
DualRTPChannel< RTPBaseUDPIPv4Socket > DualRTPUDPIPv4Channel
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
uint32 microtimeout_t
Time interval expressed in microseconds.
unsigned short tpport_t
Transport Protocol Ports.
Socket::Error drop(const InetMcastAddress &ia)
SOCKET getRecvSocket() const
SOCKET volatile so
the actual socket descriptor, in Windows, unlike posix it cannot be used as an file descriptor that w...
RTPBaseUDPIPv4Socket(const InetAddress &ia, tpport_t port)
Constructor for receiver.
SingleRTPChannel SymmetricRTPChannel
Actually, RTP with a single channel can be called 'Symmetric RTP'.
bool isPendingRecv(microtimeout_t timeout) const
size_t ccioctl(SOCKET so, int request, size_t &len)
ssize_t send(const void *buf, size_t len)
Send a message packet to a peer host.
SOCKET getRecvSocket() const
Error setMulticast(bool enable)
Set the multicast.
Socket::Error join(const InetMcastAddress &ia, uint32 iface)
Socket::Error setTimeToLive(unsigned char ttl)
Error setTimeToLive(char ttl)
Set time to live.
Error drop(const IPV4Multicast &ia)
Drop membership from a multicast group.
Socket::Error setMulticast(bool enable)
A UDP/IPv4 socket class targetted at RTP stacks.
void endSocket(void)
Used as the default destructor for ending a socket.
size_t getNextPacketSize() const
bool isPendingRecv(microtimeout_t timeout)
size_t getNextPacketSize() const
Get size of next datagram waiting to be read.
InetHostAddress getSender(tpport_t &port) const
RTPBaseUDPIPv4Socket SingleRTPChannel
May be used in applications where using the same socket for both sending and receiving is not a limit...
Socket::Error setMulticast(bool enable)
Socket::Error join(const InetMcastAddress &ia, uint32 iface)
IPV4Host getSender(tpport_t *port=NULL) const
size_t recv(unsigned char *buffer, size_t len)
DualRTPChannel(const InetAddress &ia, tpport_t port)
ssize_t receive(void *buf, size_t len, bool reply=false)
Receive a message from any host.
Base elements for RTP stacks: constants, types and global functions.
size_t send(const unsigned char *const buffer, size_t len)
void setPeer(const InetAddress &ia, tpport_t port)
void setPeer(const IPV4Host &host, tpport_t port)
set the peer address to send message packets to.
void setPeer(const InetAddress &host, tpport_t port)
size_t recv(unsigned char *buffer, size_t len)
InetHostAddress getSender(tpport_t &port) const
size_t send(const unsigned char *const buffer, size_t len)