#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    82

    C#.... Perplexed by video streaming latency


    I am developing a windows GUI client app that accesses a Closed Circuit TV (CCTV) video stream from a Linux based open source back end server app called ZoneMinder. I am using a Web browser control in my Windows client. Specifically, I'm calling the following function:

    Code:
    webBrowser1.Navigate(@"http://XXX.XXXXXX:PORT/index.php?action=login&view=postlogin&username=XXXXX&password=XXXXXX&view=watch&mid=7");
    The above function refreshes the image about once every five seconds. But if I use the native web page front end, the image is refreshed about once every second. That is, if I use Firefox or IE to access and display the video stream, the refresh rate is one second.

    The backend ZM server is generating the video stream using a H.264 codec.

    So, my questions; why is Navigate so sloooooow? And how can I reduce the time between image refreshes?

    Net version is 4.030319 RtmRel.

    Also, to avoid any cross posting issues. This issue has been previously posted on Code Guru

    The remote network connection security issue brought up on that forum is a non issue. SSL is being used for remote connections.
  2. #2
  3. No Profile Picture
    Still Learning
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Montreal, Canada
    Posts
    55
    Rep Power
    39
    This is just a hunch but what browser identification is your control presenting to the site.

    The User Agent information may change how the sever responds to the client.

    The server may think the "browser" is not capable of receiving full speed transfers.
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,393
    Rep Power
    1871
    http://www.wireshark.org/
    Use this to spy on all the network traffic between you and the video server.

    Focus on the initial protocol exchanges and compare differences between what you do in your code, and what a regular browser does.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    82
    I did determine that the control was using the default IE webbrowser. Wireshark output is as follows:

    Code:
    ..U
    0090  73 65 72 2d 41 67 65 6e 74 3a 20 4d 69 63 72 6f   ser-Agent: Micro
    00a0  73 6f 66 74 2d 57 69 6e 64 6f 77 73 2f 36 2e 31   soft-Windows/6.1
    Also, using the following code in my app

    Code:
     string js = @"<SCRIPT type=text/javascript>function getUserAgent(){document.write(navigator.userAgent)}</SCRIPT>";
    
                System.Windows.Forms.WebBrowser wb = new WebBrowser();
                wb.Url = new Uri("about:blank");
                wb.Document.Write(js);
                wb.Document.InvokeScript("getUserAgent");
    
                string userAgent = wb.DocumentText.Substring(js.Length);
    
                System.Console.WriteLine(userAgent);
    produces the following output:

    Code:
    			"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; MDDC)"

    Previously, I had briefly checked both browsers (Firefox and IE) for any issues. Neither exhibited any slowness issues during my very brief test independent of using my control. So, I focused my attention on potential Webbrowser control issues. I revisited IE after wireshark etc. gave me the impression that it was the default browser used by the control and realized that initially it is very fast as in one second refresh rates but it eventually slows down to about 5 second refresh rates. The five second refresh rate become consistent with IE after a few minutes.

    So, now I have to override the default bahavior of the control to use Firefox if it is installed. Otherwise, I'm stuck with IE.

    Unfortunately, I developed "tunnel vision" on this issue and incorrectly made the assumption that the control was the source of the problem.

    Thanx guys. I really appreciate the help getting me back on the right track!

IMN logo majestic logo threadwatch logo seochat tools logo