perthcpe23 / android-mjpeg-view

Custom View to display MJPEG
MIT License
64 stars 20 forks source link

Fixing boundary detection using stream headers #1

Closed hughreeling closed 5 years ago

hughreeling commented 5 years ago

When the connection to the stream is established, the headers contain 'Content-type' and this contains a 'boundary' string that identified the string used to delimit images in the stream. This change extracts this string, and uses is in the regex to identify the frame breaks.

hughreeling commented 5 years ago

One other thought - didn't put too much care into the error handling - just threw exceptions - perhaps we need to do more there.

perthcpe23 commented 5 years ago

How about falling back to default Regex like the one we've been using?

Pattern pattern = Pattern.compile("--[_a-zA-Z0-9]*boundary\\s+(.*)\\r\\n\\r\\n",Pattern.DOTALL);
hughreeling commented 5 years ago

Good idea. I'll update tonight.

perthcpe23 commented 5 years ago

I made a change about falling back to a default pattern. Could you please check if you satisfy with that, if not, feel free to make any change you would like. Then, I can merge all these changes and release a new version. (Sorry, accidentally close the issue, re-opened)

hughreeling commented 5 years ago

Looks fantastic- nice. If you're good with it, I'm fine with merging.