[xiph-commits] r7624 - trunk/oggdsf/src/lib/core/directshow/dsfOggDemux

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Tue Aug 24 08:08:43 PDT 2004


Author: illiminable
Date: 2004-08-24 08:08:42 -0700 (Tue, 24 Aug 2004)
New Revision: 7624

Added:
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.h
Modified:
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj
Log:
* Added a basic file cache system for network support.

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.cpp	2004-08-24 14:47:24 UTC (rev 7623)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.cpp	2004-08-24 15:08:42 UTC (rev 7624)
@@ -0,0 +1,39 @@
+#include "StdAfx.h"
+#include ".\singlemediafilecache.h"
+
+SingleMediaFileCache::SingleMediaFileCache(void)
+{
+}
+
+SingleMediaFileCache::~SingleMediaFileCache(void)
+{
+}
+
+bool SingleMediaFileCache::open(string inFileName) {
+	mLocalFile.open(inFileName.c_str(), ios_base::in|ios_base::out|ios_base::binary);
+	return mLocalFile.is_open();
+}
+void SingleMediaFileCache::close() {
+	mLocalFile.close();
+	
+}
+bool SingleMediaFileCache::write(const unsigned char* inBuff, unsigned long inBuffSize) {
+	if (inBuffSize != 0) {
+		mLocalFile.write((const char*)inBuff, inBuffSize);
+		mBytesWritten += inBuffSize;
+	}
+
+	return mLocalFile.fail();
+}
+unsigned long SingleMediaFileCache::read(unsigned char* outBuff, unsigned long inBuffSize) {
+	mLocalFile.read((char*)outBuff, inBuffSize);
+	return mLocalFile.gcount();
+}
+bool SingleMediaFileCache::readSeek(unsigned long inSeekPos) {
+	if (inSeekPos < mBytesWritten) {
+		mLocalFile.seekg(inSeekPos);
+		return true;
+	} else {
+		return false;
+	}
+}
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.h	2004-08-24 14:47:24 UTC (rev 7623)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.h	2004-08-24 15:08:42 UTC (rev 7624)
@@ -0,0 +1,32 @@
+#pragma once
+
+//This class will be a cache of a single media file.
+//It will only allow a single chunk of data to be cached...
+// ie you can't cache bytes 0-1000 and 2000-3000...
+// only consecutive blocks for now.
+//
+//Data can be read randomly... but only written sequentially.
+//Will act as a buffer so that data read off the network can be put straight
+// into the file and then read as needed.
+
+#include <string>
+#include <fstream>
+using namespace std;
+class SingleMediaFileCache
+{
+public:
+	SingleMediaFileCache(void);
+	~SingleMediaFileCache(void);
+
+	bool open(string inFileName);
+	void close();
+	bool write(const unsigned char* inBuff, unsigned long inBuffSize);
+	unsigned long read(unsigned char* outBuff, unsigned long inBuffSize);
+	bool readSeek(unsigned long inSeekPos);
+protected:
+	fstream mLocalFile;
+
+	unsigned long mBytesWritten;
+	
+	bool mIsComplete;
+};

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj	2004-08-24 14:47:24 UTC (rev 7623)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj	2004-08-24 15:08:42 UTC (rev 7624)
@@ -188,6 +188,9 @@
 				RelativePath="RegWrap.cpp">
 			</File>
 			<File
+				RelativePath=".\SingleMediaFileCache.cpp">
+			</File>
+			<File
 				RelativePath="SpeexStream.cpp">
 			</File>
 			<File
@@ -267,6 +270,9 @@
 				RelativePath="resource.h">
 			</File>
 			<File
+				RelativePath=".\SingleMediaFileCache.h">
+			</File>
+			<File
 				RelativePath="SpeexStream.h">
 			</File>
 			<File



More information about the commits mailing list