- if( !(psz_descfilename = config_GetPsz( p_vout,
- "motiondetect-description" ) ) )
- {
- free( p_vout->p_sys );
- return VLC_EGENERIC;
- }
-
- p_vout->p_sys->p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( !p_vout->p_sys->p_playlist )
- {
- msg_Err( p_vout, "playlist not found" );
- free( p_vout->p_sys );
- return VLC_EGENERIC;
- }
-
- /* Parse description file and allocate areas */
- p_file = fopen( psz_descfilename, "r" );
- if( !p_file )
- {
- msg_Err( p_this, "Failed to open descritpion file %s",
- psz_descfilename );
- free( psz_descfilename );
- free( p_vout->p_sys );
- return VLC_EGENERIC;
- }
- p_vout->p_sys->i_areas = 0;
- while( fscanf( p_file, "%d,%d,%d,%d,%d,%d,%d,",
- &x1, &y1, &x2, &y2, &i_level,
- &i_downspeed, &i_upspeed ) == 7 )
- {
- for( i = 0 ; i < 255 ; i++ )
- {
- fread( buffer + i, 1, 1, p_file );
- if( *( buffer + i ) == '\n' )
- break;
- }
- *( buffer + i ) = 0;
- p_vout->p_sys->i_areas++;
- p_vout->p_sys->pp_areas = realloc( p_vout->p_sys->pp_areas,
- p_vout->p_sys->i_areas *
- sizeof( area_t ) );
- if( !p_vout->p_sys->pp_areas )
- /*FIXME: clean this... */
- return VLC_ENOMEM;
- p_area = malloc( sizeof( area_t ) );
- if( !p_area )
- break;
-
- p_area->i_x1 = x1;
- p_area->i_x2 = x2;
- p_area->i_y1 = y1;
- p_area->i_y2 = y2;
- p_area->i_matches = 0;
- p_area->i_level = i_level;
- p_area->i_downspeed = i_downspeed;
- p_area->i_upspeed = i_upspeed;
-
- p_area->psz_mrl = strdup(buffer);
- p_vout->p_sys->pp_areas[p_vout->p_sys->i_areas-1] = p_area;
- }
- fclose( p_file );