L
ljy_17
Unregistered / Unconfirmed
GUEST, unregistred user!
我剛接觸DirectX編程,而且用的是delphi+dspack!
偶得到一個基於DirectX的VC++網絡播放器代碼!實在沒有能力轉換為DELPHI!
所以請大家幫忙轉換!其實傳送部分可不必轉換!隻要轉換播放內存的部分就可!
我先貼出修改過的memfile文件!
有意轉換者請留下EMAIL,我將所有代碼發送到你們的信箱!
//
// MemFilter.h
//
#ifndef __MemFilter_h__
#define __MemFilter_h__
#include <streams.h>
#include <stdio.h>
#include "asyncio.h"
#include "asyncrdr.h"
#include "CMediaSocketClient.h"
#include "CDataAdmin.h"
#include "MyDef.h"
//////////////////////////////////////////////////////////////////////
// Define an internal filter that wraps the base CBaseReader stuff //
//////////////////////////////////////////////////////////////////////
class CMemStream : public CAsyncStream
{
private:
CCritSec m_csLock;
CDataAdmin * m_pDataList;
ULONG m_ulPositionInPack;
// Total length available
LONGLONG m_llLength;
// Bytes totally read
DWORD m_dwTimeStart;
public:
CMemStream(CDataAdmin* inBuffer)
{
m_pDataList = inBuffer;
m_ulPositionInPack = 0;
m_llLength = 0;
}
HRESULT SetPointer(LONGLONG llPos)
{
return S_OK;
}
HRESULT Read(PBYTE pbBuffer,
DWORD dwBytesToRead,
BOOL bAlign,
LPDWORD pdwBytesRead)
{
if (m_pDataList == NULL)
return S_FALSE;
CAutoLock lck(&m_csLock);
DWORD dwHaveRead = 0;
PMPEG1_PACK pPack = NULL;
while (dwHaveRead < dwBytesToRead)
{
if (dwBytesToRead - dwHaveRead >= MPEG1_PACK_SIZE - m_ulPositionInPack)
{
// Just copy the whole pack data
pPack = m_pDataList->GetDataBuffer();
if (pPack != NULL)
{
CopyMemory((PVOID)(pbBuffer + dwHaveRead),
(PVOID)((PBYTE)(pPack) + m_ulPositionInPack), (SIZE_T)MPEG1_PACK_SIZE - m_ulPositionInPack);
m_pDataList->ReleaseDataBuffer(pPack);
dwHaveRead += MPEG1_PACK_SIZE - m_ulPositionInPack;
m_ulPositionInPack = 0;
}
else
if (m_pDataList->IsFlushing())
{
// FILE * fp = fopen("c://log.txt","a+");
// fprintf(fp,"failed!/n");
// fclose(fp);
return E_FAIL;
}
else
{
// FILE * fp = fopen("c://log.txt","a+");
// fprintf(fp,"SLEEP!/n");
// fclose(fp);
Sleep(10);
}
}
else
{
// Copy part of the pack data
pPack = m_pDataList->PointToDataHead();
if (pPack != NULL)
{
m_ulPositionInPack = dwBytesToRead - dwHaveRead;
CopyMemory((PVOID)(pbBuffer + dwHaveRead),
(PVOID)(pPack), (SIZE_T)m_ulPositionInPack);
dwHaveRead += m_ulPositionInPack;
}
else
if (m_pDataList->IsFlushing())
{
// FILE * fp = fopen("c://log.txt","a+");
// fprintf(fp,"failed!/n");
// fclose(fp);
return E_FAIL;
}
else
{
// FILE * fp = fopen("c://log.txt","a+");
// fprintf(fp,"SLEEP!/n");
// fclose(fp);
Sleep(10);
}
}
}
*pdwBytesRead = dwBytesToRead;
return S_OK;
}
LONGLONG Size(LONGLONG *pSizeAvailable)
{
*pSizeAvailable = m_llLength;
return 0x7fffffffff;
}
DWORD Alignment()
{
return 1;
}
void Lock()
{
m_csLock.Lock();
}
void Unlock()
{
m_csLock.Unlock();
}
void AddAvailableLength(LONGLONG inLength)
{
m_llLength += inLength;
}
};
class CMemReader : public CAsyncReader
{
public:
// We're not going to be CoCreate'd so wedo
n't need registration
// stuff etc
STDMETHODIMP Register()
{
return S_OK;
}
STDMETHODIMP Unregister()
{
return S_OK;
}
CMemReader(CMemStream *pStream, CMediaType *pmt, HRESULT *phr) :
CAsyncReader(NAME("Mem Reader"), NULL, pStream, phr)
{
m_mt = *pmt;
}
};
#endif // __MemFilter_h__
偶得到一個基於DirectX的VC++網絡播放器代碼!實在沒有能力轉換為DELPHI!
所以請大家幫忙轉換!其實傳送部分可不必轉換!隻要轉換播放內存的部分就可!
我先貼出修改過的memfile文件!
有意轉換者請留下EMAIL,我將所有代碼發送到你們的信箱!
//
// MemFilter.h
//
#ifndef __MemFilter_h__
#define __MemFilter_h__
#include <streams.h>
#include <stdio.h>
#include "asyncio.h"
#include "asyncrdr.h"
#include "CMediaSocketClient.h"
#include "CDataAdmin.h"
#include "MyDef.h"
//////////////////////////////////////////////////////////////////////
// Define an internal filter that wraps the base CBaseReader stuff //
//////////////////////////////////////////////////////////////////////
class CMemStream : public CAsyncStream
{
private:
CCritSec m_csLock;
CDataAdmin * m_pDataList;
ULONG m_ulPositionInPack;
// Total length available
LONGLONG m_llLength;
// Bytes totally read
DWORD m_dwTimeStart;
public:
CMemStream(CDataAdmin* inBuffer)
{
m_pDataList = inBuffer;
m_ulPositionInPack = 0;
m_llLength = 0;
}
HRESULT SetPointer(LONGLONG llPos)
{
return S_OK;
}
HRESULT Read(PBYTE pbBuffer,
DWORD dwBytesToRead,
BOOL bAlign,
LPDWORD pdwBytesRead)
{
if (m_pDataList == NULL)
return S_FALSE;
CAutoLock lck(&m_csLock);
DWORD dwHaveRead = 0;
PMPEG1_PACK pPack = NULL;
while (dwHaveRead < dwBytesToRead)
{
if (dwBytesToRead - dwHaveRead >= MPEG1_PACK_SIZE - m_ulPositionInPack)
{
// Just copy the whole pack data
pPack = m_pDataList->GetDataBuffer();
if (pPack != NULL)
{
CopyMemory((PVOID)(pbBuffer + dwHaveRead),
(PVOID)((PBYTE)(pPack) + m_ulPositionInPack), (SIZE_T)MPEG1_PACK_SIZE - m_ulPositionInPack);
m_pDataList->ReleaseDataBuffer(pPack);
dwHaveRead += MPEG1_PACK_SIZE - m_ulPositionInPack;
m_ulPositionInPack = 0;
}
else
if (m_pDataList->IsFlushing())
{
// FILE * fp = fopen("c://log.txt","a+");
// fprintf(fp,"failed!/n");
// fclose(fp);
return E_FAIL;
}
else
{
// FILE * fp = fopen("c://log.txt","a+");
// fprintf(fp,"SLEEP!/n");
// fclose(fp);
Sleep(10);
}
}
else
{
// Copy part of the pack data
pPack = m_pDataList->PointToDataHead();
if (pPack != NULL)
{
m_ulPositionInPack = dwBytesToRead - dwHaveRead;
CopyMemory((PVOID)(pbBuffer + dwHaveRead),
(PVOID)(pPack), (SIZE_T)m_ulPositionInPack);
dwHaveRead += m_ulPositionInPack;
}
else
if (m_pDataList->IsFlushing())
{
// FILE * fp = fopen("c://log.txt","a+");
// fprintf(fp,"failed!/n");
// fclose(fp);
return E_FAIL;
}
else
{
// FILE * fp = fopen("c://log.txt","a+");
// fprintf(fp,"SLEEP!/n");
// fclose(fp);
Sleep(10);
}
}
}
*pdwBytesRead = dwBytesToRead;
return S_OK;
}
LONGLONG Size(LONGLONG *pSizeAvailable)
{
*pSizeAvailable = m_llLength;
return 0x7fffffffff;
}
DWORD Alignment()
{
return 1;
}
void Lock()
{
m_csLock.Lock();
}
void Unlock()
{
m_csLock.Unlock();
}
void AddAvailableLength(LONGLONG inLength)
{
m_llLength += inLength;
}
};
class CMemReader : public CAsyncReader
{
public:
// We're not going to be CoCreate'd so wedo
n't need registration
// stuff etc
STDMETHODIMP Register()
{
return S_OK;
}
STDMETHODIMP Unregister()
{
return S_OK;
}
CMemReader(CMemStream *pStream, CMediaType *pmt, HRESULT *phr) :
CAsyncReader(NAME("Mem Reader"), NULL, pStream, phr)
{
m_mt = *pmt;
}
};
#endif // __MemFilter_h__