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

Side by Side Diff: webrtc/video/replay.cc

Issue 1751903002: Replace scoped_ptr with unique_ptr in webrtc/video/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « webrtc/video/payload_router_unittest.cc ('k') | webrtc/video/send_statistics_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdio.h> 11 #include <stdio.h>
12 12
13 #include <map> 13 #include <map>
14 #include <memory>
14 #include <sstream> 15 #include <sstream>
15 16
16 #include "gflags/gflags.h" 17 #include "gflags/gflags.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
20 #include "webrtc/base/scoped_ptr.h"
21 #include "webrtc/call.h" 21 #include "webrtc/call.h"
22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 23 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
24 #include "webrtc/system_wrappers/include/clock.h" 24 #include "webrtc/system_wrappers/include/clock.h"
25 #include "webrtc/system_wrappers/include/sleep.h" 25 #include "webrtc/system_wrappers/include/sleep.h"
26 #include "webrtc/test/encoder_settings.h" 26 #include "webrtc/test/encoder_settings.h"
27 #include "webrtc/test/null_transport.h" 27 #include "webrtc/test/null_transport.h"
28 #include "webrtc/test/fake_decoder.h" 28 #include "webrtc/test/fake_decoder.h"
29 #include "webrtc/test/rtp_file_reader.h" 29 #include "webrtc/test/rtp_file_reader.h"
30 #include "webrtc/test/run_loop.h" 30 #include "webrtc/test/run_loop.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 virtual void EncodedFrameCallback(const EncodedFrame& encoded_frame) { 203 virtual void EncodedFrameCallback(const EncodedFrame& encoded_frame) {
204 fwrite(encoded_frame.data_, 1, encoded_frame.length_, file_); 204 fwrite(encoded_frame.data_, 1, encoded_frame.length_, file_);
205 } 205 }
206 206
207 private: 207 private:
208 FILE* file_; 208 FILE* file_;
209 }; 209 };
210 210
211 void RtpReplay() { 211 void RtpReplay() {
212 rtc::scoped_ptr<test::VideoRenderer> playback_video( 212 std::unique_ptr<test::VideoRenderer> playback_video(
213 test::VideoRenderer::Create("Playback Video", 640, 480)); 213 test::VideoRenderer::Create("Playback Video", 640, 480));
214 FileRenderPassthrough file_passthrough(flags::OutBase(), 214 FileRenderPassthrough file_passthrough(flags::OutBase(),
215 playback_video.get()); 215 playback_video.get());
216 216
217 rtc::scoped_ptr<Call> call(Call::Create(Call::Config())); 217 std::unique_ptr<Call> call(Call::Create(Call::Config()));
218 218
219 test::NullTransport transport; 219 test::NullTransport transport;
220 VideoReceiveStream::Config receive_config(&transport); 220 VideoReceiveStream::Config receive_config(&transport);
221 receive_config.rtp.remote_ssrc = flags::Ssrc(); 221 receive_config.rtp.remote_ssrc = flags::Ssrc();
222 receive_config.rtp.local_ssrc = kReceiverLocalSsrc; 222 receive_config.rtp.local_ssrc = kReceiverLocalSsrc;
223 receive_config.rtp.fec.ulpfec_payload_type = flags::FecPayloadType(); 223 receive_config.rtp.fec.ulpfec_payload_type = flags::FecPayloadType();
224 receive_config.rtp.fec.red_payload_type = flags::RedPayloadType(); 224 receive_config.rtp.fec.red_payload_type = flags::RedPayloadType();
225 receive_config.rtp.nack.rtp_history_ms = 1000; 225 receive_config.rtp.nack.rtp_history_ms = 1000;
226 if (flags::TransmissionOffsetId() != -1) { 226 if (flags::TransmissionOffsetId() != -1) {
227 receive_config.rtp.extensions.push_back( 227 receive_config.rtp.extensions.push_back(
228 RtpExtension(RtpExtension::kTOffset, flags::TransmissionOffsetId())); 228 RtpExtension(RtpExtension::kTOffset, flags::TransmissionOffsetId()));
229 } 229 }
230 if (flags::AbsSendTimeId() != -1) { 230 if (flags::AbsSendTimeId() != -1) {
231 receive_config.rtp.extensions.push_back( 231 receive_config.rtp.extensions.push_back(
232 RtpExtension(RtpExtension::kAbsSendTime, flags::AbsSendTimeId())); 232 RtpExtension(RtpExtension::kAbsSendTime, flags::AbsSendTimeId()));
233 } 233 }
234 receive_config.renderer = &file_passthrough; 234 receive_config.renderer = &file_passthrough;
235 235
236 VideoSendStream::Config::EncoderSettings encoder_settings; 236 VideoSendStream::Config::EncoderSettings encoder_settings;
237 encoder_settings.payload_name = flags::Codec(); 237 encoder_settings.payload_name = flags::Codec();
238 encoder_settings.payload_type = flags::PayloadType(); 238 encoder_settings.payload_type = flags::PayloadType();
239 VideoReceiveStream::Decoder decoder; 239 VideoReceiveStream::Decoder decoder;
240 rtc::scoped_ptr<DecoderBitstreamFileWriter> bitstream_writer; 240 std::unique_ptr<DecoderBitstreamFileWriter> bitstream_writer;
241 if (!flags::DecoderBitstreamFilename().empty()) { 241 if (!flags::DecoderBitstreamFilename().empty()) {
242 bitstream_writer.reset(new DecoderBitstreamFileWriter( 242 bitstream_writer.reset(new DecoderBitstreamFileWriter(
243 flags::DecoderBitstreamFilename().c_str())); 243 flags::DecoderBitstreamFilename().c_str()));
244 receive_config.pre_decode_callback = bitstream_writer.get(); 244 receive_config.pre_decode_callback = bitstream_writer.get();
245 } 245 }
246 decoder = test::CreateMatchingDecoder(encoder_settings); 246 decoder = test::CreateMatchingDecoder(encoder_settings);
247 if (!flags::DecoderBitstreamFilename().empty()) { 247 if (!flags::DecoderBitstreamFilename().empty()) {
248 // Replace with a null decoder if we're writing the bitstream to a file 248 // Replace with a null decoder if we're writing the bitstream to a file
249 // instead. 249 // instead.
250 delete decoder.decoder; 250 delete decoder.decoder;
251 decoder.decoder = new test::FakeNullDecoder(); 251 decoder.decoder = new test::FakeNullDecoder();
252 } 252 }
253 receive_config.decoders.push_back(decoder); 253 receive_config.decoders.push_back(decoder);
254 254
255 VideoReceiveStream* receive_stream = 255 VideoReceiveStream* receive_stream =
256 call->CreateVideoReceiveStream(receive_config); 256 call->CreateVideoReceiveStream(receive_config);
257 257
258 rtc::scoped_ptr<test::RtpFileReader> rtp_reader(test::RtpFileReader::Create( 258 std::unique_ptr<test::RtpFileReader> rtp_reader(test::RtpFileReader::Create(
259 test::RtpFileReader::kRtpDump, flags::InputFile())); 259 test::RtpFileReader::kRtpDump, flags::InputFile()));
260 if (rtp_reader.get() == nullptr) { 260 if (rtp_reader.get() == nullptr) {
261 rtp_reader.reset(test::RtpFileReader::Create(test::RtpFileReader::kPcap, 261 rtp_reader.reset(test::RtpFileReader::Create(test::RtpFileReader::kPcap,
262 flags::InputFile())); 262 flags::InputFile()));
263 if (rtp_reader.get() == nullptr) { 263 if (rtp_reader.get() == nullptr) {
264 fprintf(stderr, 264 fprintf(stderr,
265 "Couldn't open input file as either a rtpdump or .pcap. Note " 265 "Couldn't open input file as either a rtpdump or .pcap. Note "
266 "that .pcapng is not supported.\nTrying to interpret the file as " 266 "that .pcapng is not supported.\nTrying to interpret the file as "
267 "length/packet interleaved.\n"); 267 "length/packet interleaved.\n");
268 rtp_reader.reset(test::RtpFileReader::Create( 268 rtp_reader.reset(test::RtpFileReader::Create(
(...skipping 14 matching lines...) Expand all
283 test::RtpPacket packet; 283 test::RtpPacket packet;
284 if (!rtp_reader->NextPacket(&packet)) 284 if (!rtp_reader->NextPacket(&packet))
285 break; 285 break;
286 ++num_packets; 286 ++num_packets;
287 switch (call->Receiver()->DeliverPacket(webrtc::MediaType::ANY, packet.data, 287 switch (call->Receiver()->DeliverPacket(webrtc::MediaType::ANY, packet.data,
288 packet.length, PacketTime())) { 288 packet.length, PacketTime())) {
289 case PacketReceiver::DELIVERY_OK: 289 case PacketReceiver::DELIVERY_OK:
290 break; 290 break;
291 case PacketReceiver::DELIVERY_UNKNOWN_SSRC: { 291 case PacketReceiver::DELIVERY_UNKNOWN_SSRC: {
292 RTPHeader header; 292 RTPHeader header;
293 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); 293 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
294 parser->Parse(packet.data, packet.length, &header); 294 parser->Parse(packet.data, packet.length, &header);
295 if (unknown_packets[header.ssrc] == 0) 295 if (unknown_packets[header.ssrc] == 0)
296 fprintf(stderr, "Unknown SSRC: %u!\n", header.ssrc); 296 fprintf(stderr, "Unknown SSRC: %u!\n", header.ssrc);
297 ++unknown_packets[header.ssrc]; 297 ++unknown_packets[header.ssrc];
298 break; 298 break;
299 } 299 }
300 case PacketReceiver::DELIVERY_PACKET_ERROR: 300 case PacketReceiver::DELIVERY_PACKET_ERROR:
301 fprintf(stderr, "Packet error, corrupt packets or incorrect setup?\n"); 301 fprintf(stderr, "Packet error, corrupt packets or incorrect setup?\n");
302 break; 302 break;
303 } 303 }
(...skipping 17 matching lines...) Expand all
321 } 321 }
322 } // namespace webrtc 322 } // namespace webrtc
323 323
324 int main(int argc, char* argv[]) { 324 int main(int argc, char* argv[]) {
325 ::testing::InitGoogleTest(&argc, argv); 325 ::testing::InitGoogleTest(&argc, argv);
326 google::ParseCommandLineFlags(&argc, &argv, true); 326 google::ParseCommandLineFlags(&argc, &argv, true);
327 327
328 webrtc::test::RunTest(webrtc::RtpReplay); 328 webrtc::test::RunTest(webrtc::RtpReplay);
329 return 0; 329 return 0;
330 } 330 }
OLDNEW
« no previous file with comments | « webrtc/video/payload_router_unittest.cc ('k') | webrtc/video/send_statistics_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698