StampedOggPacket.cpp

Go to the documentation of this file.
00001 //===========================================================================
00002 //Copyright (C) 2003, 2004 Zentaro Kavanagh
00003 //
00004 //Redistribution and use in source and binary forms, with or without
00005 //modification, are permitted provided that the following conditions
00006 //are met:
00007 //
00008 //- Redistributions of source code must retain the above copyright
00009 //  notice, this list of conditions and the following disclaimer.
00010 //
00011 //- Redistributions in binary form must reproduce the above copyright
00012 //  notice, this list of conditions and the following disclaimer in the
00013 //  documentation and/or other materials provided with the distribution.
00014 //
00015 //- Neither the name of Zentaro Kavanagh nor the names of contributors 
00016 //  may be used to endorse or promote products derived from this software 
00017 //  without specific prior written permission.
00018 //
00019 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020 //``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021 //LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00022 //PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
00023 //CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00024 //EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00025 //PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026 //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027 //LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028 //NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 //===========================================================================
00031 
00032 #include "stdafx.h"
00033 #include <libOOOgg/StampedOggPacket.h>
00034 
00035 StampedOggPacket::StampedOggPacket(void)
00036         //:     OggPacket()
00037         :       mStampType(NONE)
00038         ,       mStartTime(0)
00039         ,       mEndTime(0)
00040 
00041 {
00042 }
00043 
00044 StampedOggPacket::~StampedOggPacket(void)
00045 {
00046 }
00047 
00048 StampedOggPacket::StampedOggPacket(unsigned char* inPackData, unsigned long inPacketSize, bool inIsTruncated, bool inIsContinuation, LOOG_INT64 inStartTime = 0, LOOG_INT64 inEndTime = 0, unsigned short inStampType = 0)
00049         :       OggPacket(inPackData, inPacketSize, inIsTruncated, inIsContinuation)
00050         ,       mStartTime(inStartTime)
00051         ,       mEndTime(inEndTime)
00052         ,       mStampType(inStampType)
00053         
00054         
00055 {
00056         //mStampType =inStampType;
00057 }
00058 
00059 void StampedOggPacket::merge(const StampedOggPacket* inMorePacket) {
00060 
00061         //Make a new buffer the size of both data segs together
00062         unsigned char* locBuff = new unsigned char[mPacketSize + inMorePacket->mPacketSize];            //Stored in the member var and deleted by base destructor
00063         //Copy this packets data to the start
00064         memcpy((void*)locBuff, (const void*)mPacketData, mPacketSize);
00065         //Copy the next packets data after it
00066         memcpy((void*)(locBuff + mPacketSize), (const void*)inMorePacket->mPacketData, inMorePacket->mPacketSize);
00067         //Delete our original packet data
00068         delete[] mPacketData;
00069         //Now make our data be the combined data
00070         mPacketData = locBuff;
00071         //Make the size the sum of both packets
00072         mPacketSize += inMorePacket->mPacketSize;
00073 
00074         //Copy time stamping
00075 
00076         
00077         //Don't copy start stamp, keep the current packets start stamp.
00078         //mStartTime = inMorePacket->startTime();
00079         //
00080         mEndTime = inMorePacket->mEndTime;
00081         mStampType = inMorePacket->mStampType;
00082 
00083         //---::: Changed, uses two flags no.
00084         //If the next part of the packet isn't complete then this packet is not complete.
00085         //mIsComplete = inMorePacket->mIsComplete;
00086 
00087         //The new packet is truncated only if the incoming packet is
00088         mIsTruncated = inMorePacket->mIsTruncated;
00089 
00090         //This is not a continuation... a continuation is a packet that does not start at the start of the real packet.
00091         mIsContinuation = false;
00092 }
00093 
00094 //Returns a packet the caller is responsible for.
00095 OggPacket* StampedOggPacket::clone() {
00096         //Make a new buffer for packet data
00097         unsigned char* locBuff = new unsigned char[mPacketSize];                //Given to constructor of stamped packet... it deletes it.
00098 
00099         //Copy the packet data into the new buffer
00100         memcpy((void*)locBuff, (const void*)mPacketData, mPacketSize);
00101 
00102         //Create the new packet
00103         StampedOggPacket* retPack = new StampedOggPacket(locBuff, mPacketSize, mIsTruncated, mIsContinuation, mStartTime, mEndTime, mStampType);                //Caller takes responsibiility for this.
00104         return retPack;
00105 }
00106 LOOG_INT64 StampedOggPacket::startTime() {
00107         return mStartTime;
00108 }
00109 LOOG_INT64 StampedOggPacket::endTime() {
00110         return mEndTime;
00111 }
00112 
00113 void StampedOggPacket::setStartTime(LOOG_INT64 inStartTime) {
00114         mStartTime = inStartTime;
00115 }
00116 void StampedOggPacket::setEndTime(LOOG_INT64 inEndTime) {
00117         mEndTime = inEndTime;
00118 }
00119 
00120 void StampedOggPacket::setTimeStamp(LOOG_INT64 inStartTime, LOOG_INT64 inEndTime, StampedOggPacket::eStampType inStampType) {
00121         mStartTime = inStartTime;
00122         mEndTime = inEndTime;
00123         mStampType = (unsigned short)inStampType;
00124 }

Generated on Tue Feb 15 14:54:21 2005 for oggdsf by  doxygen 1.3.9