📄 flvdecoderprop.cpp
字号:
// FLVDecoderProp.h: implementation of CFLVDecoderProp class
//
//////////////////////////////////////////////////////////////////////
//#include "stdafx.h"
#include <streams.h>
#include <commctrl.h>
#include <olectl.h>
#include <memory.h>
#include <stdlib.h>
#include <stdio.h>
#include <tchar.h>
#include "resource.h"
#include "iFLVDecoder.h"
#include "FLVDecoder.h"
#include "FLVDecoderProp.h"
///////////////////////////////////////////////////////////////////////
// CreateInstance: Used by the DirectShow base classes to create
// instances
///////////////////////////////////////////////////////////////////////
//CUnknown *CFLVDecoderProp::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
CUnknown *WINAPI CFLVDecoderProp::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
{
CUnknown *punk = new CFLVDecoderProp(lpunk, phr);
if (punk == NULL) {
*phr = E_OUTOFMEMORY;
}
return punk;
}
///////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////
CFLVDecoderProp::CFLVDecoderProp(LPUNKNOWN pUnk, HRESULT *phr) :
CBasePropertyPage(NAME("FLVDecoder Property Page"),
pUnk,IDD_PROPERTIES,IDS_TITLE),
m_pIFLVDecoder(NULL),
m_bIsInitialized(FALSE)
{
ASSERT(phr);
}
///////////////////////////////////////////////////////////////////////
// OnReceiveMessage: Handles the messages for our property window
///////////////////////////////////////////////////////////////////////
BOOL CFLVDecoderProp::OnReceiveMessage(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG: // init property page
break;
case WM_COMMAND:
{
if (m_bIsInitialized) {
// Set dirty to indicate the setting has changed
m_bDirty = TRUE;
if (m_pPageSite)
m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
}
return (LRESULT) 1;
}
}
return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
}
///////////////////////////////////////////////////////////////////////
// OnConnect: Called when we connect to a transform filter
///////////////////////////////////////////////////////////////////////
HRESULT CFLVDecoderProp::OnConnect(IUnknown *pUnknown)
{
ASSERT(m_pIFLVDecoder == NULL);
HRESULT hr = pUnknown->QueryInterface(IID_IFLVDecoder, (void **) &m_pIFLVDecoder);
if (FAILED(hr)) {
return E_NOINTERFACE;
}
ASSERT(m_pIFLVDecoder);
m_bIsInitialized = FALSE ;
return NOERROR;
}
///////////////////////////////////////////////////////////////////////
// OnDisconnect: Likewise called when we disconnect from a filter
///////////////////////////////////////////////////////////////////////
HRESULT CFLVDecoderProp::OnDisconnect()
{
if (m_pIFLVDecoder == NULL) {
return E_UNEXPECTED;
}
m_pIFLVDecoder->Release();
m_pIFLVDecoder = NULL;
return NOERROR;
}
///////////////////////////////////////////////////////////////////////
// OnActivate: We are being activated
///////////////////////////////////////////////////////////////////////
HRESULT CFLVDecoderProp::OnActivate()
{
ASSERT(m_pIFLVDecoder);
// Get the current setup of the filter
m_pIFLVDecoder->GetParams(&m_FLVDecoderParams);
// Set the control to the current setup
SetControlValues();
m_bIsInitialized = TRUE;
return NOERROR;
}
///////////////////////////////////////////////////////////////////////
// OnDeactivate: We are being deactivated
///////////////////////////////////////////////////////////////////////
HRESULT CFLVDecoderProp::OnDeactivate(void)
{
ASSERT(m_pIFLVDecoder);
m_bIsInitialized = FALSE;
return NOERROR;
}
///////////////////////////////////////////////////////////////////////
// OnApplyChanges: Apply any changes so far made
///////////////////////////////////////////////////////////////////////
HRESULT CFLVDecoderProp::OnApplyChanges()
{
ASSERT(m_pIFLVDecoder);
// Update the setup from controls and set it into the filter
GetControlValues();
m_pIFLVDecoder->SetParams(&m_FLVDecoderParams);
return NOERROR;
}
///////////////////////////////////////////////////////////////////////
// GetControlValues: read the setup from current controls
///////////////////////////////////////////////////////////////////////
void CFLVDecoderProp::GetControlValues()
{
// param1
m_FLVDecoderParams.param1 =
IsDlgButtonChecked( m_Dlg, IDC_PARAMETERS1 ) == BST_CHECKED;
// param2
TCHAR sz[STR_MAX_LENGTH];
Edit_GetText(GetDlgItem(m_Dlg, IDC_PARAMETERS2), sz, STR_MAX_LENGTH);
m_FLVDecoderParams.param2 = atof(sz);
}
///////////////////////////////////////////////////////////////////////
// SetControlValues: set the current setup to the controls
///////////////////////////////////////////////////////////////////////
void CFLVDecoderProp::SetControlValues()
{
// param1
CheckDlgButton(m_Dlg, IDC_PARAMETERS1, m_FLVDecoderParams.param1);
// param2
TCHAR sz[STR_MAX_LENGTH];
_stprintf(sz, TEXT("%f"), m_FLVDecoderParams.param2);
Edit_SetText(GetDlgItem(m_Dlg, IDC_PARAMETERS2), sz);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -