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:
2025-11-29 16:24:34 +09:00
commit e067522598
5135 changed files with 1745744 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
# Microsoft Developer Studio Project File - Name="ASFCopy" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=ASFCopy - 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 "ASFCopy.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 "ASFCopy.mak" CFG="ASFCopy - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ASFCopy - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "ASFCopy - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "ASFCopy - 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 "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "." /I "..\..\BaseClasses" /I "..\..\..\..\..\include" /I "..\..\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# 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 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:console /machine:I386
# ADD LINK32 ..\..\common\wmstub.lib ..\..\common\wmvcore.lib strmiids.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib 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 /stack:0x200000,0x200000 /subsystem:console /machine:I386 /nodefaultlib:"msvcrt"
!ELSEIF "$(CFG)" == "ASFCopy - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "ASFCopy___Win32_Debug"
# PROP BASE Intermediate_Dir "ASFCopy___Win32_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 "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "." /I "..\..\BaseClasses" /I "..\..\..\..\..\include" /I "..\..\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# 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 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:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ..\..\common\wmstub.lib ..\..\common\wmvcore.lib strmiids.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib 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 /stack:0x200000,0x200000 /subsystem:console /debug /machine:I386 /nodefaultlib:"msvcrt" /pdbtype:sept
!ENDIF
# Begin Target
# Name "ASFCopy - Win32 Release"
# Name "ASFCopy - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\asfcopy.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\asferr.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\nserror.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\wmsbuffer.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\wmsdk.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\wmsdkidl.h
# End Source File
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "ASFCopy"=.\ASFCopy.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,185 @@
# Microsoft Developer Studio Generated NMAKE File, Based on ASFCopy.dsp
!IF "$(CFG)" == ""
CFG=ASFCopy - Win32 Debug
!MESSAGE No configuration specified. Defaulting to ASFCopy - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "ASFCopy - Win32 Release" && "$(CFG)" != "ASFCopy - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!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 "ASFCopy.mak" CFG="ASFCopy - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ASFCopy - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "ASFCopy - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
!IF "$(CFG)" == "ASFCopy - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\ASFCopy.exe"
CLEAN :
-@erase "$(INTDIR)\asfcopy.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\ASFCopy.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "." /I "..\..\BaseClasses" /I "..\..\..\..\..\include" /I "..\..\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\ASFCopy.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
RSC=rc.exe
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\ASFCopy.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=strmiids.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib 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:console /incremental:no /pdb:"$(OUTDIR)\ASFCopy.pdb" /machine:I386 /nodefaultlib:"msvcrt" /out:"$(OUTDIR)\ASFCopy.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\asfcopy.obj"
"$(OUTDIR)\ASFCopy.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "ASFCopy - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\ASFCopy.exe"
CLEAN :
-@erase "$(INTDIR)\asfcopy.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\ASFCopy.exe"
-@erase "$(OUTDIR)\ASFCopy.ilk"
-@erase "$(OUTDIR)\ASFCopy.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "." /I "..\..\BaseClasses" /I "..\..\..\..\..\include" /I "..\..\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\ASFCopy.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /D /GZ /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
RSC=rc.exe
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\ASFCopy.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=strmiids.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib 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:console /incremental:yes /pdb:"$(OUTDIR)\ASFCopy.pdb" /debug /machine:I386 /nodefaultlib:"msvcrt" /out:"$(OUTDIR)\ASFCopy.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\asfcopy.obj"
"$(OUTDIR)\ASFCopy.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("ASFCopy.dep")
!INCLUDE "ASFCopy.dep"
!ELSE
!MESSAGE Warning: cannot find "ASFCopy.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "ASFCopy - Win32 Release" || "$(CFG)" == "ASFCopy - Win32 Debug"
SOURCE=.\asfcopy.cpp
"$(INTDIR)\asfcopy.obj" : $(SOURCE) "$(INTDIR)"
!ENDIF

View File

