Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nutter

macrumors 6502
Original poster
Mar 31, 2005
432
0
London, England
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!)
 

Nutter

macrumors 6502
Original poster
Mar 31, 2005
432
0
London, England
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.
 

adeesh

macrumors newbie
Sep 11, 2008
4
0
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.