- put references to RtpDump to #ifdef USE_RTPDUMP where possible

This commit is contained in:
Dmytro Bogovych 2019-03-14 10:30:38 +02:00
parent eb4d3237c0
commit 11db9b7450
6 changed files with 42 additions and 11 deletions

View File

@ -7,8 +7,11 @@
#include "HL_Exception.h" #include "HL_Exception.h"
#include "HL_String.h" #include "HL_String.h"
#include "jrtplib/src/rtprawpacket.h" #if defined(USE_RTP_DUMP)
#include "jrtplib/src/rtpipv4address.h" # include "jrtplib/src/rtprawpacket.h"
# include "jrtplib/src/rtpipv4address.h"
#endif
#if !defined(TARGET_WIN) #if !defined(TARGET_WIN)
# include <alloca.h> # include <alloca.h>
#endif #endif
@ -97,6 +100,7 @@ int RtpHelper::findPayloadLength(const void* buffer, size_t length)
return -1; return -1;
} }
#if defined(USE_RTPDUMP)
RtpDump::RtpDump(const char *filename) RtpDump::RtpDump(const char *filename)
:mFilename(filename) :mFilename(filename)
{} {}
@ -172,6 +176,8 @@ void RtpDump::flush()
} }
fclose(f); fclose(f);
} }
#endif
// -------------- MediaStreamId -------------------- // -------------- MediaStreamId --------------------
bool MediaStreamId::operator < (const MediaStreamId& right) const bool MediaStreamId::operator < (const MediaStreamId& right) const
@ -206,7 +212,10 @@ void writeToJson(const MediaStreamId& id, std::ostringstream& oss)
oss << " \"src\": \"" << id.mSource.toStdString() << "\"," << std::endl oss << " \"src\": \"" << id.mSource.toStdString() << "\"," << std::endl
<< " \"dst\": \"" << id.mDestination.toStdString() << "\"," << std::endl << " \"dst\": \"" << id.mDestination.toStdString() << "\"," << std::endl
<< " \"ssrc\": \"" << StringHelper::toHex(id.mSSRC) << "\"," << std::endl << " \"ssrc\": \"" << StringHelper::toHex(id.mSSRC) << "\"," << std::endl
<< " \"link_id\": \"" << id.mLinkId.toString() << "\"" << std::endl; #if !defined(USE_NULL_UUID)
<< " \"link_id\": \"" << id.mLinkId.toString() << "\"" << std::endl
#endif
;
} }
std::string MediaStreamId::getDetectDescription() const std::string MediaStreamId::getDetectDescription() const

View File

