Wednesday, December 30, 2015

The death of IMpeg2Data and the false start of IPSITables


In the Windows Vista-era, I wrote a DVB-T program. Apart from letting you view TV, it read and parsed DVB-SI. With the removal of Media Centre in Windows 10, I recently tried to get it working again but quickly hit a fairly major snag.

I was using the IMpeg2Data interface to retrieve DVB-SI. In particular, the IMpeg2Data::GetTable and IMpeg2Data::GetStreamOfSections methods.

However, you'll note that Microsoft state:
[IMpeg2Data is no longer available for use as of Windows 7. Instead, use the IPSITables interface to get program specific information (PSI) tables from an MPEG-2 transport stream.]
Fine, the API has been replaced, it should be straightforward to use the new one. Except, it is very poorly documented, and the documentation that is there does not make sense.

Let's have a look at the documentation for the parameters of the only method that the new interface has, IPSITables::GetTable:
dwTSID [in]
Transport stream identifier (TSID) for the table that is retrieved (bytes 0 - 15) and the original network ID (ONID) for an Event Information Table (EIT) that is retrieved (bytes 16 - 31).
dwTID_PID [in]
Table identifier (TID) or the program ID (PID) that identifies the transport stream packet.
dwHashedVer [in]
Hash value that identifies the table contents.
dwPara4 [in]
PID for a Program Mapping Table or the service ID (SID) for an EIT. Otherwise, not used.
ppIUnknown [out]
Pointer to the IUnknown interface for the table object that is retrieved. The caller is responsible for freeing the memory.
How many things are wrong with it?
  • Can a DWORD store 32 bytes now?
  • Is a PID is a program ID now rather than a packet identifier?
  • What the hell the hash value (or hashed version as suggested by the name of the parameter) – the word hash comes up in neither ISO/IEC 13818-1 nor ETSI EN 300 468. CRC32 does – but how on earth would you know the checksum of the table you are trying to retrieve?
  • When do you put the TID in dwTID_PID and when do you put the PID? If you put the PID there, where do you put the TID?
  • What do you put in bits 16 – 31 of dwTSID when it's not an EIT?
  • What do you do if you don't know the TSID?
  • And even if you manage to work all that out, you get a pointer to an IUnknown interface, with no information on what interfaces it actually implements!
As for IMpeg2Data::GetStreamOfSections, there doesn't appear to even be a replacement.

The old IMpeg2Data method was reasonably well-documented and more importantly the method parameters actually made sense.

I wondered what Microsoft actually meant by IMpeg2Data is no longer available for use as of Windows 7. I noticed that the filter and interface are still present. Alas, my experience of what they mean is that IMpeg2Data::GetTable times out and returns EVENT_E_INTERNALERROR, while IMpeg2Data::GetStreamOfSections returns S_OK but no data ever arrives. It is bizarre as it suggests the method implementations are still in place.

In any case, I'm pretty sure my TV app will never work again. Never mind...

Tuesday, December 29, 2015

Windows 10: 'How do you want to open this file'? dialog box

It certainly feels like all the feedback I enter into the Windows Feedback app on Windows 10 ends up in free fall towards the floor of a bottomless abyss. So, perhaps inscribing my thoughts on the more traditional world wide web will be a more productive use of time.

My first in a series of complaints is the 'How do you want to open this file?' dialog box:



My initial complaint (which I'll come back to) was simply that it does not mention which file it is talking about. On closer inspection, though, there are other things amiss. Firstly, albeit a minor quibble, the title seems a bit silly to me – if someone asked me that question I would probably reply 'quickly'. Not sure what is wrong with 'Which app do you want to open this file with?' (apart from being slightly longer).

Secondly, if you view the images at their original sizes, you'll notice the icons are distorted. I use 125% DPI on this PC which is presumably something to do with it.

Back to the original complaint. It can be summarised as: I was running a script in the background. The script sometimes runs a Python script. Some time after I started the script, one of these dialog boxes popped up and I had no idea what file it was referring to. It annoyed me that it did not tell me.

Now I've started writing, I've realised I have even more complaints with this dialog box. Why does it close when you click somewhere else? There is zero visual indication it is going to do that. And, why is there no cancel button?

On my laptop, if I try to open a JPEG I get this:


I haven't as yet selected "%1" to see what happens.

And here's another one. If you try to change the program associated with a file extension via Control Panel, you get this version of the dialog box:


The title makes no sense. There is no 'this .py file'!