Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
CPI_Stream_LocalFile.c
Package: Visual C++视频音频开发实用工程案例精选.rar [view]
Upload User: tuheem
Upload Date: 2007-05-01
Package Size: 21889k
Code Size: 3k
Category:
Multimedia Develop
Development Platform:
Visual C++
- #include "stdafx.h"
- #include "globals.h"
- #include "CPI_Stream.h"
- typedef struct _CPs_InStream_File
- {
- HANDLE m_hFile;
- } CPs_InStream_File;
- //
- void CPSLOCAL_Uninitialise(CPs_InStream* pStream);
- BOOL CPSLOCAL_Read(CPs_InStream* pStream, void* pDestBuffer, const unsigned int iBytesToRead, unsigned int* piBytesRead);
- void CPSLOCAL_Seek(CPs_InStream* pStream, const unsigned int iNewOffset);
- unsigned int CPSLOCAL_GetLength(CPs_InStream* pStream);
- BOOL CPSLOCAL_IsSeekable(CPs_InStream* pStream);
- unsigned int CPSLOCAL_Tell(CPs_InStream* pStream);
- CPs_InStream* CP_CreateInStream_LocalFile(const char* pcFlexiURL, HWND hWndOwner)
- {
- HANDLE hFile;
- hFile = CreateFile(pcFlexiURL, GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
- OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
- if(hFile == INVALID_HANDLE_VALUE)
- return NULL;
- {
- CPs_InStream* pNewStream = (CPs_InStream*)malloc(sizeof(CPs_InStream));
- CPs_InStream_File* pContext = (CPs_InStream_File*)malloc(sizeof(CPs_InStream_File));
- pNewStream->Uninitialise = CPSLOCAL_Uninitialise;
- pNewStream->Read = CPSLOCAL_Read;
- pNewStream->Seek = CPSLOCAL_Seek;
- pNewStream->Tell = CPSLOCAL_Tell;
- pNewStream->GetLength = CPSLOCAL_GetLength;
- pNewStream->IsSeekable = CPSLOCAL_IsSeekable;
- pNewStream->m_pModuleCookie = pContext;
- pContext->m_hFile = hFile;
- return pNewStream;
- }
- }
- //
- void CPSLOCAL_Uninitialise(CPs_InStream* pStream)
- {
- CPs_InStream_File* pContext = (CPs_InStream_File*)pStream->m_pModuleCookie;
- CP_CHECKOBJECT(pContext);
- CloseHandle(pContext->m_hFile);
- free(pContext);
- free(pStream);
- }
- //
- BOOL CPSLOCAL_Read(CPs_InStream* pStream, void* pDestBuffer, const unsigned int iBytesToRead, unsigned int* piBytesRead)
- {
- CPs_InStream_File* pContext = (CPs_InStream_File*)pStream->m_pModuleCookie;
- CP_CHECKOBJECT(pContext);
- return ReadFile(pContext->m_hFile, pDestBuffer, iBytesToRead, piBytesRead, 0);
- }
- //
- void CPSLOCAL_Seek(CPs_InStream* pStream, const unsigned int iNewOffset)
- {
- CPs_InStream_File* pContext = (CPs_InStream_File*)pStream->m_pModuleCookie;
- CP_CHECKOBJECT(pContext);
- SetFilePointer(pContext->m_hFile, iNewOffset, 0, FILE_BEGIN);
- }
- //
- unsigned int CPSLOCAL_GetLength(CPs_InStream* pStream)
- {
- CPs_InStream_File* pContext = (CPs_InStream_File*)pStream->m_pModuleCookie;
- CP_CHECKOBJECT(pContext);
- return GetFileSize(pContext->m_hFile, NULL);
- }
- //
- BOOL CPSLOCAL_IsSeekable(CPs_InStream* pStream)
- {
- return TRUE;
- }
- //
- #define GetFilePointer(hFile) SetFilePointer(hFile, 0, NULL, FILE_CURRENT)
- unsigned int CPSLOCAL_Tell(CPs_InStream* pStream)
- {
- CPs_InStream_File* pContext = (CPs_InStream_File*)pStream->m_pModuleCookie;
- CP_CHECKOBJECT(pContext);
- return GetFilePointer(pContext->m_hFile);
- }