1b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org/*
2b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *
4b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Use of this source code is governed by a BSD-style license
5b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  that can be found in the LICENSE file in the root of the source
6b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  tree. An additional intellectual property rights grant can be found
7b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  in the file PATENTS.  All contributing project authors may
8b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
9b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org */
10b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
11b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// This file implements a class that writes a stream of RTP and RTCP packets
12b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// to a file according to the format specified by rtpplay. See
13b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// http://www.cs.columbia.edu/irt/software/rtptools/.
14b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Notes: supported platforms are Windows, Linux and Mac OSX
15b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
16b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#ifndef WEBRTC_MODULES_UTILITY_INTERFACE_RTP_DUMP_H_
17b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#define WEBRTC_MODULES_UTILITY_INTERFACE_RTP_DUMP_H_
18b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
19f72d6b0ae18a7d27c6437397eda03beb4e60e5abpbos@webrtc.org#include "webrtc/system_wrappers/interface/file_wrapper.h"
20f72d6b0ae18a7d27c6437397eda03beb4e60e5abpbos@webrtc.org#include "webrtc/typedefs.h"
21b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
22b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgnamespace webrtc {
23b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass RtpDump
24b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org{
25b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgpublic:
26b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Factory method.
27b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    static RtpDump* CreateRtpDump();
28b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
29b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Delete function. Destructor disabled.
30b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    static void DestroyRtpDump(RtpDump* object);
31b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
32b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Open the file fileNameUTF8 for writing RTP/RTCP packets.
33b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Note: this API also adds the rtpplay header.
34f85a509a2d847b32cddf23d077d83fc0601a43d7pbos@webrtc.org    virtual int32_t Start(const char* fileNameUTF8) = 0;
35b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
36b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Close the existing file. No more packets will be recorded.
37f85a509a2d847b32cddf23d077d83fc0601a43d7pbos@webrtc.org    virtual int32_t Stop() = 0;
38b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
39b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Return true if a file is open for recording RTP/RTCP packets.
40b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    virtual bool IsActive() const = 0;
41b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
42b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Writes the RTP/RTCP packet in packet with length packetLength in bytes.
43b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Note: packet should contain the RTP/RTCP part of the packet. I.e. the
44b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // first bytes of packet should be the RTP/RTCP header.
45f85a509a2d847b32cddf23d077d83fc0601a43d7pbos@webrtc.org    virtual int32_t DumpPacket(const uint8_t* packet,
46f85a509a2d847b32cddf23d077d83fc0601a43d7pbos@webrtc.org                               uint16_t packetLength) = 0;
47b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
48b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgprotected:
49b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    virtual ~RtpDump();
50b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org};
513b89e10f31160da35b408fd00cb8f89d2b08862dpbos@webrtc.org}  // namespace webrtc
52b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#endif // WEBRTC_MODULES_UTILITY_INTERFACE_RTP_DUMP_H_
53