Move sourcecode into 'senf/' directory
[senf.git] / senf / Packets / DefaultBundle / RTPPacket.cc
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Philipp Batroff <pug@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file 
24     \brief RTPPacket non-inline non-template implementation */
25
26 #include "RTPPacket.hh"
27 //#include "UDPPacket.ih"
28
29 // Custom includes
30 #include <boost/io/ios_state.hpp>
31
32 #define prefix_
33
34 namespace 
35 {
36     std::string ptName(int pt){
37         struct pt_item
38         {
39             int pt;
40             std::string name;
41         };
42         static pt_item ptList[27] = {
43             {0,"PCMU"},{1,"1016"},{2,"G721"},{3,"GSM"},
44             {5,"DVI8"},{6,"DVI16"},{7,"LPC"},{8,"PCMA"},
45             {9,"G722"},{10,"L16"},{11,"L16S"},{14,"MPA"},
46             {25,"CELB"},{26,"JPEG"},{31,"H261"},{32,"MPV"},
47             {33,"MP2T"},{34,"263"},{110,"MPEG AAC"},{111,"11L16"},
48             {112,"11L16S"},{113,"22L16"},{114,"22L16S"},{115,"32L16"},
49             {116,"32L16S"},{127,"HTML"},{-1,""}
50         };
51         int n = 0;
52         while ( ptList[n].pt != -1)
53         {
54             if( ptList[n].pt == pt)
55                 return ptList[n].name;
56             ++n;
57         }
58         
59         return "UNKNOWN";
60     }
61 }
62
63 prefix_ void senf::RTPPacketType::dump(packet p, std::ostream &os)
64 {
65     boost::io::ios_all_saver ias(os);
66     os << "Real Time Protocol:\n"
67        <<     "  version                 : " << p->version() << "\n"
68        <<     "  padding                 : " << p->padding() << "\n"
69        <<     "  extension               : " << p->extension() << "\n"
70        <<     "  contributing source cnt : " << p->csrcCount() << "\n"
71        <<     "  marker                  : " << p->marker() << "\n"
72        <<     "  payload type            : " << p->payloadType() << " "<< ptName(p->payloadType() ) <<"\n"
73        <<     "  sequence number         : " << p->seqNumber() << "\n"
74        <<     "  timestamp               : " << p->timeStamp() << "\n"
75        <<     "  sync source id          : " << p->synSourceId() << "\n";
76 }
77
78 #undef prefix_