1 /* 2 * Copyright (c) 2004-2007 Marcus Overhagen <marcus@overhagen.de> 3 * 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: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 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. 23 */ 24 25 #ifndef __TRANSPORT_STREAM_DEMUX_H 26 #define __TRANSPORT_STREAM_DEMUX_H 27 28 #include <Locker.h> 29 #include "mpeg_ts_packet.h" 30 31 class PacketQueue; 32 class Packet; 33 34 class TransportStreamDemux 35 { 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(); 42 43 void SetPIDs(int vid_pid, int aud_pid, int pcr_pid); 44 45 void AddData(Packet *packet); 46 47 void TimesourceInfo(bigtime_t *perf_time, bigtime_t *sys_time); 48 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); 52 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); 58 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; 77 }; 78 79 80 inline void 81 TransportStreamDemux::TimesourceInfo(bigtime_t *perf_time, bigtime_t *sys_time) 82 { 83 fTimeSourceLocker.Lock(); 84 *perf_time = fPerformanceTime; 85 *sys_time = fSystemTime; 86 fTimeSourceLocker.Unlock(); 87 } 88 89 90 #endif 91