X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fdvb%2Fpmt.h;h=bd6c4f166f20f3c1082be2c2474f1fb1407c2112;hp=b917383bb71aaaa4205a9d480a0729dbbeb066c9;hb=10e7e45ae92d4fe06f70126ed256b87896dbc432;hpb=a6f6641c559ba36617562c3a9e71338d620b7193 diff --git a/lib/dvb/pmt.h b/lib/dvb/pmt.h index b917383..bd6c4f1 100644 --- a/lib/dvb/pmt.h +++ b/lib/dvb/pmt.h @@ -1,10 +1,13 @@ #ifndef __lib_dvb_dvbmid_h #define __lib_dvb_dvbmid_h +#ifndef SWIG +#include #include #include #include #include +#include #include #include @@ -14,44 +17,66 @@ #include #include -class eDVBServicePMTHandler; +class eDVBCAService; +class eDVBScan; + +struct channel_data: public Object +{ + ePtr m_channel; + ePtr m_stateChangedConn; + int m_prevChannelState; + int m_dataDemux; +}; + +// TODO .. put all static stuff into a 'eDVBCAServiceHandler class' + +typedef std::map CAServiceMap; +typedef std::map ChannelMap; class eDVBCAService: public Object { - eDVBServicePMTHandler &m_parent; - int m_sock, m_clilen; + ePtr m_sn; + eServiceReferenceDVB m_service; + uint8_t m_used_demux[32]; + unsigned int m_prev_build_hash; + + int m_sock, m_clilen; struct sockaddr_un m_servaddr; unsigned int m_sendstate; - unsigned char *m_capmt; + unsigned char m_capmt[2048]; eTimer m_retryTimer; void sendCAPMT(); void Connect(); + void socketCB(int what); + + static void DVBChannelAdded(eDVBChannel*); + static void DVBChannelStateChanged(iDVBChannel*); + static CAServiceMap exist; + static ChannelMap exist_channels; + static ePtr m_chanAddedConn; + static channel_data *getChannelData(eDVBChannelID &chid); + + eDVBCAService(); + ~eDVBCAService(); public: - eDVBCAService( eDVBServicePMTHandler &parent ) - :m_parent(parent), m_sendstate(0), m_capmt(NULL), m_retryTimer(eApp) - { - CONNECT(m_retryTimer.timeout, eDVBCAService::sendCAPMT); - Connect(); -// eDebug("[eDVBCAHandler] new service %s", service.toString().c_str() ); - } - ~eDVBCAService() - { - delete [] m_capmt; - ::close(m_sock); -// eDebug("[eDVBCAHandler] leave service %s", me.toString().c_str() ); - } - void buildCAPMT(); + static void registerChannelCallback(eDVBResourceManager *res_mgr); + static RESULT register_service( const eServiceReferenceDVB &ref, int demux_nums[2], eDVBCAService *&caservice ); + static RESULT unregister_service( const eServiceReferenceDVB &ref, int demux_nums[2], eTable *ptr ); + void buildCAPMT(eTable *ptr); }; +#endif + class eDVBServicePMTHandler: public Object { +#ifndef SWIG friend class eDVBCAService; eServiceReferenceDVB m_reference; ePtr m_service; int m_last_channel_state; - uint16_t m_pmt_pid; eDVBCAService *m_ca_servicePtr; + eDVBScan *m_dvb_scan; // for sdt scan eAUTable > m_PMT; eAUTable > m_PAT; @@ -63,54 +88,126 @@ class eDVBServicePMTHandler: public Object void channelStateChanged(iDVBChannel *); ePtr m_channelStateChanged_connection; + void channelEvent(iDVBChannel *, int event); + ePtr m_channelEvent_connection; + void SDTScanEvent(int); + ePtr m_scan_event_connection; void PMTready(int error); void PATready(int error); - int m_record; + int m_pmt_pid; + + int m_use_decode_demux; + uint8_t m_decode_demux_num; public: - eDVBServicePMTHandler(int record); + eDVBServicePMTHandler(); ~eDVBServicePMTHandler(); - +#endif + +#ifdef SWIG +private: + eDVBServicePMTHandler(); +public: +#endif + enum { eventNoResources, // a requested resource couldn't be allocated + eventTuneFailed, // tune failed eventNoPAT, // no pat could be received (timeout) eventNoPATEntry, // no pat entry for the corresponding SID could be found eventNoPMT, // no pmt could be received (timeout) eventNewProgramInfo, // we just received a PMT - eventTuned // a channel was sucessfully (re-)tuned in, you may start additional filters now + eventTuned, // a channel was sucessfully (re-)tuned in, you may start additional filters now + + eventSOF, // seek pre start + eventEOF, // a file playback did end + + eventMisconfiguration, // a channel was not found in any list, or no frontend was found which could provide this channel }; - +#ifndef SWIG Signal1 serviceEvent; - + struct videoStream { int pid; + int component_tag; + enum { vtMPEG2, vtMPEG4_H264 }; + int type; }; struct audioStream { int pid; - enum { atMPEG, atAC3, atDTS }; + enum { atMPEG, atAC3, atDTS, atAAC }; int type; // mpeg2, ac3, dts, ... - // language code, ... + + int component_tag; + std::string language_code; /* iso-639, if available. */ }; - + + struct subtitleStream + { + int pid; + int subtitling_type; /* see ETSI EN 300 468 table 26 component_type + when stream_content is 0x03 + 0x10..0x13, 0x20..0x23 is used for dvb subtitles + 0x01 is used for teletext subtitles */ + union + { + int composition_page_id; // used for dvb subtitles + int teletext_page_number; // used for teletext subtitles + }; + union + { + int ancillary_page_id; // used for dvb subtitles + int teletext_magazine_number; // used for teletext subtitles + }; + std::string language_code; + bool operator<(const subtitleStream &s) const + { + if (pid != s.pid) + return pid < s.pid; + if (teletext_page_number != s.teletext_page_number) + return teletext_page_number < s.teletext_page_number; + return teletext_magazine_number < s.teletext_magazine_number; + } + }; + struct program { std::vector videoStreams; std::vector audioStreams; - // ca info + int defaultAudioStream; + std::vector subtitleStreams; + std::set caids; int pcrPid; int pmtPid; + int textPid; + bool isCrypted() { return !caids.empty(); } + + PyObject *createPythonObject(); }; - + int getProgramInfo(struct program &program); - int getDemux(ePtr &demux); - int getPVRChannel(ePtr &pvr_channel); + int getDataDemux(ePtr &demux); + int getDecodeDemux(ePtr &demux); + PyObject *getCaIds(); - int tune(eServiceReferenceDVB &ref); + int getPVRChannel(ePtr &pvr_channel); + int getServiceReference(eServiceReferenceDVB &service) { service = m_reference; return 0; } + int getService(ePtr &service) { service = m_service; return 0; } + int getPMT(ePtr > &ptr) { return m_PMT.getCurrent(ptr); } + int getChannel(eUsePtr &channel); + void resetCachedProgram() { m_have_cached_program = false; } + + int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0, bool simulate=false); + void free(); +private: + bool m_have_cached_program; + program m_cached_program; +#endif }; #endif