Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: webrtc/modules/audio_coding/neteq/tools/rtp_file_source.cc

Issue 1697823002: Replace scoped_ptr with unique_ptr in webrtc/modules/audio_coding/neteq/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@up-codecs
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" 11 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <string.h> 14 #include <string.h>
15 #ifdef WIN32 15 #ifdef WIN32
16 #include <winsock2.h> 16 #include <winsock2.h>
17 #else 17 #else
18 #include <netinet/in.h> 18 #include <netinet/in.h>
19 #endif 19 #endif
20 20
21 #include <memory>
22
21 #include "webrtc/base/checks.h" 23 #include "webrtc/base/checks.h"
22 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" 24 #include "webrtc/modules/audio_coding/neteq/tools/packet.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 25 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
24 #include "webrtc/test/rtp_file_reader.h" 26 #include "webrtc/test/rtp_file_reader.h"
25 27
26 namespace webrtc { 28 namespace webrtc {
27 namespace test { 29 namespace test {
28 30
29 RtpFileSource* RtpFileSource::Create(const std::string& file_name) { 31 RtpFileSource* RtpFileSource::Create(const std::string& file_name) {
30 RtpFileSource* source = new RtpFileSource(); 32 RtpFileSource* source = new RtpFileSource();
31 RTC_CHECK(source->OpenFile(file_name)); 33 RTC_CHECK(source->OpenFile(file_name));
32 return source; 34 return source;
33 } 35 }
34 36
35 bool RtpFileSource::ValidRtpDump(const std::string& file_name) { 37 bool RtpFileSource::ValidRtpDump(const std::string& file_name) {
36 rtc::scoped_ptr<RtpFileReader> temp_file( 38 std::unique_ptr<RtpFileReader> temp_file(
37 RtpFileReader::Create(RtpFileReader::kRtpDump, file_name)); 39 RtpFileReader::Create(RtpFileReader::kRtpDump, file_name));
38 return !!temp_file; 40 return !!temp_file;
39 } 41 }
40 42
41 bool RtpFileSource::ValidPcap(const std::string& file_name) { 43 bool RtpFileSource::ValidPcap(const std::string& file_name) {
42 rtc::scoped_ptr<RtpFileReader> temp_file( 44 std::unique_ptr<RtpFileReader> temp_file(
43 RtpFileReader::Create(RtpFileReader::kPcap, file_name)); 45 RtpFileReader::Create(RtpFileReader::kPcap, file_name));
44 return !!temp_file; 46 return !!temp_file;
45 } 47 }
46 48
47 RtpFileSource::~RtpFileSource() { 49 RtpFileSource::~RtpFileSource() {
48 } 50 }
49 51
50 bool RtpFileSource::RegisterRtpHeaderExtension(RTPExtensionType type, 52 bool RtpFileSource::RegisterRtpHeaderExtension(RTPExtensionType type,
51 uint8_t id) { 53 uint8_t id) {
52 assert(parser_.get()); 54 assert(parser_.get());
53 return parser_->RegisterRtpHeaderExtension(type, id); 55 return parser_->RegisterRtpHeaderExtension(type, id);
54 } 56 }
55 57
56 Packet* RtpFileSource::NextPacket() { 58 Packet* RtpFileSource::NextPacket() {
57 while (true) { 59 while (true) {
58 RtpPacket temp_packet; 60 RtpPacket temp_packet;
59 if (!rtp_reader_->NextPacket(&temp_packet)) { 61 if (!rtp_reader_->NextPacket(&temp_packet)) {
60 return NULL; 62 return NULL;
61 } 63 }
62 if (temp_packet.original_length == 0) { 64 if (temp_packet.original_length == 0) {
63 // May be an RTCP packet. 65 // May be an RTCP packet.
64 // Read the next one. 66 // Read the next one.
65 continue; 67 continue;
66 } 68 }
67 rtc::scoped_ptr<uint8_t[]> packet_memory(new uint8_t[temp_packet.length]); 69 std::unique_ptr<uint8_t[]> packet_memory(new uint8_t[temp_packet.length]);
68 memcpy(packet_memory.get(), temp_packet.data, temp_packet.length); 70 memcpy(packet_memory.get(), temp_packet.data, temp_packet.length);
69 rtc::scoped_ptr<Packet> packet(new Packet( 71 std::unique_ptr<Packet> packet(new Packet(
70 packet_memory.release(), temp_packet.length, 72 packet_memory.release(), temp_packet.length,
71 temp_packet.original_length, temp_packet.time_ms, *parser_.get())); 73 temp_packet.original_length, temp_packet.time_ms, *parser_.get()));
72 if (!packet->valid_header()) { 74 if (!packet->valid_header()) {
73 assert(false); 75 assert(false);
74 return NULL; 76 return NULL;
75 } 77 }
76 if (filter_.test(packet->header().payloadType) || 78 if (filter_.test(packet->header().payloadType) ||
77 (use_ssrc_filter_ && packet->header().ssrc != ssrc_)) { 79 (use_ssrc_filter_ && packet->header().ssrc != ssrc_)) {
78 // This payload type should be filtered out. Continue to the next packet. 80 // This payload type should be filtered out. Continue to the next packet.
79 continue; 81 continue;
(...skipping 13 matching lines...) Expand all
93 rtp_reader_.reset(RtpFileReader::Create(RtpFileReader::kPcap, file_name)); 95 rtp_reader_.reset(RtpFileReader::Create(RtpFileReader::kPcap, file_name));
94 if (!rtp_reader_) { 96 if (!rtp_reader_) {
95 FATAL() << "Couldn't open input file as either a rtpdump or .pcap. Note " 97 FATAL() << "Couldn't open input file as either a rtpdump or .pcap. Note "
96 "that .pcapng is not supported."; 98 "that .pcapng is not supported.";
97 } 99 }
98 return true; 100 return true;
99 } 101 }
100 102
101 } // namespace test 103 } // namespace test
102 } // namespace webrtc 104 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h ('k') | webrtc/modules/audio_coding/neteq/tools/rtpcat.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698