MJPEG Stream Client January 25, 2011 04:11PM | Registered: 14 years ago Posts: 18 |
Re: MJPEG Stream Client January 25, 2011 08:51PM | Registered: 14 years ago Posts: 18 |
Re: MJPEG Stream Client January 26, 2011 12:14AM | Registered: 14 years ago Posts: 18 |
Re: MJPEG Stream Client January 26, 2011 12:44AM | Registered: 14 years ago Posts: 18 |
char* findImage(const char * buf, int bytes_read) { char * p = buf; char find[2]; find[0]=(char)0xFF; find[1]=(char)0xD8; int k = 0; while (p = memchr(buf, find[0],bytes_read) && k < bytes_read) { if (*++p == find[1]) { return --p; } k++; } return NULL; }However it does not do so :S
Re: MJPEG Stream Client January 26, 2011 04:40AM | Registered: 15 years ago Posts: 444 |
char *p = buf; while(k < bytes_read)}{ if(memcmp(find,p,2) == 0){ return p; } else { p++; } k++ } return NULL;I can't garentee that this code will be correct, but it should give you an idea.
Re: MJPEG Stream Client January 26, 2011 10:40AM | Registered: 14 years ago Posts: 379 |
Re: MJPEG Stream Client January 26, 2011 05:29PM | Registered: 14 years ago Posts: 18 |
Thanks, did'nt see that one. Fixed it now. I guess it would always return null and therefor give me wrong readings? Shouldn't it cause an exception when trying to dump the image when it's pointing to null?Quote
You increment k, then you check the same area of memory again in your memchr() function. Also, memchr is not the best function to use here. Try using memcmp.
Re: MJPEG Stream Client January 26, 2011 10:54PM | Registered: 15 years ago Posts: 444 |
Re: MJPEG Stream Client January 27, 2011 08:45PM | Registered: 14 years ago Posts: 18 |