void splitForSend(const INFPacket& src, PacketList& destList){
        //clear out queue
        destList.clear();

        //segments
        std::vector<Uint8> tmp;
        tmp.reserve(maxSendSize);

        size_t dataIndex = 0;
        Uint16 len = 0;
        Uint8 len_buff[2];
        unsigned int remaining = 0;
        while( dataIndex < src.data.size() ){
            //  Packet header
            if( dataIndex == 0 ){
                tmp.push_back(ControlByte::START.getVal() );
            } else {
                tmp.push_back(ControlByte::CONTINUE.getVal() );
            }

            //  data
            //minus 2 from maxSendSize for the START/END
            //minus 2 again, becuase 2 bytes are used to store the length
            //  of this segment

            //how much of the input data is left to be packed
            remaining = src.data.size() - dataIndex;
            //the length of the next segment
            if( remaining > (maxSendSize-4) ){
                len = (maxSendSize-4);
            } else {
                len = remaining;
            }
            //insert the length of this segment
            SDLNet_Write16(len, len_buff);
            tmp.push_back( len_buff[0] );
            tmp.push_back( len_buff[1] );

            //write the actual data
            for(int i = 0; i < len; ++i){
                tmp.push_back( src.data[dataIndex] );
                ++dataIndex;
            }

            //  Packet footer
            if( dataIndex == src.getLength() ){
                tmp.push_back(ControlByte::END.getVal() );
            } else {
                tmp.push_back(ControlByte::WAIT_MORE.getVal() );
            }

            //  Put the packet on the list
            destList.push_back(tmp);
            tmp.clear();
        }
    }
Esempio n. 2
0
void CutupProtocol::FreePackets( PacketList& packetList ) const
{
	PacketList::iterator iter = packetList.begin();
	for (; iter != packetList.end(); iter++)
	{
		FreePacket(*iter);
	}

	packetList.clear();
}
Esempio n. 3
0
File: Demux.cpp Progetto: artcom/y60
void Demux::clearPacketCache()
{
    map<int, PacketList>::iterator it;
    for (it=_myPacketLists.begin(); it != _myPacketLists.end(); ++it) {
        PacketList::iterator it2;
        PacketList* thePacketList = &(it->second);
        for (it2=thePacketList->begin(); it2 != thePacketList->end(); ++it2) {
            av_free_packet(*it2);
            delete *it2;
        }
        thePacketList->clear();
    }
}
Esempio n. 4
0
void FFMpegDemuxer::clearPacketCache()
{
    map<int, PacketList>::iterator it;
    for (it = m_PacketLists.begin(); it != m_PacketLists.end(); ++it) {
        PacketList::iterator it2;
        PacketList* pPacketList = &(it->second);
        for (it2 = pPacketList->begin(); it2 != pPacketList->end(); ++it2) {
            av_free_packet(*it2);
            delete *it2;
        }
        pPacketList->clear();
    }
}
Esempio n. 5
0
File: Demux.cpp Progetto: artcom/y60
void Demux::clearPacketCache(const int theStreamIndex)
{
    if (_myPacketLists.find(theStreamIndex) == _myPacketLists.end()) {
        AC_ERROR << "Demux::clearPacketCache called with nonexistent stream index "
            << theStreamIndex << ".";
    }
    PacketList * myCurPacketList = &(_myPacketLists.find(theStreamIndex)->second);
    PacketList::iterator it;
    for (it=myCurPacketList->begin(); it != myCurPacketList->end(); ++it) {
        av_free_packet(*it);
        delete *it;
    }
    myCurPacketList->clear();
}