Add decoder selection ui

This commit is contained in:
2025-09-20 13:44:21 +09:00
parent ed5b5bd237
commit b098ce5cf4
3 changed files with 104 additions and 5 deletions

View File

@@ -76,6 +76,23 @@
Click="StopButton_Click"/>
</StackPanel>
<!-- Decoder Selection -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,10">
<TextBlock Text="Decoder:"
VerticalAlignment="Center"
Margin="0,0,10,0"/>
<ComboBox x:Name="DecoderSelectionComboBox"
Width="200"
Height="32"
VerticalAlignment="Center"
Margin="0,0,20,0"
SelectionChanged="DecoderSelectionComboBox_SelectionChanged">
<ComboBoxItem Content="AV1 Decoder (Auto)" IsSelected="True" Tag="AUTO"/>
<ComboBoxItem Content="AV1 Hardware (Media Foundation)" Tag="HARDWARE_MF"/>
<ComboBoxItem Content="AV1 Software (dav1d)" Tag="SOFTWARE"/>
</ComboBox>
</StackPanel>
<!-- File Output Options -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<CheckBox x:Name="EnableFileOutputCheckBox"

View File

@@ -37,9 +37,13 @@ namespace winrt::Vav2Player::implementation
{
// Initialize UI state
UpdateFileOutputControls();
UpdateStatus("Ready");
// Show initial decoder selection
std::string decoderTypeName = GetDecoderTypeName(m_selectedDecoderType);
UpdateStatus("Ready - Selected decoder: " + decoderTypeName);
OutputDebugStringA("MainWindow UI initialized\n");
OutputDebugStringA(("Default decoder type: " + decoderTypeName + "\n").c_str());
}
catch (const std::exception& e)
{
@@ -83,8 +87,10 @@ namespace winrt::Vav2Player::implementation
if (!m_decoder)
{
OutputDebugStringA(("Creating decoder for codec: " + metadata.codec_name + "\n").c_str());
// Media Foundation 하드웨어 가속 디코더 강제 사용 (테스트 목적)
m_decoder = VideoDecoderFactory::CreateDecoder(metadata.codec_type, VideoDecoderFactory::DecoderType::HARDWARE_MF);
std::string decoderTypeName = GetDecoderTypeName(m_selectedDecoderType);
OutputDebugStringA(("Using selected decoder type: " + decoderTypeName + "\n").c_str());
m_decoder = VideoDecoderFactory::CreateDecoder(metadata.codec_type, m_selectedDecoderType);
if (m_decoder) {
OutputDebugStringA(("Successfully created decoder: " + m_decoder->GetCodecName() + "\n").c_str());
@@ -565,8 +571,9 @@ namespace winrt::Vav2Player::implementation
// Initialize decoder if not already done
if (!m_decoder)
{
OutputDebugStringA("Creating AV1 decoder for streaming playback (HARDWARE_MF mode)\n");
m_decoder = VideoDecoderFactory::CreateDecoder(VideoCodecType::AV1, VideoDecoderFactory::DecoderType::HARDWARE_MF);
std::string decoderTypeName = GetDecoderTypeName(m_selectedDecoderType);
OutputDebugStringA(("Creating AV1 decoder for streaming playback (" + decoderTypeName + ")\n").c_str());
m_decoder = VideoDecoderFactory::CreateDecoder(VideoCodecType::AV1, m_selectedDecoderType);
if (m_decoder) {
OutputDebugStringA(("Successfully created decoder: " + m_decoder->GetCodecName() + "\n").c_str());
@@ -830,6 +837,59 @@ namespace winrt::Vav2Player::implementation
}
}
// Decoder Selection Event Handler
void MainWindow::DecoderSelectionComboBox_SelectionChanged(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::Controls::SelectionChangedEventArgs const&)
{
try
{
auto selectedIndex = DecoderSelectionComboBox().SelectedIndex();
auto selectedItem = DecoderSelectionComboBox().SelectedItem().as<winrt::Microsoft::UI::Xaml::Controls::ComboBoxItem>();
auto tag = selectedItem.Tag().as<winrt::hstring>();
std::string tagStr = winrt::to_string(tag);
// Convert tag to DecoderType
VideoDecoderFactory::DecoderType newDecoderType = VideoDecoderFactory::DecoderType::AUTO;
if (tagStr == "SOFTWARE")
{
newDecoderType = VideoDecoderFactory::DecoderType::SOFTWARE;
}
else if (tagStr == "HARDWARE_MF")
{
newDecoderType = VideoDecoderFactory::DecoderType::HARDWARE_MF;
}
else if (tagStr == "AUTO")
{
newDecoderType = VideoDecoderFactory::DecoderType::AUTO;
}
// If decoder type changed, reset decoder
if (newDecoderType != m_selectedDecoderType)
{
m_selectedDecoderType = newDecoderType;
// Reset decoder if currently playing or file loaded
if (m_decoder)
{
m_decoder.reset();
m_playbackInitialized = false;
std::string decoderTypeName = GetDecoderTypeName(m_selectedDecoderType);
UpdateStatus("Decoder changed to: " + decoderTypeName);
OutputDebugStringA(("Decoder type changed to: " + decoderTypeName + "\n").c_str());
}
else
{
std::string decoderTypeName = GetDecoderTypeName(m_selectedDecoderType);
UpdateStatus("Selected decoder: " + decoderTypeName);
}
}
}
catch (...)
{
UpdateStatus("Error changing decoder selection");
}
}
// File Output Control Event Handlers
void MainWindow::EnableFileOutputCheckBox_Checked(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&)
{
@@ -967,4 +1027,19 @@ namespace winrt::Vav2Player::implementation
OutputFolderText().Foreground(winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(winrt::Microsoft::UI::Colors::Red()));
}
}
std::string MainWindow::GetDecoderTypeName(VideoDecoderFactory::DecoderType decoderType) const
{
switch (decoderType)
{
case VideoDecoderFactory::DecoderType::AUTO:
return "AV1 Decoder (Auto)";
case VideoDecoderFactory::DecoderType::HARDWARE_MF:
return "AV1 Hardware (Media Foundation)";
case VideoDecoderFactory::DecoderType::SOFTWARE:
return "AV1 Software (dav1d)";
default:
return "Unknown Decoder";
}
}
}

View File

@@ -26,6 +26,9 @@ namespace winrt::Vav2Player::implementation
void PauseButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
void StopButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
// Decoder selection event handler
void DecoderSelectionComboBox_SelectionChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::Controls::SelectionChangedEventArgs const& e);
// File Output control event handlers
void EnableFileOutputCheckBox_Checked(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
void EnableFileOutputCheckBox_Unchecked(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
@@ -44,6 +47,9 @@ namespace winrt::Vav2Player::implementation
// Current file path
std::string m_currentFilePath;
// Decoder selection state
VideoDecoderFactory::DecoderType m_selectedDecoderType = VideoDecoderFactory::DecoderType::AUTO;
// UI state
bool m_isPlaying = false;
bool m_isFileLoaded = false;
@@ -67,6 +73,7 @@ namespace winrt::Vav2Player::implementation
void StartPlaybackTimer();
void StopPlaybackTimer();
void InitializeUI();
std::string GetDecoderTypeName(VideoDecoderFactory::DecoderType decoderType) const;
// File Output helper methods
void UpdateFileOutputControls();