03ab0fc901d74ab6f16cab7a592f82bee6b8baba
[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 Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.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 "Scheduler/Scheduler.hh"
26 #include "Packets/MPEGDVBBundle/TransportPacket.hh"
27 #include "Packets/MPEGDVBBundle/SNDUPacket.hh"
28 #include "Socket/Protocols/DVB/DVBDemuxHandles.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::FileHandle, 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 std::exception
69 {
70     ULEdecException(char const * what) : what_(what) {};
71     ULEdecException(std::string const what) : what_(what) {};
72     virtual char const * what() const throw() { return what_.c_str(); }
73     virtual ~ULEdecException() throw() {};
74     std::string what_;
75 };
76
77
78 \f
79 // Local Variables:
80 // mode: c++
81 // fill-column: 100
82 // c-file-style: "senf"
83 // indent-tabs-mode: nil
84 // ispell-local-dictionary: "american"
85 // compile-command: "scons -u test"
86 // comment-column: 40
87 // End: