void BeginObservations() { if (!observing) { mutex.Wait(); UpdateActivity(); observing = 1; } }
static int LoopInput( playlist_t *p_playlist ) { playlist_private_t *p_sys = pl_priv(p_playlist); input_thread_t *p_input = p_sys->p_input; if( !p_input ) return VLC_EGENERIC; if( ( p_sys->request.b_request || !vlc_object_alive( p_playlist ) ) && !p_input->b_die ) { PL_DEBUG( "incoming request - stopping current input" ); input_Stop( p_input, true ); } /* This input is dead. Remove it ! */ if( p_input->b_dead ) { PL_DEBUG( "dead input" ); PL_UNLOCK; /* We can unlock as we return VLC_EGENERIC (no event will be lost) */ /* input_resource_t must be manipulated without playlist lock */ if( !var_CreateGetBool( p_input, "sout-keep" ) ) input_resource_TerminateSout( p_sys->p_input_resource ); /* The DelCallback must be issued without playlist lock */ var_DelCallback( p_input, "intf-event", InputEvent, p_playlist ); PL_LOCK; p_sys->p_input = NULL; input_Close( p_input ); UpdateActivity( p_playlist, -DEFAULT_INPUT_ACTIVITY ); return VLC_EGENERIC; } /* This input is dying, let it do */ else if( p_input->b_die ) { PL_DEBUG( "dying input" ); } /* This input has finished, ask it to die ! */ else if( p_input->b_error || p_input->b_eof ) { PL_DEBUG( "finished input" ); input_Stop( p_input, false ); } return VLC_SUCCESS; }
/** * Start the input for an item * * \param p_playlist the playlist object * \param p_item the item to play * \return nothing */ static int PlayItem( playlist_t *p_playlist, playlist_item_t *p_item ) { playlist_private_t *p_sys = pl_priv(p_playlist); input_item_t *p_input = p_item->p_input; PL_ASSERT_LOCKED; msg_Dbg( p_playlist, "creating new input thread" ); p_input->i_nb_played++; set_current_status_item( p_playlist, p_item ); p_sys->status.i_status = PLAYLIST_RUNNING; UpdateActivity( p_playlist, DEFAULT_INPUT_ACTIVITY ); assert( p_sys->p_input == NULL ); if( !p_sys->p_input_resource ) p_sys->p_input_resource = input_resource_New( VLC_OBJECT( p_playlist ) ); input_thread_t *p_input_thread = input_Create( p_playlist, p_input, NULL, p_sys->p_input_resource ); if( p_input_thread ) { p_sys->p_input = p_input_thread; var_AddCallback( p_input_thread, "intf-event", InputEvent, p_playlist ); var_SetAddress( p_playlist, "input-current", p_input_thread ); if( input_Start( p_sys->p_input ) ) { vlc_object_release( p_input_thread ); p_sys->p_input = p_input_thread = NULL; } } char *psz_uri = input_item_GetURI( p_item->p_input ); if( psz_uri && ( !strncmp( psz_uri, "directory:", 10 ) || !strncmp( psz_uri, "vlc:", 4 ) ) ) { free( psz_uri ); return VLC_SUCCESS; } free( psz_uri ); /* TODO store art policy in playlist private data */ if( var_GetInteger( p_playlist, "album-art" ) == ALBUM_ART_WHEN_PLAYED ) { bool b_has_art; char *psz_arturl, *psz_name; psz_arturl = input_item_GetArtURL( p_input ); psz_name = input_item_GetName( p_input ); /* p_input->p_meta should not be null after a successfull CreateThread */ b_has_art = !EMPTY_STR( psz_arturl ); if( !b_has_art || strncmp( psz_arturl, "attachment://", 13 ) ) { PL_DEBUG( "requesting art for %s", psz_name ); playlist_AskForArtEnqueue( p_playlist, p_input ); } free( psz_arturl ); free( psz_name ); } /* FIXME: this is not safe !!*/ PL_UNLOCK; var_SetAddress( p_playlist, "item-current", p_input ); PL_LOCK; return VLC_SUCCESS; }
void Update(YARPImageOf<YarpPixelMono>& img, YARPImageOf<YarpPixelBGR>& dest, FiveBoxesInARow& out_boxes) { if (first) { prev.PeerCopy(img); first = 0; } int count = 0; int count2 = 0; int index = 0; mutex.Wait(); UpdateActivity(); int box_index = 0; for (int k=0; k<FiveBoxesInARow::GetMaxBoxes(); k++) { out_boxes(k).valid = false; } for (int i=0; i<MAX_TRACKER; i++) { if (tracker[i].is_active) { count2++; } if (tracker[i].is_tracking) { count++; int ox = tracker[i].box.cx; int oy = tracker[i].box.cy; int x = ox; int y = oy; int theta = 15; if (oy>theta && oy<=img.GetHeight()-theta && ox>theta && ox<=img.GetWidth()-theta) { if (tracker[i].is_lagged) { track_tool.Apply(face_prev,img,ox,oy); tracker[i].is_lagged = 0; } else { track_tool.Apply(prev,img,ox,oy); } x = track_tool.GetX(); y = track_tool.GetY(); } int dx = x-ox; int dy = y-oy; if (dx!=0 || dy!=0) { // printf("Delta %d %d (to %d %d)\n", dx, dy, x, y); } tracker[i].box.brx += dx; tracker[i].box.bry += dy; tracker[i].box.tlx += dx; tracker[i].box.tly += dy; tracker[i].box.cx += dx; tracker[i].box.cy += dy; if (index<FiveBoxesInARow::GetMaxBoxes()) { CBox2Send& dest2 = out_boxes(box_index); box_index++; Box& src = tracker[i].box; dest2.xmin = src.tlx; dest2.ymin = src.tly; dest2.xmax = src.brx; dest2.ymax = src.bry; dest2.valid = true; for (int i = -3; i<= 3; i++) { for (int j=-3; j<=3; j++) { if ((i+j)%2) { dest.SafePixel(x+j,y+i) = YarpPixelBGR(255,255,255); } else { dest.SafePixel(x+j,y+i) = YarpPixelBGR(0,0,0); } } } } } } mutex.Post(); //if (count>0) { // printf("*** %d trackers tracking, %d active\n", count, // count2); } prev.PeerCopy(img); }