[Rejected] IPTV-Filter: Support for rtp and http (1 Viewer)

SilentException

Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    Re: AW: Re: IPTV-Filter: Support for rtp and http

    This patch is bit messy due to logging -> LOGGING changes and other logging related changes. Would it be possible to get one without so we could just see those rtp/http added?

    Hi tontsa,

    would it be OK just to rename the #define for logging or should we remove all logging related stuff?

    If logging is not of critical value, you should remove IFDEF and log lines. Otherwise, leave just log lines.
     

    Stepko

    Retired Team Member
  • Premium Supporter
  • September 29, 2007
    186
    152
    Hamburg/Wolfsburg
    Home Country
    Germany Germany
    AW: Re: AW: Re: IPTV-Filter: Support for rtp and http

    Hi,

    all logging is removed. Attached are the new .patch files, again one with Visual Studio project file and one without. I use VS2005 and I'm not sure if the project file is compatible with other versions.
    If you have any problems with the changes or questions, please let me know.

    Stepko
     

    Attachments

    • mp_iptv_woProject(svn24669).patch
      44.9 KB
    • mp_iptv_wProject(svn24669).patch
      48.5 KB

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Re: AW: Re: AW: Re: IPTV-Filter: Support for rtp and http

    Any new progress on this one?

    Sorry for a late reply - IPTV is something that team developers don't have that much experience (or knowledge), basicly because I know no one who has access to IPTV service. I did have a quick look on the patch and here are some quick review comments (the actual functionality is not reviewed at all).

    1) MP coding conventions should be followed. For example

    Code:
    if (foo) {
    } else {
    }

    should be

    Code:
    if (foo) {
    } else {
    }

    Code:
    if(m_socket >= 0) {closesocket(m_socket); m_socket = -1;};

    should be

    Code:
    if (m_socket >= 0) 
    {
      closesocket(m_socket); 
      m_socket = -1;
    }

    This might sound like unimportant nagging, but actually it is quite important for big projects to keep the code as easy to read as possible (the original filter code might have also the wrong coding conventions in use - didn't check that at all)

    2) Should the user agent string be configurable? Or does it work for all broadcasters / content providers?
    Code:
    hINet = InternetOpen("Mozilla/4.0", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );

    3) Some error logging / handling missing?

    Code:
    +    if ( hData ) {
    +		  if (!HttpSendRequest( hData, NULL, -1, NULL, 0)) {
    +		  }

    4) Cannot we use some events or callback notifications to detect when new data arrives? This would reduce possibility for stuttering because of late data arrival (quite unlikely)

    Code:
    +    // If nothing recieved wait 100ms and read once more
    +    if (len == 0) {
    +      Sleep(100);  
    +      resp = InternetReadFile( hData, pData, cbData, (LPDWORD)&len ) ;

    5) could we just use a pointer to array that has 12 byte offset?

    Code:
    // This buffer will hold the data only for a short time. Its nessecary because we need to skip the first 12 bytes

    6) variables not initialized before used, might trigger compiler warning (unless VS notices that the getPacketData() fills the variables)

    Code:
       unsigned int firstTimestamp;
       unsigned int lastTimestamp;
       bool isContinous;
       int processedBytes = rtpHandler.getPacketData(pData, cbData, firstTimestamp, lastTimestamp, isContinous);

    7) Timestamps aren't used? Any specific reason why not?

    Code:
        REFERENCE_TIME rtStart = 0; //firstTimestamp;
        REFERENCE_TIME rtStop  = 0; //lastTimestamp;

    8) Shouldn't content as well be freed to prevent a memory leaks? (#include "..\alloctracing.h" can be used to track down leaks)

    Code:
    void ZeroURL(URL_COMPONENTS *url) {
      url->lpszScheme = NULL;
      url->lpszExtraInfo = NULL;
      url->lpszHostName = NULL;
      url->lpszPassword = NULL;
      url->lpszUrlPath = NULL;
      url->lpszUserName = NULL;
    
      url->dwSchemeLength    = -1;
      url->dwHostNameLength  = -1;
      url->dwUrlPathLength   = -1;
      url->dwExtraInfoLength = -1;
    };

    9) Possible heap corruption. fn lenght could be over 2kb (not in normal cases most likely, but could allow someone to use buffer overflow attacks - there might be few similar places in MP's exsting code but we shouldn't at least add more :p)

    Code:
      char pBuff[2048];
      memset(pBuff,0,2048);
      memcpy(pBuff,fn,strlen(fn)+1);

    10) Comment doesn't match the actual code. Also the buffer settings might be good to be configurable since network speed could affect this?

    Code:
    #define IPTV_BUFFER_SIZE 10 * 1024 //By default 32KB buffer size

    11) Copyright should be ...2010

    Code:
    *	Copyright (C) 2006-2009 Team MediaPortal

    12) packetItem should free it's own resources. Also it would be good to use setters and getters for accessing the data instead of directly using the member variables

    Code:
        packetItem *temp = firstItem;
        firstItem = firstItem->next;
        delete temp->data;
        delete temp;
    ...
      newItem->data = new char[length];
      memcpy(newItem->data, data, length);
      newItem->size = length;
      newItem->next = NULL;
      newItem->sequenceNr = sequenceNr;
      newItem->timestamp = timestamp;

    13) Quite useless comment :)

    Code:
      // If buffer is greater than IPTV_RTP_INTERNAL_BUFFER_SIZE deliver data
      if (packetSizeTotal >= IPTV_RTP_INTERNAL_BUFFER_SIZE) return true;

    Quite big patch and not that much on a quick look that should be improved. Hopefully someone can take a more deeper look into the patch.
     

    Stepko

    Retired Team Member
  • Premium Supporter
  • September 29, 2007
    186
    152
    Hamburg/Wolfsburg
    Home Country
    Germany Germany
    AW: Re: AW: Re: AW: Re: IPTV-Filter: Support for rtp and http

    Thanks for looking into our code and for your suggestions/notes.

    1) MP coding conventions [...]
    When I started to work on the filter I set up VS to meet the coding conventions. But while coding I didn't pay much attention on that. I'm used to a different style (more the Java way). :)
    But I do understand the reasons why the the coding convention is important. Will change the code to meet the conventions better...

    4) Cannot we use some events or callback notifications to detect when new data arrives? This would reduce possibility for stuttering because of late data arrival (quite unlikely)
    I found the code in the original version and many socket examples show it the same way. But after your post I searched a bit in msdn. It seems that there is a possibility to register a callback. I think that callback method would run in a different thread. Then we need to synchronize it with the main thread, at least in the rtp part. Do you think it's worth the work?

    5) could we just use a pointer to array that has 12 byte offset?
    The socket writes the received data into that array. I don't think it's possible to tell the socket to use a 12 byte offset. The comment is not as accurate as it should be. The first 12 byte are the rtp header. The filter uses the header to check if it is a rtp packet and to detect dropped packets. I think we need the short-time array, or do I missunderstand you completely :confused:

    6) variables not initialized before used, might trigger compiler warning (unless VS notices that the getPacketData() fills the variables)
    I don't get warings with VS 2005. But besides this any variables should be initialized. Who knows how the next compiler version handles it...

    7) Timestamps aren't used? Any specific reason why not?
    Jap, and this is a long story. In the beginning my inet connection was very bad when it comes to IPTV (main reason was that my isp used wrong settings on my cable). That was very bad for watching TV but good to test the filter in terms of error correction. RTP uses udp for transmission and so I got lots of packet losts. I tried different ways to handle the losts packets. I played with the discontinuity flag of the MediaSample, set the timestamp, submitted only continuous data in one mediaSample, inserted missing data with last arrived data as well as with zeros and some other things.... I tested it all with ffdshow dxva, CoreAVC and MS DTV codec. The results were exactly the same when I set the timestamp and when I didn't. Do the dx filters really care about the timestamp? I got the best results without setting the discontinuity flag and without setting the timestamp and with filling the "holes" in the datastream with zeroes. Thats why I set up the filter to work this way.
    But I think you devs and especially you, tourettes, have more experience in dx coding. If there is a good reason to set timestamps and discontinuity flag we can change it.

    8) Shouldn't content as well be freed to prevent a memory leaks? (#include "..\alloctracing.h" can be used to track down leaks)
    Code:
    void ZeroURL(URL_COMPONENTS *url) {
     [...]
    };
    I think I don't get what you mean. ZeroURL is used to initialize the url structure. What conatent do you mean? Anyway, thank for the hint with alloctracing.h. Will check the filter with that.

    9) Possible heap corruption. fn lenght could be over 2kb (not in normal cases most likely, but could allow someone to use buffer overflow attacks - there might be few similar places in MP's exsting code but we shouldn't at least add more :p)
    Oops. You're absolutely right.

    10) Comment doesn't match the actual code. Also the buffer settings might be good to be configurable since network speed could affect this?
    Oops, again. Changed the value often while doing the testings and forgot the comment... :oops:

    12) packetItem should free it's own resources. Also it would be good to use setters and getters for accessing the data instead of directly using the member variables
    Wanted to keep packetItem as lightweight as possible. But you're probably right, it's better the way you suggest.

    13) Quite useless comment :)
    :D

    Quite big patch and not that much on a quick look that should be improved. Hopefully someone can take a more deeper look into the patch.
    That sounds good in my ears. I think there are some people out there who would like to have this patch in the official code.

    I will change the things you mentioned and upload a new version the next days. Hopefully one of the devs have the time then to look into it.


    :D again for looking into it, tourettes

    Stepko
     

    bradholland

    Portal Member
    August 20, 2008
    7
    0
    Hi guys,

    Im a little out of my depth reading this, but someone pointed me to this topic as a possible solution to the problems I am having.

    My tv provider delivers my tv streams to me using the tcp:// protocol.
    I.e a stream looks like this.

    tcp://xxx.xxx.xxx.xxx:4990 (for me this is BBC1)

    is there any chance that you can edit your patch to allow me to enter tcp:// streams into tv server?

    or perhaps you know another way i can add these streams to tv server?

    many thanks
    Brad
     

    Ausdigital

    Portal Pro
    September 17, 2008
    122
    5
    Home Country
    I am seeking assistance setting up IPTV that uses RTP. Hence the reason I am here. I have downloaded the MPIPTVSource.ax file that has been modified but not having any success having it scan for IPTV channels.

    Here is a link to the error reports it generates when I run it - here

    and the link that prompted the questioning that lead me here - here

    Any one able to help?

    Cheers!
     

    paalkr

    Portal Pro
    June 30, 2008
    145
    20
    Home Country
    Norway Norway
    Hi!

    Thanks for the great effort by adding rtp support to the IPTV filter. For SD channels everything seems to work OK, but I have some trouble with the HD channels. The IPTV provider is Telenor (Norwegian).

    I have described the IPTV streams in this post

    My setup is described in this post

    The test recording has been performed by manual control in the TV server setup only, so there should not be any codec issues (I use SAF 5.00 btw).

    Download link for recorded TS stream: http://dl.dropbox.com/u/12465334/NRK1 HD.ts

    Log files from TV server are attached. Hopefully the issue with HDTV can be resolved, thanks in advance!

    Regards,
    PK
     

    anton2703

    New Member
    November 22, 2010
    11
    0
    Home Country
    Russian Federation Russian Federation
    Hi, Stepko

    Thanks a lot for your TV filters. Few time ago I solved problems with picture and sound using your filter MPIPTVSource_hEx_v1_release:
    https://forum.team-mediaportal.com/654127-post126.html

    I changed it to filter in this post, tv works but my problems came back.

    Have you addition of MPIPTVSource_hEx_v1_release which supports http stream?
     

    Stepko

    Retired Team Member
  • Premium Supporter
  • September 29, 2007
    186
    152
    Hamburg/Wolfsburg
    Home Country
    Germany Germany
    AW: IPTV-Filter: Support for rtp and http

    Rejected! I reject my own patch :D
    Georgius improoved the filter to a more stable version which can be downloaded for testing here.
     

    Users who are viewing this thread

    Top Bottom