📄 wizard.cpp
字号:
sizer->Add( file_text, 0, wxALL, 5 ); sizer->Add( new wxButton( this, Open_Event, wxU("Choose") ) ); mainSizer->Add( sizer, 0, 0, 0) ; mainSizer->Add( 0, 0, 1 ); SetSizer(mainSizer); mainSizer->Fit(this);}void wizTranscodeExtraPage::OnSelectFile( wxCommandEvent &event){ wxFileDialog *file_dialog = new wxFileDialog( this, wxU(_("Open File")), wxT(""), wxT(""), wxT("*"), wxSAVE ); if( file_dialog && file_dialog->ShowModal() == wxID_OK ) { if( file_dialog->GetFilename().mb_str() ) { file_text->SetValue( file_dialog->GetFilename() ); } }}void wizTranscodeExtraPage::OnWizardPageChanging( wxWizardEvent& event ){ if( event.GetDirection() && file_text->GetValue().IsEmpty() ) { wxMessageBox( wxU( CHOOSE_OUTFILE ), wxU( ERROR_MSG ), wxICON_WARNING | wxOK, this->p_parent ); event.Veto(); } if( event.GetDirection() ) { p_parent->SetTranscodeOut( file_text->GetValue().mb_str()); }}wxWizardPage *wizTranscodeExtraPage::GetPrev() const { return p_prev; }wxWizardPage *wizTranscodeExtraPage::GetNext() const {return p_next; }/*********************************************************** * Extra streaming page ***********************************************************/wizStreamingExtraPage::wizStreamingExtraPage( wxWizard *parent, wxWizardPage *prev, wxWizardPage *next) : wxWizardPage(parent){ p_next = next; p_prev = prev; p_parent = (WizardDialog *) parent; wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); /* Create the texts */ pageHeader( this, mainSizer, EXTRASTREAMING_TITLE, EXTRASTREAMING_TEXT ); mainSizer->Add( 0, 0, 1 ); wxFlexGridSizer *sizer = new wxFlexGridSizer( 2,2,1) ; /* TTL */ sizer->Add( new wxStaticText( this, -1, wxU(_("Time-To-Live (TTL)"))), 0, wxALL, 5 ); ttl_spin = new wxSpinCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 1, 255, 1 ); ttl_spin->SetToolTip(wxU(_(TTL) ) ) ; sizer->Add( ttl_spin, 0, wxALL , 5 ); /* SAP announce */ sap_checkbox = new wxCheckBox( this, SAP_Event, wxU(_("SAP Announce")) ); sap_checkbox->SetToolTip( wxU(_( SAP ) ) ); sizer->Add( sap_checkbox, 0, 0 , 0 ); sap_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition, wxSize(100,25) ); sap_text->SetToolTip( wxU(_( SAP ) ) ); sizer->Add( sap_text, 0, wxALL , 5 ); mainSizer->Add(sizer, 0, wxALL, 5 ); mainSizer->Add( 0, 0, 1 ); SetSizer(mainSizer); mainSizer->Fit(this);}void wizStreamingExtraPage::OnSAP( wxCommandEvent &event ){ sap_text->Enable( event.IsChecked() );}void wizStreamingExtraPage::OnWizardPageChanging(wxWizardEvent& event){ if( sap_checkbox->IsChecked() ) { if( sap_text->GetValue().IsEmpty() ) { p_parent->SetSAP( true, NULL ); } else { p_parent->SetSAP( true, (const char *)sap_text->GetValue().mb_str() ); } } else { p_parent->SetSAP( false, NULL ); } p_parent->SetTTL( ttl_spin->GetValue() );}wxWizardPage *wizStreamingExtraPage::GetPrev() const { return p_prev; }wxWizardPage *wizStreamingExtraPage::GetNext() const {return p_next; }/*************************************************************************** * Implementation of the wizard itself ***************************************************************************/wizHelloPage *page1;wizInputPage *page2 ;wizTranscodeCodecPage *tr_page1 ;wizStreamingMethodPage *st_page1;wizTranscodeExtraPage *tr_page2 ;wizStreamingExtraPage *st_page2;wizEncapPage *encap_page;WizardDialog::WizardDialog(intf_thread_t *_p_intf, wxWindow *_p_parent, char *psz_uri, int _i_from, int _i_to ) :wxWizard( _p_parent, -1, wxU(_("Streaming/Transcoding Wizard")), wxNullBitmap, wxDefaultPosition){ /* Initializations */ p_intf = _p_intf; SetPageSize(wxSize(400,420)); /* Initialize structure */ i_action = 0; i_from = _i_from; i_to = _i_to; i_ttl = 1; vb = 0; ab = 0; acodec=NULL; vcodec=NULL; page1 = new wizHelloPage(this); page2 = new wizInputPage(this, page1, p_intf); if( psz_uri ) { page2->SetUri( psz_uri ); } if( i_from != 0 || i_to != 0 ) { page2->SetPartial( i_from, i_to ); } encap_page = new wizEncapPage(this ); tr_page1 = new wizTranscodeCodecPage(this, encap_page ); st_page1 = new wizStreamingMethodPage(this, encap_page); tr_page2 = new wizTranscodeExtraPage(this, encap_page, NULL ); st_page2 = new wizStreamingExtraPage(this, encap_page, NULL ); /* Page 1 -> 2 */ page1->SetNext( page2 ); /* 2->1 in constructor of 2 */ /* Page 2 -> 3 */ page2->SetTranscodePage(tr_page1); page2->SetStreamingPage(st_page1); page2->SetPintf( p_intf ); tr_page1->SetPrev(page2); st_page1->SetPrev(page2); /* Page 3 -> 4 */ encap_page->SetTranscodePage( tr_page2 ); encap_page->SetStreamingPage( st_page2 ); /* 3->4 in constructor of 3 */// encap_page->SetPrev(tr_page1);}WizardDialog::~WizardDialog(){ Destroy(); delete page1; delete page2; delete tr_page1; delete st_page1 ; delete st_page2; delete tr_page2; delete encap_page;}void WizardDialog::SetMrl( const char *mrl ){ this->mrl = strdup( mrl );}void WizardDialog::SetTTL( int i_ttl ){ this->i_ttl = i_ttl;}void WizardDialog::SetSAP( bool b_enabled, const char *psz_text ){ this->b_sap = b_enabled; if( b_enabled ) { if( psz_text != NULL ) { this->psz_sap_name = strdup( psz_text ); } else { this->psz_sap_name = NULL; } }}void WizardDialog::SetPartial( int i_from, int i_to ){ this->i_from = i_from; this->i_to = i_to;}void WizardDialog::SetTranscode( char *vcodec, int vb, char *acodec,int ab){ if( strcmp( vcodec, "dummy") ) { this->vcodec= strdup(vcodec); } if( strcmp( acodec, "dummy" ) ) { this->acodec = strdup(acodec); } this->vb = vb; this->ab = ab;}void WizardDialog::SetStream( char *method, char *address ){ this->method = strdup( method ); this->address = strdup( address );}void WizardDialog::SetTranscodeOut( const char *address ){ this->address = strdup( address );}void WizardDialog::SetMux( char *mux ){ this->mux = strdup( mux );}void WizardDialog::SetAction( int i_action ){ this->i_action = i_action;}int WizardDialog::GetAction(){ return i_action;}void WizardDialog::Run(){ if( RunWizard(page1) ) { int i_size; char *psz_opt; if( i_action == ACTION_TRANSCODE ) { msg_Dbg( p_intf,"Starting transcode of %s to file %s", mrl, address); msg_Dbg( p_intf,"Using %s (%i kbps) / %s (%i kbps),encap %s", vcodec,vb,acodec,ab,mux); char *psz_transcode; if( vcodec != NULL || acodec != NULL ) { int i_tr_size = 14; if( vcodec != NULL ) i_tr_size += strlen( vcodec ) + 17; if( acodec != NULL ) i_tr_size += strlen( acodec ) + 17; if( vb > 999999 ) vb = 999999; else if( vb < 0 ) vb = 0; if( ab > 999999 ) ab = 999999; else if( ab < 0 ) ab = 0; psz_transcode = (char *)malloc( i_tr_size * sizeof(char) ); strcpy( psz_transcode, "transcode{" ); if( vcodec != NULL ) { sprintf( psz_transcode + strlen( psz_transcode ), "vcodec=%s,vb=%i%s", vcodec, vb, ( acodec != NULL ) ? "," : "}:" ); } if( acodec != NULL ) { sprintf( psz_transcode + strlen( psz_transcode ), "acodec=%s,ab=%i}:", acodec, ab ); } } else psz_transcode = ""; i_size = 73 + strlen(mux) + strlen(address) + strlen(psz_transcode); psz_opt = (char *)malloc( i_size * sizeof(char) ); snprintf( psz_opt, i_size, ":sout=#%sstandard{mux=%s,url=%s," "access=file}", psz_transcode, mux, address ); if( *psz_transcode ) free( psz_transcode ); } else { msg_Dbg( p_intf, "Starting stream of %s to %s using %s, encap %s", mrl, address, method, mux); if( b_sap ) { char *psz_sap_option = NULL; if( psz_sap_name ) { psz_sap_option = (char *) malloc( strlen( psz_sap_name ) + 15 ); snprintf( psz_sap_option,strlen( psz_sap_name ) + 15, "sap,name=\"%s\"",psz_sap_name ); } else psz_sap_option = strdup( "sap" ); i_size = 40 + strlen(mux) + strlen(address) + strlen( psz_sap_option); psz_opt = (char *)malloc( i_size * sizeof(char) ); snprintf( psz_opt, i_size, ":sout=#standard{mux=%s,url=%s,access=%s,%s}", mux, address,method, psz_sap_option); if( psz_sap_option ) free( psz_sap_option ); } else { i_size = 40 + strlen(mux) + strlen(address); psz_opt = (char *)malloc( i_size * sizeof(char) ); snprintf( psz_opt, i_size, ":sout=#standard{mux=%s,url=%s,access=%s}", mux, address,method); } } playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE); if( p_playlist ) { playlist_item_t *p_item = playlist_ItemNew( p_playlist, mrl, ITEM_NAME ); playlist_ItemAddOption( p_item, psz_opt); if( i_from != 0) { char psz_from[20]; snprintf( psz_from, 20, "start-time=%i", i_from); playlist_ItemAddOption( p_item, psz_from); } if( i_to != 0) { char psz_to[20]; snprintf( psz_to, 20, "stop-time=%i", i_to); playlist_ItemAddOption( p_item, psz_to); } char psz_ttl[20]; snprintf( psz_ttl, 20, "ttl=%i",i_ttl ); playlist_ItemAddOption( p_item, psz_ttl ); playlist_AddItem( p_playlist, p_item, PLAYLIST_GO, PLAYLIST_END ); vlc_object_release(p_playlist); } else { wxMessageBox( wxU( NO_PLAYLIST ), wxU( ERROR_MSG ), wxICON_WARNING | wxOK, this ); } }}/**************************************************************** * Local helper functions ****************************************************************/static int ismult( const char *psz_uri ){ char *psz_end; unsigned long i_value; /* IPv6 */ if( psz_uri[0] == '[') return strncasecmp( &psz_uri[1], "FF" , 2) ? VLC_FALSE : VLC_TRUE; /* IPv4 */ i_value = strtoul( psz_uri, &psz_end, 10 ); if( *psz_end != '.' ) { return( VLC_FALSE ); } return( ( i_value >= 224 && i_value < 240 ) ? VLC_TRUE : VLC_FALSE );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -