Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
# Microsoft Developer Studio Project File - Name="VMRPlayer" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=VMRPlayer - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "VMRPlayer.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "VMRPlayer.mak" CFG="VMRPlayer - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "VMRPlayer - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "VMRPlayer - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "VMRPlayer - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\DirectShow\BaseClasses" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D WINVER=0x501 /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG" /d "WIN32"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 ..\..\..\DirectShow\baseclasses\release\strmbase.lib strmiids.lib quartz.lib ddraw.lib dxguid.lib version.lib shell32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib comctl32.lib shell32.lib /nologo /subsystem:windows /pdb:none /machine:I386 /OPT:NOREF /OPT:ICF
|
||||
|
||||
!ELSEIF "$(CFG)" == "VMRPlayer - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\DirectShow\BaseClasses" /D "_DEBUG" /D "DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D WINVER=0x501 /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG" /d "WIN32"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 ..\..\..\DirectShow\baseclasses\debug\strmbasd.lib strmiids.lib quartz.lib ddraw.lib dxguid.lib version.lib shell32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib comctl32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcmtd" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "VMRPlayer - Win32 Release"
|
||||
# Name "VMRPlayer - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\app.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\commands.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\persist.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\vcdplyer.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\app.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\project.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\vcdplyer.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\perftool.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\toolbar.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\vcdplyer.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\vmr.bmp
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "VMRPlayer"=".\VMRPlayer.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,443 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: app.h
|
||||
//
|
||||
// Desc: DirectShow sample code
|
||||
// - Main header file for VMRPlayer sample
|
||||
//
|
||||
// Copyright (c) 1994 - 2001, Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** Function prototypes
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
DoMainLoop(
|
||||
void
|
||||
);
|
||||
|
||||
BOOL
|
||||
InitApplication(
|
||||
HINSTANCE hInstance
|
||||
);
|
||||
|
||||
BOOL
|
||||
InitInstance(
|
||||
HINSTANCE hInstance,
|
||||
int nCmdShow
|
||||
);
|
||||
|
||||
BOOL
|
||||
LoadWindowPos(
|
||||
LPRECT lprc
|
||||
);
|
||||
|
||||
BOOL
|
||||
SaveWindowPos(
|
||||
HWND hwnd
|
||||
);
|
||||
|
||||
void
|
||||
PatB(
|
||||
HDC hdc,
|
||||
int x,
|
||||
int y,
|
||||
int dx,
|
||||
int dy,
|
||||
DWORD rgb
|
||||
);
|
||||
|
||||
void
|
||||
UpdateMpegMovieRect(
|
||||
void
|
||||
);
|
||||
|
||||
void
|
||||
GetAdjustedClientRect(
|
||||
RECT *prc
|
||||
);
|
||||
|
||||
BOOL
|
||||
DrawStats(
|
||||
HDC hdc
|
||||
);
|
||||
|
||||
void
|
||||
CalcMovieRect(
|
||||
LPRECT lprc
|
||||
);
|
||||
|
||||
LPCTSTR
|
||||
IdStr(
|
||||
int idResource
|
||||
);
|
||||
|
||||
void
|
||||
UpdateSystemColors(
|
||||
void
|
||||
);
|
||||
|
||||
void
|
||||
SetDurationLength(
|
||||
REFTIME rt
|
||||
);
|
||||
|
||||
void
|
||||
SetCurrentPosition(
|
||||
REFTIME rt
|
||||
);
|
||||
|
||||
TCHAR *
|
||||
FormatRefTime(
|
||||
TCHAR *sz,
|
||||
REFTIME rt
|
||||
);
|
||||
|
||||
void
|
||||
DoMpegVideoPropertyPage();
|
||||
|
||||
void
|
||||
DoMpegAudioPropertyPage();
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** Registry routines
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
ProfileIntIn(
|
||||
const TCHAR *szKey,
|
||||
int iDefault
|
||||
);
|
||||
|
||||
BOOL
|
||||
ProfileIntOut(
|
||||
const TCHAR *szKey,
|
||||
int iDefault
|
||||
);
|
||||
|
||||
void
|
||||
ProfileStringOut (
|
||||
LPTSTR szKey,
|
||||
LPTSTR sz
|
||||
);
|
||||
|
||||
UINT
|
||||
ProfileStringIn (
|
||||
LPTSTR szKey,
|
||||
LPTSTR szDef,
|
||||
LPTSTR sz,
|
||||
DWORD cb
|
||||
);
|
||||
|
||||
BOOL
|
||||
LoadWindowPos(
|
||||
LPRECT lprc
|
||||
);
|
||||
|
||||
BOOL
|
||||
SaveWindowPos(
|
||||
HWND hwnd
|
||||
);
|
||||
|
||||
HKEY
|
||||
GetAppKey(
|
||||
BOOL fCreate
|
||||
);
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** Message crackers
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
/* void Cls_OnUser(HWND hwnd, WPARAM wParam, LPARAM lParam ) */
|
||||
#define HANDLE_WM_USER(hwnd, wParam, lParam, fn) \
|
||||
((fn)(hwnd, wParam, lParam), 0L)
|
||||
|
||||
/* LRESULT Cls_OnNotify(HWND hwnd, int idFrom, NMHDR FAR* pnmhdr); */
|
||||
#ifndef HANDLE_WM_NOTIFY
|
||||
#define HANDLE_WM_NOTIFY(hwnd, wParam, lParam, fn) \
|
||||
(fn)((hwnd), (int)(wParam), (NMHDR FAR*)(lParam))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** VideoCd window class prototypes
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
extern "C" LRESULT CALLBACK
|
||||
VideoCdWndProc(
|
||||
HWND hwnd,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnClose(
|
||||
HWND hwnd
|
||||
);
|
||||
|
||||
BOOL
|
||||
VideoCd_OnQueryEndSession(
|
||||
HWND hwnd
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnDestroy(
|
||||
HWND hwnd
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnCommand(
|
||||
HWND hwnd,
|
||||
int id,
|
||||
HWND hwndCtl,
|
||||
UINT codeNotify
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnPaint(
|
||||
HWND hwnd
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnTimer(
|
||||
HWND hwnd,
|
||||
UINT id
|
||||
);
|
||||
|
||||
BOOL
|
||||
VideoCd_OnCreate(
|
||||
HWND hwnd,
|
||||
LPCREATESTRUCT lpCreateStruct
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnSize(
|
||||
HWND hwnd,
|
||||
UINT state,
|
||||
int cx,
|
||||
int cy
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnActivate(
|
||||
HWND hwnd,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnHScroll(
|
||||
HWND hwnd,
|
||||
HWND hwndCtl,
|
||||
UINT code,
|
||||
int pos
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnUser(
|
||||
HWND hwnd,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnSysColorChange(
|
||||
HWND hwnd
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnMenuSelect(
|
||||
HWND hwnd,
|
||||
HMENU hmenu,
|
||||
int item,
|
||||
HMENU hmenuPopup,
|
||||
UINT flags
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnInitMenuPopup(
|
||||
HWND hwnd,
|
||||
HMENU hMenu,
|
||||
UINT item,
|
||||
BOOL fSystemMenu
|
||||
);
|
||||
|
||||
#ifdef WM_NOTIFY
|
||||
LRESULT
|
||||
VideoCd_OnNotify(
|
||||
HWND hwnd,
|
||||
int idFrom,
|
||||
NMHDR FAR* pnmhdr
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
VideoCd_OnGraphNotify(
|
||||
void
|
||||
);
|
||||
|
||||
void
|
||||
VideoCd_OnDropFiles(
|
||||
HWND hwnd,
|
||||
HDROP hdrop);
|
||||
|
||||
void
|
||||
SetPlayButtonsEnableState(
|
||||
void
|
||||
);
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** Command processing functions
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BOOL
|
||||
VcdPlyerCaptureImage(
|
||||
LPCSTR szFile
|
||||
);
|
||||
|
||||
BOOL
|
||||
VcdPlyerDisplayCapturedImage(
|
||||
LPCSTR szFile
|
||||
);
|
||||
|
||||
BOOL
|
||||
VcdPlayerOpenCmd(
|
||||
int i
|
||||
);
|
||||
|
||||
BOOL
|
||||
VcdPlayerCloseCmd(
|
||||
void
|
||||
);
|
||||
|
||||
BOOL
|
||||
VcdPlayerPlayCmd(
|
||||
void
|
||||
);
|
||||
|
||||
BOOL
|
||||
VcdPlayerStopCmd(
|
||||
void
|
||||
);
|
||||
|
||||
BOOL
|
||||
VcdPlayerRewindCmd(
|
||||
void
|
||||
);
|
||||
|
||||
BOOL
|
||||
VcdPlayerPauseCmd(
|
||||
void
|
||||
);
|
||||
|
||||
BOOL
|
||||
VcdPlayerStepCmd(
|
||||
void
|
||||
);
|
||||
|
||||
void
|
||||
VcdPlayerSeekCmd(
|
||||
REFTIME rtSeekBy
|
||||
);
|
||||
|
||||
void
|
||||
ProcessOpen(
|
||||
TCHAR *achFileName,
|
||||
BOOL bPlay = FALSE
|
||||
);
|
||||
|
||||
int
|
||||
VcdPlayerChangeTimeFormat(
|
||||
int id
|
||||
);
|
||||
|
||||
BOOL CALLBACK TransDlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
|
||||
BOOL CALLBACK AppImgDlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
|
||||
LRESULT CALLBACK AboutDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** Recent filename stuff
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
typedef TCHAR RECENTFILES[MAX_PATH];
|
||||
#define MAX_RECENT_FILES 10
|
||||
#define ID_RECENT_FILE_BASE 500
|
||||
|
||||
int
|
||||
GetRecentFiles(
|
||||
int LastCount
|
||||
);
|
||||
|
||||
int
|
||||
SetRecentFiles(
|
||||
TCHAR *FileName,
|
||||
int iCount
|
||||
);
|
||||
|
||||
#define CAPTURED_IMAGE_NAME TEXT("VMRImage.bmp\0")
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** Global Variables
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
extern int cxMovie;
|
||||
extern int cyMovie;
|
||||
extern HWND hwndApp;
|
||||
extern HWND g_hwndStatusbar;
|
||||
|
||||
extern int cx;
|
||||
extern int cy;
|
||||
extern int xOffset;
|
||||
extern int yOffset;
|
||||
extern TCHAR g_achFileName[];
|
||||
extern OPENFILENAME ofn;
|
||||
extern DWORD g_State;
|
||||
extern int nRecentFiles;
|
||||
extern int g_TimeFormat;
|
||||
extern LONG lMovieOrgX, lMovieOrgY;
|
||||
extern BOOL g_bSecondFileLoaded;
|
||||
extern RECENTFILES aRecentFiles[MAX_RECENT_FILES];
|
||||
|
||||
extern FLOAT g_xPos, g_yPos, g_xSize, g_ySize, g_Alpha;
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** Constants
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
#define LEFT_MARGIN 0
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** Video CD Player states
|
||||
**
|
||||
** These are bit flags
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define VCD_PLAYING 0x0001
|
||||
#define VCD_STOPPED 0x0002
|
||||
#define VCD_PAUSED 0x0004
|
||||
#define VCD_SKIP_F 0x0008
|
||||
#define VCD_SKIP_B 0x0010
|
||||
#define VCD_FF 0x0020
|
||||
#define VCD_RW 0x0040
|
||||
#define VCD_SEEKING (VCD_FF | VCD_RW)
|
||||
#define VCD_LOADED 0x0080
|
||||
#define VCD_NO_CD 0x0100
|
||||
#define VCD_DATA_CD_LOADED 0x0200
|
||||
#define VCD_EDITING 0x0400
|
||||
#define VCD_PAUSED_AND_MOVED 0x0800
|
||||
#define VCD_PLAY_PENDING 0x1000
|
||||
#define VCD_WAS_PLAYING 0x2000
|
||||
#define VCD_IN_USE 0x4000
|
||||
#define VCD_STEPPING 0x8000
|
||||
|
||||
enum {PerformanceTimer = 32, StatusTimer = 33};
|
||||
@@ -0,0 +1,486 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: commands.cpp
|
||||
//
|
||||
// Desc: DirectShow sample code
|
||||
// - Processes commands from the user.
|
||||
//
|
||||
// Copyright (c) 1994 - 2001, Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
#include <streams.h>
|
||||
#include "project.h"
|
||||
|
||||
typedef LPBITMAPINFOHEADER PDIB;
|
||||
|
||||
extern CMpegMovie *pMpegMovie;
|
||||
extern void RepositionMovie(HWND hwnd);
|
||||
|
||||
// Constants
|
||||
#define BFT_BITMAP 0x4d42 /* 'BM' */
|
||||
|
||||
// Macros
|
||||
#define DibNumColors(lpbi) ((lpbi)->biClrUsed == 0 && (lpbi)->biBitCount <= 8 \
|
||||
? (int)(1 << (int)(lpbi)->biBitCount) \
|
||||
: (int)(lpbi)->biClrUsed)
|
||||
|
||||
#define DibSize(lpbi) ((lpbi)->biSize + (lpbi)->biSizeImage + (int)(lpbi)->biClrUsed * sizeof(RGBQUAD))
|
||||
|
||||
#define DibPaletteSize(lpbi) (DibNumColors(lpbi) * sizeof(RGBQUAD))
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlyerCaptureImage
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
VcdPlyerCaptureImage(
|
||||
LPCSTR szFile
|
||||
)
|
||||
{
|
||||
if(pMpegMovie)
|
||||
{
|
||||
BYTE* lpCurrImage = NULL;
|
||||
|
||||
if(pMpegMovie->GetCurrentImage(&lpCurrImage) == S_OK)
|
||||
{
|
||||
BITMAPFILEHEADER hdr;
|
||||
HFILE fh;
|
||||
OFSTRUCT of;
|
||||
DWORD dwSize;
|
||||
PDIB pdib = (PDIB)lpCurrImage;
|
||||
|
||||
fh = OpenFile(szFile,&of,OF_CREATE|OF_READWRITE);
|
||||
|
||||
if(fh == -1)
|
||||
return FALSE;
|
||||
|
||||
dwSize = DibSize(pdib);
|
||||
|
||||
hdr.bfType = BFT_BITMAP;
|
||||
hdr.bfSize = dwSize + sizeof(BITMAPFILEHEADER);
|
||||
hdr.bfReserved1 = 0;
|
||||
hdr.bfReserved2 = 0;
|
||||
hdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + pdib->biSize +
|
||||
DibPaletteSize(pdib);
|
||||
|
||||
_lwrite(fh,(LPCSTR)(LPVOID)&hdr,sizeof(BITMAPFILEHEADER));
|
||||
_hwrite(fh,(LPCSTR)(LPVOID)pdib,dwSize);
|
||||
|
||||
_lclose(fh);
|
||||
|
||||
CoTaskMemFree(lpCurrImage);
|
||||
|
||||
TCHAR szText[128], szDir[MAX_PATH];
|
||||
GetCurrentDirectory(MAX_PATH, szDir);
|
||||
wsprintf(szText, TEXT("Captured current image to %s\\%s."), szDir, szFile);
|
||||
MessageBox(hwndApp, szText, TEXT("Captured bitmap"), MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlyerDisplayCapturedImage
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
VcdPlyerDisplayCapturedImage(
|
||||
LPCSTR szFile
|
||||
)
|
||||
{
|
||||
// Open the bitmap with the system-default application
|
||||
ShellExecute(hwndApp, "open\0", szFile, NULL, NULL, SW_SHOWNORMAL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlayerOpenCmd
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
VcdPlayerOpenCmd(
|
||||
int strmID
|
||||
)
|
||||
{
|
||||
static BOOL fFirstTime = TRUE;
|
||||
BOOL fRet;
|
||||
TCHAR achFileName[MAX_PATH];
|
||||
TCHAR achFilter[MAX_PATH];
|
||||
LPTSTR lp;
|
||||
|
||||
if(fFirstTime)
|
||||
{
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hwndApp;
|
||||
ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST |
|
||||
OFN_SHAREAWARE | OFN_PATHMUSTEXIST;
|
||||
}
|
||||
|
||||
lstrcpy(achFilter, IdStr(STR_FILE_FILTER));
|
||||
ofn.lpstrFilter = achFilter;
|
||||
|
||||
/*
|
||||
** Convert the resource string into to something suitable for
|
||||
** GetOpenFileName ie. replace '#' characters with '\0' characters.
|
||||
*/
|
||||
for(lp = achFilter; *lp; lp++)
|
||||
{
|
||||
if(*lp == TEXT('#'))
|
||||
{
|
||||
*lp = TEXT('\0');
|
||||
}
|
||||
}
|
||||
|
||||
ofn.lpstrFile = achFileName;
|
||||
ofn.nMaxFile = sizeof(achFileName) / sizeof(TCHAR);
|
||||
ZeroMemory(achFileName, sizeof(achFileName));
|
||||
|
||||
fRet = GetOpenFileName(&ofn);
|
||||
if(fRet)
|
||||
{
|
||||
if(strmID == 0)
|
||||
{
|
||||
fFirstTime = FALSE;
|
||||
ProcessOpen(achFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pMpegMovie)
|
||||
{
|
||||
pMpegMovie->RenderSecondFile(achFileName);
|
||||
}
|
||||
}
|
||||
|
||||
InitStreamParams(strmID);
|
||||
}
|
||||
|
||||
return fRet;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlayerCloseCmd
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
VcdPlayerCloseCmd(
|
||||
void
|
||||
)
|
||||
{
|
||||
if(pMpegMovie)
|
||||
{
|
||||
LONG cx, cy;
|
||||
|
||||
g_State = VCD_NO_CD;
|
||||
pMpegMovie->GetMoviePosition(&lMovieOrgX, &lMovieOrgY, &cx, &cy);
|
||||
pMpegMovie->StopMovie();
|
||||
pMpegMovie->CloseMovie();
|
||||
|
||||
SetDurationLength((REFTIME)0);
|
||||
SetCurrentPosition((REFTIME)0);
|
||||
|
||||
delete pMpegMovie;
|
||||
pMpegMovie = NULL;
|
||||
}
|
||||
|
||||
g_bSecondFileLoaded = FALSE;
|
||||
InvalidateRect(hwndApp, NULL, FALSE);
|
||||
UpdateWindow(hwndApp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlayerPlayCmd
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
VcdPlayerPlayCmd(
|
||||
void
|
||||
)
|
||||
{
|
||||
BOOL fStopped = (g_State & VCD_STOPPED);
|
||||
BOOL fPaused = (g_State & VCD_PAUSED);
|
||||
|
||||
if((fStopped || fPaused))
|
||||
{
|
||||
if(pMpegMovie)
|
||||
{
|
||||
pMpegMovie->PlayMovie();
|
||||
}
|
||||
|
||||
g_State &= ~(fStopped ? VCD_STOPPED : VCD_PAUSED);
|
||||
g_State |= VCD_PLAYING;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlayerPlayCmd
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
VcdPlayerStopCmd(
|
||||
void
|
||||
)
|
||||
{
|
||||
BOOL fPlaying = (g_State & VCD_PLAYING);
|
||||
BOOL fPaused = (g_State & VCD_PAUSED);
|
||||
|
||||
if((fPlaying || fPaused))
|
||||
{
|
||||
if(pMpegMovie)
|
||||
{
|
||||
pMpegMovie->StopMovie();
|
||||
SetCurrentPosition(pMpegMovie->GetCurrentPosition());
|
||||
}
|
||||
|
||||
g_State &= ~(fPlaying ? VCD_PLAYING : VCD_PAUSED);
|
||||
g_State |= VCD_STOPPED;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlayerStepCmd
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
VcdPlayerStepCmd(
|
||||
void
|
||||
)
|
||||
{
|
||||
if(pMpegMovie)
|
||||
{
|
||||
// Ensure that the video is paused to update toolbar buttons
|
||||
if(g_State & VCD_PLAYING)
|
||||
VcdPlayerPauseCmd();
|
||||
|
||||
if(pMpegMovie->FrameStepMovie())
|
||||
{
|
||||
g_State |= VCD_STEPPING;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlayerPauseCmd
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
VcdPlayerPauseCmd(
|
||||
void
|
||||
)
|
||||
{
|
||||
BOOL fPlaying = (g_State & VCD_PLAYING);
|
||||
BOOL fPaused = (g_State & VCD_PAUSED);
|
||||
|
||||
if(fPlaying)
|
||||
{
|
||||
if(pMpegMovie)
|
||||
{
|
||||
pMpegMovie->PauseMovie();
|
||||
SetCurrentPosition(pMpegMovie->GetCurrentPosition());
|
||||
}
|
||||
|
||||
g_State &= ~VCD_PLAYING;
|
||||
g_State |= VCD_PAUSED;
|
||||
}
|
||||
else if(fPaused)
|
||||
{
|
||||
if(pMpegMovie)
|
||||
{
|
||||
pMpegMovie->PlayMovie();
|
||||
}
|
||||
|
||||
g_State &= ~VCD_PAUSED;
|
||||
g_State |= VCD_PLAYING;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlayerSeekCmd
|
||||
*
|
||||
\**************************************************************************/
|
||||
void
|
||||
VcdPlayerSeekCmd(
|
||||
REFTIME rtSeekBy
|
||||
)
|
||||
{
|
||||
REFTIME rt;
|
||||
REFTIME rtDur;
|
||||
|
||||
rtDur = pMpegMovie->GetDuration();
|
||||
rt = pMpegMovie->GetCurrentPosition() + rtSeekBy;
|
||||
|
||||
rt = max(0, min(rt, rtDur));
|
||||
|
||||
pMpegMovie->SeekToPosition(rt,TRUE);
|
||||
SetCurrentPosition(pMpegMovie->GetCurrentPosition());
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* ProcessOpen
|
||||
*
|
||||
\**************************************************************************/
|
||||
void
|
||||
ProcessOpen(
|
||||
TCHAR *achFileName,
|
||||
BOOL bPlay
|
||||
)
|
||||
{
|
||||
/*
|
||||
** If we currently have a video loaded we need to discard it here.
|
||||
*/
|
||||
if(g_State & VCD_LOADED)
|
||||
{
|
||||
VcdPlayerCloseCmd();
|
||||
}
|
||||
|
||||
lstrcpy(g_achFileName, achFileName);
|
||||
|
||||
pMpegMovie = new CMpegMovie(hwndApp);
|
||||
if(pMpegMovie)
|
||||
{
|
||||
HRESULT hr = pMpegMovie->OpenMovie(g_achFileName);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
TCHAR achTmp[MAX_PATH];
|
||||
|
||||
nRecentFiles = SetRecentFiles(achFileName, nRecentFiles);
|
||||
|
||||
wsprintf(achTmp, IdStr(STR_APP_TITLE_LOADED),
|
||||
g_achFileName);
|
||||
g_State = (VCD_LOADED | VCD_STOPPED);
|
||||
|
||||
// SetDurationLength(pMpegMovie->GetDuration());
|
||||
g_TimeFormat = VcdPlayerChangeTimeFormat(g_TimeFormat);
|
||||
|
||||
RepositionMovie(hwndApp);
|
||||
pMpegMovie->SetBorderClr(RGB(0x00, 0x80, 0x80));
|
||||
|
||||
// If play
|
||||
if(bPlay)
|
||||
{
|
||||
pMpegMovie->PlayMovie();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TCHAR Buffer[MAX_ERROR_TEXT_LEN];
|
||||
|
||||
if(AMGetErrorText(hr, Buffer, MAX_ERROR_TEXT_LEN))
|
||||
{
|
||||
MessageBox(hwndApp, Buffer,
|
||||
IdStr(STR_APP_TITLE), MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(hwndApp,
|
||||
TEXT("Failed to open the movie. Either the file was ")
|
||||
TEXT("not found or the wave device is in use."),
|
||||
IdStr(STR_APP_TITLE), MB_OK);
|
||||
}
|
||||
|
||||
pMpegMovie->CloseMovie();
|
||||
delete pMpegMovie;
|
||||
pMpegMovie = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
InitStreamParams(0);
|
||||
|
||||
InvalidateRect(hwndApp, NULL, FALSE);
|
||||
UpdateWindow(hwndApp);
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlayerChangeTimeFormat
|
||||
*
|
||||
* Tries to change the time format to id. Returns the time format that
|
||||
* actually got set. This may differ from id if the graph does not support
|
||||
* the requested time format.
|
||||
*
|
||||
\**************************************************************************/
|
||||
int
|
||||
VcdPlayerChangeTimeFormat(
|
||||
int id
|
||||
)
|
||||
{
|
||||
// Menu items are disabled while we are playing
|
||||
BOOL bRet = FALSE;
|
||||
int idActual = id;
|
||||
|
||||
ASSERT(pMpegMovie);
|
||||
ASSERT(pMpegMovie->StatusMovie() != MOVIE_NOTOPENED);
|
||||
|
||||
// Change the time format with the filtergraph
|
||||
switch(id)
|
||||
{
|
||||
case IDM_FRAME:
|
||||
bRet = pMpegMovie->SetTimeFormat(TIME_FORMAT_FRAME);
|
||||
break;
|
||||
|
||||
case IDM_FIELD:
|
||||
bRet = pMpegMovie->SetTimeFormat(TIME_FORMAT_FIELD);
|
||||
break;
|
||||
|
||||
case IDM_SAMPLE:
|
||||
bRet = pMpegMovie->SetTimeFormat(TIME_FORMAT_SAMPLE);
|
||||
break;
|
||||
|
||||
case IDM_BYTES:
|
||||
bRet = pMpegMovie->SetTimeFormat(TIME_FORMAT_BYTE);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!bRet)
|
||||
{
|
||||
// IDM_TIME and all other cases, everyone should support IDM_TIME
|
||||
bRet = pMpegMovie->SetTimeFormat(TIME_FORMAT_MEDIA_TIME);
|
||||
ASSERT(bRet);
|
||||
idActual = IDM_TIME;
|
||||
}
|
||||
|
||||
// Pause the movie to get a current position
|
||||
|
||||
SetDurationLength(pMpegMovie->GetDuration());
|
||||
SetCurrentPosition(pMpegMovie->GetCurrentPosition());
|
||||
|
||||
return idActual;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* VcdPlayerRewindCmd
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
VcdPlayerRewindCmd(
|
||||
void
|
||||
)
|
||||
{
|
||||
if(pMpegMovie)
|
||||
{
|
||||
pMpegMovie->SeekToPosition((REFTIME)0,FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,401 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: persist.cpp
|
||||
//
|
||||
// Desc: DirectShow sample code
|
||||
// - State persistence helper functions
|
||||
//
|
||||
// Copyright (c) 1994 - 2001, Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <streams.h>
|
||||
#include <atlbase.h>
|
||||
#include <atlconv.cpp>
|
||||
#include <mmreg.h>
|
||||
|
||||
#include "project.h"
|
||||
|
||||
// Constants
|
||||
const int CX_DEFAULT = 400; /* Default window width */
|
||||
const int CY_DEFAULT = 400; /* Default window height */
|
||||
|
||||
// Global data
|
||||
RECENTFILES aRecentFiles[MAX_RECENT_FILES];
|
||||
int nRecentFiles;
|
||||
|
||||
// Global static data
|
||||
static TCHAR cszWindow[] = TEXT("Window");
|
||||
static TCHAR cszAppKey[] = TEXT("Software\\Microsoft\\Multimedia Tools\\VMRPlayer");
|
||||
|
||||
|
||||
/*+ GetAppKey
|
||||
*
|
||||
*-=================================================================*/
|
||||
|
||||
HKEY
|
||||
GetAppKey(
|
||||
BOOL fCreate
|
||||
)
|
||||
{
|
||||
HKEY hKey = 0;
|
||||
|
||||
if(fCreate)
|
||||
{
|
||||
if(RegCreateKey(HKEY_CURRENT_USER, cszAppKey, &hKey) == ERROR_SUCCESS)
|
||||
return hKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(RegOpenKey(HKEY_CURRENT_USER, cszAppKey, &hKey) == ERROR_SUCCESS)
|
||||
return hKey;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*+ ProfileIntIn
|
||||
*
|
||||
*-=================================================================*/
|
||||
|
||||
int
|
||||
ProfileIntIn(
|
||||
const TCHAR *szKey,
|
||||
int iDefault
|
||||
)
|
||||
{
|
||||
DWORD dwType=0;
|
||||
int iValue=0;
|
||||
BYTE aData[20];
|
||||
DWORD cb;
|
||||
HKEY hKey;
|
||||
|
||||
if((hKey = GetAppKey(TRUE)) == 0)
|
||||
{
|
||||
return iDefault;
|
||||
}
|
||||
|
||||
*(UINT *)&aData = 0;
|
||||
cb = sizeof(aData);
|
||||
|
||||
if(RegQueryValueEx(hKey, szKey, NULL, &dwType, aData, &cb))
|
||||
{
|
||||
iValue = iDefault;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dwType == REG_DWORD || dwType == REG_BINARY)
|
||||
{
|
||||
iValue = *(int *)&aData;
|
||||
}
|
||||
else if(dwType == REG_SZ)
|
||||
{
|
||||
iValue = atoi((LPSTR)aData);
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return iValue;
|
||||
}
|
||||
|
||||
|
||||
/*+ ProfileIntOut
|
||||
*
|
||||
*-=================================================================*/
|
||||
|
||||
BOOL
|
||||
ProfileIntOut(
|
||||
const TCHAR *szKey,
|
||||
int iVal
|
||||
)
|
||||
{
|
||||
HKEY hKey;
|
||||
BOOL bRet = FALSE;
|
||||
|
||||
hKey = GetAppKey(TRUE);
|
||||
if(hKey)
|
||||
{
|
||||
RegSetValueEx(hKey, szKey, 0, REG_DWORD, (LPBYTE)&iVal, sizeof(DWORD));
|
||||
RegCloseKey(hKey);
|
||||
bRet = TRUE;
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
/*+ ProfileStringIn
|
||||
*
|
||||
*-=================================================================*/
|
||||
|
||||
UINT
|
||||
ProfileStringIn(
|
||||
LPTSTR szKey,
|
||||
LPTSTR szDef,
|
||||
LPTSTR sz,
|
||||
DWORD cb
|
||||
)
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD dwType;
|
||||
|
||||
if((hKey = GetAppKey(FALSE)) == 0)
|
||||
{
|
||||
lstrcpy(sz, szDef);
|
||||
return lstrlen(sz);
|
||||
}
|
||||
|
||||
if(RegQueryValueEx(hKey, szKey, NULL, &dwType, (LPBYTE)sz, &cb) || dwType != REG_SZ)
|
||||
{
|
||||
lstrcpy(sz, szDef);
|
||||
cb = lstrlen(sz);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return cb;
|
||||
}
|
||||
|
||||
|
||||
/*+ ProfileStringOut
|
||||
*
|
||||
*-=================================================================*/
|
||||
|
||||
void
|
||||
ProfileStringOut(
|
||||
LPTSTR szKey,
|
||||
LPTSTR sz
|
||||
)
|
||||
{
|
||||
HKEY hKey;
|
||||
|
||||
hKey = GetAppKey(TRUE);
|
||||
if(hKey)
|
||||
RegSetValueEx(hKey, szKey, 0, REG_SZ, (LPBYTE)sz, sizeof(TCHAR) * (lstrlen(sz)+1));
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
|
||||
/*+ LoadWindowPos
|
||||
*
|
||||
* retrieve the window position information from dragn.ini
|
||||
*
|
||||
*-=================================================================*/
|
||||
|
||||
#ifndef SPI_GETWORKAREA
|
||||
#define SPI_GETWORKAREA 48 // because NT doesnt have this define yet
|
||||
#endif
|
||||
|
||||
BOOL
|
||||
LoadWindowPos(
|
||||
LPRECT lprc
|
||||
)
|
||||
{
|
||||
static RECT rcDefault = {0,0,CX_DEFAULT,CY_DEFAULT};
|
||||
RECT rcScreen;
|
||||
RECT rc;
|
||||
HKEY hKey = GetAppKey(FALSE);
|
||||
|
||||
// read window placement from the registry.
|
||||
//
|
||||
*lprc = rcDefault;
|
||||
|
||||
if(hKey)
|
||||
{
|
||||
DWORD cb;
|
||||
DWORD dwType;
|
||||
|
||||
cb = sizeof(rc);
|
||||
if(! RegQueryValueEx(hKey, cszWindow, NULL, &dwType, (LPBYTE)&rc, &cb)
|
||||
&& dwType == REG_BINARY && cb == sizeof(RECT))
|
||||
{
|
||||
*lprc = rc;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
// if we fail to get the working area (screen-tray), then assume
|
||||
// the screen is 640x480
|
||||
//
|
||||
if(! SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, FALSE))
|
||||
{
|
||||
rcScreen.top = rcScreen.left = 0;
|
||||
rcScreen.right = 640;
|
||||
rcScreen.bottom = 480;
|
||||
}
|
||||
|
||||
// if the proposed window position is outside the screen,
|
||||
// use the default placement
|
||||
//
|
||||
if(! IntersectRect(&rc, &rcScreen, lprc))
|
||||
{
|
||||
*lprc = rcDefault;
|
||||
}
|
||||
|
||||
return ! IsRectEmpty(lprc);
|
||||
}
|
||||
|
||||
|
||||
/*+ SaveWindowPos
|
||||
*
|
||||
* store the window position information in dragn.ini
|
||||
*
|
||||
*-=================================================================*/
|
||||
|
||||
BOOL
|
||||
SaveWindowPos(
|
||||
HWND hwnd
|
||||
)
|
||||
{
|
||||
WINDOWPLACEMENT wpl;
|
||||
HKEY hKey = GetAppKey(TRUE);
|
||||
|
||||
if(!hKey)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// save the current size and position of the window to the registry
|
||||
//
|
||||
ZeroMemory(&wpl, sizeof(wpl));
|
||||
wpl.length = sizeof(wpl);
|
||||
GetWindowPlacement(hwnd, &wpl);
|
||||
|
||||
RegSetValueEx(hKey, cszWindow, 0, REG_BINARY,
|
||||
(LPBYTE)&wpl.rcNormalPosition,
|
||||
sizeof(wpl.rcNormalPosition));
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*****************************Private*Routine******************************\
|
||||
* GetRecentFiles
|
||||
*
|
||||
* Reads at most MAX_RECENT_FILES from vcdplyer.ini. Returns the number
|
||||
* of files actually read. Updates the File menu to show the "recent" files.
|
||||
*
|
||||
\**************************************************************************/
|
||||
|
||||
int
|
||||
GetRecentFiles(
|
||||
int iLastCount
|
||||
)
|
||||
{
|
||||
int i;
|
||||
TCHAR FileName[MAX_PATH];
|
||||
TCHAR szKey[32];
|
||||
HMENU hSubMenu;
|
||||
|
||||
//
|
||||
// Delete the files from the menu
|
||||
//
|
||||
hSubMenu = GetSubMenu(GetMenu(hwndApp), 0);
|
||||
|
||||
// Delete the separator at slot 3 and all the other recent file entries
|
||||
if(iLastCount != 0)
|
||||
{
|
||||
DeleteMenu(hSubMenu, 3, MF_BYPOSITION);
|
||||
|
||||
for(i = 1; i <= iLastCount; i++)
|
||||
{
|
||||
DeleteMenu(hSubMenu, ID_RECENT_FILE_BASE + i, MF_BYCOMMAND);
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 1; i <= MAX_RECENT_FILES; i++)
|
||||
{
|
||||
DWORD len;
|
||||
TCHAR szMenuName[MAX_PATH + 3];
|
||||
|
||||
wsprintf(szKey, TEXT("File %d"), i);
|
||||
len = ProfileStringIn(szKey, TEXT(""), FileName, MAX_PATH * sizeof(TCHAR));
|
||||
if(len == 0)
|
||||
{
|
||||
i = i - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
lstrcpy(aRecentFiles[i - 1], FileName);
|
||||
wsprintf(szMenuName, TEXT("&%d %s"), i, FileName);
|
||||
|
||||
if(i == 1)
|
||||
{
|
||||
InsertMenu(hSubMenu, 3, MF_SEPARATOR | MF_BYPOSITION, (UINT)-1, NULL);
|
||||
}
|
||||
|
||||
InsertMenu(hSubMenu, 3 + i, MF_STRING | MF_BYPOSITION,
|
||||
ID_RECENT_FILE_BASE + i, szMenuName);
|
||||
}
|
||||
|
||||
//
|
||||
// i is the number of recent files in the array.
|
||||
//
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*****************************Private*Routine******************************\
|
||||
* SetRecentFiles
|
||||
*
|
||||
* Writes the most recent files to the vcdplyer.ini file. Purges the oldest
|
||||
* file if necessary.
|
||||
*
|
||||
\**************************************************************************/
|
||||
int
|
||||
SetRecentFiles(
|
||||
TCHAR *FileName, // File name to add
|
||||
int iCount // Current count of files
|
||||
)
|
||||
{
|
||||
TCHAR FullPathFileName[MAX_PATH];
|
||||
TCHAR *lpFile;
|
||||
TCHAR szKey[32];
|
||||
int iCountNew;
|
||||
int i;
|
||||
|
||||
//
|
||||
// Check for dupes - we don't allow them !
|
||||
//
|
||||
for(i = 0; i < iCount; i++)
|
||||
{
|
||||
if(0 == lstrcmpi(FileName, aRecentFiles[i]))
|
||||
{
|
||||
return iCount;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Throw away the oldest entry
|
||||
//
|
||||
MoveMemory(&aRecentFiles[1], &aRecentFiles[0],
|
||||
sizeof(aRecentFiles) - sizeof(aRecentFiles[1]));
|
||||
|
||||
//
|
||||
// Copy in the full path of the new file.
|
||||
//
|
||||
GetFullPathName(FileName, MAX_PATH, FullPathFileName, &lpFile);
|
||||
lstrcpy(aRecentFiles[0], FullPathFileName);
|
||||
|
||||
//
|
||||
// Update the count of files, saturate to MAX_RECENT_FILES.
|
||||
//
|
||||
iCountNew = min(iCount + 1, MAX_RECENT_FILES);
|
||||
|
||||
//
|
||||
// Clear the old stuff and the write out the recent files to disk
|
||||
//
|
||||
for(i = 1; i <= iCountNew; i++)
|
||||
{
|
||||
wsprintf(szKey, TEXT("File %d"), i);
|
||||
ProfileStringOut(szKey, aRecentFiles[i - 1]);
|
||||
}
|
||||
|
||||
//
|
||||
// Update the file menu
|
||||
//
|
||||
GetRecentFiles(iCount);
|
||||
|
||||
return iCountNew; // the updated count of files.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: project.h
|
||||
//
|
||||
// Desc: DirectShow sample code
|
||||
// - Master header file that includes all other header files used
|
||||
// by the project. This enables precompiled headers during build.
|
||||
//
|
||||
// Copyright (c) 1994 - 2001, Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <windows.h>
|
||||
#include <commdlg.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "vcdplyer.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
void InitStreamParams(int i);
|
||||
@@ -0,0 +1,29 @@
|
||||
Windows XP DirectShow Sample -- VMRPlayer
|
||||
-----------------------------------------
|
||||
|
||||
This sample demonstrates using the Video Mixing Renderer to blend
|
||||
one or two running videos and a static image.
|
||||
|
||||
Begin by opening a primary video stream from the File menu. If you
|
||||
would like to render a second file that will be alpha-blended with
|
||||
the primary file, then open a secondary video stream from the File menu.
|
||||
|
||||
To control size, position, and alpha blending properties of the
|
||||
primary or secondary video, choose "Primary Stream" or "Secondary Stream"
|
||||
from the VMR Properties menu. By default, the Primary stream will have
|
||||
an alpha value of 1.0 and the secondary stream will blend with an
|
||||
alpha value of 0.5. The properties dialogs are implemented as modal dialogs.
|
||||
|
||||
You may also overlay an alpha-blended static image by opening the
|
||||
"Static App Image" option on the VMR Properties menu. Enable the
|
||||
"Display App Image" checkbox to cause the image to appear. By default,
|
||||
the image will be centered and will blend with an alpha value of 0.5.
|
||||
|
||||
NOTE: This sample requires Windows XP (or greater) functionality
|
||||
and will exit on other systems.
|
||||
|
||||
Usage:
|
||||
VMRPlayer </P filename>
|
||||
|
||||
/P: Optional filename to automatically render and play at startup
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
// Copyright (c) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//
|
||||
// These are indexes used by the toolbar.
|
||||
//
|
||||
#define IDC_STATIC -1
|
||||
|
||||
#define IDX_SEPARATOR -1
|
||||
#define IDX_1 0
|
||||
#define IDX_2 1
|
||||
#define IDX_3 2
|
||||
#define IDX_4 3
|
||||
#define IDX_5 4
|
||||
#define IDX_6 5
|
||||
#define IDX_7 6
|
||||
#define IDX_8 7
|
||||
#define IDX_9 8
|
||||
#define IDX_10 9
|
||||
#define IDX_11 10
|
||||
#define IDX_12 11
|
||||
#define DEFAULT_TBAR_SIZE 10
|
||||
#define NUMBER_OF_BITMAPS 12
|
||||
|
||||
#define ID_STATUSBAR 28
|
||||
#define ID_TOOLBAR 29
|
||||
#define ID_TRACKBAR 30
|
||||
|
||||
#define IDR_MAIN_MENU 101
|
||||
#define IDR_TOOLBAR 102
|
||||
#define IDR_VIDEOCD_ICON 103
|
||||
#define IDR_ACCELERATOR 104
|
||||
#define IDR_VMR 105
|
||||
#define IDD_ABOUTBOX 200
|
||||
|
||||
#define IDC_XPOS_TRK 1000
|
||||
#define IDC_YPOS_TRK 1001
|
||||
#define IDC_XPOS 1002
|
||||
#define IDC_YPOS 1003
|
||||
#define IDC_XSIZE_TRK 1004
|
||||
#define IDC_YSIZE_TRK 1005
|
||||
#define IDC_XSIZE 1006
|
||||
#define IDC_YSIZE 1007
|
||||
#define IDC_IMAGE_ENABLE 1008
|
||||
#define IDC_ALPHA_TRK2 1009
|
||||
#define IDC_ALPHA 1010
|
||||
|
||||
#define IDM_FILE_OPEN 40001
|
||||
#define IDM_FILE_OPEN2 40005
|
||||
#define IDM_FILE_CLOSE 40002
|
||||
#define IDM_FILE_EXIT 40003
|
||||
|
||||
#define IDM_APP_IMAGE 42000
|
||||
#define IDM_STREAM_A 42001
|
||||
#define IDM_STREAM_B 42002
|
||||
#define IDM_CAPTURE_IMAGE 42003
|
||||
#define IDM_DISPLAY_CAPTURED_IMAGE 42004
|
||||
|
||||
#define IDM_HELP_ABOUT 40102
|
||||
|
||||
// Toolbar commands
|
||||
#define IDM_MOVIE_STOP 40010
|
||||
#define IDM_MOVIE_PLAY 40011
|
||||
#define IDM_MOVIE_PREVTRACK 40012
|
||||
#define IDM_MOVIE_PAUSE 40013
|
||||
#define IDM_MOVIE_SKIP_FORE 40014
|
||||
#define IDM_MOVIE_SKIP_BACK 40015
|
||||
#define IDM_MOVIE_STEP 40021
|
||||
|
||||
#define MENU_STRING_BASE 1000
|
||||
|
||||
// Different time formats
|
||||
#define IDM_TIME 40150
|
||||
#define IDM_FRAME 40151
|
||||
#define IDM_FIELD 40152
|
||||
#define IDM_SAMPLE 40153
|
||||
#define IDM_BYTES 40154
|
||||
|
||||
// File
|
||||
#define STR_FILE_OPEN IDM_FILE_OPEN + MENU_STRING_BASE
|
||||
#define STR_FILE_OPEN2 IDM_FILE_OPEN2 + MENU_STRING_BASE
|
||||
#define STR_FILE_CLOSE IDM_FILE_CLOSE + MENU_STRING_BASE
|
||||
#define STR_FILE_EXIT IDM_FILE_EXIT + MENU_STRING_BASE
|
||||
|
||||
// Properties Menu
|
||||
#define STR_APP_IMAGE IDM_APP_IMAGE + MENU_STRING_BASE
|
||||
#define STR_STREAM_A IDM_STREAM_A + MENU_STRING_BASE
|
||||
#define STR_STREAM_B IDM_STREAM_B + MENU_STRING_BASE
|
||||
#define STR_CAPTURE_IMAGE IDM_CAPTURE_IMAGE + MENU_STRING_BASE
|
||||
#define STR_DISPLAY_CAPTURED_IMAGE IDM_DISPLAY_CAPTURED_IMAGE + MENU_STRING_BASE
|
||||
|
||||
// Help Menu HELP_MENU_BASE
|
||||
#define STR_HELP_ABOUT IDM_HELP_ABOUT + MENU_STRING_BASE
|
||||
|
||||
// System Menu
|
||||
#define STR_SYSMENU_RESTORE 1800
|
||||
#define STR_SYSMENU_MOVE 1801
|
||||
#define STR_SYSMENU_MINIMIZE 1802
|
||||
#define STR_SYSMENU_CLOSE 1803
|
||||
#define STR_SYSMENU_MAXIMIZE 1804
|
||||
#define STR_SYSMENU_TASK_LIST 1805
|
||||
|
||||
#define STR_FILE_FILTER 2000
|
||||
#define STR_APP_TITLE 2001
|
||||
#define STR_APP_TITLE_LOADED 2002
|
||||
|
||||
#define IDD_AUDIOPROP 4000
|
||||
#define IDD_VIDEOPROP 4001
|
||||
|
||||
#define STR_MAX_STRING_LEN 256
|
||||
@@ -0,0 +1,31 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by vcdplyer.rc
|
||||
//
|
||||
#define ID_BUTTON40001 40001
|
||||
#define ID_BUTTON40002 40002
|
||||
#define ID_BUTTON40003 40003
|
||||
#define ID_BUTTON40004 40004
|
||||
#define ID_BUTTON40005 40005
|
||||
#define ID_BUTTON40006 40006
|
||||
#define ID_BUTTON40007 40007
|
||||
#define ID_BUTTON40008 40008
|
||||
#define ID_BUTTON40009 40009
|
||||
#define ID_BUTTON40010 40010
|
||||
#define ID_BUTTON40011 40011
|
||||
#define ID_BUTTON40012 40012
|
||||
#define ID_BUTTON40013 40013
|
||||
#define ID_BUTTON40014 40014
|
||||
#define ID_BUTTON40016 40016
|
||||
#define ID_BUTTON40017 40017
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40019
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,978 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: vcdplyer.cpp
|
||||
//
|
||||
// Desc: DirectShow sample code
|
||||
// - A VMR-enabled player application
|
||||
//
|
||||
// Copyright (c) 1994 - 2001, Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <streams.h>
|
||||
#include <mmreg.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <atlbase.h>
|
||||
|
||||
#include "project.h"
|
||||
|
||||
#include <initguid.h>
|
||||
|
||||
extern int FrameStepCount;
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* CMpegMovie
|
||||
*
|
||||
* Constructors and destructors
|
||||
*
|
||||
\**************************************************************************/
|
||||
CMpegMovie::CMpegMovie(HWND hwndApplication) :
|
||||
m_hwndApp(hwndApplication),
|
||||
m_MediaEvent(NULL),
|
||||
m_Mode(MOVIE_NOTOPENED),
|
||||
m_Fg(NULL),
|
||||
m_Gb(NULL),
|
||||
m_Mc(NULL),
|
||||
m_Ms(NULL),
|
||||
m_Me(NULL),
|
||||
m_Wc(NULL),
|
||||
m_pMixControl(NULL),
|
||||
m_TimeFormat(TIME_FORMAT_MEDIA_TIME)
|
||||
{
|
||||
}
|
||||
CMpegMovie::~CMpegMovie()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* SetRenderingMode
|
||||
*
|
||||
\**************************************************************************/
|
||||
static HRESULT SetRenderingMode( IBaseFilter* pBaseFilter, VMRMode mode )
|
||||
{
|
||||
// Test VMRConfig, VMRMonitorConfig
|
||||
IVMRFilterConfig* pConfig;
|
||||
|
||||
HRESULT hr = pBaseFilter->QueryInterface(IID_IVMRFilterConfig, (LPVOID *)&pConfig);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
hr = pConfig->SetRenderingMode(mode);
|
||||
hr = pConfig->SetRenderingPrefs(RenderPrefs_ForceOverlays|RenderPrefs_AllowOverlays);
|
||||
pConfig->Release();
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* AddVideoMixingRendererToFG
|
||||
*
|
||||
\**************************************************************************/
|
||||
HRESULT
|
||||
CMpegMovie::AddVideoMixingRendererToFG()
|
||||
{
|
||||
IBaseFilter* pBF = NULL;
|
||||
HRESULT hRes = CoCreateInstance(CLSID_VideoMixingRenderer,
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
IID_IBaseFilter,
|
||||
(LPVOID *)&pBF);
|
||||
|
||||
if(SUCCEEDED(hRes))
|
||||
{
|
||||
hRes = m_Fg->AddFilter(pBF, L"Video Mixing Renderer");
|
||||
|
||||
if(SUCCEEDED(hRes))
|
||||
{
|
||||
// Test VMRConfig, VMRMonitorConfig
|
||||
IVMRFilterConfig* pConfig;
|
||||
HRESULT hRes2 = pBF->QueryInterface(IID_IVMRFilterConfig, (LPVOID *)&pConfig);
|
||||
if(SUCCEEDED(hRes2))
|
||||
{
|
||||
hRes2 = pConfig->SetNumberOfStreams(2);
|
||||
hRes2 = pConfig->SetRenderingMode(VMRMode_Windowless);
|
||||
hRes2 = pConfig->SetRenderingPrefs(RenderPrefs_AllowOverlays);
|
||||
// RenderPrefs_ForceOverlays);
|
||||
// RenderPrefs_ForceOffscreen);
|
||||
// RenderPrefs_DoNotRenderColorKeyAndBorder);
|
||||
pConfig->Release();
|
||||
}
|
||||
|
||||
IVMRMonitorConfig* pMonitorConfig;
|
||||
HRESULT hRes3 = pBF->QueryInterface(IID_IVMRMonitorConfig, (LPVOID *)&pMonitorConfig);
|
||||
if(SUCCEEDED(hRes3))
|
||||
{
|
||||
// STDMETHODIMP SetMonitor( const VMRGUID *pGUID );
|
||||
// STDMETHODIMP GetMonitor( VMRGUID *pGUID );
|
||||
// STDMETHODIMP SetDefaultMonitor( const VMRGUID *pGUID );
|
||||
// STDMETHODIMP GetDefaultMonitor( VMRGUID *pGUID );
|
||||
// STDMETHODIMP GetAvailableMonitors( VMRMONITORINFO* pInfo, DWORD dwMaxInfoArraySize, DWORD* pdwNumDevices );
|
||||
VMRGUID guid;
|
||||
HRESULT hr4 = pMonitorConfig->GetMonitor(&guid);
|
||||
pMonitorConfig->Release();
|
||||
}
|
||||
|
||||
hRes = pBF->QueryInterface(IID_IVMRWindowlessControl, (LPVOID *)&m_Wc);
|
||||
}
|
||||
}
|
||||
|
||||
if(pBF)
|
||||
{
|
||||
pBF->Release();
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hRes))
|
||||
{
|
||||
HRESULT hr = m_Wc->SetVideoClippingWindow(m_hwndApp);
|
||||
hr = m_Wc->SetAspectRatioMode(VMR_ARMODE_LETTER_BOX);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_Wc)
|
||||
{
|
||||
m_Wc->Release();
|
||||
m_Wc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return hRes;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* RenderSecondFile
|
||||
*
|
||||
\**************************************************************************/
|
||||
HRESULT
|
||||
CMpegMovie::RenderSecondFile(
|
||||
TCHAR* lpFileName
|
||||
)
|
||||
{
|
||||
USES_CONVERSION;
|
||||
HRESULT hRes;
|
||||
WCHAR FileName[MAX_PATH];
|
||||
|
||||
// Since the user might have already rendered the second file,
|
||||
// free it if it has been rendered
|
||||
if (m_Gb)
|
||||
{
|
||||
m_Gb->Release();
|
||||
m_Gb = NULL;
|
||||
|
||||
hRes = m_Fg->QueryInterface(IID_IGraphBuilder, (LPVOID *)&m_Gb);
|
||||
if(FAILED(hRes))
|
||||
{
|
||||
MessageBeep(0);
|
||||
return hRes;
|
||||
}
|
||||
}
|
||||
|
||||
wcscpy(FileName, T2W(lpFileName));
|
||||
|
||||
hRes = m_Gb->RenderFile(FileName, NULL);
|
||||
if(SUCCEEDED(hRes) && m_pMixControl)
|
||||
{
|
||||
hRes = m_pMixControl->SetAlpha(1, 0.5f);
|
||||
g_bSecondFileLoaded = TRUE;
|
||||
}
|
||||
|
||||
return hRes;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* OpenMovie
|
||||
*
|
||||
\**************************************************************************/
|
||||
HRESULT
|
||||
CMpegMovie::OpenMovie(
|
||||
TCHAR *lpFileName
|
||||
)
|
||||
{
|
||||
USES_CONVERSION;
|
||||
IUnknown *pUnk;
|
||||
HRESULT hres;
|
||||
WCHAR FileName[MAX_PATH];
|
||||
|
||||
wcscpy(FileName, T2W(lpFileName));
|
||||
|
||||
hres = CoInitialize(NULL);
|
||||
if(hres == S_FALSE)
|
||||
CoUninitialize();
|
||||
|
||||
hres = CoCreateInstance(
|
||||
CLSID_FilterGraph,
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
IID_IUnknown,
|
||||
(LPVOID *)&pUnk);
|
||||
|
||||
if(SUCCEEDED(hres))
|
||||
{
|
||||
m_Mode = MOVIE_OPENED;
|
||||
hres = pUnk->QueryInterface(IID_IFilterGraph, (LPVOID *)&m_Fg);
|
||||
if(FAILED(hres))
|
||||
{
|
||||
pUnk->Release();
|
||||
return hres;
|
||||
}
|
||||
|
||||
hres = AddVideoMixingRendererToFG();
|
||||
if(FAILED(hres))
|
||||
{
|
||||
m_Fg->Release(); m_Fg = NULL;
|
||||
return hres;
|
||||
}
|
||||
|
||||
hres = pUnk->QueryInterface(IID_IGraphBuilder, (LPVOID *)&m_Gb);
|
||||
if(FAILED(hres))
|
||||
{
|
||||
pUnk->Release();
|
||||
m_Fg->Release(); m_Fg = NULL;
|
||||
m_Wc->Release(); m_Wc = NULL;
|
||||
return hres;
|
||||
}
|
||||
|
||||
hres = m_Gb->RenderFile(FileName, NULL);
|
||||
if(FAILED(hres))
|
||||
{
|
||||
pUnk->Release();
|
||||
m_Fg->Release(); m_Fg = NULL;
|
||||
m_Wc->Release(); m_Wc = NULL;
|
||||
m_Gb->Release(); m_Gb = NULL;
|
||||
return hres;
|
||||
}
|
||||
|
||||
hres = m_Wc->QueryInterface(IID_IVMRMixerControl, (LPVOID *) &m_pMixControl);
|
||||
if(FAILED(hres))
|
||||
{
|
||||
pUnk->Release();
|
||||
m_Fg->Release(); m_Fg = NULL;
|
||||
m_Wc->Release(); m_Wc = NULL;
|
||||
m_Gb->Release(); m_Gb = NULL;
|
||||
m_pMixControl = NULL;
|
||||
return hres;
|
||||
}
|
||||
|
||||
hres = pUnk->QueryInterface(IID_IMediaControl, (LPVOID *)&m_Mc);
|
||||
if(FAILED(hres))
|
||||
{
|
||||
pUnk->Release();
|
||||
m_Fg->Release(); m_Fg = NULL;
|
||||
m_Wc->Release(); m_Wc = NULL;
|
||||
m_Gb->Release(); m_Gb = NULL;
|
||||
return hres;
|
||||
}
|
||||
|
||||
//
|
||||
// Not being able to get the IMediaEvent interface doesn't
|
||||
// necessarly mean that we can't play the graph.
|
||||
//
|
||||
pUnk->QueryInterface(IID_IMediaEvent, (LPVOID *)&m_Me);
|
||||
GetMovieEventHandle();
|
||||
|
||||
pUnk->QueryInterface(IID_IMediaSeeking, (LPVOID *)&m_Ms);
|
||||
pUnk->Release();
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Fg = NULL;
|
||||
}
|
||||
|
||||
return hres;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* CloseMovie
|
||||
*
|
||||
\**************************************************************************/
|
||||
DWORD
|
||||
CMpegMovie::CloseMovie(
|
||||
)
|
||||
{
|
||||
m_Mode = MOVIE_NOTOPENED;
|
||||
|
||||
if(m_Mc)
|
||||
{
|
||||
if(m_Me)
|
||||
{
|
||||
m_MediaEvent = NULL;
|
||||
m_Me->Release();
|
||||
m_Me = NULL;
|
||||
}
|
||||
|
||||
if(m_pMixControl)
|
||||
{
|
||||
m_pMixControl->Release();
|
||||
m_pMixControl = NULL;
|
||||
}
|
||||
|
||||
if(m_Ms)
|
||||
{
|
||||
m_Ms->Release();
|
||||
m_Ms = NULL;
|
||||
}
|
||||
|
||||
if(m_Wc)
|
||||
{
|
||||
m_Wc->Release();
|
||||
m_Wc = NULL;
|
||||
}
|
||||
|
||||
m_Mc->Release();
|
||||
m_Mc = NULL;
|
||||
|
||||
if(m_Gb)
|
||||
{
|
||||
m_Gb->Release();
|
||||
m_Gb = NULL;
|
||||
}
|
||||
|
||||
if(m_Fg)
|
||||
{
|
||||
m_Fg->Release();
|
||||
m_Fg = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
QzUninitialize();
|
||||
return 0L;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* CMpegMovie::GetNativeMovieSize
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::GetNativeMovieSize(
|
||||
LONG *pcx,
|
||||
LONG *pcy
|
||||
)
|
||||
{
|
||||
BOOL bRet = FALSE;
|
||||
if(m_Wc)
|
||||
{
|
||||
bRet = (m_Wc->GetNativeVideoSize(pcx, pcy, NULL, NULL) == S_OK);
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* GetMoviePosition
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::GetMoviePosition(
|
||||
LONG *px,
|
||||
LONG *py,
|
||||
LONG *pcx,
|
||||
LONG *pcy
|
||||
)
|
||||
{
|
||||
BOOL bRet = FALSE;
|
||||
|
||||
if(m_Wc)
|
||||
{
|
||||
RECT src={0}, dest={0};
|
||||
HRESULT hr = m_Wc->GetVideoPosition(&src, &dest);
|
||||
*px = dest.left;
|
||||
*py = dest.right;
|
||||
*pcx = dest.right - dest.left;
|
||||
*pcy = dest.bottom - dest.top;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* PutMoviePosition
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::PutMoviePosition(
|
||||
LONG x,
|
||||
LONG y,
|
||||
LONG cx,
|
||||
LONG cy
|
||||
)
|
||||
{
|
||||
BOOL bRet = FALSE;
|
||||
|
||||
RECT rc;
|
||||
SetRect(&rc, x, y, x + cx, y + cy);
|
||||
if(m_Wc)
|
||||
{
|
||||
bRet = (m_Wc->SetVideoPosition(NULL, &rc) == S_OK);
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* PlayMovie
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::PlayMovie(
|
||||
)
|
||||
{
|
||||
REFTIME rt, rtAbs, rtDur;
|
||||
HRESULT hr=S_OK;
|
||||
|
||||
rt = GetCurrentPosition();
|
||||
rtDur = GetDuration();
|
||||
|
||||
//
|
||||
// If we are near the end of the movie seek to the start, otherwise
|
||||
// stay where we are.
|
||||
//
|
||||
rtAbs = rt - rtDur;
|
||||
if(rtAbs < (REFTIME)0)
|
||||
{
|
||||
rtAbs = -rtAbs;
|
||||
}
|
||||
|
||||
if(rtAbs < (REFTIME)1)
|
||||
{
|
||||
SeekToPosition((REFTIME)0,FALSE);
|
||||
}
|
||||
|
||||
//
|
||||
// Change mode after setting m_Mode but before starting the graph
|
||||
//
|
||||
m_Mode = MOVIE_PLAYING;
|
||||
hr = m_Mc->Run();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* PauseMovie
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::PauseMovie(
|
||||
)
|
||||
{
|
||||
m_Mode = MOVIE_PAUSED;
|
||||
|
||||
HRESULT hr = m_Mc->Pause();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* GetStateMovie
|
||||
*
|
||||
\**************************************************************************/
|
||||
|
||||
OAFilterState
|
||||
CMpegMovie::GetStateMovie(
|
||||
)
|
||||
{
|
||||
OAFilterState State;
|
||||
|
||||
HRESULT hr = m_Mc->GetState(INFINITE,&State);
|
||||
return State;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* StopMovie
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::StopMovie(
|
||||
)
|
||||
{
|
||||
m_Mode = MOVIE_STOPPED;
|
||||
HRESULT hr = m_Mc->Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* StatusMovie
|
||||
*
|
||||
\**************************************************************************/
|
||||
EMpegMovieMode
|
||||
CMpegMovie::StatusMovie(
|
||||
)
|
||||
{
|
||||
if(m_Mc)
|
||||
{
|
||||
FILTER_STATE fs;
|
||||
HRESULT hr;
|
||||
|
||||
hr = m_Mc->GetState(100, (OAFilterState *)&fs);
|
||||
|
||||
// Don't know what the state is so just stay at old state.
|
||||
if(hr == VFW_S_STATE_INTERMEDIATE)
|
||||
{
|
||||
return m_Mode;
|
||||
}
|
||||
|
||||
switch(fs)
|
||||
{
|
||||
case State_Stopped:
|
||||
m_Mode = MOVIE_STOPPED;
|
||||
break;
|
||||
|
||||
case State_Paused:
|
||||
m_Mode = MOVIE_PAUSED;
|
||||
break;
|
||||
|
||||
case State_Running:
|
||||
m_Mode = MOVIE_PLAYING;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return m_Mode;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* CanMovieFrameStep
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::CanMovieFrameStep()
|
||||
{
|
||||
IVideoFrameStep* lpFS;
|
||||
HRESULT hr;
|
||||
|
||||
hr = m_Fg->QueryInterface(__uuidof(IVideoFrameStep), (LPVOID *)&lpFS);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
hr = lpFS->CanStep(0L, NULL);
|
||||
lpFS->Release();
|
||||
}
|
||||
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* FrameStepMovie
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::FrameStepMovie()
|
||||
{
|
||||
IVideoFrameStep* lpFS;
|
||||
HRESULT hr;
|
||||
|
||||
hr = m_Fg->QueryInterface(__uuidof(IVideoFrameStep), (LPVOID *)&lpFS);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
FrameStepCount++;
|
||||
|
||||
hr = lpFS->Step(1, NULL);
|
||||
lpFS->Release();
|
||||
}
|
||||
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* GetMediaEventHandle
|
||||
*
|
||||
* Returns the IMediaEvent event hamdle for the filter graph iff the
|
||||
* filter graph exists.
|
||||
*
|
||||
\**************************************************************************/
|
||||
HANDLE
|
||||
CMpegMovie::GetMovieEventHandle(
|
||||
)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if(m_Me != NULL)
|
||||
{
|
||||
if(m_MediaEvent == NULL)
|
||||
{
|
||||
hr = m_Me->GetEventHandle((OAEVENT *)&m_MediaEvent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MediaEvent = NULL;
|
||||
}
|
||||
|
||||
return m_MediaEvent;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* GetMovieEventCode
|
||||
*
|
||||
\**************************************************************************/
|
||||
long
|
||||
CMpegMovie::GetMovieEventCode()
|
||||
{
|
||||
HRESULT hr;
|
||||
long lEventCode;
|
||||
LONG_PTR lParam1, lParam2;
|
||||
|
||||
if(m_Me != NULL)
|
||||
{
|
||||
hr = m_Me->GetEvent(&lEventCode, &lParam1, &lParam2, 0);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
hr = m_Me->FreeEventParams(lEventCode, lParam1, lParam2);
|
||||
return lEventCode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* GetDuration
|
||||
*
|
||||
* Returns the duration of the current movie
|
||||
*
|
||||
\**************************************************************************/
|
||||
REFTIME
|
||||
CMpegMovie::GetDuration()
|
||||
{
|
||||
HRESULT hr;
|
||||
LONGLONG Duration;
|
||||
|
||||
// Should we seek using IMediaSelection
|
||||
if(m_TimeFormat != TIME_FORMAT_MEDIA_TIME)
|
||||
{
|
||||
hr = m_Ms->GetDuration(&Duration);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
return double(Duration);
|
||||
}
|
||||
}
|
||||
else if(m_Ms != NULL)
|
||||
{
|
||||
hr = m_Ms->GetDuration(&Duration);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
return double(Duration) / UNITS;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* GetCurrentPosition
|
||||
*
|
||||
* Returns the duration of the current movie
|
||||
*
|
||||
\**************************************************************************/
|
||||
REFTIME
|
||||
CMpegMovie::GetCurrentPosition()
|
||||
{
|
||||
REFTIME rt = (REFTIME)0;
|
||||
HRESULT hr;
|
||||
LONGLONG Position;
|
||||
|
||||
// Should we return a media position
|
||||
if(m_TimeFormat != TIME_FORMAT_MEDIA_TIME)
|
||||
{
|
||||
hr = m_Ms->GetPositions(&Position, NULL);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
return double(Position);
|
||||
}
|
||||
}
|
||||
else if(m_Ms != NULL)
|
||||
{
|
||||
hr = m_Ms->GetPositions(&Position, NULL);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
return double(Position) / UNITS;
|
||||
}
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
||||
/*****************************Private*Routine******************************\
|
||||
* SeekToPosition
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::SeekToPosition(
|
||||
REFTIME rt,
|
||||
BOOL bFlushData
|
||||
)
|
||||
{
|
||||
HRESULT hr;
|
||||
LONGLONG llTime = LONGLONG(m_TimeFormat == TIME_FORMAT_MEDIA_TIME ? rt * double(UNITS) : rt );
|
||||
|
||||
if(m_Ms != NULL)
|
||||
{
|
||||
FILTER_STATE fs;
|
||||
hr = m_Mc->GetState(100, (OAFilterState *)&fs);
|
||||
|
||||
hr = m_Ms->SetPositions(&llTime, AM_SEEKING_AbsolutePositioning, NULL, 0);
|
||||
|
||||
// This gets new data through to the renderers
|
||||
if(fs == State_Stopped && bFlushData)
|
||||
{
|
||||
hr = m_Mc->Pause();
|
||||
hr = m_Mc->GetState(INFINITE, (OAFilterState *)&fs);
|
||||
hr = m_Mc->Stop();
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*****************************Public*Routine******************************\
|
||||
* FindInterfaceFromFilterGraph
|
||||
*
|
||||
\**************************************************************************/
|
||||
HRESULT
|
||||
CMpegMovie::FindInterfaceFromFilterGraph(
|
||||
REFIID iid, // interface to look for
|
||||
LPVOID *lp // place to return interface pointer in
|
||||
)
|
||||
{
|
||||
IEnumFilters* pEF;
|
||||
IBaseFilter* pFilter;
|
||||
|
||||
// Grab an enumerator for the filter graph.
|
||||
HRESULT hr = m_Fg->EnumFilters(&pEF);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Check out each filter.
|
||||
while(pEF->Next(1, &pFilter, NULL) == S_OK)
|
||||
{
|
||||
hr = pFilter->QueryInterface(iid, lp);
|
||||
pFilter->Release();
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pEF->Release();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
/*****************************Public*Routine******************************\
|
||||
* IsTimeFormatSupported
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::IsTimeFormatSupported(GUID Format)
|
||||
{
|
||||
return m_Ms != NULL && m_Ms->IsFormatSupported(&Format) == S_OK;
|
||||
}
|
||||
|
||||
|
||||
/*****************************Public*Routine******************************\
|
||||
* IsTimeSupported
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::IsTimeSupported()
|
||||
{
|
||||
return m_Ms != NULL && m_Ms->IsFormatSupported(&TIME_FORMAT_MEDIA_TIME) == S_OK;
|
||||
}
|
||||
|
||||
|
||||
/*****************************Public*Routine******************************\
|
||||
* GetTimeFormat
|
||||
*
|
||||
\**************************************************************************/
|
||||
GUID
|
||||
CMpegMovie::GetTimeFormat()
|
||||
{
|
||||
return m_TimeFormat;
|
||||
}
|
||||
|
||||
/*****************************Public*Routine******************************\
|
||||
* SetTimeFormat
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::SetTimeFormat(GUID Format)
|
||||
{
|
||||
HRESULT hr = m_Ms->SetTimeFormat(&Format);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
m_TimeFormat = Format;
|
||||
}
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* SetFocus
|
||||
*
|
||||
\**************************************************************************/
|
||||
void
|
||||
CMpegMovie::SetFocus()
|
||||
{
|
||||
if(m_Fg)
|
||||
{
|
||||
// Tell the resource manager that we are being made active. This
|
||||
// will then cause the sound to switch to us. This is especially
|
||||
// important when playing audio only files as there is no other
|
||||
// playback window.
|
||||
IResourceManager* pResourceManager;
|
||||
|
||||
HRESULT hr = m_Fg->QueryInterface(IID_IResourceManager, (void**)&pResourceManager);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
IUnknown* pUnknown;
|
||||
|
||||
hr = m_Fg->QueryInterface(IID_IUnknown, (void**)&pUnknown);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
hr = pResourceManager->SetFocus(pUnknown);
|
||||
pUnknown->Release();
|
||||
}
|
||||
|
||||
pResourceManager->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* RepaintVideo
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::RepaintVideo(
|
||||
HWND hwnd,
|
||||
HDC hdc
|
||||
)
|
||||
{
|
||||
BOOL bRet = FALSE;
|
||||
|
||||
if(m_Wc)
|
||||
{
|
||||
bRet = (m_Wc->RepaintVideo(hwnd, hdc) == S_OK);
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* SetAppImage
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::SetAppImage(
|
||||
VMRALPHABITMAP* lpBmpInfo
|
||||
)
|
||||
{
|
||||
IVMRMixerBitmap* pBmp;
|
||||
HRESULT hres = m_Wc->QueryInterface(IID_IVMRMixerBitmap, (LPVOID *)&pBmp);
|
||||
if(SUCCEEDED(hres))
|
||||
{
|
||||
hres = pBmp->SetAlphaBitmap(lpBmpInfo);
|
||||
pBmp->Release();
|
||||
}
|
||||
|
||||
return hres;
|
||||
}
|
||||
|
||||
|
||||
/******************************Public*Routine******************************\
|
||||
* UpdateAppImage
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL
|
||||
CMpegMovie::UpdateAppImage(VMRALPHABITMAP* lpBmpInfo)
|
||||
{
|
||||
IVMRMixerBitmap* pBmp;
|
||||
|
||||
if (!m_Wc)
|
||||
return FALSE;
|
||||
|
||||
HRESULT hres = m_Wc->QueryInterface(IID_IVMRMixerBitmap, (LPVOID *)&pBmp);
|
||||
if(SUCCEEDED(hres))
|
||||
{
|
||||
hres = pBmp->UpdateAlphaBitmapParameters(lpBmpInfo);
|
||||
pBmp->Release();
|
||||
}
|
||||
|
||||
return hres;
|
||||
}
|
||||
|
||||
|
||||
/*****************************Private*Routine******************************\
|
||||
* SetBorderClr
|
||||
*
|
||||
\**************************************************************************/
|
||||
void
|
||||
CMpegMovie::SetBorderClr(COLORREF clr)
|
||||
{
|
||||
m_Wc->SetBorderColor(clr);
|
||||
}
|
||||
|
||||
|
||||
/*****************************Private*Routine******************************\
|
||||
* VerifyVMR
|
||||
*
|
||||
\**************************************************************************/
|
||||
BOOL VerifyVMR(void)
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
// Verify that the VMR exists on this system
|
||||
IBaseFilter* pBF = NULL;
|
||||
hres = CoCreateInstance(CLSID_VideoMixingRenderer,
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
IID_IBaseFilter,
|
||||
(LPVOID *)&pBF);
|
||||
|
||||
if(SUCCEEDED(hres))
|
||||
{
|
||||
pBF->Release();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(hwndApp,
|
||||
TEXT("This application requires the Video Mixing Renderer, which is present\r\n")
|
||||
TEXT("only on Windows XP.\r\n\r\n")
|
||||
TEXT("The Video Mixing Renderer (VMR) is also not enabled when viewing a \r\n")
|
||||
TEXT("remote Windows XP machine through a Remote Desktop session.\r\n")
|
||||
TEXT("You can run VMR-enabled applications only on your local machine.")
|
||||
TEXT("\r\n\r\nThis sample will now exit."),
|
||||
TEXT("Video Mixing Renderer capabilities are required"), MB_OK);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: vcdplyer.h
|
||||
//
|
||||
// Desc: DirectShow sample code
|
||||
// - Class header file for VMRPlayer sample
|
||||
//
|
||||
// Copyright (c) 1994 - 2001, Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
** CMpegMovie - an Mpeg movie playback class.
|
||||
** -------------------------------------------------------------------------
|
||||
*/
|
||||
enum EMpegMovieMode { MOVIE_NOTOPENED = 0x00,
|
||||
MOVIE_OPENED = 0x01,
|
||||
MOVIE_PLAYING = 0x02,
|
||||
MOVIE_STOPPED = 0x03,
|
||||
MOVIE_PAUSED = 0x04 };
|
||||
|
||||
BOOL VerifyVMR(void);
|
||||
|
||||
struct IMpegAudioDecoder;
|
||||
struct IMpegVideoDecoder;
|
||||
struct IQualProp;
|
||||
|
||||
class CMpegMovie
|
||||
{
|
||||
private:
|
||||
// Our state variable - records whether we are opened, playing etc.
|
||||
EMpegMovieMode m_Mode;
|
||||
HANDLE m_MediaEvent;
|
||||
HWND m_hwndApp;
|
||||
GUID m_TimeFormat;
|
||||
|
||||
IFilterGraph *m_Fg;
|
||||
IGraphBuilder *m_Gb;
|
||||
IMediaControl *m_Mc;
|
||||
IMediaSeeking *m_Ms;
|
||||
IMediaEvent *m_Me;
|
||||
IVMRWindowlessControl *m_Wc;
|
||||
|
||||
HRESULT AddVideoMixingRendererToFG();
|
||||
HRESULT AddBallToFG();
|
||||
void GetPerformanceInterfaces();
|
||||
HRESULT FindInterfaceFromFilterGraph(
|
||||
REFIID iid, // interface to look for
|
||||
LPVOID *lp // place to return interface pointer in
|
||||
);
|
||||
|
||||
public:
|
||||
CMpegMovie(HWND hwndApplication);
|
||||
~CMpegMovie();
|
||||
|
||||
HRESULT OpenMovie(TCHAR *lpFileName);
|
||||
DWORD CloseMovie();
|
||||
BOOL PlayMovie();
|
||||
BOOL PauseMovie();
|
||||
BOOL StopMovie();
|
||||
OAFilterState GetStateMovie();
|
||||
HANDLE GetMovieEventHandle();
|
||||
long GetMovieEventCode();
|
||||
BOOL PutMoviePosition(LONG x, LONG y, LONG cx, LONG cy);
|
||||
BOOL GetMoviePosition(LONG *x, LONG *y, LONG *cx, LONG *cy);
|
||||
BOOL GetNativeMovieSize(LONG *cx, LONG *cy);
|
||||
BOOL CanMovieFrameStep();
|
||||
BOOL FrameStepMovie();
|
||||
REFTIME GetDuration();
|
||||
REFTIME GetCurrentPosition();
|
||||
BOOL SeekToPosition(REFTIME rt,BOOL bFlushData);
|
||||
EMpegMovieMode StatusMovie();
|
||||
BOOL IsTimeFormatSupported(GUID Format);
|
||||
BOOL IsTimeSupported();
|
||||
BOOL SetTimeFormat(GUID Format);
|
||||
GUID GetTimeFormat();
|
||||
void SetFocus();
|
||||
BOOL ConfigDialog(HWND hwnd);
|
||||
BOOL RepaintVideo(HWND hwnd, HDC hdc);
|
||||
BOOL SetAppImage(VMRALPHABITMAP* lpBmpInfo);
|
||||
BOOL UpdateAppImage(VMRALPHABITMAP* lpBmpInfo);
|
||||
void SetBorderClr(COLORREF clr);
|
||||
|
||||
void DisplayModeChanged() {
|
||||
m_Wc->DisplayModeChanged();
|
||||
}
|
||||
|
||||
HRESULT GetCurrentImage(LPBYTE* lplpDib)
|
||||
{
|
||||
return m_Wc->GetCurrentImage(lplpDib);
|
||||
}
|
||||
|
||||
HRESULT RenderSecondFile(TCHAR *lpFileName);
|
||||
|
||||
IVMRMixerControl *m_pMixControl;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resrc1.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "resource.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDR_TOOLBAR BITMAP DISCARDABLE "toolbar.bmp"
|
||||
IDR_VMR BITMAP DISCARDABLE "vmr.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDR_VIDEOCD_ICON ICON DISCARDABLE "perftool.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAIN_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Open Primary Stream...", IDM_FILE_OPEN
|
||||
MENUITEM "Open &Second Stream...", IDM_FILE_OPEN2, GRAYED
|
||||
MENUITEM "&Close", IDM_FILE_CLOSE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", IDM_FILE_EXIT
|
||||
END
|
||||
POPUP "&VMR Properties"
|
||||
BEGIN
|
||||
MENUITEM "Static App &Image...", IDM_APP_IMAGE
|
||||
MENUITEM "&Primary Stream...", IDM_STREAM_A
|
||||
MENUITEM "&Secondary Stream...", IDM_STREAM_B
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Capture Bitmap Image", IDM_CAPTURE_IMAGE
|
||||
MENUITEM "&Display Captured Image", IDM_DISPLAY_CAPTURED_IMAGE
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About DirectShow VMRPlayer Sample...", IDM_HELP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_AUDIOPROP DIALOG DISCARDABLE 0, 0, 218, 177
|
||||
STYLE DS_MODALFRAME | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "App Image Control"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
CONTROL "Slider1",IDC_XPOS_TRK,"msctls_trackbar32",TBS_TOP |
|
||||
TBS_NOTICKS | WS_TABSTOP,48,24,155,15
|
||||
CONTROL "Slider2",IDC_YPOS_TRK,"msctls_trackbar32",TBS_TOP |
|
||||
TBS_NOTICKS | WS_TABSTOP,48,44,155,15
|
||||
CONTROL "Slider1",IDC_XSIZE_TRK,"msctls_trackbar32",TBS_TOP |
|
||||
TBS_NOTICKS | WS_TABSTOP,48,81,155,15
|
||||
CONTROL "Slider2",IDC_YSIZE_TRK,"msctls_trackbar32",TBS_TOP |
|
||||
TBS_NOTICKS | WS_TABSTOP,48,101,155,15
|
||||
CONTROL "Slider2",IDC_ALPHA_TRK2,"msctls_trackbar32",TBS_TOP |
|
||||
TBS_NOTICKS | WS_TABSTOP,48,133,155,15
|
||||
CONTROL "Display App Image",IDC_IMAGE_ENABLE,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,13,157,72,10
|
||||
DEFPUSHBUTTON "Close",IDOK,161,154,50,14
|
||||
LTEXT "X = ",IDC_STATIC,10,24,14,8
|
||||
LTEXT "Y =",IDC_STATIC,11,43,13,8
|
||||
GROUPBOX "Position",IDC_STATIC,7,7,204,57
|
||||
LTEXT "0.000",IDC_XPOS,24,24,21,8
|
||||
LTEXT "0.000",IDC_YPOS,24,43,23,8
|
||||
LTEXT "X = ",IDC_STATIC,10,81,14,8
|
||||
LTEXT "Y =",IDC_STATIC,11,100,13,8
|
||||
GROUPBOX "Size",IDC_STATIC,7,64,204,57
|
||||
LTEXT "0.000",IDC_XSIZE,24,81,21,8
|
||||
LTEXT "0.000",IDC_YSIZE,25,100,23,8
|
||||
GROUPBOX "Alpha",IDC_STATIC,7,122,204,29
|
||||
LTEXT "A =",IDC_STATIC,11,132,13,8
|
||||
LTEXT "0.000",IDC_ALPHA,25,132,23,8
|
||||
END
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About VMRPlayer"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
ICON IDR_VIDEOCD_ICON,-1,11,17,20,20
|
||||
LTEXT "DirectShow VMRPlayer Sample",-1,40,10,131,8,SS_NOPREFIX
|
||||
LTEXT "Copyright (C) 1999-2001 Microsoft Corporation",-1,40,34,
|
||||
188,8
|
||||
DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP
|
||||
LTEXT "Version 8.1",-1,40,22,119,8,SS_NOPREFIX
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_ACCELERATOR ACCELERATORS DISCARDABLE
|
||||
BEGIN
|
||||
"S", IDM_MOVIE_STOP, VIRTKEY, CONTROL, NOINVERT
|
||||
"P", IDM_MOVIE_PLAY, VIRTKEY, CONTROL, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resrc1.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""windows.h""\r\n"
|
||||
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""resource.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_AUDIOPROP, DIALOG
|
||||
BEGIN
|
||||
VERTGUIDE, 7
|
||||
VERTGUIDE, 24
|
||||
VERTGUIDE, 48
|
||||
VERTGUIDE, 203
|
||||
VERTGUIDE, 211
|
||||
HORZGUIDE, 32
|
||||
HORZGUIDE, 51
|
||||
HORZGUIDE, 167
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Toolbar
|
||||
//
|
||||
|
||||
IDR_TOOLBAR TOOLBAR DISCARDABLE 16, 15
|
||||
BEGIN
|
||||
BUTTON ID_BUTTON40001
|
||||
BUTTON ID_BUTTON40002
|
||||
BUTTON ID_BUTTON40003
|
||||
BUTTON ID_BUTTON40004
|
||||
BUTTON ID_BUTTON40005
|
||||
BUTTON ID_BUTTON40006
|
||||
BUTTON ID_BUTTON40007
|
||||
BUTTON ID_BUTTON40008
|
||||
BUTTON ID_BUTTON40009
|
||||
BUTTON ID_BUTTON40010
|
||||
BUTTON ID_BUTTON40011
|
||||
BUTTON ID_BUTTON40012
|
||||
BUTTON ID_BUTTON40013
|
||||
BUTTON ID_BUTTON40014
|
||||
BUTTON ID_BUTTON40016
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 8,1,0,0
|
||||
PRODUCTVERSION 8,1,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "DirectShow Windows XP Sample\0"
|
||||
VALUE "CompanyName", "Microsoft\0"
|
||||
VALUE "FileDescription", "VMR Player Application\0"
|
||||
VALUE "FileVersion", "8.10\0"
|
||||
VALUE "InternalName", "VMR Player\0"
|
||||
VALUE "LegalCopyright", "Copyright (c) 2000-2001 Microsoft Corporation\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "VMRPlayer.EXE\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "DirectX 8.1 SDK\0"
|
||||
VALUE "ProductVersion", "8.1\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDM_MOVIE_STOP "Stop"
|
||||
IDM_MOVIE_PLAY "Play"
|
||||
IDM_MOVIE_PREVTRACK "Rewind to beginning"
|
||||
IDM_MOVIE_PAUSE "Pause"
|
||||
IDM_MOVIE_SKIP_FORE "Fast Forward"
|
||||
IDM_MOVIE_SKIP_BACK "Rewind"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDM_MOVIE_STEP "Step one frame"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
STR_FILE_OPEN "Open a new movie to play"
|
||||
STR_FILE_CLOSE "Close the movie"
|
||||
STR_FILE_EXIT "Quit DirectShow VMRPlayer Sample"
|
||||
STR_FILE_OPEN2 "Open a second stream to alpha blend with the primary stream"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
STR_APP_IMAGE "Modify static image properties"
|
||||
STR_STREAM_A "Modify primary image properties"
|
||||
STR_STREAM_B "Modify secondary image properties"
|
||||
STR_CAPTURE_IMAGE "Capture the current frame to disk"
|
||||
STR_DISPLAY_CAPTURED_IMAGE "Display the most recent captured image"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
STR_HELP_ABOUT "Display information about DirectShow VMRPlayer Sample"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
STR_SYSMENU_RESTORE "Restore the window to normal size"
|
||||
STR_SYSMENU_MOVE "Changes the window position"
|
||||
STR_SYSMENU_MINIMIZE "Reduce the window to an icon"
|
||||
STR_SYSMENU_CLOSE "Closes the window"
|
||||
STR_SYSMENU_MAXIMIZE "Enlarges the window to its maximum size"
|
||||
STR_SYSMENU_TASK_LIST "Opens the task list"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
STR_FILE_FILTER "All Movies#*.mpg;*.avi;*.dat;*.mov#Mpeg Files (*.mpg)#*.mpg#Video CD Files (*.dat)#*.dat#QuickTime Files (*.mov)#*.mov#All Files (*.*)#*.*#"
|
||||
STR_APP_TITLE "DirectShow VMRPlayer Sample"
|
||||
STR_APP_TITLE_LOADED "DirectShow VMRPlayer Sample - %s"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Reference in New Issue
Block a user