@@ -0,0 +1,738 @@
//------------------------------------------------------------------------------
// File: ASFCopy.cpp
//
// Desc: DirectShow sample code - ASF copy.
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
#include <streams.h>
// Disable warning C4268, which is generated within <wmsdk.h>
#pragma warning(disable:4268)
#include <wmsdk.h>
#pragma warning(default:4268)
#include <atlbase.h>
#include <atlimpl.cpp>
#include <stdio.h>
#include <dshowasf.h>
//
// Build warning to remind developers of the dependency on the
// Windows Media Format SDK libraries, which do not ship with
// the DirectX SDK.
//
#pragma message("NOTE: To link and run this sample, you must install the Windows Media Format SDK.")
#pragma message("After signing a license agreement with Microsoft, you will receive a")
#pragma message("unique version of WMStub.LIB, which should be added to this VC++ project.")
#pragma message("Without this library, you will receive linker errors for the following:")
#pragma message(" WMCreateCertificate")
#pragma message("You must also add WMVCore.LIB to the linker settings to resolve the following:")
#pragma message(" WMCreateProfileManager")
// Global data
BOOL fVerbose = FALSE;
// Function prototypes
HRESULT MapProfileIdToProfile(int iProfile, IWMProfile **ppProfile);
class CKeyProvider : public IServiceProvider
{
public:
//
// IUnknown interface
//
STDMETHODIMP QueryInterface(REFIID riid, void ** ppv);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
CKeyProvider();
// IServiceProvider
STDMETHODIMP QueryService(REFIID siid, REFIID riid, void **ppv);
private:
ULONG m_cRef;
};
CKeyProvider::CKeyProvider() : m_cRef(0)
{
}
//////////////////////////////////////////////////////////////////////////
//
// IUnknown methods
//
//////////////////////////////////////////////////////////////////////////
ULONG CKeyProvider::AddRef()
{
return ++m_cRef;
}
ULONG CKeyProvider::Release()
{
ASSERT(m_cRef > 0);
m_cRef--;
if(m_cRef == 0)
{
delete this;
// don't return m_cRef, because the object doesn't exist anymore
return((ULONG) 0);
}
return(m_cRef);
}
//
// QueryInterface
//
// We only support IUnknown and IServiceProvider
//
HRESULT CKeyProvider::QueryInterface(REFIID riid, void ** ppv)
{
if(riid == IID_IServiceProvider || riid == IID_IUnknown)
{
*ppv = (void *) static_cast<IServiceProvider *>(this);
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP CKeyProvider::QueryService(REFIID siid, REFIID riid, void **ppv)
{
if(siid == __uuidof(IWMReader) && riid == IID_IUnknown)
{
IUnknown *punkCert;
HRESULT hr = WMCreateCertificate(&punkCert);
if(SUCCEEDED(hr))
*ppv = (void *) punkCert;
else
printf("CKeyProvider::QueryService failed to create certificate! hr=0x%x\n", hr);
return hr;
}
return E_NOINTERFACE;
}
HRESULT FindPinOnFilter( IBaseFilter * pFilter, PIN_DIRECTION PinDir,
DWORD dwPin, BOOL fConnected, IPin ** ppPin )
{
HRESULT hr = S_OK;
IEnumPins * pEnumPin = NULL;
IPin * pConnectedPin = NULL;
PIN_DIRECTION PinDirection;
ULONG ulFetched;
DWORD nFound = 0;
ASSERT( pFilter != NULL );
*ppPin = NULL;
hr = pFilter->EnumPins( &pEnumPin );
if(SUCCEEDED(hr))
{
while ( S_OK == ( hr = pEnumPin->Next( 1L, ppPin, &ulFetched ) ) )
{
hr = (*ppPin)->ConnectedTo( &pConnectedPin );
if (pConnectedPin)
{
pConnectedPin->Release();
pConnectedPin = NULL;
}
if ( ( ( VFW_E_NOT_CONNECTED == hr ) && !fConnected ) ||
( ( S_OK == hr ) && fConnected ) )
{
hr = (*ppPin)->QueryDirection( &PinDirection );
if ( ( S_OK == hr ) && ( PinDirection == PinDir ) )
{
if ( nFound == dwPin ) break;
nFound++;
}
}
(*ppPin)->Release();
}
}
pEnumPin->Release();
return hr;
} // FindPinOnFilter
HRESULT GetPin(IBaseFilter *pFilter, DWORD dwPin, IPin **ppPin)
{
IEnumPins *pins;
*ppPin = NULL;
HRESULT hr = pFilter->EnumPins(&pins);
if(FAILED(hr))
{
DbgLog((LOG_ERROR,1,TEXT("EnumPins failed! (%x)\n"), hr));
return hr;
}
if(dwPin > 0)
{
hr = pins->Skip(dwPin);
if(FAILED(hr))
{
DbgLog((LOG_ERROR,1,TEXT("Skip(%d) failed! (%x)\n"), dwPin, hr));
pins->Release();
return hr;
}
if(hr == S_FALSE)
{
DbgLog((LOG_ERROR,1,TEXT("Skip(%d) ran out of pins!\n"), dwPin));
pins->Release();
return hr;
}
}
DWORD n;
hr = pins->Next(1, ppPin, &n);
if(FAILED(hr))
{
DbgLog((LOG_ERROR,1,TEXT("Next() failed! (%x)\n"), hr));
}
if(hr == S_FALSE)
{
DbgLog((LOG_ERROR,1,TEXT("Next() ran out of pins! \n")));
pins->Release();
return hr;
}
pins->Release();
return hr;
}
void ListProfiles()
{
USES_CONVERSION;
int wextent = 0, Loop = 0;
DWORD cProfiles = 0;
DWORD cchName, cchDescription;
CComPtr <IWMProfileManager> pIWMProfileManager;
printf("Standard system profiles:\n");
HRESULT hr = WMCreateProfileManager(&pIWMProfileManager);
if(FAILED(hr))
{
printf("ListProfiles: Failed to create profile manager! hr=0x%x\n", hr);
return; // error
}
CComQIPtr<IWMProfileManager2, &IID_IWMProfileManager2> pIPM2(pIWMProfileManager);
if(!pIPM2)
{
printf("ListProfiles: Failed to QI IWMProfileManager2! hr=0x%x\n", hr);
return;
}
// we only use 7_0 profiles
hr = pIPM2->SetSystemProfileVersion( WMT_VER_7_0 );
if(FAILED(hr))
{
printf("ListProfiles: Failed to set system profile version! hr=0x%x\n", hr);
return;
}
hr = pIWMProfileManager->GetSystemProfileCount(&cProfiles);
if(FAILED(hr))
{
printf("ListProfiles: Failed to get system profile count! hr=0x%x\n", hr);
return;
}
// Load the profile strings
for(int i = 0; i < (int)cProfiles; ++i)
{
CComPtr <IWMProfile> pIWMProfile;
hr = pIWMProfileManager->LoadSystemProfile(i, &pIWMProfile);
if(FAILED(hr))
{
printf("ListProfiles: Failed to load system profile! hr=0x%x\n", hr);
return;
}
// How large is the profile name?
hr = pIWMProfile->GetName(NULL, &cchName);
if(FAILED(hr))
{
printf("ListProfiles: Failed to read profile name size! hr=0x%x\n", hr);
return;
}
WCHAR *wszProfile = new WCHAR[ cchName + 1 ];
if(NULL == wszProfile)
return;
hr = pIWMProfile->GetName(wszProfile, &cchName);
if(FAILED(hr))
{
printf("ListProfiles: Failed to read profile name! hr=0x%x\n", hr);
return;
}
// How large is the description?
hr = pIWMProfile->GetDescription(NULL, &cchDescription);
if(FAILED(hr))
{
printf("ListProfiles: Failed to read profile description size! hr=0x%x\n", hr);
return;
}
WCHAR *wszDescription = new WCHAR[ cchDescription + 1 ];
if(NULL == wszDescription)
return;
hr = pIWMProfile->GetDescription(wszDescription, &cchDescription);
if(FAILED(hr))
{
printf("ListProfiles: Failed to read profile description! hr=0x%x\n", hr);
return;
}
// Display the profile name and description
if (fVerbose)
printf(" %3d: %ls \n[%ls]\n\n", i, wszProfile, wszDescription);
else
printf(" %3d: %ls\n", i, wszProfile);
delete[] wszProfile;
delete[] wszDescription;
}
}
//=======================
// CreateFilterGraph
//=======================
HRESULT CreateFilterGraph(IGraphBuilder **pGraph)
{
HRESULT hr;
hr = CoCreateInstance(CLSID_FilterGraph, // get the graph object
NULL,
CLSCTX_INPROC_SERVER,
IID_IGraphBuilder,
(void **) pGraph);
if(FAILED(hr))
{
printf("CreateFilterGraph: Failed to create graph! hr=0x%x\n", hr);
*pGraph = NULL;
return hr;
}
return S_OK;
}
HRESULT CreateFilter(REFCLSID clsid, IBaseFilter **ppFilter)
{
HRESULT hr;
hr = CoCreateInstance(clsid,
NULL,
CLSCTX_INPROC_SERVER,
IID_IBaseFilter,
(void **) ppFilter);
if(FAILED(hr))
{
printf("CreateFilter: Failed to create filter! hr=0x%x\n", hr);
*ppFilter = NULL;
return hr;
}
return S_OK;
}
HRESULT SetNoClock(IFilterGraph *graph)
{
// Keep a useless clock from being instantiated....
IMediaFilter *graphF;
HRESULT hr = graph->QueryInterface(IID_IMediaFilter, (void **) &graphF);
if(SUCCEEDED(hr))
{
hr = graphF->SetSyncSource(NULL);
if (FAILED(hr))
printf("SetNoClock: Failed to set sync source! hr=0x%x\n", hr);
graphF->Release();
}
else
{
printf("SetNoClock: Failed to QI for media filter! hr=0x%x\n", hr);
}
return hr;
}
HRESULT MapProfileIdToProfile(int iProfile, IWMProfile **ppProfile)
{
DWORD cProfiles;
*ppProfile = 0;
CComPtr <IWMProfileManager> pIWMProfileManager;
HRESULT hr = WMCreateProfileManager( &pIWMProfileManager );
if(FAILED(hr))
{
printf("MapProfile: Failed to create profile manager! hr=0x%x\n", hr);
return hr;
}
// We only use 7_0 profiles
CComQIPtr<IWMProfileManager2, &IID_IWMProfileManager2> pIPM2(pIWMProfileManager);
if(!pIPM2)
{
printf("MapProfile: Failed to QI IWMProfileManager2!\n");
return E_UNEXPECTED;
}
hr = pIPM2->SetSystemProfileVersion( WMT_VER_7_0 );
if(FAILED(hr))
{
printf("MapProfile: Failed to set system profile version! hr=0x%x\n", hr);
return hr;
}
hr = pIWMProfileManager->GetSystemProfileCount( &cProfiles );
if(FAILED(hr))
{
printf("MapProfile: Failed to get system profile count! hr=0x%x\n", hr);
return hr;
}
// Invalid profile requested?
if( (DWORD)iProfile >= cProfiles )
{
printf("Invalid profile: %d\n", iProfile);
return E_INVALIDARG;
}
return (pIWMProfileManager->LoadSystemProfile( iProfile, ppProfile ));
}
void WaitForCompletion( IGraphBuilder *pGraph )
{
HRESULT hr;
LONG lEvCode = 0;
IMediaEvent *pEvent;
pGraph->QueryInterface(IID_IMediaEvent, (void **) &pEvent);
printf("Waiting for completion...\n This could take several minutes, "
"depending on file size and selected profile.\n");
do
{
MSG Message;
while(PeekMessage(&Message, NULL, 0, 0, TRUE))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
hr = pEvent->WaitForCompletion(10, &lEvCode);
} while(lEvCode == 0);
pEvent->Release();
}
HRESULT CopyASF(int argc, char *argv[])
{
HRESULT hr;
WCHAR SourceFile[256], TargetFile[256];
BOOL fListProfiles = TRUE;
DWORD dwProfile=0;
int i = 1;
// Parse command line options
while(i < argc && (argv[i][0] == '-' || argv[i][0] == '/'))
{
// options
if(lstrcmpiA(argv[i] + 1, "v") == 0)
{
fVerbose = TRUE;
printf("Verbose mode enabled.\n");
}
else if((i+1 < argc) && lstrcmpiA(argv[i] + 1, "p") == 0)
{
fListProfiles = FALSE;
dwProfile = atoiA(argv[i+1]);
i++; // skip two args here
}
i++;
}
// List profiles only?
if(fListProfiles)
{
printf("Usage: asfcopy [/v] /p profnum file1 [ file2 ...] target\n\n");
HRESULT hr = CoInitialize(NULL);
ListProfiles();
CoUninitialize();
return -1;
}
// Fail with usage information if improper number of arguments
if(argc < i+2)
{
printf("Usage: asfcopy [/v] /p profnum file1 [ file2 ...] target\n");
return -1;
}
CComPtr <IGraphBuilder> pGraph;
CComPtr <IObjectWithSite> pObjectWithSite;
CComPtr <IBaseFilter> pMux;
CComPtr <IBaseFilter> pWriter;
CComPtr <IFileSinkFilter> pFS;
CComPtr <IConfigInterleaving> pConfigInterleaving;
CComPtr <IConfigAsfWriter> pConfigAsfWriter;
CComPtr <IMediaControl> pGraphC;
// Convert target filename
MultiByteToWideChar(CP_ACP, 0, argv[argc - 1], -1, TargetFile, 256);
hr = CreateFilterGraph(&pGraph);
if(FAILED(hr))
{
printf("Couldn't create filter graph! hr=0x%x", hr);
return hr;
}
CKeyProvider prov;
prov.AddRef(); // Don't let COM try to free our static object
// Give the graph a pointer to us for callbacks & QueryService
hr = pGraph->QueryInterface(IID_IObjectWithSite, (void**)&pObjectWithSite);
if(SUCCEEDED(hr))
{
hr = pObjectWithSite->SetSite((IUnknown *) (IServiceProvider *) &prov);
if(FAILED(hr))
{
printf("Failed to set service provider! hr=0x%x\n", hr);
return hr;
}
}
hr = CreateFilter(CLSID_WMAsfWriter, &pMux);
if(FAILED(hr))
{
printf("Failed to create WMAsfWriter filter! hr=0x%x\n", hr);
return hr;
}
hr = pMux->QueryInterface(IID_IFileSinkFilter, (void **) &pFS);
if(FAILED(hr))
{
// We need a writer also
hr = CreateFilter(CLSID_FileWriter, &pWriter);
if(FAILED(hr))
{
printf("Failed to create FileWriter filter! hr=0x%x\n", hr);
return hr;
}
else
{
hr = pWriter->QueryInterface(IID_IFileSinkFilter, (void **) &pFS);
if(FAILED(hr))
{
printf("Failed to create QI IFileSinkFilter! hr=0x%x\n", hr);
return hr;
}
}
}
hr = pFS->SetFileName(TargetFile, NULL);
if(FAILED(hr))
{
printf("Failed to set target filename! hr=0x%x\n", hr);
return hr;
}
hr = pGraph->AddFilter(pMux, L"Mux");
if(FAILED(hr))
{
printf("Failed to add Mux filter to graph! hr=0x%x\n", hr);
return hr;
}
// Set interleaving mode to FULL
// !!! ASF won't support this, but that's okay
hr = pMux->QueryInterface(IID_IConfigInterleaving, (void **) &pConfigInterleaving);
if(SUCCEEDED(hr))
{
printf("Setting interleaving mode to INTERLEAVE_FULL\r\n");
hr = pConfigInterleaving->put_Mode(INTERLEAVE_FULL);
}
// !!! We should only require a profile if we're using a filter which needs it
hr = pMux->QueryInterface(IID_IConfigAsfWriter, (void **) &pConfigAsfWriter);
if(SUCCEEDED(hr))
{
if (fVerbose)
printf("Setting profile to %d\r\n", dwProfile);
CComPtr<IWMProfile> pProfile;
hr = MapProfileIdToProfile(dwProfile, &pProfile);
if(FAILED(hr)) {
printf("Failed to map profile ID! hr=0x%x\n", hr);
return hr;
}
// Note that the ASF writer will not run if the number of streams
// does not match the profile.
hr = pConfigAsfWriter->ConfigureFilterUsingProfile(pProfile);
if(FAILED(hr)) {
printf("Failed to configure filter to use profile! hr=0x%x\n", hr);
return hr;
}
}
else
{
printf("Failed to QI for IConfigAsfWriter! hr=0x%x\n", hr);
return hr;
}
// Connect writer filter if needed
if(pWriter)
{
IPin *pMuxOut, *pWriterIn;
hr = pGraph->AddFilter(pWriter, L"Writer");
if(FAILED(hr))
{
printf("Failed to add FileWriter filter to graph! hr=0x%x\n", hr);
return hr;
}
// Look for the first unconnected output pin
hr = FindPinOnFilter(pMux, PINDIR_OUTPUT, 0, FALSE, &pMuxOut);
if(FAILED(hr))
{
printf("Failed to find output pin on Mux! hr=0x%x\n", hr);
return hr;
}
// Find the first connected pin
hr = FindPinOnFilter(pWriter, PINDIR_INPUT, 0, FALSE, &pWriterIn);
if(FAILED(hr))
{
printf("Failed to find input pin on FileWriter! hr=0x%x\n", hr);
pMuxOut->Release();
return hr;
}
hr = pGraph->ConnectDirect(pMuxOut, pWriterIn, NULL);
pMuxOut->Release();
pWriterIn->Release();
if(FAILED(hr))
{
printf("Failed to connect Mux to FileWriter! hr=0x%x\n", hr);
return hr;
}
if(fVerbose)
printf("Connected Mux and writer, hr = 0x%x\n", hr);
}
// Set sync source to NULL to speed processing
SetNoClock(pGraph);
// Render all source files listed on the command line
while(i < argc - 1)
{
MultiByteToWideChar(CP_ACP, 0, argv[i], -1,
SourceFile, 256);
printf("Copying %ls to %ls\n", SourceFile, TargetFile);
hr = pGraph->RenderFile(SourceFile, NULL);
if(FAILED(hr))
printf("Failed to render source file %s! hr=0x%x\n", argv[i], hr);
else if (fVerbose)
printf("RenderFile('%ls') returned hr=0x%x\n", SourceFile, hr);
++i;
}
// Run the graph
hr = pGraph->QueryInterface(IID_IMediaControl, (void **) &pGraphC);
if(FAILED(hr))
{
printf("Failed to QI for IMediaControl! hr=0x%x\n", hr);
return hr;
}
hr = pGraphC->Run();
if(FAILED(hr))
{
printf("Failed to run the graph! hr=0x%x\nCopy aborted.\n\n", hr);
printf("Please check that you have selected the correct profile for copying.\n"
"Note that if your source ASF file is audio-only, then selecting a\n"
"video profile will cause a failure when running the graph.\n\n");
ListProfiles();
}
else
{
WaitForCompletion(pGraph);
printf("Copy complete.\n");
// Stop the graph
hr = pGraphC->Stop();
}
return hr;
}
int __cdecl
main(
int argc,
char *argv[]
)
{
// Initialize COM
HRESULT hr = CoInitialize(NULL);
// Since COM smart pointers are used, the main functionality is wrapped
// in CopyASF(). When the function returns, the smart pointers will clean
// up properly, and then we'll uninitialize COM.
hr = CopyASF(argc, argv);
CoUninitialize();
return hr;
}

View File

@@ -0,0 +1,470 @@
///////////////////////////////////////////////////////////////////////////
//
// ASFErr.h - definition of ASF HRESULT codes
//
// Microsoft Windows Media Technology
// Copyright (C) Microsoft Corporation, 1999-2001. All Rights Reserved.
//
// This file is generated by the MC tool from ASFErr.mc
//
#ifndef _ASFERR_H
#define _ASFERR_H
#define STATUS_SEVERITY(hr) (((hr) >> 30) & 0x3)
///////////////////////////////////////////////////////////////////////////
//
// Advanced Streaming Format (ASF) Errors (2000-2999)
//
//
// Values are 32 bit values layed out as follows:
//
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
// +---+-+-+-----------------------+-------------------------------+
// |Sev|C|R| Facility | Code |
// +---+-+-+-----------------------+-------------------------------+
//
// where
//
// Sev - is the severity code
//
// 00 - Success
// 01 - Informational
// 10 - Warning
// 11 - Error
//
// C - is the Customer code flag
//
// R - is a reserved bit
//
// Facility - is the facility code
//
// Code - is the facility's status code
//
//
// Define the facility codes
//
#define FACILITY_NS 0xD
//
// Define the severity codes
//
#define STATUS_SEVERITY_WARNING 0x2
#define STATUS_SEVERITY_SUCCESS 0x0
#define STATUS_SEVERITY_INFORMATIONAL 0x1
#define STATUS_SEVERITY_ERROR 0x3
//
// MessageId: ASF_E_BUFFEROVERRUN
//
// MessageText:
//
// An attempt was made to seek or position past the end of a buffer.%0
//
#define ASF_E_BUFFEROVERRUN 0xC00D07D0L
//
// MessageId: ASF_E_BUFFERTOOSMALL
//
// MessageText:
//
// The supplied input or output buffer was too small.%0
//
#define ASF_E_BUFFERTOOSMALL 0xC00D07D1L
//
// MessageId: ASF_E_BADLANGUAGEID
//
// MessageText:
//
// The language ID was not found.%0
//
#define ASF_E_BADLANGUAGEID 0xC00D07D2L
//
// MessageId: ASF_E_NOPAYLOADLENGTH
//
// MessageText:
//
// The multiple payload packet is missing the payload length.%0
//
#define ASF_E_NOPAYLOADLENGTH 0xC00D07DBL
//
// MessageId: ASF_E_TOOMANYPAYLOADS
//
// MessageText:
//
// The packet contains too many payloads.%0
//
#define ASF_E_TOOMANYPAYLOADS 0xC00D07DCL
//
// MessageId: ASF_E_PACKETCONTENTTOOLARGE
//
// MessageText:
//
// ASF_E_PACKETCONTENTTOOLARGE
//
#define ASF_E_PACKETCONTENTTOOLARGE 0xC00D07DEL
//
// MessageId: ASF_E_UNKNOWNPACKETSIZE
//
// MessageText:
//
// Expecting a fixed packet size but min. and max. are not equal.%0
//
#define ASF_E_UNKNOWNPACKETSIZE 0xC00D07E0L
//
// MessageId: ASF_E_INVALIDHEADER
//
// MessageText:
//
// ASF_E_INVALIDHEADER
//
#define ASF_E_INVALIDHEADER 0xC00D07E2L
//
// MessageId: ASF_E_NOCLOCKOBJECT
//
// MessageText:
//
// The object does not have a valid clock object.%0
//
#define ASF_E_NOCLOCKOBJECT 0xC00D07E6L
//
// MessageId: ASF_E_UNKNOWNCLOCKTYPE
//
// MessageText:
//
// ASF_E_UNKNOWNCLOCKTYPE
//
#define ASF_E_UNKNOWNCLOCKTYPE 0xC00D07EBL
//
// MessageId: ASF_E_OPAQUEPACKET
//
// MessageText:
//
// An attempt was made to restore or access an opaque packet.%0
//
#define ASF_E_OPAQUEPACKET 0xC00D07EDL
//
// MessageId: ASF_E_WRONGVERSION
//
// MessageText:
//
// ASF_E_WRONGVERSION
//
#define ASF_E_WRONGVERSION 0xC00D07EEL
//
// MessageId: ASF_E_OVERFLOW
//
// MessageText:
//
// An attempt was made to store a value which was larger than then destination's maximum value.%0
//
#define ASF_E_OVERFLOW 0xC00D07EFL
//
// MessageId: ASF_E_NOTFOUND
//
// MessageText:
//
// The object was not found.%0
//
#define ASF_E_NOTFOUND 0xC00D07F0L
//
// Someone else is using MessageIds 2033 & 2034, so we skip them
//
// 2033 = NS_E_NOTHING_TO_DO
// 2034 = NS_E_NO_MULTICAST
//
// MessageId: ASF_E_OBJECTTOOBIG
//
// MessageText:
//
// The object is too large to be processed in the requested manner.%0
//
#define ASF_E_OBJECTTOOBIG 0xC00D07F3L
//
// MessageId: ASF_E_UNEXPECTEDVALUE
//
// MessageText:
//
// A value was not set as expected.%0
//
#define ASF_E_UNEXPECTEDVALUE 0xC00D07F4L
//
// MessageId: ASF_E_INVALIDSTATE
//
// MessageText:
//
// The request is not valid in the object's current state.%0
//
#define ASF_E_INVALIDSTATE 0xC00D07F5L
//
// MessageId: ASF_E_NOLIBRARY
//
// MessageText:
//
// This object does not have a valid library pointer; it was not properly created or it has been Shutdown().%0
//
#define ASF_E_NOLIBRARY 0xC00D07F6L
//
// MessageId: ASF_E_ALREADYINITIALIZED
//
// MessageText:
//
// This object has already been initialized; the setting cannot be changed.%0
//
#define ASF_E_ALREADYINITIALIZED 0xC00D07F7L
//
// MessageId: ASF_E_INVALIDINIT
//
// MessageText:
//
// This object has not been initialized properly; that operation cannot be performed.%0
//
#define ASF_E_INVALIDINIT 0xC00D07F8L
//
// MessageId: ASF_E_NOHEADEROBJECT
//
// MessageText:
//
// The ASF Header object could not be found.%0
//
#define ASF_E_NOHEADEROBJECT 0xC00D07F9L
//
// MessageId: ASF_E_NODATAOBJECT
//
// MessageText:
//
// The ASF Data object could not be found.%0
//
#define ASF_E_NODATAOBJECT 0xC00D07FAL
//
// MessageId: ASF_E_NOINDEXOBJECT
//
// MessageText:
//
// The ASF Index object could not be found.%0
//
#define ASF_E_NOINDEXOBJECT 0xC00D07FBL
//
// MessageId: ASF_E_NOSTREAMPROPS
//
// MessageText:
//
// A Stream Properties object with the correct stream number could not be found.%0
//
#define ASF_E_NOSTREAMPROPS 0xC00D07FCL
//
// MessageId: ASF_E_NOFILEPROPS
//
// MessageText:
//
// The File Properties object could not be found.%0
//
#define ASF_E_NOFILEPROPS 0xC00D07FDL
//
// MessageId: ASF_E_NOLANGUAGELIST
//
// MessageText:
//
// The Language List object could not be found.%0
//
#define ASF_E_NOLANGUAGELIST 0xC00D07FEL
//
// MessageId: ASF_E_NOINDEXPARAMETERS
//
// MessageText:
//
// The Index Parameters object could not be found.%0
//
#define ASF_E_NOINDEXPARAMETERS 0xC00D07FFL
//
// MessageId: ASF_E_UNSUPPORTEDERRORCONCEALMENT
//
// MessageText:
//
// The requested error concealment strategy is not supported by this component.%0
//
#define ASF_E_UNSUPPORTEDERRORCONCEALMENT 0xC00D0800L
//
// MessageId: ASF_E_INVALIDFLAGS
//
// MessageText:
//
// The flags for this object or set of objects are not properly set.%0
//
#define ASF_E_INVALIDFLAGS 0xC00D0801L
//
// MessageId: ASF_E_BADDATADESCRIPTOR
//
// MessageText:
//
// One or more data descriptors is not properly set.%0
//
#define ASF_E_BADDATADESCRIPTOR 0xC00D0802L
//
// MessageId: ASF_E_BADINDEXTIMEINTERVAL
//
// MessageText:
//
// The index has an invalid time interval (probably zero).%0
//
#define ASF_E_BADINDEXTIMEINTERVAL 0xC00D0803L
//
// MessageId: ASF_E_INVALIDTIME
//
// MessageText:
//
// The given time value is not valid.%0
//
#define ASF_E_INVALIDTIME 0xC00D0804L
//
// MessageId: ASF_E_INVALIDINDEX
//
// MessageText:
//
// The given index value is not valid.%0
//
#define ASF_E_INVALIDINDEX 0xC00D0805L
//
// MessageId: ASF_E_STREAMNUMBERINUSE
//
// MessageText:
//
// The specified stream number is already in use.%0
//
#define ASF_E_STREAMNUMBERINUSE 0xC00D0806L
//
// MessageId: ASF_E_BADMEDIATYPE
//
// MessageText:
//
// The specified media type does not work with this component.%0
//
#define ASF_E_BADMEDIATYPE 0xC00D0807L
//
// MessageId: ASF_E_WRITEFAILED
//
// MessageText:
//
// The object could not be written as specified.%0
//
#define ASF_E_WRITEFAILED 0xC00D0808L
//
// MessageId: ASF_E_NOTENOUGHDESCRIPTORS
//
// MessageText:
//
// The given data unit requires a larger number of descriptors to be fully parsed.%0
//
#define ASF_E_NOTENOUGHDESCRIPTORS 0xC00D0809L
//
// MessageId: ASF_E_INDEXBLOCKUNLOADED
//
// MessageText:
//
// The index entries for the specified index block have been unloaded from memory and are not available.%0
//
#define ASF_E_INDEXBLOCKUNLOADED 0xC00D080AL
//
// MessageId: ASF_E_NOTENOUGHBANDWIDTH
//
// MessageText:
//
// The specified bandwidth is not large enough.%0
//
#define ASF_E_NOTENOUGHBANDWIDTH 0xC00D080BL
//
// MessageId: ASF_E_EXCEEDEDMAXIMUMOBJECTSIZE
//
// MessageText:
//
// The object has exceeded its maximum size.%0
//
#define ASF_E_EXCEEDEDMAXIMUMOBJECTSIZE 0xC00D080CL
//
// MessageId: ASF_E_BADDATAUNIT
//
// MessageText:
//
// The given data unit is corrupted, badly formatted, or otherwise not valid.%0
//
#define ASF_E_BADDATAUNIT 0xC00D080DL
//
// MessageId: ASF_E_HEADERSIZE
//
// MessageText:
//
// The ASF header has exceeded the specified maximum size.%0
//
#define ASF_E_HEADERSIZE 0xC00D080EL
///////////////////////////////////////////////////////////////////////////
//
// Advanced Streaming Format (ASF) Success Codes (2000-2999)
//
//
// MessageId: ASF_S_OPAQUEPACKET
//
// MessageText:
//
// ASF_S_OPAQUEPACKET
//
#define ASF_S_OPAQUEPACKET 0x000D07F0L
///////////////////////////////////////////////////////////////////////////
//
// Advanced Streaming Format (ASF) Warnings (2000-2999)
//
#endif // _ASFERR_H

View File

@@ -0,0 +1,28 @@
DirectShow Sample -- ASFCopy
----------------------------
Transcodes one or more files to an ASF file.
To build this sample, you must install the Microsoft Windows Media Format SDK
and obtain a software certificate. After you obtain the software certificate,
build the sample by linking two additional libraries: WMStub.lib and WMVCore.lib.
Usage:
ASFCopy [/v] /p profile file1 [file2 ...] target
The following command-line switches are supported:
/p Specifies the profile number.
/v Verbose mode.
Specify an ASF profile using the /p switch. If you omit this switch, ASFCopy
displays a list of the standard system profiles.
Specify the name of one or more source files, and the name of the target file.
If you specify more than one source file, the application multiplexes all of
the source files. You must specify a profile that matches the streams
contained in the source files, or else the application will not work correctly.
For example, if you specify Video for Web Servers (56 Kbps), the combined
source files must have exactly one video stream and one audio stream.