vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / media-add-ons / dvb / TransportStreamDemux.h
blobe054617789ee1e209c6407a376f8749147417aa9
1 /*
2 * Copyright (c) 2004-2007 Marcus Overhagen <marcus@overhagen.de>
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify,
8 * merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef __TRANSPORT_STREAM_DEMUX_H
26 #define __TRANSPORT_STREAM_DEMUX_H
28 #include <Locker.h>
29 #include "mpeg_ts_packet.h"
31 class PacketQueue;
32 class Packet;
34 class TransportStreamDemux
36 public:
37 TransportStreamDemux(
38 PacketQueue *vid_queue, PacketQueue *aud_queue,
39 PacketQueue *vid_queue2, PacketQueue *aud_queue2,
40 PacketQueue *mpeg_ts_queue);
41 virtual ~TransportStreamDemux();
43 void SetPIDs(int vid_pid, int aud_pid, int pcr_pid);
45 void AddData(Packet *packet);
47 void TimesourceInfo(bigtime_t *perf_time, bigtime_t *sys_time);
49 private:
50 void ProcessData(const void *data, int size, bigtime_t start_time, bigtime_t delta);
51 void ProcessPacket(const mpeg_ts_packet *pkt, bigtime_t start_time);
53 protected:
54 virtual void ProcessPCR(const mpeg_ts_packet *pkt, bigtime_t start_time);
55 virtual void ProcessPAT(const mpeg_ts_packet *pkt);
56 virtual void ProcessAUD(const mpeg_ts_packet *pkt);
57 virtual void ProcessVID(const mpeg_ts_packet *pkt);
59 private:
60 int64 fCount;
61 bigtime_t fSystemTime;
62 bigtime_t fPerformanceTime;
63 bigtime_t fLastEndTime;
64 int fVidPid;
65 int fAudPid;
66 int fPcrPid;
67 PacketQueue * fVidQueue;
68 PacketQueue * fVidQueue2;
69 PacketQueue * fAudQueue;
70 PacketQueue * fAudQueue2;
71 PacketQueue * fMpegTsQueue;
72 Packet * fVidPacket;
73 Packet * fAudPacket;
74 bool fVidPacketValid;
75 bool fAudPacketValid;
76 BLocker fTimeSourceLocker;
80 inline void
81 TransportStreamDemux::TimesourceInfo(bigtime_t *perf_time, bigtime_t *sys_time)
83 fTimeSourceLocker.Lock();
84 *perf_time = fPerformanceTime;
85 *sys_time = fSystemTime;
86 fTimeSourceLocker.Unlock();
90 #endif