From 60f60cc76e43197a0825ffac9aff0b7007a94175 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 20 Nov 2013 12:57:17 +0100 Subject: Framework API now complete in its first iteration. So far with support for raw, opus and amrwb. --- src/rtp.h | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 src/rtp.h (limited to 'src/rtp.h') diff --git a/src/rtp.h b/src/rtp.h new file mode 100644 index 0000000..b7aa8b4 --- /dev/null +++ b/src/rtp.h @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * rtp.h + * + * Mon Sep 2 15:24:09 CEST 2013 + * Copyright 2013 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of lrtp. + * + * lrtp is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * lrtp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with lrtp; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __LRTP_RTP_H__ +#define __LRTP_RTP_H__ + +#include +#include +#include + +typedef struct { + uint16_t cc:4; // CSRC count + uint16_t x:1; // Header extension flag + uint16_t p:1; // Padding flag + uint16_t version:2; // Protocol version + + uint16_t m:1; // Marker bit + uint16_t pt:7; // Payload type + + uint16_t seq; // Sequence number + + uint32_t ts; // Timestamp + uint32_t ssrc; // Synchronization source +} rtp_header_t; + +#define MAX_RTP_PACKET_SIZE (16 * 1024) +#define MAX_RTP_PAYLOAD_SIZE ( MAX_RTP_PACKET_SIZE - sizeof(rtp_header_t) ) + +typedef struct { + rtp_header_t header; + char body[MAX_RTP_PAYLOAD_SIZE]; +} rtp_t; + +typedef unsigned int csrc_t; + +class RTP { +public: + RTP(); + + /* // Not implemented + void setHeaderExtension(); + int headerExtension(); + */ + + void setPadding(unsigned char padding); + unsigned char padding() const; + + void setPayloadType(unsigned char pt); + unsigned char payloadType() const; + + void setMarker(bool bit); + bool marker() const; + + void setSeq(uint16_t seq); + uint16_t seq() const; + + void setTimestamp(uint32_t seq); + uint32_t timestamp() const; + + void setSSrc(uint32_t ssrc); + uint32_t SSrc() const; + + void addCSrc(csrc_t csrc); + std::list getCSrcs() const; + void removeCSrc(csrc_t csrc); + void clearCSrcs(); + + void setPayload(const char *payload, size_t size); + size_t payload(char *payload, size_t maxsize) const; + size_t payloadSize() const; + const char *payloadData() const; + + size_t packet(char *packet, size_t maxsize) const; + void fromPacket(const char *packet, size_t size); + + bool isValid(); + void setValid(bool valid); + +private: + std::list csrcs; + + rtp_header_t header; + + unsigned char pads; + + char pload[MAX_RTP_PAYLOAD_SIZE]; + size_t pload_size; + + bool is_valid; +}; + +#endif/*__LRTP_RTP_H__*/ -- cgit v1.2.3