[xiph-commits] r7302 -
illiminable at dactyl.lonelymoon.com
illiminable
Fri Jul 23 23:50:54 PDT 2004
trunk/oggdsf/src/lib/core/ogg/libVorbisComment
Message-ID: <20040724065054.C34F69AAAB at dactyl.lonelymoon.com>
Author: illiminable
Date: Fri Jul 23 23:50:54 2004
New Revision: 7302
Added:
trunk/oggdsf/src/lib/core/ogg/libVorbisComment/FileComments.cpp
trunk/oggdsf/src/lib/core/ogg/libVorbisComment/FileComments.h
trunk/oggdsf/src/lib/core/ogg/libVorbisComment/StreamCommentInfo.cpp
trunk/oggdsf/src/lib/core/ogg/libVorbisComment/StreamCommentInfo.h
Modified:
trunk/oggdsf/src/lib/core/ogg/libVorbisComment/libVorbisComment.vcproj
Log:
* Improvements to comment library.
Added: trunk/oggdsf/src/lib/core/ogg/libVorbisComment/FileComments.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libVorbisComment/FileComments.cpp 2004-07-24 05:45:50 UTC (rev 7301)
+++ trunk/oggdsf/src/lib/core/ogg/libVorbisComment/FileComments.cpp 2004-07-24 06:50:52 UTC (rev 7302)
@@ -0,0 +1,94 @@
+#include "StdAfx.h"
+#include ".\filecomments.h"
+
+FileComments::FileComments(void)
+ : mMinorStreamCount(0)
+{
+}
+
+FileComments::~FileComments(void)
+{
+}
+
+bool FileComments::acceptOggPage(OggPage* inOggPage) {
+ //Get a callback... check whether we have a comment.
+ VorbisComments* locVorbisComments = NULL;
+ StreamCommentInfo* locStreamInfo = NULL;
+ for (unsigned long i = 0; i < inOggPage->numPackets(); i++) {
+ OggPacket* locPacket = NULL;
+ locPacket = inOggPage->getPacket(i);
+ if (strncmp((const char*)locPacket->packetData(), "\003vorbis", 7) == 0) {
+ //Comment Packet
+ locVorbisComments = new VorbisComments;
+ locStreamInfo = new StreamCommentInfo;
+ bool locIsOK = locVorbisComments->parseOggPacket(locPacket, 7);
+
+ locStreamInfo->setCodecID(StreamCommentInfo::VORBIS);
+ locStreamInfo->setPageStart(mBytePos);
+ locStreamInfo->setComments(locVorbisComments);
+ locStreamInfo->setMajorStreamNo(0); //Temp... increase for chaining
+ locStreamInfo->setMinorStreamNo(mMinorStreamCount);
+
+ mMinorStreamCount++;
+
+
+ } else if ((strncmp((char*)locPacket->packetData(), "\201theora", 7)) == 0) {
+ bool locIsOK = locVorbisComments->parseOggPacket(locPacket, 7);
+ locStreamInfo->setCodecID(StreamCommentInfo::THEORA);
+ locStreamInfo->setPageStart(mBytePos);
+ locStreamInfo->setComments(locVorbisComments);
+ locStreamInfo->setMajorStreamNo(0); //Temp... increase for chaining
+ locStreamInfo->setMinorStreamNo(mMinorStreamCount);
+
+ mMinorStreamCount++;
+ }
+ }
+
+ return true;
+
+}
+bool FileComments::loadFile(string inFileName) {
+ mBytePos = 0;
+ const unsigned long BUFF_SIZE = 4096;
+ OggDataBuffer locOggBuff;
+
+ locOggBuff.registerVirtualCallback(this);
+
+ fstream locFile;
+ locFile.open(inFileName.c_str(), ios_base::in | ios_base::binary);
+ if (locFile.is_open() != true) {
+ return false;
+ }
+ char* locBuff = new char[BUFF_SIZE];
+ unsigned long locBytesRead = 0;
+ while (!locFile.eof()) {
+ locFile.read(locBuff, BUFF_SIZE);
+ locBytesRead = locFile.gcount();
+ locOggBuff.feed(locBuff, locBytesRead);
+ }
+
+ delete locBuff;
+
+}
+string FileComments::fileName() {
+ return mFileName;
+}
+
+bool FileComments::writeOutAll() {
+ return false;
+}
+bool FileComments::writeOutStream(unsigned long inIndex) {
+ return false;
+}
+
+bool FileComments::addStreamComment(StreamCommentInfo* inStreamComment) {
+ mStreams.push_back(inStreamComment);
+ return true;
+}
+StreamCommentInfo* FileComments::getStreamComment(unsigned long inIndex) {
+ if (inIndex < mStreams.size()) {
+ return mStreams[inIndex];
+ } else {
+ return NULL;
+ }
+}
Added: trunk/oggdsf/src/lib/core/ogg/libVorbisComment/FileComments.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libVorbisComment/FileComments.h 2004-07-24 05:45:50 UTC (rev 7301)
+++ trunk/oggdsf/src/lib/core/ogg/libVorbisComment/FileComments.h 2004-07-24 06:50:52 UTC (rev 7302)
@@ -0,0 +1,36 @@
+#pragma once
+#include "IOggCallback.h"
+#include "StreamCommentInfo.h"
+#include "OggPage.h"
+#include "OggDataBuffer.h"
+#include <string>
+#include <vector>
+
+using namespace std;
+
+class FileComments
+ : public IOggCallback
+{
+public:
+ FileComments(void);
+ ~FileComments(void);
+
+
+
+ bool loadFile(string inFileName);
+ string fileName();
+
+ bool writeOutAll();
+ bool writeOutStream(unsigned long inIndex);
+
+ bool addStreamComment(StreamCommentInfo* inStreamComment);
+ StreamCommentInfo* getStreamComment(unsigned long inIndex);
+
+ //IOggCallback implementation
+ virtual bool acceptOggPage(OggPage* inOggPage);
+protected:
+ vector<StreamCommentInfo*> mStreams;
+ string mFileName;
+ unsigned long mMinorStreamCount;
+ __int64 mBytePos;
+};
Added: trunk/oggdsf/src/lib/core/ogg/libVorbisComment/StreamCommentInfo.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libVorbisComment/StreamCommentInfo.cpp 2004-07-24 05:45:50 UTC (rev 7301)
+++ trunk/oggdsf/src/lib/core/ogg/libVorbisComment/StreamCommentInfo.cpp 2004-07-24 06:50:52 UTC (rev 7302)
@@ -0,0 +1,57 @@
+#include "StdAfx.h"
+#include ".\streamcommentinfo.h"
+
+StreamCommentInfo::StreamCommentInfo(void)
+ : mIsDirty(false)
+ , mPageStart(0)
+ , mCodecID(NO_CODEC)
+ , mComments(NULL)
+{
+}
+
+StreamCommentInfo::~StreamCommentInfo(void)
+{
+ delete mComments;
+}
+
+
+VorbisComments* StreamCommentInfo::comments() {
+ return mComments;
+}
+void StreamCommentInfo::setComments(VorbisComments* inComments) {
+ mComments = inComments;
+}
+__int64 StreamCommentInfo::pageStart() {
+ return mPageStart;
+
+}
+void StreamCommentInfo::setPageStart(__int64 inPageStart) {
+ mPageStart = inPageStart;
+}
+unsigned short StreamCommentInfo::codecID() {
+ return mCodecID;
+}
+void StreamCommentInfo::setCodecID(unsigned short inCodecID) {
+ mCodecID = inCodecID;
+}
+
+bool StreamCommentInfo::isDirty() {
+ return mIsDirty;
+}
+void StreamCommentInfo::setIsDirty(bool inIsDirty) {
+ mIsDirty = inIsDirty;
+}
+
+unsigned long StreamCommentInfo::majorStreamNo() {
+ return mMajorStreamNo;
+}
+void StreamCommentInfo::setMajorStreamNo(unsigned long inMajorStreamNo) {
+ mMajorStreamNo = inMajorStreamNo;
+}
+
+unsigned long StreamCommentInfo::minorStreamNo() {
+ return mMinorStreamNo;
+}
+void StreamCommentInfo::setMinorStreamNo(unsigned long inMinorStreamNo) {
+ mMinorStreamNo = inMinorStreamNo;
+}
Added: trunk/oggdsf/src/lib/core/ogg/libVorbisComment/StreamCommentInfo.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libVorbisComment/StreamCommentInfo.h 2004-07-24 05:45:50 UTC (rev 7301)
+++ trunk/oggdsf/src/lib/core/ogg/libVorbisComment/StreamCommentInfo.h 2004-07-24 06:50:52 UTC (rev 7302)
@@ -0,0 +1,42 @@
+#pragma once
+#include "VorbisComments.h"
+class StreamCommentInfo
+{
+public:
+ StreamCommentInfo(void);
+ ~StreamCommentInfo(void);
+
+ enum eCodecIDs {
+ NO_CODEC = 0,
+ VORBIS = 1,
+ THEORA = 2
+
+ };
+ VorbisComments* comments();
+ void setComments(VorbisComments* inComments);
+
+ __int64 pageStart();
+ void setPageStart(__int64 inPageStart);
+
+ unsigned short codecID();
+ void setCodecID(unsigned short inCodecID);
+
+ bool isDirty();
+ void setIsDirty(bool inIsDirty);
+
+ unsigned long majorStreamNo();
+ void setMajorStreamNo(unsigned long inMajorStreamNo);
+
+ unsigned long minorStreamNo();
+ void setMinorStreamNo(unsigned long inMinorStreamNo);
+
+protected:
+ VorbisComments* mComments;
+ __int64 mPageStart;
+ unsigned short mCodecID;
+
+ bool mIsDirty;
+
+ unsigned long mMajorStreamNo;
+ unsigned long mMinorStreamNo;
+};
Modified: trunk/oggdsf/src/lib/core/ogg/libVorbisComment/libVorbisComment.vcproj
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libVorbisComment/libVorbisComment.vcproj 2004-07-24 05:45:50 UTC (rev 7301)
+++ trunk/oggdsf/src/lib/core/ogg/libVorbisComment/libVorbisComment.vcproj 2004-07-24 06:50:52 UTC (rev 7302)
@@ -127,6 +127,9 @@
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
+ RelativePath=".\FileComments.cpp">
+ </File>
+ <File
RelativePath="libVorbisComment.cpp">
</File>
<File
@@ -148,6 +151,9 @@
</FileConfiguration>
</File>
<File
+ RelativePath=".\StreamCommentInfo.cpp">
+ </File>
+ <File
RelativePath="VorbisComments.cpp">
</File>
</Filter>
@@ -155,6 +161,9 @@
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
+ RelativePath=".\FileComments.h">
+ </File>
+ <File
RelativePath="libVorbisComment.h">
</File>
<File
@@ -164,6 +173,9 @@
RelativePath="stdafx.h">
</File>
<File
+ RelativePath=".\StreamCommentInfo.h">
+ </File>
+ <File
RelativePath="VorbisComments.h">
</File>
</Filter>
More information about the commits
mailing list