OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/media/webrtc_rtp_dump_writer.h" | 5 #include "chrome/browser/media/webrtc_rtp_dump_writer.h" |
6 | 6 |
7 #include "base/big_endian.h" | 7 #include "base/big_endian.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 WriteRtpDumpFileHeaderBigEndian(start_time_, dest_buffer); | 299 WriteRtpDumpFileHeaderBigEndian(start_time_, dest_buffer); |
300 } | 300 } |
301 | 301 |
302 size_t packet_dump_length = kPacketDumpHeaderSize + header_length; | 302 size_t packet_dump_length = kPacketDumpHeaderSize + header_length; |
303 | 303 |
304 // Flushes the buffer to disk if the buffer is full. | 304 // Flushes the buffer to disk if the buffer is full. |
305 if (dest_buffer->size() + packet_dump_length > dest_buffer->capacity()) | 305 if (dest_buffer->size() + packet_dump_length > dest_buffer->capacity()) |
306 FlushBuffer(incoming, false, FlushDoneCallback()); | 306 FlushBuffer(incoming, false, FlushDoneCallback()); |
307 | 307 |
308 WritePacketDumpHeaderBigEndian( | 308 WritePacketDumpHeaderBigEndian( |
309 start_time_, packet_dump_length, packet_length, dest_buffer); | 309 start_time_, base::checked_cast<uint16>(packet_dump_length), |
| 310 base::checked_cast<uint16>(packet_length), dest_buffer); |
310 | 311 |
311 // Writes the actual RTP packet header. | 312 // Writes the actual RTP packet header. |
312 AppendToBuffer(packet_header, header_length, dest_buffer); | 313 AppendToBuffer(packet_header, header_length, dest_buffer); |
313 } | 314 } |
314 | 315 |
315 void WebRtcRtpDumpWriter::EndDump(RtpDumpType type, | 316 void WebRtcRtpDumpWriter::EndDump(RtpDumpType type, |
316 const EndDumpCallback& finished_callback) { | 317 const EndDumpCallback& finished_callback) { |
317 DCHECK(thread_checker_.CalledOnValidThread()); | 318 DCHECK(thread_checker_.CalledOnValidThread()); |
318 DCHECK(type == RTP_DUMP_OUTGOING || incoming_file_thread_worker_ != NULL); | 319 DCHECK(type == RTP_DUMP_OUTGOING || incoming_file_thread_worker_ != NULL); |
319 DCHECK(type == RTP_DUMP_INCOMING || outgoing_file_thread_worker_ != NULL); | 320 DCHECK(type == RTP_DUMP_INCOMING || outgoing_file_thread_worker_ != NULL); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 base::Bind(&WebRtcRtpDumpWriter::OnDumpEnded, | 438 base::Bind(&WebRtcRtpDumpWriter::OnDumpEnded, |
438 weak_ptr_factory_.GetWeakPtr(), | 439 weak_ptr_factory_.GetWeakPtr(), |
439 context, | 440 context, |
440 false)); | 441 false)); |
441 return; | 442 return; |
442 } | 443 } |
443 | 444 |
444 // This object might be deleted after running the callback. | 445 // This object might be deleted after running the callback. |
445 context.callback.Run(context.incoming_succeeded, context.outgoing_succeeded); | 446 context.callback.Run(context.incoming_succeeded, context.outgoing_succeeded); |
446 } | 447 } |
OLD | NEW |