87bf9f36afeba8d2a2a68ebf7085e96a98afdecd
[senf.git] / Examples / DVBAdapter / ULEdec.hh
1 // $Id: ULEdec.cc 355 2007-07-26 14:17:02Z tho $
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Thorsten Horstmann <tho@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 // Definition of non-inline non-template functions
24
25 #include <senf/Scheduler/Scheduler.hh>
26 #include <senf/Packets/MPEGDVBBundle/TransportPacket.hh>
27 #include <senf/Packets/MPEGDVBBundle/SNDUPacket.hh>
28 #include <senf/Socket/Protocols/DVB.hh>
29
30
31 class ULEdec
32 {
33 public:
34     ULEdec(unsigned short adapter=0, unsigned short device=0);
35
36 private:
37     typedef senf::PacketData::iterator iterator;
38
39     enum ReceiverState {
40         Idle,
41         Reassembly
42     };
43
44     senf::DVBDemuxPESHandle demuxHandle;
45     senf::DVBDvrHandle dvrHandle;
46
47     senf::SNDUPacket snduPacket;
48
49     ReceiverState receiver_state;
50     unsigned char priv_tscc;
51     bool priv_sndu_type_1;
52     iterator snduPacketData_iter;
53
54     void handleEvent(senf::Scheduler::EventId event);
55     void handleTSPacket(senf::TransportPacket tsPacket);
56     void handleSNDUPacket();
57
58     iterator readNewSNDUPacket(iterator i, const iterator i_end);
59     iterator readContSNDUPacket(iterator i, const iterator i_end);
60     iterator readRawSNDUPacketData(iterator i, iterator const i_end);
61
62     inline bool isSDNUPacketComplete();
63     inline iterator::difference_type snduPacketBytesLeft();
64
65 };
66
67
68 struct ULEdecException : public senf::Exception
69 {
70     ULEdecException(std::string const & what)
71         : senf::Exception(what) {}
72 };
73
74
75 \f
76 // Local Variables:
77 // mode: c++
78 // fill-column: 100
79 // c-file-style: "senf"
80 // indent-tabs-mode: nil
81 // ispell-local-dictionary: "american"
82 // compile-command: "scons -u"
83 // comment-column: 40
84 // End: