summaryrefslogtreecommitdiff
path: root/src/rtp.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rtp.cc')
-rw-r--r--src/rtp.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/rtp.cc b/src/rtp.cc
index 28a9203..767a506 100644
--- a/src/rtp.cc
+++ b/src/rtp.cc
@@ -137,17 +137,21 @@ void RTP::clearCSrcs()
header.cc = csrcs.size();
}
-void RTP::setPayload(const char *pl, size_t size)
+int RTP::setPayload(const char *pl, size_t size)
{
if(size > MAX_RTP_PAYLOAD_SIZE) {
- printf("ERROR: Payload is too big for RTP pakcet.\n");
+ printf("ERROR: Payload is too big for RTP packet (%d bytes, max is %d).\n",
+ size, MAX_RTP_PAYLOAD_SIZE);
// TODO: Report error.
+ return -1;
}
memcpy(pload, pl, size);
pload_size = size;
setValid(true);
+
+ return size;
}
size_t RTP::payload(char *payload, size_t maxsize) const
@@ -215,13 +219,13 @@ size_t RTP::packet(char *packet, size_t maxsize) const
return p - packet;
}
-void RTP::fromPacket(const char *packet, size_t size)
+int RTP::fromPacket(const char *packet, size_t size)
{
rtp_header_t *hdr = (rtp_header_t *)packet;
if(hdr->version != 2) {
printf("ERROR: Wrong RTP header version.\n");
- return; // TODO: Invalid RTP version error
+ return -1; // TODO: Invalid RTP version error
}
setMarker(hdr->m);
@@ -246,9 +250,11 @@ void RTP::fromPacket(const char *packet, size_t size)
// Read out payload
size_t plsz = size - (sizeof(rtp_header_t) + hdr->cc*sizeof(csrc_t) + pads);
char *pl = (char*)pcsrc;
- setPayload(pl, plsz);
+ if(setPayload(pl, plsz) < 0) return -1;
setValid(true);
+
+ return size;
}
bool RTP::isValid()