d9ad1ed9060fd0d1242c98516f8d056ee27e8930
[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
28 // Custom includes
29 #include <boost/io/ios_state.hpp>
30
31 #define prefix_
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33
34 namespace
35 {
36     std::string ptName(int pt)
37     {
38         struct pt_item
39         {
40             int pt;
41             std::string name;
42         };
43         static pt_item ptList[27] = {
44             {0,"PCMU"},{1,"1016"},{2,"G721"},{3,"GSM"},
45             {5,"DVI8"},{6,"DVI16"},{7,"LPC"},{8,"PCMA"},
46             {9,"G722"},{10,"L16"},{11,"L16S"},{14,"MPA"},
47             {25,"CELB"},{26,"JPEG"},{31,"H261"},{32,"MPV"},
48             {33,"MP2T"},{34,"263"},{110,"MPEG AAC"},{111,"11L16"},
49             {112,"11L16S"},{113,"22L16"},{114,"22L16S"},{115,"32L16"},
50             {116,"32L16S"},{127,"HTML"},{-1,""}
51         };
52         int n = 0;
53         while (ptList[n].pt != -1)
54         {
55             if (ptList[n].pt == pt)
56                 return ptList[n].name;
57             ++n;
58         }
59
60         return "UNKNOWN";
61     }
62 }
63
64 prefix_ void senf::RTPPacketType::dump(packet p, std::ostream & os)
65 {
66     boost::io::ios_all_saver ias(os);
67     os << "Real Time Protocol:\n"
68        << senf::fieldName("version")               << p->version() << "\n"
69        << senf::fieldName("padding")               << p->padding() << "\n"
70        << senf::fieldName("extension")             << p->extension() << "\n"
71        << senf::fieldName("contributing source cnt")   << p->csrcCount() << "\n"
72        << senf::fieldName("marker")                << p->marker() << "\n"
73        << senf::fieldName("payload type")          << p->payloadType() << " "
74            << ptName(p->payloadType() ) <<"\n"
75        << senf::fieldName("sequence number")       << p->seqNumber() << "\n"
76        << senf::fieldName("timestamp")             << p->timeStamp() << "\n"
77        << senf::fieldName("sync source id")        << p->synSourceId() << "\n";
78 }
79
80 //-/////////////////////////////////////////////////////////////////////////////////////////////////
81 #undef prefix_