wizard.cpp

来自「uclinux 下的vlc播放器源代码」· C++ 代码 · 共 1,664 行 · 第 1/4 页

CPP
1,664
字号
    video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""),                                  wxDefaultPosition, wxSize(200,25), 0, NULL,                                   wxCB_DROPDOWN| wxCB_READONLY );    for( i= 0; vcodecs_array[i].psz_display != NULL; i++ )    {        video_combo->Append( wxU( vcodecs_array[i].psz_display ) ,                            (void *)&vcodecs_array[i] );    }    i_video_codec = 0;    video_combo->SetSelection(0);    video_sizer1->Add( video_combo, 0 , wxALIGN_LEFT , 0 );    video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,                       wxLEFT ,5);    vb_combo = new wxComboBox( this, VideoBitrate_Event, wxT("1024"),                               wxDefaultPosition, wxDefaultSize,                               WXSIZEOF(vbitrates_array), vbitrates_array, wxCB_READONLY );    video_sizer1->Add( vb_combo, 0, wxALIGN_LEFT , 0 );    /* Line 3 : text */    video_text = new wxStaticText( this, -1,                     wxU( vlc_wraptext( TR_VIDEO_TEXT, TEXTWIDTH ) ) );    /* Fill the main video sizer */    video_sizer->Add( video_sizer1 , 0, wxEXPAND , 5 );    video_sizer->Add( video_text, 0, wxLEFT|wxTOP , 5 );    /* Audio box */    wxStaticBox *audio_box = new wxStaticBox( this, -1, wxU(_("Audio")) );    wxStaticBoxSizer *audio_sizer = new wxStaticBoxSizer( audio_box,                                                          wxVERTICAL );    /* Line1: enabler */    wxFlexGridSizer *audio_sizer1 = new wxFlexGridSizer( 2,3,20);    audio_sizer1->Add( new wxCheckBox( this, AudioEnable_Event,                            wxU(_("Transcode audio") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 );    audio_sizer1->Add( 0, 0, 1 );    /* Line 2 : codec */    audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5);    audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""),                                  wxDefaultPosition, wxSize(200,25), 0, NULL,                                   wxCB_DROPDOWN| wxCB_READONLY );    for( i= 0; acodecs_array[i].psz_display != NULL; i++ )    {        audio_combo->Append( wxU( acodecs_array[i].psz_display ) ,                            (void *)&acodecs_array[i] );    }    i_audio_codec = 0;    audio_combo->SetSelection(0);    audio_sizer1->Add( audio_combo, 0 , wxALIGN_LEFT, 0 );    audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,                       wxLEFT ,5);    ab_combo = new wxComboBox( this, AudioBitrate_Event, wxT("192"),                               wxDefaultPosition, wxDefaultSize,                               WXSIZEOF(abitrates_array), abitrates_array, wxCB_READONLY );    audio_sizer1->Add( ab_combo, 0, wxALIGN_LEFT, 0 );    /* Line 3 : text */    audio_text = new wxStaticText( this, -1,                     wxU( vlc_wraptext( TR_AUDIO_TEXT, TEXTWIDTH ) ) );    audio_sizer->Add(audio_sizer1, 0, wxEXPAND, 5);    audio_sizer->Add( audio_text, 0, wxLEFT | wxTOP, 5 );    main_sizer->Add( video_sizer, 1, wxGROW, 0 );    main_sizer->Add( audio_sizer, 1, wxGROW, 0 );    main_sizer->Layout();    SetSizerAndFit( main_sizer );    /* Default disabled */    video_combo->Disable(); video_text->Disable();vb_combo->Disable();    audio_combo->Disable(); audio_text->Disable();ab_combo->Disable();}wizTranscodeCodecPage::~wizTranscodeCodecPage(){    if( acodec ) free( acodec );    if( vcodec ) free( vcodec );}void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event){   video_combo->Enable( event.IsChecked() );   vb_combo->Enable( event.IsChecked() );   video_text->Enable( event.IsChecked() );}void wizTranscodeCodecPage::OnEnableAudio(wxCommandEvent& event){   audio_combo->Enable( event.IsChecked() );   ab_combo->Enable( event.IsChecked() );   audio_text->Enable( event.IsChecked() );}void wizTranscodeCodecPage::OnVideoCodecChange(wxCommandEvent& event){    struct codec *c = (struct codec*)             (video_combo->GetClientData(video_combo->GetSelection()));    video_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH ) ) );    i_video_codec = video_combo->GetSelection();    vcodec = strdup(c->psz_codec);}void wizTranscodeCodecPage::OnAudioCodecChange(wxCommandEvent& event){    struct codec *c = (struct codec*)             (audio_combo->GetClientData(audio_combo->GetSelection()));    audio_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH ) ) );    i_audio_codec = audio_combo->GetSelection();    acodec = strdup(c->psz_codec);}void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event){    unsigned int i,j;    if( !event.GetDirection() )    {            GetPrev()->Enable();            return;    }    /* Set the dummy codec ( accept all muxers ) if needed */    if( !video_combo->IsEnabled() )    {        i_video_codec = VCODECS_NUMBER;    }    if( !audio_combo->IsEnabled() )    {        i_audio_codec = ACODECS_NUMBER;    }    ((wizEncapPage *)GetNext())->SetPrev(this);    for( i = 0 ; i< MUXERS_NUMBER ; i++ )    {        if( vcodecs_array[i_video_codec].muxers[i] != -1 )        {            for( j = 0 ; j<  MUXERS_NUMBER ; j++ )            {                if( acodecs_array[i_audio_codec].muxers[j] ==                              vcodecs_array[i_video_codec].muxers[i] )                {                    ((wizEncapPage*)GetNext())->EnableEncap(                               vcodecs_array[i_video_codec].muxers[i] );                }            }        }    }    struct codec *c = (struct codec*)             (video_combo->GetClientData( video_combo->IsEnabled() ?                                          video_combo->GetSelection(): i_video_codec ));    vcodec = strdup(c->psz_codec);    c = (struct codec*)           (audio_combo->GetClientData( audio_combo->IsEnabled() ?                                       audio_combo->GetSelection() : i_audio_codec ));    acodec = strdup(c->psz_codec);    int vb = atoi(vb_combo->GetValue().mb_str(wxConvUTF8) );    if( vb == 0 )    {         vb = 1024;    }    int ab = atoi(ab_combo->GetValue().mb_str(wxConvUTF8) );    if( ab == 0)    {        ab = 192;    }    p_parent->SetTranscode( vcodec, vb , acodec, ab );    ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );    p_parent->SetAction( p_parent->GetAction() );    return;}wxWizardPage *wizTranscodeCodecPage::GetPrev() const { return p_prev; }wxWizardPage *wizTranscodeCodecPage::GetNext() const { return p_next; }void wizTranscodeCodecPage::SetPrev( wxWizardPage *page) {p_prev = page; }/*************************************************** * First streaming page: choose method             * ***************************************************/wizStreamingMethodPage::wizStreamingMethodPage( intf_thread_t *p_this, wxWizard *parent,    wxWizardPage *next) : wxWizardPage(parent), p_intf( p_this ){    int i;    p_next = next;    p_parent = (WizardDialog *)parent;    mainSizer = new wxBoxSizer(wxVERTICAL);    /* Create the texts */    pageHeader( this, mainSizer,  STREAMING1_TITLE, STREAMING1_TEXT );    mainSizer->Add( 0,50,0 );    i_method = 0;    wxStaticBox *method_box = new wxStaticBox( this, -1,                                               wxU(_("Streaming method")) );    wxStaticBoxSizer *method_sizer = new wxStaticBoxSizer(method_box,                                                          wxHORIZONTAL );    for( i = 0 ; i< 3 ; i++ )    {        method_radios[i] = new wxRadioButton( this, MethodRadio0_Event + i,                               wxU( methods_array[i].psz_method ) );        method_radios[i]->SetToolTip( wxU(_( methods_array[i].psz_descr ) ) );        method_sizer->Add( method_radios[i], 0, wxALL, 5 );    }    method_sizer->Layout();    wxStaticBox *address_box = new wxStaticBox( this, -1,                    wxU(_("Destination")) );    address_sizer = new wxStaticBoxSizer(address_box,                                         wxVERTICAL );    /* Big kludge, we take the longest text to get the size */    address_text = new wxStaticText(this, -1,               wxU( vlc_wraptext(methods_array[2].psz_address, TEXTWIDTH ) ),               wxDefaultPosition, wxDefaultSize );    address_txtctrl = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,                                      wxSize(200,25));    address_sizer->Add( address_text, 0, wxALL, 5 );    address_sizer->Add( address_txtctrl, 0, wxALL, 5 );    address_sizer->Layout();    /* Set the minimum size */    address_sizer->SetMinSize( address_sizer->GetSize() );    address_text->SetLabel( wxU(     vlc_wraptext( _(methods_array[0].psz_address), TEXTWIDTH )));    mainSizer->Add( method_sizer, 0, wxALL | wxEXPAND, 5 );    mainSizer->Add( address_sizer, 0, wxALL | wxEXPAND, 5 );    mainSizer->Add( 0,0,1 );    mainSizer->Layout();    SetSizer(mainSizer);    mainSizer->Fit(this);    return;}void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event){    unsigned int i;    if( !event.GetDirection() ) return;    /* Check valid address */    if( i_method == 1     && !net_AddressIsMulticast( (vlc_object_t *)p_intf,                                 address_txtctrl->GetValue().mb_str(wxConvUTF8)) )    {        wxMessageBox( wxU( INVALID_MCAST_ADDRESS ) , wxU( ERROR_MSG ),                      wxICON_WARNING | wxOK, this->p_parent );        event.Veto();    }    else if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() )    {        wxMessageBox( wxU( NO_ADDRESS_TEXT ) , wxU( ERROR_MSG ),                      wxICON_WARNING | wxOK, this->p_parent );        event.Veto();    }    ((wizEncapPage *)GetNext())->SetPrev(this);    for( i = 0 ; i< MUXERS_NUMBER ; i++ )    {        if( methods_array[i_method].muxers[i] != -1 )        {            ((wizEncapPage*)GetNext())->EnableEncap(                               methods_array[i_method].muxers[i] );        }    }    p_parent->SetStream( methods_array[i_method].psz_access ,                         address_txtctrl->GetValue().mb_str(wxConvUTF8) );    /* Set the action for the muxer page */    ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );    return;}wxWizardPage *wizStreamingMethodPage::GetPrev() const { return p_prev; }wxWizardPage *wizStreamingMethodPage::GetNext() const { return p_next; }void wizStreamingMethodPage::SetPrev( wxWizardPage *page) {p_prev = page; }void wizStreamingMethodPage::OnMethodChange( wxCommandEvent& event ){    i_method = event.GetId() - MethodRadio0_Event;    address_text->SetLabel( wxU(     vlc_wraptext( _(methods_array[i_method].psz_address), TEXTWIDTH )));    address_sizer->Layout();    mainSizer->Layout();}/*************************************************** * Choose encapsulation format                     * ***************************************************/wizEncapPage::wizEncapPage( wxWizard *parent ) : wxWizardPage(parent){    int i;    i_mux = 0;    p_parent = (WizardDialog *)parent;    p_streaming_page = NULL;    p_transcode_page = NULL;    p_prev = NULL;    wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);    /* Create the texts */    pageHeader( this, mainSizer, ENCAP_TITLE, ENCAP_TEXT );    mainSizer->Add( 0,0,1 );    for( i = 0 ; i< MUXERS_NUMBER ; i++ )    {        encap_radios[i] = new wxRadioButton( this, EncapRadio0_Event + i,                               wxU( encaps_array[i].psz_encap ) );        encap_radios[i]->SetToolTip( wxU(_( encaps_array[i].psz_descr ) ) );        mainSizer->Add( encap_radios[i], 0, wxLEFT, 5 );        encap_radios[i]->Disable();    }    mainSizer->Add( 0,0,1 );    SetSizer(mainSizer);    mainSizer->Fit(this);}wizEncapPage::~wizEncapPage(){}void wizEncapPage::OnWizardPageChanging(wxWizardEvent& event){    int i;    if( !event.GetDirection() )    {        for( i = 0 ; i< MUXERS_NUMBER ; i++ )        {            encap_radios[i]->Disable();        }    }    p_parent->SetMux( encaps_array[i_mux].psz_mux );    if( p_parent->GetAction() == ACTION_STREAM )    {        if( strstr( p_parent->method, "rtp" ))        {            ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable();            ((wizStreamingExtraPage *)GetNext())->sap_text->Enable(false);        }        else        {           ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable( false );           ((wizStreamingExtraPage *)GetNext())->sap_text->Enable( false );        }    }    return;}void wizEncapPage::OnEncapChange( wxCommandEvent& event ){    i_mux = event.GetId() - EncapRadio0_Event;}void wizEncapPage::EnableEncap( int encap ){    int i;    for( i = 0 ; i< MUXERS_NUMBER ; i++)    {        if( encaps_array[i].id == encap )        {            encap_radios[i]->Enable();            encap_radios[i]->SetValue(true);            i_mux = i;        }    }}void wizEncapPage::SetStreamingPage( wxWizardPage *page){    p_streaming_page = page;}void wizEncapPage::SetTranscodePage( wxWizardPage *page){    p_transcode_page = page;}wxWizardPage *wizEncapPage::GetPrev() const { return p_prev; }wxWizardPage *wizEncapPage::GetNext() const{    if( i_action== ACTION_STREAM )        return p_streaming_page;    else       return p_transcode_page;}void wizEncapPage::SetAction( int i_act  ) { i_action = i_act; }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?