Retrieve EPG from MPEG2 TS (TsWriter?) (1 Viewer)

Acheros

New Member
November 10, 2010
2
0
Home Country
Austria Austria
Hi,

I'd like to know whether it's possible to get EPG information from an MPEG2 Transport Stream programmatically.

The idea is to build up a DirectShow graph basically looking like this:

MPEG2 TS -> TsWriter? -> EPG_info_into_file

I've had a look at TsWriter. While it does accept an MEDIASUBTYPE_MPEG2_TRANSPORT at the Input pin, I don't see any output pins created. CMpTsFilter::GetPinCount() in TsWriter.cpp in the current SVN also just returns 1. So I assume that I have no chance of having an output pin to somehow get the data.

I don't have a DVB-card/tuner, just the plain MPEG2 TS with EPG data in it.

Thanks,
Acheros
 

miroslav22

Development Group Member
  • Premium Supporter
  • September 4, 2009
    703
    460
    Warwick
    Home Country
    United Kingdom United Kingdom
    I believe tswriter is just a sink filter and never has an output pin. You would have to parse and extract the EPG data from within the tswriter code.
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Have a look on:

    Code:
    DECLARE_INTERFACE_(ITsEpgScanner, IUnknown)
    {
    	//epg
    	STDMETHOD(GrabEPG)(THIS_)PURE;
    	STDMETHOD(IsEPGReady) (THIS_ BOOL* yesNo)PURE;
    	STDMETHOD(GetEPGChannelCount) (THIS_ ULONG* channelCount)PURE;
    	STDMETHOD(GetEPGEventCount) (THIS_ ULONG channel, ULONG* eventCount)PURE;
    	STDMETHOD(GetEPGChannel) (THIS_ ULONG channel, WORD* networkId, WORD* transportid,WORD* service_id  )PURE;
    	STDMETHOD(GetEPGEvent) (THIS_ ULONG channel, ULONG eventid,ULONG* language,ULONG* dateMJD,ULONG* timeUTC,ULONG* duration,char** genre,int* starRating,char** classification    )PURE;
    	STDMETHOD(GetEPGLanguage) (THIS_ ULONG channel, ULONG eventid,ULONG languageIndex,ULONG* language,char** eventText, char** eventDescription, unsigned int* parentalRating  )PURE;
    
    	//mhw
    	STDMETHOD(GrabMHW)()PURE;
    	STDMETHOD(IsMHWReady) (THIS_ BOOL* yesNo)PURE;
    	STDMETHOD(GetMHWTitleCount)(THIS_ UINT* count)PURE;
    	STDMETHOD(GetMHWTitle)(THIS_ UINT program, UINT* id, UINT* transportId, UINT* networkId, UINT* channelId, ULONG* programId, UINT* themeId, UINT* PPV, BYTE* Summaries, UINT* duration, ULONG* dateStart, ULONG* timeStart,char** title,char** programName)PURE;
    	STDMETHOD(GetMHWChannel)(THIS_ UINT channelNr, UINT* channelId, UINT* networkId, UINT* transportId, char** channelName)PURE;
    	STDMETHOD(GetMHWSummary)(THIS_ ULONG programId, char** summary)PURE;
    	STDMETHOD(GetMHWTheme)(THIS_ UINT themeId, char** theme)PURE;
    	STDMETHOD(Reset)(THIS_)PURE;
    	STDMETHOD(AbortGrabbing)(THIS_)PURE;
      
    	STDMETHOD(SetCallBack)(THIS_ IEpgCallback* callback)PURE;
    };
     

    Acheros

    New Member
    November 10, 2010
    2
    0
    Home Country
    Austria Austria
    Thanks for your replies. I've had a look at the code, but there are some things i don't understand yet.

    If the TsWriter.ax has no output pins, how do you guys from Mediaportal use it and where does it sink it's data to? I don't get what this filter currently does :D

    Is it possible to rewrite the TsWriter.ax filter in such a way, that it outputs EPG data to a file? I just need to know whether it's theoretically feasible.

    Do you have any further information on this filter? Unfortunately, the code doesn't provide too many comments and I couldn't find much documentation on this.

    Thanks
     

    miroslav22

    Development Group Member
  • Premium Supporter
  • September 4, 2009
    703
    460
    Warwick
    Home Country
    United Kingdom United Kingdom
    Its main functions are:

    Filters the relevant pids from the mux and writes the transport stream files to disk for live tv/recording (this is why no output pin is needed - nothing is rendered in this graph)

    Channel scanning - Scans the nit, sdt etc from a mux to let MP know about network/channel information for a transponder
    EPG scanning - Scans relevant pids/tables for EPG data to be sent back to MP and inserted into the database

    You should be able to do what you require - you just need to change the code to filter and process the pids containin the data you are interested in. You can then write this to disk or do what you need with it within tswriter.
     

    gemx

    Retired Team Member
  • Premium Supporter
  • October 31, 2006
    1,972
    539
    Home Country
    Germany Germany
    The filter indeed has no output pin.

    It writes the wanted channel inside a tuned transponder to disk and also parses the PID tables.

    The EPG info is stored in some pids depending on the broadcaster.

    TsWriter gathers the EPG and stores them in memory.

    In order to get the EPG entries you have to use the "ITsEpgScanner" interface.

    Basically the following steps are requiered:

    1) call "GrabEPG()" to start grabbing the EPG infos
    2) check "IsEPGReady" to see if EPG grabbing has finished
    3) call "GetEPGChannelCount" to get the number of channels for which there are entries
    4) call "GetEPGChannel" to get the ids that describe the channel inside the current transponder
    5) call "GetEPGEventCount" to get the number of events for the desired channel
    6) call "GetEPGEvent" for all events for all channels

    Here is a little example (without error checking etc.)
    Code:
      GrabEPG();
      bool isEPGReady=false;
      while (isEPGReady)
      {
         IsEPGReady(&isEPGReady);
         sleep(10);
       }
       ulong channelCount=0;
       GetEPGChannelCount(&channelCount);
       for (int i=0;i<channelCount;i++)
       {
          ulong eventCount;
          GetEPGEventCount(i,&eventCount);
          for (int j=0;j<eventCount;j++)
          {
            GetEPGEvent(i,j,.....);
            ....
          }
       }


    STDMETHOD(GrabEPG)(THIS_)PURE;
    STDMETHOD(IsEPGReady) (THIS_ BOOL* yesNo)PURE;
    STDMETHOD(GetEPGChannelCount) (THIS_ ULONG* channelCount)PURE;
    STDMETHOD(GetEPGEventCount) (THIS_ ULONG channel, ULONG* eventCount)PURE;
    STDMETHOD(GetEPGChannel) (THIS_ ULONG channel, WORD* networkId, WORD* transportid,WORD* service_id )PURE;
    STDMETHOD(GetEPGEvent) (THIS_ ULONG channel, ULONG eventid,ULONG* language,ULONG* dateMJD,ULONG* timeUTC,ULONG* duration,char** genre,int* starRating,char** classification )PURE;
    STDMETHOD(GetEPGLanguage) (THIS_ ULONG channel, ULONG eventid,ULONG languageIndex,ULONG* language,char** eventText, char** eventDescription, unsigned int* parentalRating )PURE;
     

    Users who are viewing this thread

    Top Bottom