#include "chrome/browser/media/webrtc/webrtc_rtp_dump_writer.h"
#include <string.h>
#include "base/containers/extend.h"
#include "base/containers/span.h"
#include "base/containers/span_writer.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/numerics/byte_conversions.h"
#include "base/task/thread_pool.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/zlib/zlib.h"
namespace {
static const size_t kMinimumGzipOutputBufferSize = …;
const char kRtpDumpFileHeaderFirstLine[] = …;
static const size_t kRtpDumpFileHeaderSize = …;
void WriteRtpDumpFileHeaderBigEndian(base::TimeTicks start,
std::vector<uint8_t>* output) { … }
static const size_t kPacketDumpHeaderSize = …;
void WritePacketDumpHeaderBigEndian(const base::TimeTicks& start,
uint16_t dump_length,
uint16_t packet_length,
std::vector<uint8_t>* output) { … }
}
class WebRtcRtpDumpWriter::FileWorker { … };
WebRtcRtpDumpWriter::WebRtcRtpDumpWriter(
const base::FilePath& incoming_dump_path,
const base::FilePath& outgoing_dump_path,
size_t max_dump_size,
base::RepeatingClosure max_dump_size_reached_callback)
: … { … }
WebRtcRtpDumpWriter::~WebRtcRtpDumpWriter() { … }
void WebRtcRtpDumpWriter::WriteRtpPacket(const uint8_t* packet_header,
size_t header_length,
size_t packet_length,
bool incoming) { … }
void WebRtcRtpDumpWriter::EndDump(RtpDumpType type,
EndDumpCallback finished_callback) { … }
size_t WebRtcRtpDumpWriter::max_dump_size() const { … }
WebRtcRtpDumpWriter::EndDumpContext::EndDumpContext(RtpDumpType type,
EndDumpCallback callback)
: … { … }
WebRtcRtpDumpWriter::EndDumpContext::EndDumpContext(EndDumpContext&& other) =
default;
WebRtcRtpDumpWriter::EndDumpContext::~EndDumpContext() = default;
void WebRtcRtpDumpWriter::FlushBuffer(bool incoming,
bool end_stream,
FlushDoneCallback callback) { … }
void WebRtcRtpDumpWriter::OnFlushDone(
FlushDoneCallback callback,
const std::unique_ptr<FlushResult>& result,
const std::unique_ptr<size_t>& bytes_written) { … }
void WebRtcRtpDumpWriter::OnDumpEnded(EndDumpContext context,
bool incoming,
bool success) { … }