NSURLConnection and multipart/x-mixed-replace streams

Discussion in 'Mac Programming' started by Nutter, Aug 6, 2007.

  1. macrumors 6502

    Joined:
    Mar 31, 2005
    Location:
    London, England
    #1
    I'm trying to use NSURLConnection to access an MJPEG stream.

    All that I've seen leads me to believe that my delegate should receive a connection:didReceiveResponse: message at the start of each new frame. Apple's documentation mentions this explicitly, and it's also described in this post to the Webkitsdk-dev mailing list:
    http://lists.apple.com/archives/Webkitsdk-dev/2005/Dec/msg00036.html

    However, it's not working like that for me. I'm getting one connection:didReceiveResponse: message, followed by an indefinite series of connection:didReceiveData: messages. Like this:

    connection:didRecieveResponse:
    connection:didReceiveData:
    connection:didReceiveData:
    connection:didReceiveData:
    connection:didReceiveData:

    ... and so on.

    The connection definitely isn't finishing or failing, and I'm continuing to receive data long after the first frame must have finished transmitting, but I never get another connection:didReceiveResponse: message. I've tried this with two different network cameras now, and the result is the same.

    Does anyone have any idea why this is happening?

    (I posted this question on the Cocoa-dev mailing list, but didn't get a response. I'm tearing my hair out over this, so if anyone has any experience at all with multipart streams and NSURLConnection, advice would be much appreciated!)
     
  2. thread starter macrumors 6502

    Joined:
    Mar 31, 2005
    Location:
    London, England
    #2
    For anyone interested, it looks like something is in fact broken with either the documentation or the implementation of this.

    You will only get one response message for a multipart stream, followed by the raw data from the first boundary onwards. It's up to you to parse the stream for the headers and content of each part.
     
  3. macrumors newbie

    Joined:
    Sep 11, 2008
    #3
    I am new to COCOA. And i am trying to implement the Multipart parser but i am struck in making the buffer from the data and checking boundaries in this data.
    Can you please send the code for the Multipart parser?

    I will be very thankful to you for this.

    Thanks
    Adeesh Jain
     
  4. macrumors newbie

    Joined:
    Sep 11, 2008
    #4
    Please send me the code for multipart parser at jain.adeesh@gmail.com. Or please help me in resolving the issue.

    You are our last hope. Please help us.
     

Share This Page