@ -6,8 +6,15 @@
#ifndef __HL_RTP_H #ifndef __HL_RTP_H
#define __HL_RTP_H #define __HL_RTP_H
#include "jrtplib/src/rtppacket.h" #if defined(USE_RTPDUMP)
#include "HL_Uuid.h" # include "jrtplib/src/rtppacket.h"
#endif
#if !defined(USE_NULL_UUID)
# include "HL_Uuid.h"
#endif
#include "HL_InternetAddress.h" #include "HL_InternetAddress.h"
#include <vector> #include <vector>
@ -42,6 +49,7 @@ public:
static int findPayloadLength(const void* buffer, size_t length); static int findPayloadLength(const void* buffer, size_t length);
}; };
#if defined(USE_RTPDUMP)
class RtpDump class RtpDump
{ {
protected: protected:
@ -66,6 +74,7 @@ public:
void add(const void* data, size_t len); void add(const void* data, size_t len);
void flush(); void flush();
}; };
#endif
struct MediaStreamId struct MediaStreamId
{ {
@ -73,7 +82,9 @@ struct MediaStreamId
InternetAddress mDestination; InternetAddress mDestination;
uint32_t mSSRC = 0; uint32_t mSSRC = 0;
bool mSsrcIsId = true; bool mSsrcIsId = true;
#if !defined(USE_NULL_UUID)
Uuid mLinkId; Uuid mLinkId;
#endif
bool operator < (const MediaStreamId& s2) const; bool operator < (const MediaStreamId& s2) const;
bool operator == (const MediaStreamId& right) const; bool operator == (const MediaStreamId& right) const;

View File

@ -24,7 +24,7 @@ using namespace MT;
AudioStream::AudioStream(const CodecList::Settings& settings) AudioStream::AudioStream(const CodecList::Settings& settings)
:mPacketTime(0), mEncodedTime(0), mCodecSettings(settings), :mPacketTime(0), mEncodedTime(0), mCodecSettings(settings),
mRemoteTelephoneCodec(0), mRtpSession(), mTransmittingPayloadType(-1), mRemoteTelephoneCodec(0), mRtpSession(), mTransmittingPayloadType(-1),
mRtpSender(mStat), mRtpDump(NULL) mRtpSender(mStat)
{ {
mOutputBuffer.setCapacity(16384); mOutputBuffer.setCapacity(16384);
mCapturedAudio.setCapacity(16384); mCapturedAudio.setCapacity(16384);
@ -75,11 +75,13 @@ AudioStream::~AudioStream()
if (mRtpSession.IsActive()) if (mRtpSession.IsActive())
mRtpSession.Destroy(); mRtpSession.Destroy();
#if defined(USE_RTPDUMP)
if (mRtpDump) if (mRtpDump)
{ {
mRtpDump->flush(); mRtpDump->flush();
delete mRtpDump; delete mRtpDump;
} }
#endif
mCaptureResampler8.stop(); mCaptureResampler8.stop();
mCaptureResampler16.stop(); mCaptureResampler16.stop();

View File

@ -79,7 +79,9 @@ namespace MT
NativeRtpSender mRtpSender; NativeRtpSender mRtpSender;
AudioStreamMap mStreamMap; // Map of media streams. Key is RTP's SSRC value. AudioStreamMap mStreamMap; // Map of media streams. Key is RTP's SSRC value.
Audio::DataWindow mOutputBuffer; Audio::DataWindow mOutputBuffer;
RtpDump* mRtpDump; #if defined(USE_RTPDUMP)
RtpDump* mRtpDump = nullptr;
#endif
Audio::Resampler mCaptureResampler8, Audio::Resampler mCaptureResampler8,
mCaptureResampler16, mCaptureResampler16,
mCaptureResampler32, mCaptureResampler32,

View File

@ -1,4 +1,4 @@
/* Copyright(C) 2007-2014 VoIP objects (voipobjects.com) /* Copyright(C) 2007-2019 VoIP objects (voipobjects.com)
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -9,7 +9,7 @@
using namespace MT; using namespace MT;
NativeRtpSender::NativeRtpSender(Statistics& stat) NativeRtpSender::NativeRtpSender(Statistics& stat)
:mDumpWriter(NULL), mStat(stat), mSrtpSession(NULL) :mStat(stat), mSrtpSession(nullptr)
{ {
} }
@ -22,8 +22,10 @@ bool NativeRtpSender::SendRTP(const void *data, size_t len)
if (mTarget.mRtp.isEmpty() || !mSocket.mRtp) if (mTarget.mRtp.isEmpty() || !mSocket.mRtp)
return false; return false;
#if defined(USE_RTPDUMP)
if (mDumpWriter) if (mDumpWriter)
mDumpWriter->add(data, len); mDumpWriter->add(data, len);
#endif
// Copy data to intermediary buffer bigger that original // Copy data to intermediary buffer bigger that original
int sendLength = len; int sendLength = len;
@ -99,6 +101,7 @@ RtpPair<PDatagramSocket>& NativeRtpSender::socket()
return mSocket; return mSocket;
} }
#if defined(USE_RTPDUMP)
void NativeRtpSender::setDumpWriter(RtpDump *dump) void NativeRtpSender::setDumpWriter(RtpDump *dump)
{ {
mDumpWriter = dump; mDumpWriter = dump;
@ -108,6 +111,7 @@ RtpDump* NativeRtpSender::dumpWriter()
{ {
return mDumpWriter; return mDumpWriter;
} }
#endif
void NativeRtpSender::setSrtpSession(SrtpSession* srtp) void NativeRtpSender::setSrtpSession(SrtpSession* srtp)
{ {

View File

@ -39,9 +39,10 @@ namespace MT
void setSocket(const RtpPair<PDatagramSocket>& socket); void setSocket(const RtpPair<PDatagramSocket>& socket);
RtpPair<PDatagramSocket>& socket(); RtpPair<PDatagramSocket>& socket();
#if defined(USE_RTPDUMP)
void setDumpWriter(RtpDump* dump); void setDumpWriter(RtpDump* dump);
RtpDump* dumpWriter(); RtpDump* dumpWriter();
#endif
void setSrtpSession(SrtpSession* srtp); void setSrtpSession(SrtpSession* srtp);
SrtpSession* srtpSession(); SrtpSession* srtpSession();
@ -49,7 +50,9 @@ namespace MT
RtpPair<PDatagramSocket> mSocket; RtpPair<PDatagramSocket> mSocket;
RtpPair<InternetAddress> mTarget; RtpPair<InternetAddress> mTarget;
Statistics& mStat; Statistics& mStat;
RtpDump* mDumpWriter; #if defined(USE_RTPDUMP)
RtpDump* mDumpWriter = nullptr;
#endif
SrtpSession* mSrtpSession; SrtpSession* mSrtpSession;
char mSendBuffer[MAX_VALID_UDPPACKET_SIZE]; char mSendBuffer[MAX_VALID_UDPPACKET_SIZE];
}; };