/***************************************************************************** * input_ControlVarStop: *****************************************************************************/ void input_ControlVarStop( input_thread_t *p_input ) { demux_t* p_demux = input_priv(p_input)->master->p_demux; int i_cur_title; if( !input_priv(p_input)->b_preparsing ) InputDelCallbacks( p_input, p_input_callbacks ); if( input_priv(p_input)->i_title > 1 ) InputDelCallbacks( p_input, p_input_title_navigation_callbacks ); for( int i = 0; i < input_priv(p_input)->i_title; i++ ) { char name[sizeof("title ") + 3 * sizeof (int)]; sprintf( name, "title %2u", i ); var_DelCallback( p_input, name, NavigationCallback, (void *)(intptr_t)i ); } if( !demux_Control( p_demux, DEMUX_GET_TITLE, &i_cur_title ) ) { const input_title_t* t = input_priv(p_input)->title[ i_cur_title ]; if( t->i_seekpoint > 1 ) InputDelCallbacks( p_input, p_input_seekpoint_navigation_callbacks ); } }
Test::Result PK_Key_Generation_Test::test_key(const std::string& algo, const Botan::Private_Key& key) { Test::Result result(algo + " keygen"); const std::string pub_pem = Botan::X509::PEM_encode(key); try { Botan::DataSource_Memory input_pub(pub_pem); std::unique_ptr<Botan::Public_Key> restored_pub(Botan::X509::load_key(input_pub)); result.test_eq("recovered public key from private", restored_pub.get(), true); result.test_eq("public key has same type", restored_pub->algo_name(), key.algo_name()); result.test_eq("public key passes checks", restored_pub->check_key(Test::rng(), false), true); } catch(std::exception& e) { result.test_failure("roundtrip public key", e.what()); } const std::string priv_pem = Botan::PKCS8::PEM_encode(key); try { Botan::DataSource_Memory input_priv(priv_pem); std::unique_ptr<Botan::Private_Key> restored_priv( Botan::PKCS8::load_key(input_priv, Test::rng())); result.test_eq("recovered private key from blob", restored_priv.get(), true); result.test_eq("reloaded key has same type", restored_priv->algo_name(), key.algo_name()); result.test_eq("private key passes checks", restored_priv->check_key(Test::rng(), false), true); } catch(std::exception& e) { result.test_failure("roundtrip private key", e.what()); } const std::string passphrase = Test::random_password(); const std::string enc_priv_pem = Botan::PKCS8::PEM_encode(key, Test::rng(), passphrase, std::chrono::milliseconds(10)); try { Botan::DataSource_Memory input_priv(priv_pem); std::unique_ptr<Botan::Private_Key> restored_priv( Botan::PKCS8::load_key(input_priv, Test::rng(), passphrase)); result.test_eq("recovered private key from encrypted blob", restored_priv.get(), true); result.test_eq("reloaded key has same type", restored_priv->algo_name(), key.algo_name()); result.test_eq("private key passes checks", restored_priv->check_key(Test::rng(), false), true); } catch(std::exception& e) { result.test_failure("roundtrip private key", e.what()); } return result; }
/***************************************************************************** * input_ControlVarTitle: * Create all variables for a title *****************************************************************************/ void input_ControlVarTitle( input_thread_t *p_input, int i_title ) { const input_title_t *t = input_priv(p_input)->title[i_title]; vlc_value_t text; int i; /* Create/Destroy command variables */ if( t->i_seekpoint <= 1 ) { var_Destroy( p_input, "next-chapter" ); var_Destroy( p_input, "prev-chapter" ); } else if( var_Type( p_input, "next-chapter" ) == 0 ) { var_Create( p_input, "next-chapter", VLC_VAR_VOID ); text.psz_string = _("Next chapter"); var_Change( p_input, "next-chapter", VLC_VAR_SETTEXT, &text, NULL ); var_AddCallback( p_input, "next-chapter", SeekpointCallback, NULL ); var_Create( p_input, "prev-chapter", VLC_VAR_VOID ); text.psz_string = _("Previous chapter"); var_Change( p_input, "prev-chapter", VLC_VAR_SETTEXT, &text, NULL ); var_AddCallback( p_input, "prev-chapter", SeekpointCallback, NULL ); } /* Build chapter list */ var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL ); for( i = 0; i < t->i_seekpoint; i++ ) { vlc_value_t val; val.i_int = i; if( t->seekpoint[i]->psz_name == NULL || *t->seekpoint[i]->psz_name == '\0' ) { /* Default value */ if( asprintf( &text.psz_string, _("Chapter %i"), i + input_priv(p_input)->i_seekpoint_offset ) == -1 ) continue; } else { text.psz_string = strdup( t->seekpoint[i]->psz_name ); } var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, &text ); free( text.psz_string ); } }
void input_SendEventMetaInfo( input_thread_t *p_input ) { Trigger( p_input, INPUT_EVENT_ITEM_INFO ); /* FIXME remove this ugliness */ vlc_event_t event; event.type = vlc_InputItemInfoChanged; vlc_event_send( &input_priv(p_input)->p_item->event_manager, &event ); }
void input_SendEventMetaName( input_thread_t *p_input, const char *psz_name ) { Trigger( p_input, INPUT_EVENT_ITEM_NAME ); /* FIXME remove this ugliness */ vlc_event_t event; event.type = vlc_InputItemNameChanged; event.u.input_item_name_changed.new_name = psz_name; vlc_event_send( &input_priv(p_input)->p_item->event_manager, &event ); }
/* FIXME: review them because vlc_event_send might be * moved inside input_item* functions. */ void input_SendEventMeta( input_thread_t *p_input ) { Trigger( p_input, INPUT_EVENT_ITEM_META ); /* FIXME remove this ugliness ? */ vlc_event_t event; event.type = vlc_InputItemMetaChanged; event.u.input_item_meta_changed.meta_type = vlc_meta_ArtworkURL; vlc_event_send( &input_priv(p_input)->p_item->event_manager, &event ); }
void input_SendEventLength( input_thread_t *p_input, mtime_t i_length ) { vlc_value_t val; /* FIXME ugly + what about meta change event ? */ if( var_GetInteger( p_input, "length" ) == i_length ) return; input_item_SetDuration( input_priv(p_input)->p_item, i_length ); val.i_int = i_length; var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL ); Trigger( p_input, INPUT_EVENT_LENGTH ); }
void stats_ComputeInputStats(input_thread_t *input, input_stats_t *st) { input_thread_private_t *priv = input_priv(input); if (!libvlc_stats(input)) return; vlc_mutex_lock(&priv->counters.counters_lock); vlc_mutex_lock(&st->lock); /* Input */ st->i_read_packets = stats_GetTotal(priv->counters.p_read_packets); st->i_read_bytes = stats_GetTotal(priv->counters.p_read_bytes); st->f_input_bitrate = stats_GetRate(priv->counters.p_input_bitrate); st->i_demux_read_bytes = stats_GetTotal(priv->counters.p_demux_read); st->f_demux_bitrate = stats_GetRate(priv->counters.p_demux_bitrate); st->i_demux_corrupted = stats_GetTotal(priv->counters.p_demux_corrupted); st->i_demux_discontinuity = stats_GetTotal(priv->counters.p_demux_discontinuity); /* Decoders */ st->i_decoded_video = stats_GetTotal(priv->counters.p_decoded_video); st->i_decoded_audio = stats_GetTotal(priv->counters.p_decoded_audio); /* Sout */ if (priv->counters.p_sout_send_bitrate) { st->i_sent_packets = stats_GetTotal(priv->counters.p_sout_sent_packets); st->i_sent_bytes = stats_GetTotal(priv->counters.p_sout_sent_bytes); st->f_send_bitrate = stats_GetRate(priv->counters.p_sout_send_bitrate); } /* Aout */ st->i_played_abuffers = stats_GetTotal(priv->counters.p_played_abuffers); st->i_lost_abuffers = stats_GetTotal(priv->counters.p_lost_abuffers); /* Vouts */ st->i_displayed_pictures = stats_GetTotal(priv->counters.p_displayed_pictures); st->i_lost_pictures = stats_GetTotal(priv->counters.p_lost_pictures); vlc_mutex_unlock(&st->lock); vlc_mutex_unlock(&priv->counters.counters_lock); }
static void PreparserCloseInput( void* preparser_, void* task_ ) { input_preparser_task_t* task = task_; input_preparser_req_t *req = task->req; input_preparser_t* preparser = preparser_; input_thread_t* input = task->input; input_item_t* item = input_priv(task->input)->p_item; int status; switch( atomic_load( &task->state ) ) { case END_S: status = ITEM_PREPARSE_DONE; break; case ERROR_S: status = ITEM_PREPARSE_FAILED; break; default: status = ITEM_PREPARSE_TIMEOUT; } input_Stop( input ); input_Close( input ); if( preparser->fetcher ) { task->preparse_status = status; if (!input_fetcher_Push(preparser->fetcher, item, 0, &input_fetcher_callbacks, task)) { ReqHold(task->req); return; } } free(task); input_item_SetPreparsed( item, true ); if (req->cbs && req->cbs->on_preparse_ended) req->cbs->on_preparse_ended(req->item, status, req->userdata); }
/***************************************************************************** * input_ConfigVarInit: * Create all config object variables *****************************************************************************/ void input_ConfigVarInit ( input_thread_t *p_input ) { /* Create Object Variables for private use only */ if( !input_priv(p_input)->b_preparsing ) { var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "audio-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_input, "audio-language", VLC_VAR_STRING|VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-language", VLC_VAR_STRING|VLC_VAR_DOINHERIT ); var_Create( p_input, "menu-language", VLC_VAR_STRING|VLC_VAR_DOINHERIT ); var_Create( p_input, "audio-track-id", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-track-id", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-file", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "sout-all", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "sout-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "sout-spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "sout-keep", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "input-repeat", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_input, "start-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT ); var_Create( p_input, "stop-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT ); var_Create( p_input, "run-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT ); var_Create( p_input, "input-fast-seek", VLC_VAR_BOOL|VLC_VAR_DOINHERIT ); var_Create( p_input, "input-slave", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "audio-desync", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_input, "cr-average", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_input, "clock-synchro", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); } var_Create( p_input, "can-seek", VLC_VAR_BOOL ); var_SetBool( p_input, "can-seek", true ); /* Fixed later*/ var_Create( p_input, "can-pause", VLC_VAR_BOOL ); var_SetBool( p_input, "can-pause", true ); /* Fixed later*/ var_Create( p_input, "can-rate", VLC_VAR_BOOL ); var_SetBool( p_input, "can-rate", false ); var_Create( p_input, "can-rewind", VLC_VAR_BOOL ); var_SetBool( p_input, "can-rewind", false ); var_Create( p_input, "can-record", VLC_VAR_BOOL ); var_SetBool( p_input, "can-record", false ); /* Fixed later*/ var_Create( p_input, "record", VLC_VAR_BOOL ); var_SetBool( p_input, "record", false ); var_Create( p_input, "teletext-es", VLC_VAR_INTEGER ); var_SetInteger( p_input, "teletext-es", -1 ); var_Create( p_input, "signal-quality", VLC_VAR_FLOAT ); var_SetFloat( p_input, "signal-quality", -1 ); var_Create( p_input, "signal-strength", VLC_VAR_FLOAT ); var_SetFloat( p_input, "signal-strength", -1 ); var_Create( p_input, "program-scrambled", VLC_VAR_BOOL ); var_SetBool( p_input, "program-scrambled", false ); var_Create( p_input, "cache", VLC_VAR_FLOAT ); var_SetFloat( p_input, "cache", 0.0 ); /* */ var_Create( p_input, "input-record-native", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); /* */ var_Create( p_input, "access", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "demux", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "demux-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "stream-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); /* Meta */ var_Create( p_input, "meta-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "meta-author", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "meta-artist", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "meta-genre", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "meta-copyright", VLC_VAR_STRING | VLC_VAR_DOINHERIT); var_Create( p_input, "meta-description", VLC_VAR_STRING|VLC_VAR_DOINHERIT); var_Create( p_input, "meta-date", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "meta-url", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); }
/***************************************************************************** * input_ControlVarNavigation: * Create all remaining control object variables *****************************************************************************/ void input_ControlVarNavigation( input_thread_t *p_input ) { vlc_value_t text; /* Create more command variables */ if( input_priv(p_input)->i_title > 1 ) { if( var_Type( p_input, "next-title" ) == 0 ) { var_Create( p_input, "next-title", VLC_VAR_VOID ); text.psz_string = _("Next title"); var_Change( p_input, "next-title", VLC_VAR_SETTEXT, &text, NULL ); var_AddCallback( p_input, "next-title", TitleCallback, NULL ); } if( var_Type( p_input, "prev-title" ) == 0 ) { var_Create( p_input, "prev-title", VLC_VAR_VOID ); text.psz_string = _("Previous title"); var_Change( p_input, "prev-title", VLC_VAR_SETTEXT, &text, NULL ); var_AddCallback( p_input, "prev-title", TitleCallback, NULL ); } if( var_Type( p_input, "menu-title" ) == 0 ) { var_Create( p_input, "menu-title", VLC_VAR_VOID ); text.psz_string = _("Menu title"); var_Change( p_input, "menu-title", VLC_VAR_SETTEXT, &text, NULL ); var_AddCallback( p_input, "menu-title", TitleCallback, NULL ); } if( var_Type( p_input, "menu-popup" ) == 0 ) { var_Create( p_input, "menu-popup", VLC_VAR_VOID ); text.psz_string = _("Menu popup"); var_Change( p_input, "menu-popup", VLC_VAR_SETTEXT, &text, NULL ); var_AddCallback( p_input, "menu-popup", TitleCallback, NULL ); } } /* Create titles and chapters */ var_Change( p_input, "title", VLC_VAR_CLEARCHOICES, NULL, NULL ); for( int i = 0; i < input_priv(p_input)->i_title; i++ ) { vlc_value_t val2, text2; char title[sizeof("title ") + 3 * sizeof (int)]; /* Add Navigation entries */ sprintf( title, "title %2u", i ); var_Destroy( p_input, title ); var_Create( p_input, title, VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); var_AddCallback( p_input, title, NavigationCallback, (void *)(intptr_t)i ); char psz_length[MSTRTIME_MAX_SIZE + sizeof(" []")]; if( input_priv(p_input)->title[i]->i_length > 0 ) { strcpy( psz_length, " [" ); secstotimestr( &psz_length[2], input_priv(p_input)->title[i]->i_length / CLOCK_FREQ ); strcat( psz_length, "]" ); } else psz_length[0] = '\0'; if( input_priv(p_input)->title[i]->psz_name == NULL || *input_priv(p_input)->title[i]->psz_name == '\0' ) { if( asprintf( &text.psz_string, _("Title %i%s"), i + input_priv(p_input)->i_title_offset, psz_length ) == -1 ) continue; } else { if( asprintf( &text.psz_string, "%s%s", input_priv(p_input)->title[i]->psz_name, psz_length ) == -1 ) continue; } /* Add title choice */ val2.i_int = i; var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val2, &text ); free( text.psz_string ); for( int j = 0; j < input_priv(p_input)->title[i]->i_seekpoint; j++ ) { val2.i_int = j; if( input_priv(p_input)->title[i]->seekpoint[j]->psz_name == NULL || *input_priv(p_input)->title[i]->seekpoint[j]->psz_name == '\0' ) { /* Default value */ if( asprintf( &text2.psz_string, _("Chapter %i"), j + input_priv(p_input)->i_seekpoint_offset ) == -1 ) continue; } else { text2.psz_string = strdup( input_priv(p_input)->title[i]->seekpoint[j]->psz_name ); } var_Change( p_input, title, VLC_VAR_ADDCHOICE, &val2, &text2 ); free( text2.psz_string ); } } }
/***************************************************************************** * input_ControlVarInit: * Create all control object variables with their callbacks *****************************************************************************/ void input_ControlVarInit ( input_thread_t *p_input ) { vlc_value_t val, text; /* State */ var_Create( p_input, "state", VLC_VAR_INTEGER ); val.i_int = input_priv(p_input)->i_state; var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL ); /* Rate */ var_Create( p_input, "rate", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); var_Create( p_input, "frame-next", VLC_VAR_VOID ); /* Position */ var_Create( p_input, "position", VLC_VAR_FLOAT ); /* Time */ var_Create( p_input, "time", VLC_VAR_INTEGER ); var_Create( p_input, "time-offset", VLC_VAR_INTEGER ); /* relative */ /* Bookmark */ var_Create( p_input, "bookmark", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); val.psz_string = _("Bookmark"); var_Change( p_input, "bookmark", VLC_VAR_SETTEXT, &val, NULL ); /* Program */ var_Create( p_input, "program", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Get( p_input, "program", &val ); if( val.i_int <= 0 ) var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL ); text.psz_string = _("Program"); var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL ); /* Programs */ var_Create( p_input, "programs", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); text.psz_string = _("Programs"); var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL ); /* Title */ var_Create( p_input, "title", VLC_VAR_INTEGER ); text.psz_string = _("Title"); var_Change( p_input, "title", VLC_VAR_SETTEXT, &text, NULL ); /* Chapter */ var_Create( p_input, "chapter", VLC_VAR_INTEGER ); text.psz_string = _("Chapter"); var_Change( p_input, "chapter", VLC_VAR_SETTEXT, &text, NULL ); /* Delay */ var_Create( p_input, "audio-delay", VLC_VAR_INTEGER ); var_SetInteger( p_input, "audio-delay", 1000 * var_GetInteger( p_input, "audio-desync" ) ); var_Create( p_input, "spu-delay", VLC_VAR_INTEGER ); val.i_int = -1; /* Video ES */ var_Create( p_input, "video-es", VLC_VAR_INTEGER ); var_Change( p_input, "video-es", VLC_VAR_SETVALUE, &val, NULL ); text.psz_string = _("Video Track"); var_Change( p_input, "video-es", VLC_VAR_SETTEXT, &text, NULL ); /* Audio ES */ var_Create( p_input, "audio-es", VLC_VAR_INTEGER ); var_Change( p_input, "audio-es", VLC_VAR_SETVALUE, &val, NULL ); text.psz_string = _("Audio Track"); var_Change( p_input, "audio-es", VLC_VAR_SETTEXT, &text, NULL ); /* Spu ES */ var_Create( p_input, "spu-es", VLC_VAR_INTEGER ); var_Change( p_input, "spu-es", VLC_VAR_SETVALUE, &val, NULL ); text.psz_string = _("Subtitle Track"); var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL ); var_Create( p_input, "spu-choice", VLC_VAR_INTEGER ); var_SetInteger( p_input, "spu-choice", -1 ); /* Special read only objects variables for intf */ var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "length", VLC_VAR_INTEGER ); var_Create( p_input, "bit-rate", VLC_VAR_INTEGER ); var_Create( p_input, "sample-rate", VLC_VAR_INTEGER ); /* Special "intf-event" variable. */ var_Create( p_input, "intf-event", VLC_VAR_INTEGER ); /* Add all callbacks * XXX we put callback only in non preparsing mode. We need to create the variable * unless someone want to check all var_Get/var_Change return value ... */ if( !input_priv(p_input)->b_preparsing ) InputAddCallbacks( p_input, p_input_callbacks ); }