Skip to content
Snippets Groups Projects
Commit 0176cc94 authored by pug's avatar pug
Browse files

Added RTPPacket Parser to DefaultBundle

parent 76cda039
No related branches found
No related tags found
No related merge requests found
// $Id: main.test.cc 206 2008-08-06 14:20:52Z pug $
//
// Copyright (C) 2006
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Definition of non-inline non-template functions
// Custom includes
#include "RTPPacket.hh"
#include "../../Packets/Packets.hh"
#include "../../Scheduler/ClockService.hh"
#include <boost/io/ios_state.hpp>
#define prefix_
namespace
{
std::string ptName(int pt){
struct pt_item
{
int pt;
std::string name;
};
static pt_item ptList[27] = {
{0,"PCMU"},{1,"1016"},{2,"G721"},{3,"GSM"},
{5,"DVI8"},{6,"DVI16"},{7,"LPC"},{8,"PCMA"},
{9,"G722"},{10,"L16"},{11,"L16S"},{14,"MPA"},
{25,"CELB"},{26,"JPEG"},{31,"H261"},{32,"MPV"},
{33,"MP2T"},{34,"263"},{110,"MPEG AAC"},{111,"11L16"},
{112,"11L16S"},{113,"22L16"},{114,"22L16S"},{115,"32L16"},
{116,"32L16S"},{127,"HTML"},{-1,""}
};
int n = 0;
while ( ptList[n].pt != -1)
{
if( ptList[n].pt == pt)
return ptList[n].name;
++n;
}
return "UNKNOWN";
}
}
prefix_ void senf::RTPPacketType::dump(packet p, std::ostream &os)
{
boost::io::ios_all_saver ias(os);
os << "Real Time Protocol:\n"
<< " Version : " << p->version() << "\n"
<< " Padding : " << p->padding() << "\n"
<< " Extension : " << p->extension() << "\n"
<< " Contributing Source Count(CC) : " << p->csrcCount() << "\n"
<< " Marker : " << p->marker() << "\n"
<< " Payload Type : " << p->payloadType() << " "<< ptName(p->payloadType() ) <<"\n"
<< " Sequence number : " << p->seqNumber() << "\n"
<< " Timestamp : " << p->timeStamp() << "\n"
<< " Synchronisation Source Identifier : " << p->synSourceId() << "\n";
}
#undef prefix_
// $Id: main.test.cc 206 2008-08-06 14:20:52Z pug $
//
// Copyright (C) 2006
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Definition of non-inline non-template functions
// Custom includes
#ifndef RTPPACKET_HH_
#define RTPPACKET_HH_
#include "../../Packets/Packets.hh"
#include "../../Socket/Protocols/INet/INet6Address.hh"
#include "../../Socket/Protocols/INet.hh"
namespace senf {
struct RTPPacketParser : public senf::PacketParserBase
{
SENF_LOG_CLASS_AREA();
# include SENF_PARSER()
SENF_PARSER_BITFIELD ( version, 2, unsigned ); //Version (RFC 3550)
SENF_PARSER_BITFIELD ( padding, 1, bool ); //1 if padding behind payload
SENF_PARSER_BITFIELD ( extension, 1, bool );
SENF_PARSER_BITFIELD_RO ( csrcCount, 4, unsigned ); //0-15,define the number of contributing sources
SENF_PARSER_BITFIELD ( marker, 1, bool ); //Marker M=1, used to signal speech silent compression; further use in combination with PT to be defined
SENF_PARSER_BITFIELD ( payloadType, 7, unsigned ); //Payload Type; e.g. PCM=8 (RFC 3550)
SENF_PARSER_FIELD ( seqNumber, senf::UInt16Parser ); //random number to identify initial segment of a stream, increment by 1 used to resequence segments at receiver
SENF_PARSER_FIELD ( timeStamp, senf::UInt32Parser ); //signals sampling time of 1st byte of payload; initialised; used to calculate Jitter between segments
SENF_PARSER_FIELD ( synSourceId, senf::UInt32Parser ); //Synchronisation source identifier; identifier of RFTP stream source (random number) in case of conferencing identifier of mixer
SENF_PARSER_VECTOR (csrcOpt, csrcCount, senf::UInt32Parser );
bool valid() const {return version() == 2;}
SENF_PARSER_FINALIZE(RTPPacketParser);
};
struct RTPPacketType
: public senf::PacketTypeBase,
public senf::PacketTypeMixin<RTPPacketType>
{
SENF_LOG_CLASS_AREA();
typedef senf::PacketTypeMixin<RTPPacketType> mixin;
typedef senf::ConcretePacket<RTPPacketType> packet;
typedef RTPPacketParser parser;
using mixin::nextPacketRange;
using mixin::init;
using mixin::initSize;
static void dump(packet p, std::ostream &os);
};
typedef RTPPacketType::packet RTPPacket;
}
#endif
// $Id: main.test.cc 206 2008-08-06 14:20:52Z pug $
//
// Copyright (C) 2006
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Definition of non-inline non-template functions
// Custom includes
#include "../../Packets/Packets.hh"
#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#include "RTPPacket.hh"
BOOST_AUTO_UNIT_TEST(RTPPacket_packet)
{
unsigned char data[] = {0x80 , 0x08 , 0x1b , 0xbb , 0x02 , 0xcb , 0xad , 0x80 , 0x50 , 0x48 , 0xa7, 0x8c };
senf::RTPPacket p (senf::RTPPacket::create(data));
BOOST_CHECK_EQUAL( p->version(), 2u);
BOOST_CHECK_EQUAL( p->padding(), false);
BOOST_CHECK_EQUAL( p->extension(), false);
BOOST_CHECK_EQUAL( p->csrcCount(), 0u);
BOOST_CHECK_EQUAL( p->marker(), false);
BOOST_CHECK_EQUAL( p->payloadType(), 8u);
BOOST_CHECK_EQUAL( p->seqNumber(), 0x1bbbu);
BOOST_CHECK_EQUAL( p->timeStamp(), 0x2cbad80u);
BOOST_CHECK_EQUAL( p->synSourceId(), 0x5048a78cu);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment