Skip to content

Commit

Permalink
*Пофиксили утечку
Browse files Browse the repository at this point in the history
*Оптимизировали капельку потребление оперативки
  • Loading branch information
Riflio committed Feb 25, 2018
1 parent 858be11 commit 78ced56
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 26 deletions.
4 changes: 3 additions & 1 deletion Interfaces/irtp_packet.h
Expand Up @@ -8,6 +8,8 @@ typedef char BYTE;
class IRTP_Packet
{
public:
virtual ~IRTP_Packet() {}

virtual int getPayloadStart()=0;
virtual int getPayloadLength()=0;

Expand All @@ -17,7 +19,7 @@ class IRTP_Packet
virtual unsigned int getTimeStamp()=0;
virtual unsigned short getSequence()=0;

virtual QByteArray data()=0;
virtual QByteArray &data()=0;
};

#endif // IRTP_PACKET_H
7 changes: 6 additions & 1 deletion Interfaces/isdp.h
Expand Up @@ -8,6 +8,8 @@
class ISDP
{
public:
virtual ~ISDP() {}

virtual bool parse(QByteArray data)=0;
virtual bool make(QByteArray & data)=0;

Expand Down Expand Up @@ -48,7 +50,10 @@ class ISDP
};

class sMedia {
public:
public:
~sMedia() {
qDeleteAll(attribytes);
}
mediaTypes type; //-- тип
int port; //-- порт
QString profile; //-- профиль
Expand Down
13 changes: 9 additions & 4 deletions rtp/rtp.cpp
Expand Up @@ -47,13 +47,18 @@ long long int RTP::bufOffset()
* @return
*/
bool RTP::getPacket(long long & offset, IRTP_Packet *& packet)
{
QByteArray data;
{

if ( !get(offset, data) ) return false;
RTP_packet * p = new RTP_packet();

packet = new RTP_packet(data);
if ( !get(offset, p->data() ) ) {
delete p;
p = NULL;
packet = NULL;
return false;
}

packet = p;
return true;
}

Expand Down
27 changes: 12 additions & 15 deletions rtp/rtp_packet.cpp
@@ -1,14 +1,13 @@
#include "rtp_packet.h"

RTP_packet::RTP_packet(const QByteArray & packetData ):
_packet(packetData)
RTP_packet::RTP_packet()
{

}

QByteArray RTP_packet::data()
QByteArray &RTP_packet::data()
{
return _packet;
return _data;
}

int RTP_packet::getPayloadStart()
Expand All @@ -18,7 +17,7 @@ int RTP_packet::getPayloadStart()

int RTP_packet::getPayloadLength()
{
return _packet.length() - getPayloadStart();
return _data.length() - getPayloadStart();
}

/**
Expand All @@ -27,26 +26,25 @@ int RTP_packet::getPayloadLength()
*/
BYTE RTP_packet::getCC()
{
BYTE c = (BYTE)((_packet[0]) & 0x0f);
BYTE c = (BYTE)((_data[0]) & 0x0f);
return c;
}

bool RTP_packet::hasPadding()
{
return ((_packet[0] & 0x20) >> 5) == 1;
return ((_data[0] & 0x20) >> 5) == 1;
}


unsigned int RTP_packet::getTimeStamp()
{
QByteArray ba = _packet;
{
int idx = 4; //-- с какой позиции начиная

//-- собираем 4 байта в int
unsigned int i = (((ba[idx] << 24) & 0xFF000000L)
| ((ba[idx + 1] << 16) & 0xFF0000L)
| (ba[idx + 2] << 8 & 0xFF00L)
| (ba[idx + 3] & 0xFFL));
unsigned int i = (((_data[idx] << 24) & 0xFF000000L)
| ((_data[idx + 1] << 16) & 0xFF0000L)
| (_data[idx + 2] << 8 & 0xFF00L)
| (_data[idx + 3] & 0xFFL));

return i;
}
Expand All @@ -56,11 +54,10 @@ unsigned short RTP_packet::getSequence()
{
unsigned short s;

QByteArray ba = _packet;
int idx = 2; //-- с какой позиции начиная

//-- собираем 2 байта в unsigned short
s = (((ba[idx] << 8) & 0xFF00) | (ba[idx+1] & 0xFF));
s = (((_data[idx] << 8) & 0xFF00) | (_data[idx+1] & 0xFF));

return s;
}
8 changes: 4 additions & 4 deletions rtp/rtp_packet.h
Expand Up @@ -8,8 +8,8 @@
class RTP_packet: public IRTP_Packet
{
public:
RTP_packet(const QByteArray & packetData );

RTP_packet();
virtual ~RTP_packet() {}

int getPayloadStart();
int getPayloadLength();
Expand All @@ -21,10 +21,10 @@ class RTP_packet: public IRTP_Packet
unsigned short getSequence();
const int RTP_HEADER_SIZE = 12;

QByteArray data();
QByteArray & data();

private:
QByteArray _packet;
QByteArray _data;
};

#endif // RTP_PACKET_H
2 changes: 1 addition & 1 deletion sdp/sdp.cpp
Expand Up @@ -170,7 +170,7 @@ bool SDP::make(QByteArray & data)

SDP::~SDP()
{
//TODO: доделать бы освобождение памяти :P
qDeleteAll(medias);
}


Expand Down

0 comments on commit 78ced56

Please sign in to comment.