blob: 5be9cbe14d97166d6a53ff1dbd5bbf808b766084 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org2559cbf2012-02-27 19:18:25 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_UTILITY_SOURCE_RTP_DUMP_IMPL_H_
12#define WEBRTC_MODULES_UTILITY_SOURCE_RTP_DUMP_IMPL_H_
13
pbos@webrtc.org8b062002013-07-12 08:28:10 +000014#include "webrtc/modules/utility/interface/rtp_dump.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000015
16namespace webrtc {
17class CriticalSectionWrapper;
18class FileWrapper;
19class RtpDumpImpl : public RtpDump
20{
21public:
22 RtpDumpImpl();
23 virtual ~RtpDumpImpl();
24
henrike@webrtc.orgcc774a62014-09-11 22:45:54 +000025 virtual int32_t Start(const char* fileNameUTF8) OVERRIDE;
26 virtual int32_t Stop() OVERRIDE;
27 virtual bool IsActive() const OVERRIDE;
28 virtual int32_t DumpPacket(const uint8_t* packet,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000029 size_t packetLength) OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000030private:
31 // Return the system time in ms.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000032 inline uint32_t GetTimeInMS() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000033 // Return x in network byte order (big endian).
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000034 inline uint32_t RtpDumpHtonl(uint32_t x) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000035 // Return x in network byte order (big endian).
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000036 inline uint16_t RtpDumpHtons(uint16_t x) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000037
38 // Return true if the packet starts with a valid RTCP header.
pbos@webrtc.org62bafae2014-07-08 12:10:51 +000039 // Note: See RtpUtility::RtpHeaderParser::RTCP() for details on how
niklase@google.com470e71d2011-07-07 08:21:25 +000040 // to determine if the packet is an RTCP packet.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000041 bool RTCP(const uint8_t* packet) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000042
43private:
henrike@webrtc.org105e0712011-12-16 19:53:46 +000044 CriticalSectionWrapper* _critSect;
niklase@google.com470e71d2011-07-07 08:21:25 +000045 FileWrapper& _file;
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000046 uint32_t _startTime;
niklase@google.com470e71d2011-07-07 08:21:25 +000047};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000048} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000049#endif // WEBRTC_MODULES_UTILITY_SOURCE_RTP_DUMP_IMPL_H_