[PATCH] Improvements for analog cards (1 Viewer)

misterd

Retired Team Member
  • Premium Supporter
  • April 4, 2006
    1,597
    314
    Home Country
    Germany Germany
    Hi all,
    the last couple of weeks I was working on improvements for analog cards. Most changes are more design changes to get the handling of analog cards more equivalent to dvb cards. The reason for this is quite simple. As some people already know I have started to create a new teletext module for the TvServer, which handles all teletext stuff in MP directly by using the same routines as for teletext subtitles. During the planning phase I realized that this will only work for DVB cards, because the teletext data isn't stored in the .ts files for analog cards.

    But before I tell you what I have changed, I would like to thank chemelli for all his testings. :D

    Here is the list of changes:
    - Added feature to record in .ts format - IN SVN
    - Added feature to define priorities for the software encoders in SetupTV- Will be available with MP 1.2.0
    For this new feature a db update is required. This feature is very helpful if you have more than one software encoder installed and only one of these encoder is working with your analog card (No Audio/Video found). It now also displays which encoders are installed on your local system. I don't have included an option to add or delete encoders for some reasons.
    - Moved teletext handling to MPFileWriter - IN SVN
    A result of this change is that DVB and analog cards are now using the same decoding routines. One of the next steps will be to store the teletext data in .ts files.
    - Scanning channel names is now also handled in MPFileWriter - IN SVN
    - Improved channel switching speed - IN SVN
    The graph is now reused like for DVB cards. chemelli and I have now switching times of 1-2 seconds
    - Improved startup time in some cases - IN SVN
    This is similar to the fix of diehard2 for hauppauge cards, but should solve the real issue for all cards now.

    I haven't the time to separate those changes, becuase many of them are depending on each other. :sorry:

    I have attached compiled binaries and modified source of the TvServer and TvPlugin for SVN revision 16781 up to 16795 and also include my teletext patch (#1780563). To avoid problems with compiling the filter I haven't included the modified and new sources of the filter. If the devs want to include the patch just contact me and I will publish these sources too.
    You should only test this patch if you're familiar with manipulating SQL tables.

    Install instructions: (Updated 21.01.08)
    - Install and configure TVE3 with revision 17180
    - Extract "AnalogPatch-Rev17180.zip" to a folder of your choice.
    - Execute "PatchInstaller.exe" and click on "Install..."
    - The files will be installed and the db gets updated.
    - Don't delete the folder with the patch. It is needed for uninstall.

    Uninstall instructions: (Updated 21.01.08)
    - Execute "PatchInstaller.exe" again and click on "Uninstall..."
    - All files will be restored and the db change will be reverted.

    Please report any result even if everything works for you. We need this feedback to make a decision about the patch.

    Regards,
    MisterD

    Update 06.01.08:
    - Recompiled against Revision 16907. Should work also work with Revisions 16857-16907, but I can't guarantee that.
    - Removed my teletext patch to simplify the installation. See above.

    Update 21.01.08:
    - Recompiled against Revision 17110.
    - Included Installer
    - Added ATI MPEG Video/Audio Encoder and Cyberlink MPEG Audio Encoder

    Update 27.01.08:
    - Recompiled against Revision 17180.

    Update 11.02.08:
    - Recompiled against Revision 17378.
    - The filter is now in SVN.

    Update 12.02.08:
    - Recompiled against Revision 17385.
    - Next part is in SVN
    - Fixed Installer

    Update 08.03.08:
    - Recompiled against Revision 17811

    Update 26.04.08:
    - Updated installer for TVServer 1.0 RC1
    - Recompiled against Revision 18951

    Update 18.05.08:
    - Recompiled against Revision 19127

    Update 15.06.08:
    - Recompiled against Revision 19376

    Update 20.06.08:
    - Fixed Installer for new schema name

    Update 28.09.08:
    - Recompiled against Revision 20339

    Update 20.10.08:
    - Recompiled against Revision 20432 = 1.0 RC3

    Update 28.11.08:
    - Recompiled against Revision 20955 = 1.0 RC4

    Update 26.12.08:
    - Recompiled against Revision 21156 = 1.0 final
    - Replaced source zip with new patch file

    Update 12.04.09:
    - Recompiled against Revision 22247 = 1.0.1 + fix for of mantis #2095
    - Upgraded patch for Gentle 1.5
    - Fixed installer for MySQL

    Update 24.05.09:
    - Recompiled against Revision 22555 = 1.0.2
    - Added new encoder for HVR-4000 of WinTV7

    Update 09.09.10 - UNTESTED:
    - Recompiled against MP 1.1.0
    - This version is untested

    Update 16.09.10 - UNTESTED:
    - Fixed version for MP 1.1.0
    - This version is also untested
     

    Attachments

    • AnalogPatch-Rev22555.zip
      30.7 KB
    • AnalogPatch-Rev22555.patch
      30.7 KB
    • AnalogPatch-V1.1.0.patch
      26.5 KB
    • AnalogPatch-V1.1.0.zip
      829.6 KB

    SciDoctor

    Retired Team Member
  • Premium Supporter
  • February 2, 2005
    1,465
    139
    England
    Using an ATI tuner here.

    Everything installed fine but the ATI MCE filter encoders (atimcenc.dll) aren't listed in the Software Encoder TAB'

    Can these be added if so how, i am also willing to test.

    Progress so far.

    I've edited the database to include the

    'ATI Media Center Audio Encoder'

    'ATI Media Center Video Encoder'

    When I run the TVSetup these encoders show as installed and available.


    Now the next step would be to include the specific multiplexer for these filters.

    'ATI Media Center Multiplexer'

    Question , where do I change this ?

    Looking in the logs for the graph build I can see a problem where the encoders aren't being used and the connection is called direct to the mpegdemuxer. This fails as NO encoding has occured. Where in the database do I need to add or edit details.

    2007-12-31 19:30:30.828125 [8]: analog: build graph
    2007-12-31 19:30:30.843750 [8]: analog: AddTvTunerFilter ATI T200 AVStream Analog Tuner
    2007-12-31 19:30:31.046875 [8]: analog: AddCrossBarFilter
    2007-12-31 19:30:31.046875 [8]: analog: AddCrossBarFilter try:ATI T200 AVStream Analog Xbar 0
    2007-12-31 19:30:31.171875 [8]: analog: FindCrossBarPin type:Video_Tuner direction:Input
    2007-12-31 19:30:31.171875 [8]: analog: FindCrossBarPin inputs:5 outputs:2
    2007-12-31 19:30:31.171875 [8]: analog: pin 0 type:Video_Tuner
    2007-12-31 19:30:31.171875 [8]: analog: FindCrossBarPin found pin at index:0
    2007-12-31 19:30:31.171875 [8]: analog: ConnectFilter()
    2007-12-31 19:30:31.171875 [8]: analog: PinDest:name:0: Video Tuner In [6/1] Direction:Input Connected:False
    2007-12-31 19:30:31.171875 [8]: analog: pinSource 0:name:Analog Video [5/1] Direction:Output Connected:False
    2007-12-31 19:30:31.171875 [8]: analog: pins connected
    2007-12-31 19:30:31.171875 [8]: analog: AddCrossBarFilter succeeded
    2007-12-31 19:30:31.171875 [8]: analog: AddTvAudioFilter
    2007-12-31 19:30:31.187500 [8]: analog: FindCrossBarPin type:Audio_Tuner direction:Input
    2007-12-31 19:30:31.187500 [8]: analog: FindCrossBarPin inputs:5 outputs:2
    2007-12-31 19:30:31.187500 [8]: analog: pin 0 type:Video_Tuner
    2007-12-31 19:30:31.187500 [8]: analog: pin 1 type:Video_Composite
    2007-12-31 19:30:31.187500 [8]: analog: pin 2 type:Video_SVideo
    2007-12-31 19:30:31.187500 [8]: analog: pin 3 type:Audio_Tuner
    2007-12-31 19:30:31.187500 [8]: analog: FindCrossBarPin found pin at index:3
    2007-12-31 19:30:31.187500 [8]: analog: AddTvAudioFilter try:ATI T200 AVStream Analog TV Audio 0
    2007-12-31 19:30:31.203125 [8]: analog: ConnectFilter()
    2007-12-31 19:30:31.203125 [8]: analog: PinDest:name:TVAudio In [5/1] Direction:Input Connected:False
    2007-12-31 19:30:31.203125 [8]: analog: pinSource 0:name:Analog Video [6/1] Direction:Output Connected:True
    2007-12-31 19:30:31.203125 [8]: analog: skipping pin
    2007-12-31 19:30:31.203125 [8]: analog: pinSource 1:name:Analog Audio [6/1] Direction:Output Connected:False
    2007-12-31 19:30:31.203125 [8]: analog: pins connected
    2007-12-31 19:30:31.203125 [8]: analog: AddTvAudioFilter succeeded:ATI T200 AVStream Analog TV Audio
    2007-12-31 19:30:31.203125 [8]: analog: AddTvCaptureFilter
    2007-12-31 19:30:31.218750 [8]: analog: AddTvCaptureFilter try:ATI T200 AVStream Analog Capture 0
    2007-12-31 19:30:31.234375 [8]: analog: AddTvCaptureFilter connected to crossbar successfully
    2007-12-31 19:30:31.234375 [8]: analog: FindCapturePin on capture filter
    2007-12-31 19:30:31.234375 [8]: analog: FindCapturePin pin:name:ATI Video Decoder YUV Output [20/1] Direction:Output Connected:False
    2007-12-31 19:30:31.234375 [8]: analog: FindCapturePin major:e436eb83-524f-11ce-9f53-0020af0ba770 sub:e06d8022-db46-11cf-b4d1-00805f6cbbea
    2007-12-31 19:30:31.250000 [8]: analog: FindCapturePin succeeded
    2007-12-31 19:30:31.250000 [8]: analog: FindVBIPin
    2007-12-31 19:30:31.250000 [8]: analog: VBI
    2007-12-31 19:30:31.250000 [8]: analog: SetupTeletext()
    2007-12-31 19:30:31.265625 [8]: analog:confused:inkGraphEx.SetupTeletext(): Found WST Codec filter
    2007-12-31 19:30:31.281250 [8]: analog: teletext setup
    2007-12-31 19:30:31.281250 [8]: analog: AddMpeg2Demultiplexer
    2007-12-31 19:30:31.281250 [8]: analog: connect capture->mpeg2 demux
    2007-12-31 19:30:31.296875 [8]: analog: ConnectFilters returns:0x80040217
    2007-12-31 19:30:31.296875 [8]: analog:Dispose()
    2007-12-31 19:30:31.296875 [8]: analog:All filters removed
    2007-12-31 19:30:31.312500 [8]: analog: dispose completed



    error
    2007-12-31 19:29:15.218750 [8]: Exception :TvLibrary.TvException: Unable to connect capture-> MPEG2 demultiplexer
    at TvLibrary.Implementations.Analog.TvCardAnalogBase.BuildGraph()
    at TvLibrary.Implementations.Analog.TvCardAnalog.Tune(Int32 subChannelId, IChannel channel)
    at TvService.CardTuner.Tune(User& user, IChannel channel, Int32 idChannel)
    2007-12-31 19:29:15.218750 [8]: Exception :Unable to connect capture-> MPEG2 demultiplexer
    2007-12-31 19:29:15.218750 [8]: site :Void AddMpeg2Demultiplexer()
    2007-12-31 19:29:15.218750 [8]: source :TVLibrary
    2007-12-31 19:29:15.218750 [8]: stacktrace: at TvLibrary.Implementations.Analog.TvCardAnalogBase.BuildGraph()
    at TvLibrary.Implementations.Analog.TvCardAnalog.Tune(Int32 subChannelId, IChannel channel)
    at TvService.CardTuner.Tune(User& user, IChannel channel, Int32 idChannel)

    I can see from the work you have done and the way the unmodified TVSERVER works that there aren't database fileds available for filters I need to add and that they are hard coded into the TVSERVER.

    What is needed is database fields for all directshow filters that the TVSERVER uses so changes can easily be made just like your mod does with the encoder filters.
     

    SciDoctor

    Retired Team Member
  • Premium Supporter
  • February 2, 2005
    1,465
    139
    England
    In your new database table the label '0' for video or '1' for audio encoders .

    Maybe an expansion on this and '2' for 'mpeg de/mux' filters for the graph build routine to try .

    This would also need further changes for your code.
     

    5Hundred

    Portal Pro
    December 14, 2007
    166
    4
    Home Country
    New Zealand New Zealand
    Hi and thanks for your work in this area, MP really requires some serious effort to work with SW encoding cards.

    I installed and configured as you have detailed but my Pinnacle PCTV 300i still refuses to work with TVserver, i get a no audio/video detected error when trying to view a channel.

    I have set the pinnacle encoders to number 1 priority (the card works fine with the manufacturers software) and have as number 2 the intevideo encoder. The channel scan works perfectly but within tvserver preview or MP i always get the same no audio/video detected error. My DVB-S cards work with no problems.

    I have tried the card with a standalone MP setup and it does work, so why the difference between MP standalone and MP tvserver?

    logs to follow shortly, still recovering from new year!!
     

    SciDoctor

    Retired Team Member
  • Premium Supporter
  • February 2, 2005
    1,465
    139
    England
    Quote
    'I have tried the card with a standalone MP setup and it does work, so why the difference between MP standalone and MP tvserver?'


    The difference is that with the standard MP there is an xml file with all the details of the filters needed to build the succesful graph for specific cards. It is also easy for the user to modify for success.

    With TV server the graph build tries suitable filters that are listed within the server code, if the filters aren't there the graph build fails. It is not at all easy for the user to change this.

    It is obvious from my ATI situation that the ATI encoder filters aren't included and specificaly with some tuners encoder filters include their own specific mpeg2mux filter which also aren't included.

    Use graphedit to check what directshow filters your tuner uses, build a trial graph and see if it connects and works. the log will be produced in the TVserver log files for mpwriter.
     

    misterd

    Retired Team Member
  • Premium Supporter
  • April 4, 2006
    1,597
    314
    Home Country
    Germany Germany
    I have only included the standard encoder filters that were in the code. As SciDoctor already found out, you can now manually add encoders to the db by modifying the db.
    For sure this can be done with multiplexers. Unfortunately I have no idea, how this can be included the best way into SetupTV. Any advice is really appreciated.
    There is also another option missing. Hauppauge also delivers an all-in-one encoder (video+audio+mux). Such filters are currently not supported and I think that they should be supported too.

    SciDoctor:
    I saw in the code that there is special handling for ati tuners. I have modified the condition so that it also fits to your card. Could you please try the attached dll? Perhaps this one is working for you.

    IMHO the code needs a refactoring to support all cards that are supported by MP's internal TVEngine. At the moment the automatic graph building is already really complicated in the code. Adding more and more special cases in the code would make the code no longer maintainable.

    MisterD
     

    SciDoctor

    Retired Team Member
  • Premium Supporter
  • February 2, 2005
    1,465
    139
    England
    IMHO the code needs a refactoring to support all cards that are supported by MP's internal TVEngine. At the moment the automatic graph building is already really complicated in the code. Adding more and more special cases in the code would make the code no longer maintainable.

    MisterD

    That is why it would be a good idea to move ALL filters into the database in specific fileds like you have already done with audio and video encoders.

    Thanks for your work, i will try later and feedback.

    There is an improvement as now the build is acknowledging that a software card is needing a specific muxer but it still ignores the need for audio/video encoders.

    AddTvMultiPlexer no multiplexer devices found (devices.Length == 0)

    is the specific error point, the graph build should look for the software audio/video encoders prior to this.

    -------

    2008-01-01 16:09:36.906250 [8]: analog: Tune:tv: Freq:0 Channel:128 Country:United Kingdom Tuner:Antenna Video:Tuner
    2008-01-01 16:09:36.906250 [8]: analog: build graph
    2008-01-01 16:09:36.906250 [8]: analog: AddTvTunerFilter ATI T200 AVStream Analog Tuner
    2008-01-01 16:09:37.125000 [8]: analog: AddCrossBarFilter
    2008-01-01 16:09:37.125000 [8]: analog: AddCrossBarFilter try:ATI T200 AVStream Analog Xbar 0
    2008-01-01 16:09:37.140625 [8]: analog: FindCrossBarPin type:Video_Tuner direction:Input
    2008-01-01 16:09:37.140625 [8]: analog: FindCrossBarPin inputs:5 outputs:2
    2008-01-01 16:09:37.140625 [8]: analog: pin 0 type:Video_Tuner
    2008-01-01 16:09:37.140625 [8]: analog: FindCrossBarPin found pin at index:0
    2008-01-01 16:09:37.140625 [8]: analog: ConnectFilter()
    2008-01-01 16:09:37.140625 [8]: analog: PinDest:name:0: Video Tuner In [6/1] Direction:Input Connected:False
    2008-01-01 16:09:37.140625 [8]: analog: pinSource 0:name:Analog Video [5/1] Direction:Output Connected:False
    2008-01-01 16:09:37.140625 [8]: analog: pins connected
    2008-01-01 16:09:37.140625 [8]: analog: AddCrossBarFilter succeeded
    2008-01-01 16:09:37.140625 [8]: analog: AddTvAudioFilter
    2008-01-01 16:09:37.156250 [8]: analog: FindCrossBarPin type:Audio_Tuner direction:Input
    2008-01-01 16:09:37.156250 [8]: analog: FindCrossBarPin inputs:5 outputs:2
    2008-01-01 16:09:37.156250 [8]: analog: pin 0 type:Video_Tuner
    2008-01-01 16:09:37.156250 [8]: analog: pin 1 type:Video_Composite
    2008-01-01 16:09:37.156250 [8]: analog: pin 2 type:Video_SVideo
    2008-01-01 16:09:37.156250 [8]: analog: pin 3 type:Audio_Tuner
    2008-01-01 16:09:37.156250 [8]: analog: FindCrossBarPin found pin at index:3
    2008-01-01 16:09:37.156250 [8]: analog: AddTvAudioFilter try:ATI T200 AVStream Analog TV Audio 0
    2008-01-01 16:09:37.171875 [8]: analog: ConnectFilter()
    2008-01-01 16:09:37.171875 [8]: analog: PinDest:name:TVAudio In [5/1] Direction:Input Connected:False
    2008-01-01 16:09:37.171875 [8]: analog: pinSource 0:name:Analog Video [6/1] Direction:Output Connected:True
    2008-01-01 16:09:37.171875 [8]: analog: skipping pin
    2008-01-01 16:09:37.171875 [8]: analog: pinSource 1:name:Analog Audio [6/1] Direction:Output Connected:False
    2008-01-01 16:09:37.171875 [8]: analog: pins connected
    2008-01-01 16:09:37.171875 [8]: analog: AddTvAudioFilter succeeded:ATI T200 AVStream Analog TV Audio
    2008-01-01 16:09:37.171875 [8]: analog: AddTvCaptureFilter
    2008-01-01 16:09:37.187500 [8]: analog: AddTvCaptureFilter try:ATI T200 AVStream Analog Capture 0
    2008-01-01 16:09:37.203125 [8]: analog: AddTvCaptureFilter connected to crossbar successfully
    2008-01-01 16:09:37.203125 [8]: analog: FindCapturePin on capture filter
    2008-01-01 16:09:37.203125 [8]: analog: FindCapturePin pin:name:ATI Video Decoder YUV Output [21/1] Direction:Output Connected:False
    2008-01-01 16:09:37.203125 [8]: analog: FindCapturePin major:e436eb83-524f-11ce-9f53-0020af0ba770 sub:e06d8022-db46-11cf-b4d1-00805f6cbbea
    2008-01-01 16:09:37.203125 [8]: analog: FindCapturePin succeeded
    2008-01-01 16:09:37.203125 [8]: analog: ATI AVStream Analog Capture card detected adding mux
    2008-01-01 16:09:37.218750 [8]: analog: AddTvMultiPlexer
    2008-01-01 16:09:37.218750 [8]: analog: AddTvMultiPlexer no multiplexer devices found (devices.Length == 0)
    2008-01-01 16:09:37.218750 [8]: analog: FindCapturePin on capture filter
    2008-01-01 16:09:37.218750 [8]: analog: FindCapturePin pin:name:ATI Video Decoder YUV Output [23/2] Direction:Output Connected:False
    2008-01-01 16:09:37.218750 [8]: analog: FindCapturePin major:e436eb83-524f-11ce-9f53-0020af0ba770 sub:e06d8022-db46-11cf-b4d1-00805f6cbbea
    2008-01-01 16:09:37.218750 [8]: analog: FindCapturePin succeeded
    2008-01-01 16:09:37.218750 [8]: analog: FindVBIPin
    2008-01-01 16:09:37.218750 [8]: analog: VBI
    2008-01-01 16:09:37.218750 [8]: analog: SetupTeletext()
    2008-01-01 16:09:37.250000 [8]: analog:confused:inkGraphEx.SetupTeletext(): Found WST Codec filter
    2008-01-01 16:09:37.250000 [8]: analog: teletext setup
    2008-01-01 16:09:37.250000 [8]: analog: AddMpeg2Demultiplexer
    2008-01-01 16:09:37.250000 [8]: analog: connect capture->mpeg2 demux
    2008-01-01 16:09:37.265625 [8]: analog: ConnectFilters returns:0x80040217
    2008-01-01 16:09:37.281250 [8]: analog:Dispose()
    2008-01-01 16:09:37.281250 [8]: analog:All filters removed
    2008-01-01 16:09:37.281250 [8]: analog: dispose completed
    2008-01-01 16:09:37.312500 [8]: Stopcard
    2008-01-01 16:09:37.328125 [8]: Controller: epg start
    2008-01-01 16:09:52.296875 [7]: TV service PowerEventThread 537
    2008-01-01 16:09:52.296875 [7]: TV service PowerEventThread 537
     

    misterd

    Retired Team Member
  • Premium Supporter
  • April 4, 2006
    1,597
    314
    Home Country
    Germany Germany
    That is why it would be a good idea to move ALL filters into the database in specific fileds like you have already done with audio and video encoders.
    I agree that it perhaps would be good to move all encoding, multiplexing filters into the db and give them a priority. An improvement would also be when the user could choose between automatic selection of these filter or select specific ones.
    I think that putting all other filters (tuner, capture etc.) into the db isn't the right way, because they are automatically detected. I think there are two solutions, how we can improve the detection of all cards:
    1.) Normally the server uses the automatic detection algorithm, but it also have an additional CaputreCardDefinitions.xml or something similar for those special cards like yours.
    2.) The main problem of the graph building that all cases are handled in one class (~2000 lines of code). I think it would be better if there is something like a factory/plugin system. There is one standard case and all special cases that are depending on some filter names are handled in separated classes. But this is a really complicated and time consuming job. A plugin system would perhaps also help, because than the community users could write those special cases too.


    There is an improvement as now the build is acknowledging that a software card is needing a specific muxer but it still ignores the need for audio/video encoders.

    AddTvMultiPlexer no multiplexer devices found (devices.Length == 0)

    is the specific error point, the graph build should look for the software audio/video encoders prior to this.
    OK, now I understand what's going on. The main problem is your driver, because it reports the server that it already has an MPEG2 program stream on the capture filter, which isn't true. Therefor no software encoders are added.

    I could a condition that ignore this result for your capture filter, but I'm pretty sure that than the TvServer wouldn't find the video pin when trying to add the video encoder. This would than need a special detection of this pin too.

    MisterD
     

    SciDoctor

    Retired Team Member
  • Premium Supporter
  • February 2, 2005
    1,465
    139
    England
    I can see where the problem arrises from lazy ATI programing.

    The T200 filter set is used for both analog software and hardware encoding and digital DVB-t . PIN outs not used aren't removed.

    The first pin out that is checked and found would be the hardware mpeg output if it existed.

    Question : Whenthe tv server fails on a pin connection does it reset the check for the need for software encoders on the next pin out checked or does it assume the first condition is still true? maybe this isn't happening and could be a bug causing the error (or does the whole filter flag the result and not specific pin outs)
     

    diehard2

    Retired Team Member
  • Premium Supporter
  • April 22, 2006
    518
    28
    Chicago
    Home Country
    United States of America United States of America
    Hi misterd, looks like you've done quite a bit of work. I can shed a bit of light on why it is so slow to build the analog graph sometimes. The problem is with pin connections. It takes forever when a pin connection is rejected (you can see this in graphedit) and is the reason for my special hack with the hauppauge cards. An ideal fix (which I've been too busy to implement) would be to create the graph using the current methods and

    1. iterate through the graph and get each filter's CLSID, the order of the filter in the graph, and the pin connections (by name)
    2. Store this information in the database (or an xml file)
    3. When the tv server is run again, if the card is in the system and nothing has changed, it will check the database, add all of the filters by CLSID, and connect each pin on the correct filter by pin name. This will make the appropriate connections directly instead of using trial and error.

    This would be extremely fast.
     

    Users who are viewing this thread

    Top Bottom