Patched to be more reliable with different cameras.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1084 e3e1d417-86f3-4887-817a-d78f3d33393fpull/27/merge
parent
a7e0fcef41
commit
7e926c5ac1
|
@ -438,36 +438,39 @@ int RemoteCamera::GetResponse()
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
static RegExpr *content_expr = 0;
|
static RegExpr *content_expr = 0;
|
||||||
if ( mode == SINGLE_JPEG )
|
|
||||||
{
|
|
||||||
static RegExpr *single_jpeg_expr = 0;
|
|
||||||
if ( !content_expr )
|
|
||||||
{
|
|
||||||
content_expr = new RegExpr( "^(.+?)(?:\r?\n){1,2}?$", PCRE_DOTALL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static RegExpr *multi_jpeg_expr = 0;
|
|
||||||
if ( !content_expr )
|
|
||||||
{
|
|
||||||
char content_pattern[256] = "";
|
|
||||||
snprintf( content_pattern, sizeof(content_pattern), "^(.+?)(?:\r?\n){1,2}?(?:--)?%s\r?\n", content_boundary );
|
|
||||||
content_expr = new RegExpr( content_pattern, PCRE_DOTALL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( buffer_len )
|
if ( buffer_len )
|
||||||
{
|
{
|
||||||
if ( content_expr->Match( buffer, buffer.Size() ) == 2 )
|
if ( mode == MULTI_JPEG )
|
||||||
{
|
{
|
||||||
content_length = content_expr->MatchLength( 1 );
|
if ( !content_expr )
|
||||||
Debug( 3, ( "Got end of image by pattern, content-length = %d", content_length ));
|
{
|
||||||
|
char content_pattern[256] = "";
|
||||||
|
snprintf( content_pattern, sizeof(content_pattern), "^(.+?)(?:\r?\n){1,2}?(?:--)?%s\r?\n", content_boundary );
|
||||||
|
content_expr = new RegExpr( content_pattern, PCRE_DOTALL );
|
||||||
|
}
|
||||||
|
if ( content_expr->Match( buffer, buffer.Size() ) == 2 )
|
||||||
|
{
|
||||||
|
content_length = content_expr->MatchLength( 1 );
|
||||||
|
Debug( 3, ( "Got end of image by pattern, content-length = %d", content_length ));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
content_length = buffer.Size();
|
content_length = buffer.Size();
|
||||||
Debug( 3, ( "Got end of image by closure, content-length = %d", content_length ));
|
Debug( 3, ( "Got end of image by closure, content-length = %d", content_length ));
|
||||||
|
if ( mode == SINGLE_JPEG )
|
||||||
|
{
|
||||||
|
if ( !content_expr )
|
||||||
|
{
|
||||||
|
content_expr = new RegExpr( "^(.+?)(?:\r?\n){1,2}?$", PCRE_DOTALL );
|
||||||
|
}
|
||||||
|
if ( content_expr->Match( buffer, buffer.Size() ) == 2 )
|
||||||
|
{
|
||||||
|
content_length = content_expr->MatchLength( 1 );
|
||||||
|
Debug( 3, ( "Trimmed end of image, new content-length = %d", content_length ));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue