switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Packets / DefaultBundle / RTPPacket.cc
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Philipp Batroff <pug@berlios.de>
27
28 /** \file
29     \brief RTPPacket non-inline non-template implementation */
30
31 #include "RTPPacket.hh"
32
33 // Custom includes
34 #include <boost/io/ios_state.hpp>
35
36 #define prefix_
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38
39 namespace
40 {
41     std::string ptName(int pt)
42     {
43         struct pt_item
44         {
45             int pt;
46             std::string name;
47         };
48         static pt_item ptList[27] = {
49             {0,"PCMU"},{1,"1016"},{2,"G721"},{3,"GSM"},
50             {5,"DVI8"},{6,"DVI16"},{7,"LPC"},{8,"PCMA"},
51             {9,"G722"},{10,"L16"},{11,"L16S"},{14,"MPA"},
52             {25,"CELB"},{26,"JPEG"},{31,"H261"},{32,"MPV"},
53             {33,"MP2T"},{34,"263"},{110,"MPEG AAC"},{111,"11L16"},
54             {112,"11L16S"},{113,"22L16"},{114,"22L16S"},{115,"32L16"},
55             {116,"32L16S"},{127,"HTML"},{-1,""}
56         };
57         int n = 0;
58         while (ptList[n].pt != -1)
59         {
60             if (ptList[n].pt == pt)
61                 return ptList[n].name;
62             ++n;
63         }
64
65         return "UNKNOWN";
66     }
67 }
68
69 prefix_ void senf::RTPPacketType::dump(packet p, std::ostream & os)
70 {
71     boost::io::ios_all_saver ias(os);
72     os << "Real Time Protocol:\n"
73        << senf::fieldName("version")               << p->version() << "\n"
74        << senf::fieldName("padding")               << p->padding() << "\n"
75        << senf::fieldName("extension")             << p->extension() << "\n"
76        << senf::fieldName("contributing source cnt")   << p->csrcCount() << "\n"
77        << senf::fieldName("marker")                << p->marker() << "\n"
78        << senf::fieldName("payload type")          << p->payloadType() << " "
79            << ptName(p->payloadType() ) <<"\n"
80        << senf::fieldName("sequence number")       << p->seqNumber() << "\n"
81        << senf::fieldName("timestamp")             << p->timeStamp() << "\n"
82        << senf::fieldName("sync source id")        << p->synSourceId() << "\n";
83 }
84
85 //-/////////////////////////////////////////////////////////////////////////////////////////////////
86 #undef prefix_