Ignore:
Timestamp:
12/15/07 21:04:05 (16 years ago)
Author:
radscorpion
Message:

Eye candy property page for the decoder filter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dsfilters/dec_mpc/src/mpc_prop.cpp

    r370 r374  
    2727}
    2828
     29void MakeNiceSpeed(__int64 bps, CString &v)
     30{
     31        int r=0;
     32        __int64 c=bps;
     33        LPCTSTR         rady[] = {
     34                _T("bps"),
     35                _T("kbps"),
     36                _T("mbps"),
     37                _T("gbps"),
     38                _T("tbps")
     39        };
     40
     41        // spocitame rad
     42        while (c > 1000 && r<4) {
     43                r++;
     44                c = c / 1000;
     45        }
     46
     47        c=bps;
     48        for (int i=1; i<r; i++) { c = c/1000; }
     49        double d=c / 1000.0;
     50
     51        v.Format(_T("%5.3f %s"), (float)d, rady[r]);
     52}
     53
    2954
    3055//-----------------------------------------------------------------------------
     
    4065
    4166CMPCPropertyPage::CMPCPropertyPage(LPUNKNOWN lpUnk, HRESULT *phr) :
    42         CBasePropertyPage(NAME("MPC Property Page"), lpUnk, IDD_PAGE_DECODER, IDS_PAGE_DECODER)
    43         //,
    44         //demux(NULL)
     67        CBasePropertyPage(NAME("MPC Property Page"), lpUnk, IDD_PAGE_DECODER, IDS_PAGE_DECODER),
     68        decoder(NULL)
    4569{
    4670}
     
    5377{
    5478        // hold a pointer
    55         //ASSERT(!demux);
    56         //HRESULT hr = pUnknown->QueryInterface(IID_IMusepackSplitter, (void**)&demux);
    57         //if (FAILED(hr)) return hr;
     79        ASSERT(!decoder);
     80        HRESULT hr = pUnknown->QueryInterface(IID_IMusepackDecoder, (void**)&decoder);
     81        if (FAILED(hr)) return hr;
    5882
    5983        // okej
     
    6387HRESULT CMPCPropertyPage::OnDisconnect()
    6488{
    65         //if (demux) { demux->Release(); demux = NULL; }
     89        if (decoder) { decoder->Release(); decoder = NULL; }
    6690        return NOERROR;
    6791}
     
    6993HRESULT CMPCPropertyPage::OnActivate()
    7094{
     95        SetTimer(m_Dlg, 0, 1000, NULL);
     96        UpdateVisual();
    7197        return NOERROR;
    72         /*
    73         demux->SetPropertyPageWindow(m_Dlg);
    74 
    75         // initialize out controls
    76         LVCOLUMN        col;
    77         col.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
    78 
    79         col.pszText = _T("Name");       col.cx = 150;   col.iSubItem = 0;
    80         ListView_InsertColumn(ITEM(IDC_LIST_CONTENT), 0, &col);
    81 
    82         col.pszText = _T("Value");      col.cx = 200;   col.iSubItem = 1;
    83         ListView_InsertColumn(ITEM(IDC_LIST_CONTENT), 1, &col);
    84 
    85         UpdateList();
    86         return NOERROR;
    87         */
    8898}
    8999
    90100HRESULT CMPCPropertyPage::OnDeactivate()
    91101{
    92         //demux->SetPropertyPageWindow(NULL);
     102        KillTimer(m_Dlg, 0);
    93103        return NOERROR;
    94104}
    95105
    96 /*
    97 void CMPCPropertyPage::UpdateList()
     106void CMPCPropertyPage::UpdateVisual()
    98107{
    99         // first reset everything
    100         ListView_DeleteAllItems(ITEM(IDC_LIST_CONTENT));
     108        // update visuals
     109        CString tmp;
     110        HRESULT hr;
     111        int             val;
     112        float   fval;
    101113
    102         // now check for the file
    103         MPC_File_Info           info;
    104         HRESULT hr = demux->GetFileInfo(&info);
    105         if (FAILED(hr)) return ;
     114        if (!decoder) return ;
    106115
    107         // now fill in the values
    108         CString         name, val;
    109         LVITEM          i;
    110         int                     item;
     116        // stream version
     117        if (SUCCEEDED(decoder->GetStreamVersion(&val))) { tmp.Format(_T("SV%d"), val); } else { tmp = _T("Unknown"); }
     118        Static_SetText(ITEM(IDC_STATIC_VERSION), tmp);
    111119
    112         i.mask = LVIF_TEXT;
    113         i.iSubItem = 0;
     120        // samplerate
     121        if (SUCCEEDED(decoder->GetSamplerate(&val))) { tmp.Format(_T("%d Hz"), val); } else { tmp = _T("Unknown"); }
     122        Static_SetText(ITEM(IDC_STATIC_SAMPLERATE), tmp);
     123       
     124        // channels
     125        if (SUCCEEDED(decoder->GetChannels(&val))) {
     126                switch (val) {
     127                case 1: tmp = _T("Mono (1)"); break;
     128                case 2: tmp = _T("Stereo (2)"); break;
     129                default: tmp.Format(_T("Other (%d)"), val); break;
     130                }
     131        } else {
     132                tmp = _T("Unknown");
     133        }
     134        Static_SetText(ITEM(IDC_STATIC_CHANNELS), tmp);
    114135
    115         // Duration
    116         i.pszText = _T("Duration");     i.iItem = 0;
    117         MakeNiceTime(info.duration * 1000, val);
    118         item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
    119         ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
     136        // so far only one output type
     137        Static_SetText(ITEM(IDC_STATIC_OUTPUT), _T("16-bit Integer"));
    120138
    121         // Stream version
    122         i.pszText = _T("Stream version");       i.iItem = 1;
    123         val.Format(_T("%d"), info.stream_version);
    124         item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
    125         ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
     139        // replay gain
     140        if (SUCCEEDED(decoder->GetReplaygain(&fval))) {
     141                tmp.Format(_T("%4.2f dB"), fval);
     142        } else {
     143                tmp = _T("0.00 dB");
     144        }
     145        Static_SetText(ITEM(IDC_STATIC_REPLAYGAIN), tmp);
    126146
    127         // Stream version
    128         i.pszText = _T("Sample rate");  i.iItem = 2;
    129         val.Format(_T("%d Hz"), info.sample_rate);
    130         item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
    131         ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
     147        // decoded frames
     148        __int64 frames;
     149        decoder->GetFramesDecoded(&frames);
     150        tmp.Format(_T("%I64d"), frames);
     151        Static_SetText(ITEM(IDC_STATIC_FRAMES), tmp);
    132152
    133         // Channels
    134         i.pszText = _T("Channels");     i.iItem = 3;
    135         val.Format(_T("%d"), info.channels);
    136         item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
    137         ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
    138 
    139         if (info.stream_version == 8) {
    140 
    141                 // Channels
    142                 i.pszText = _T("Frames per packet");    i.iItem = 4;
    143                 val.Format(_T("%d"), info.block_frames);
    144                 item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
    145                 ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
    146 
    147         }
     153        // bitrate
     154        decoder->GetBitrate(&fval);
     155        MakeNiceSpeed((__int64)fval, tmp);
     156        Static_SetText(ITEM(IDC_STATIC_BITRATE), tmp);
    148157}
    149 */
    150158
    151159INT_PTR CMPCPropertyPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    152160{
    153161        switch (uMsg) {
    154         case WM_UPDATE_VISUALS: break; //               UpdateList(); break;
     162        case WM_TIMER: UpdateVisual(); break;
    155163        }
    156164        return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);
Note: See TracChangeset for help on using the changeset viewer.