summaryrefslogtreecommitdiffstats
path: root/media/cast/test
diff options
context:
space:
mode:
Diffstat (limited to 'media/cast/test')
-rw-r--r--media/cast/test/cast_benchmarks.cc23
-rw-r--r--media/cast/test/end2end_unittest.cc38
-rw-r--r--media/cast/test/fake_media_source.cc16
-rw-r--r--media/cast/test/loopback_transport.cc12
-rw-r--r--media/cast/test/receiver.cc4
-rw-r--r--media/cast/test/sender.cc14
-rw-r--r--media/cast/test/simulator.cc32
-rw-r--r--media/cast/test/utility/audio_utility.cc2
-rw-r--r--media/cast/test/utility/in_process_receiver.cc6
-rw-r--r--media/cast/test/utility/tap_proxy.cc45
-rw-r--r--media/cast/test/utility/udp_proxy.cc77
-rw-r--r--media/cast/test/utility/udp_proxy_main.cc35
12 files changed, 140 insertions, 164 deletions
diff --git a/media/cast/test/cast_benchmarks.cc b/media/cast/test/cast_benchmarks.cc
index a867eb2..dcd433e 100644
--- a/media/cast/test/cast_benchmarks.cc
+++ b/media/cast/test/cast_benchmarks.cc
@@ -24,8 +24,8 @@
#include <math.h>
#include <stddef.h>
#include <stdint.h>
-
#include <map>
+#include <utility>
#include <vector>
#include "base/at_exit.h"
@@ -211,12 +211,12 @@ class RunOneBenchmark {
task_runner_receiver_(
new test::SkewedSingleThreadTaskRunner(task_runner_)),
cast_environment_sender_(new CastEnvironment(
- scoped_ptr<base::TickClock>(testing_clock_sender_).Pass(),
+ scoped_ptr<base::TickClock>(testing_clock_sender_),
task_runner_sender_,
task_runner_sender_,
task_runner_sender_)),
cast_environment_receiver_(new CastEnvironment(
- scoped_ptr<base::TickClock>(testing_clock_receiver_).Pass(),
+ scoped_ptr<base::TickClock>(testing_clock_receiver_),
task_runner_receiver_,
task_runner_receiver_,
task_runner_receiver_)),
@@ -318,20 +318,18 @@ class RunOneBenchmark {
CreateDefaultVideoEncodeAcceleratorCallback(),
CreateDefaultVideoEncodeMemoryCallback());
- receiver_to_sender_.Initialize(
- CreateSimplePipe(p).Pass(),
- transport_sender_.PacketReceiverForTesting(),
- task_runner_, &testing_clock_);
+ receiver_to_sender_.Initialize(CreateSimplePipe(p),
+ transport_sender_.PacketReceiverForTesting(),
+ task_runner_, &testing_clock_);
sender_to_receiver_.Initialize(
- CreateSimplePipe(p).Pass(),
- transport_receiver_->PacketReceiverForTesting(),
+ CreateSimplePipe(p), transport_receiver_->PacketReceiverForTesting(),
task_runner_, &testing_clock_);
task_runner_->RunTasks();
}
void ReceivePacket(scoped_ptr<Packet> packet) {
- cast_receiver_->ReceivePacket(packet.Pass());
+ cast_receiver_->ReceivePacket(std::move(packet));
}
virtual ~RunOneBenchmark() {
@@ -386,10 +384,9 @@ class RunOneBenchmark {
scoped_ptr<test::PacketPipe> CreateSimplePipe(const MeasuringPoint& p) {
scoped_ptr<test::PacketPipe> pipe = test::NewBuffer(65536, p.bitrate);
- pipe->AppendToPipe(
- test::NewRandomDrop(p.percent_packet_drop / 100.0).Pass());
+ pipe->AppendToPipe(test::NewRandomDrop(p.percent_packet_drop / 100.0));
pipe->AppendToPipe(test::NewConstantDelay(p.latency / 1000.0));
- return pipe.Pass();
+ return pipe;
}
void Run(const MeasuringPoint& p) {
diff --git a/media/cast/test/end2end_unittest.cc b/media/cast/test/end2end_unittest.cc
index 85b885b..d7eb22d 100644
--- a/media/cast/test/end2end_unittest.cc
+++ b/media/cast/test/end2end_unittest.cc
@@ -12,10 +12,10 @@
#include <math.h>
#include <stddef.h>
#include <stdint.h>
-
#include <functional>
#include <list>
#include <map>
+#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -168,7 +168,7 @@ class LoopBackPacketPipe : public test::PacketPipe {
// PacketPipe implementations.
void Send(scoped_ptr<Packet> packet) final {
- packet_receiver_.Run(packet.Pass());
+ packet_receiver_.Run(std::move(packet));
}
private:
@@ -197,9 +197,9 @@ class LoopBackTransport : public PacketSender {
scoped_ptr<test::PacketPipe> loopback_pipe(
new LoopBackPacketPipe(packet_receiver));
if (packet_pipe_) {
- packet_pipe_->AppendToPipe(loopback_pipe.Pass());
+ packet_pipe_->AppendToPipe(std::move(loopback_pipe));
} else {
- packet_pipe_ = loopback_pipe.Pass();
+ packet_pipe_ = std::move(loopback_pipe);
}
packet_pipe_->InitOnIOThread(task_runner, clock);
}
@@ -217,7 +217,7 @@ class LoopBackTransport : public PacketSender {
}
scoped_ptr<Packet> packet_copy(new Packet(packet->data));
- packet_pipe_->Send(packet_copy.Pass());
+ packet_pipe_->Send(std::move(packet_copy));
return true;
}
@@ -231,8 +231,8 @@ class LoopBackTransport : public PacketSender {
void SetPacketPipe(scoped_ptr<test::PacketPipe> pipe) {
// Append the loopback pipe to the end.
- pipe->AppendToPipe(packet_pipe_.Pass());
- packet_pipe_ = pipe.Pass();
+ pipe->AppendToPipe(std::move(packet_pipe_));
+ packet_pipe_ = std::move(pipe);
}
private:
@@ -263,7 +263,7 @@ class TestReceiverAudioCallback
scoped_ptr<ExpectedAudioFrame> expected_audio_frame(
new ExpectedAudioFrame());
expected_audio_frame->audio_bus =
- AudioBus::Create(audio_bus.channels(), audio_bus.frames()).Pass();
+ AudioBus::Create(audio_bus.channels(), audio_bus.frames());
audio_bus.CopyTo(expected_audio_frame->audio_bus.get());
expected_audio_frame->playout_time = playout_time;
expected_frames_.push_back(expected_audio_frame.release());
@@ -333,7 +333,7 @@ class TestReceiverAudioCallback
audio_bus->FromInterleaved(pcm_data, audio_bus->frames(), sizeof(int16_t));
// Delegate the checking from here...
- CheckAudioFrame(audio_bus.Pass(), audio_frame->reference_time, true);
+ CheckAudioFrame(std::move(audio_bus), audio_frame->reference_time, true);
}
int number_times_called() const { return num_called_; }
@@ -439,12 +439,12 @@ class End2EndTest : public ::testing::Test {
task_runner_receiver_(
new test::SkewedSingleThreadTaskRunner(task_runner_)),
cast_environment_sender_(new CastEnvironment(
- scoped_ptr<base::TickClock>(testing_clock_sender_).Pass(),
+ scoped_ptr<base::TickClock>(testing_clock_sender_),
task_runner_sender_,
task_runner_sender_,
task_runner_sender_)),
cast_environment_receiver_(new CastEnvironment(
- scoped_ptr<base::TickClock>(testing_clock_receiver_).Pass(),
+ scoped_ptr<base::TickClock>(testing_clock_receiver_),
task_runner_receiver_,
task_runner_receiver_,
task_runner_receiver_)),
@@ -544,7 +544,7 @@ class End2EndTest : public ::testing::Test {
reference_time +
base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs));
}
- audio_frame_input_->InsertAudio(audio_bus.Pass(), reference_time);
+ audio_frame_input_->InsertAudio(std::move(audio_bus), reference_time);
}
}
@@ -560,7 +560,7 @@ class End2EndTest : public ::testing::Test {
*audio_bus,
reference_time + delay +
base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs));
- audio_frame_input_->InsertAudio(audio_bus.Pass(), reference_time);
+ audio_frame_input_->InsertAudio(std::move(audio_bus), reference_time);
}
}
@@ -574,7 +574,7 @@ class End2EndTest : public ::testing::Test {
}
void ReceivePacket(scoped_ptr<Packet> packet) {
- cast_receiver_->ReceivePacket(packet.Pass());
+ cast_receiver_->ReceivePacket(std::move(packet));
}
void Create() {
@@ -1330,8 +1330,8 @@ TEST_F(End2EndTest, SmoothPlayoutWithFivePercentClockRateSkew) {
TEST_F(End2EndTest, EvilNetwork) {
Configure(CODEC_VIDEO_FAKE, CODEC_AUDIO_PCM16, 32000,
1);
- receiver_to_sender_.SetPacketPipe(test::EvilNetwork().Pass());
- sender_to_receiver_.SetPacketPipe(test::EvilNetwork().Pass());
+ receiver_to_sender_.SetPacketPipe(test::EvilNetwork());
+ sender_to_receiver_.SetPacketPipe(test::EvilNetwork());
Create();
StartBasicPlayer();
@@ -1353,8 +1353,8 @@ TEST_F(End2EndTest, EvilNetwork) {
TEST_F(End2EndTest, ShoveHighFrameRateDownYerThroat) {
Configure(CODEC_VIDEO_FAKE, CODEC_AUDIO_PCM16, 32000,
1);
- receiver_to_sender_.SetPacketPipe(test::EvilNetwork().Pass());
- sender_to_receiver_.SetPacketPipe(test::EvilNetwork().Pass());
+ receiver_to_sender_.SetPacketPipe(test::EvilNetwork());
+ sender_to_receiver_.SetPacketPipe(test::EvilNetwork());
Create();
StartBasicPlayer();
@@ -1386,7 +1386,7 @@ TEST_F(End2EndTest, OldPacketNetwork) {
echo_chamber->AppendToPipe(
test::NewDuplicateAndDelay(1, 160 * kFrameTimerMs));
- receiver_to_sender_.SetPacketPipe(echo_chamber.Pass());
+ receiver_to_sender_.SetPacketPipe(std::move(echo_chamber));
Create();
StartBasicPlayer();
diff --git a/media/cast/test/fake_media_source.cc b/media/cast/test/fake_media_source.cc
index 3c7a8e0..0dbe950 100644
--- a/media/cast/test/fake_media_source.cc
+++ b/media/cast/test/fake_media_source.cc
@@ -4,6 +4,8 @@
#include "media/cast/test/fake_media_source.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
@@ -271,8 +273,7 @@ void FakeMediaSource::SendNextFakeFrame() {
CHECK(!audio_bus_queue_.empty()) << "No audio decoded.";
scoped_ptr<AudioBus> bus(audio_bus_queue_.front());
audio_bus_queue_.pop();
- audio_frame_input_->InsertAudio(
- bus.Pass(), start_time_ + audio_time);
+ audio_frame_input_->InsertAudio(std::move(bus), start_time_ + audio_time);
} else {
audio_frame_input_->InsertAudio(
audio_bus_factory_->NextAudioBus(
@@ -364,8 +365,7 @@ bool FakeMediaSource::SendNextTranscodedAudio(base::TimeDelta elapsed_time) {
scoped_ptr<AudioBus> bus(audio_bus_queue_.front());
audio_bus_queue_.pop();
audio_sent_ts_->AddFrames(bus->frames());
- audio_frame_input_->InsertAudio(
- bus.Pass(), start_time_ + audio_time);
+ audio_frame_input_->InsertAudio(std::move(bus), start_time_ + audio_time);
// Make sure queue is not empty.
Decode(true);
@@ -419,7 +419,7 @@ ScopedAVPacket FakeMediaSource::DemuxOnePacket(bool* audio) {
if (av_read_frame(av_format_context_, packet.get()) < 0) {
VLOG(1) << "Failed to read one AVPacket.";
packet.reset();
- return packet.Pass();
+ return packet;
}
int stream_index = static_cast<int>(packet->stream_index);
@@ -432,7 +432,7 @@ ScopedAVPacket FakeMediaSource::DemuxOnePacket(bool* audio) {
LOG(INFO) << "Unknown packet.";
packet.reset();
}
- return packet.Pass();
+ return packet;
}
void FakeMediaSource::DecodeAudio(ScopedAVPacket packet) {
@@ -570,9 +570,9 @@ void FakeMediaSource::Decode(bool decode_audio) {
}
if (audio_packet)
- DecodeAudio(packet.Pass());
+ DecodeAudio(std::move(packet));
else
- DecodeVideo(packet.Pass());
+ DecodeVideo(std::move(packet));
}
}
diff --git a/media/cast/test/loopback_transport.cc b/media/cast/test/loopback_transport.cc
index 570d0a0..d82dcbd 100644
--- a/media/cast/test/loopback_transport.cc
+++ b/media/cast/test/loopback_transport.cc
@@ -4,6 +4,8 @@
#include "media/cast/test/loopback_transport.h"
+#include <utility>
+
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "base/time/tick_clock.h"
@@ -25,7 +27,7 @@ class LoopBackPacketPipe : public test::PacketPipe {
// PacketPipe implementations.
void Send(scoped_ptr<Packet> packet) final {
- packet_receiver_.Run(packet.Pass());
+ packet_receiver_.Run(std::move(packet));
}
private:
@@ -49,7 +51,7 @@ bool LoopBackTransport::SendPacket(PacketRef packet,
const base::Closure& cb) {
DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
scoped_ptr<Packet> packet_copy(new Packet(packet->data));
- packet_pipe_->Send(packet_copy.Pass());
+ packet_pipe_->Send(std::move(packet_copy));
bytes_sent_ += packet->data.size();
return true;
}
@@ -67,10 +69,10 @@ void LoopBackTransport::Initialize(
new LoopBackPacketPipe(packet_receiver));
if (pipe) {
// Append the loopback pipe to the end.
- pipe->AppendToPipe(loopback_pipe.Pass());
- packet_pipe_ = pipe.Pass();
+ pipe->AppendToPipe(std::move(loopback_pipe));
+ packet_pipe_ = std::move(pipe);
} else {
- packet_pipe_ = loopback_pipe.Pass();
+ packet_pipe_ = std::move(loopback_pipe);
}
packet_pipe_->InitOnIOThread(task_runner, clock);
}
diff --git a/media/cast/test/receiver.cc b/media/cast/test/receiver.cc
index 2dd0be2..67d8462 100644
--- a/media/cast/test/receiver.cc
+++ b/media/cast/test/receiver.cc
@@ -345,7 +345,7 @@ class NaivePlayer : public InProcessReceiver,
if (audio_playout_queue_.empty())
break;
- currently_playing_audio_frame_ = PopOneAudioFrame(false).Pass();
+ currently_playing_audio_frame_ = PopOneAudioFrame(false);
currently_playing_audio_frame_start_ = 0;
}
@@ -472,7 +472,7 @@ class NaivePlayer : public InProcessReceiver,
scoped_ptr<AudioBus> ret(audio_playout_queue_.front().second);
audio_playout_queue_.pop_front();
++num_audio_frames_processed_;
- return ret.Pass();
+ return ret;
}
void CheckAVSync() {
diff --git a/media/cast/test/sender.cc b/media/cast/test/sender.cc
index 4eab2a2..206bfb5 100644
--- a/media/cast/test/sender.cc
+++ b/media/cast/test/sender.cc
@@ -6,8 +6,8 @@
// or read from a file.
#include <stdint.h>
-
#include <queue>
+#include <utility>
#include "base/at_exit.h"
#include "base/base_paths.h"
@@ -127,19 +127,15 @@ void WriteLogsToFileAndDestroySubscribers(
video_event_subscriber->GetEventsAndReset(
&log_metadata, &frame_events, &packet_events);
- DumpLoggingData(log_metadata,
- frame_events,
- packet_events,
- video_log_file.Pass());
+ DumpLoggingData(log_metadata, frame_events, packet_events,
+ std::move(video_log_file));
VLOG(0) << "Dumping logging data for audio stream.";
audio_event_subscriber->GetEventsAndReset(
&log_metadata, &frame_events, &packet_events);
- DumpLoggingData(log_metadata,
- frame_events,
- packet_events,
- audio_log_file.Pass());
+ DumpLoggingData(log_metadata, frame_events, packet_events,
+ std::move(audio_log_file));
}
void WriteStatsAndDestroySubscribers(
diff --git a/media/cast/test/simulator.cc b/media/cast/test/simulator.cc
index 896b20d..a2aa6e4 100644
--- a/media/cast/test/simulator.cc
+++ b/media/cast/test/simulator.cc
@@ -36,6 +36,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <utility>
#include "base/at_exit.h"
#include "base/base_paths.h"
@@ -301,20 +302,12 @@ void RunSimulation(const base::FilePath& source_path,
base::ThreadTaskRunnerHandle task_runner_handle(task_runner);
// CastEnvironments.
- scoped_refptr<CastEnvironment> sender_env =
- new CastEnvironment(
- scoped_ptr<base::TickClock>(
- new test::SkewedTickClock(&testing_clock)).Pass(),
- task_runner,
- task_runner,
- task_runner);
- scoped_refptr<CastEnvironment> receiver_env =
- new CastEnvironment(
- scoped_ptr<base::TickClock>(
- new test::SkewedTickClock(&testing_clock)).Pass(),
- task_runner,
- task_runner,
- task_runner);
+ scoped_refptr<CastEnvironment> sender_env = new CastEnvironment(
+ scoped_ptr<base::TickClock>(new test::SkewedTickClock(&testing_clock)),
+ task_runner, task_runner, task_runner);
+ scoped_refptr<CastEnvironment> receiver_env = new CastEnvironment(
+ scoped_ptr<base::TickClock>(new test::SkewedTickClock(&testing_clock)),
+ task_runner, task_runner, task_runner);
// Event subscriber. Store at most 1 hour of events.
EncodingEventSubscriber audio_event_subscriber(AUDIO_EVENT,
@@ -360,7 +353,7 @@ void RunSimulation(const base::FilePath& source_path,
PacketProxy() : receiver(NULL) {}
void ReceivePacket(scoped_ptr<Packet> packet) {
if (receiver)
- receiver->ReceivePacket(packet.Pass());
+ receiver->ReceivePacket(std::move(packet));
}
CastReceiver* receiver;
};
@@ -413,12 +406,11 @@ void RunSimulation(const base::FilePath& source_path,
ipp.reset(new test::InterruptedPoissonProcess(
average_rates,
ipp_model.coef_burstiness(), ipp_model.coef_variance(), 0));
- receiver_to_sender.Initialize(
- ipp->NewBuffer(128 * 1024).Pass(),
- transport_sender->PacketReceiverForTesting(),
- task_runner, &testing_clock);
+ receiver_to_sender.Initialize(ipp->NewBuffer(128 * 1024),
+ transport_sender->PacketReceiverForTesting(),
+ task_runner, &testing_clock);
sender_to_receiver.Initialize(
- ipp->NewBuffer(128 * 1024).Pass(),
+ ipp->NewBuffer(128 * 1024),
transport_receiver->PacketReceiverForTesting(), task_runner,
&testing_clock);
} else {
diff --git a/media/cast/test/utility/audio_utility.cc b/media/cast/test/utility/audio_utility.cc
index 348b692..0d50b37 100644
--- a/media/cast/test/utility/audio_utility.cc
+++ b/media/cast/test/utility/audio_utility.cc
@@ -37,7 +37,7 @@ scoped_ptr<AudioBus> TestAudioBusFactory::NextAudioBus(
scoped_ptr<AudioBus> bus(AudioBus::Create(num_channels_, num_samples));
source_.OnMoreData(bus.get(), 0, 0);
bus->Scale(volume_);
- return bus.Pass();
+ return bus;
}
int CountZeroCrossings(const float* samples, int length) {
diff --git a/media/cast/test/utility/in_process_receiver.cc b/media/cast/test/utility/in_process_receiver.cc
index 788325f..1e97c9a 100644
--- a/media/cast/test/utility/in_process_receiver.cc
+++ b/media/cast/test/utility/in_process_receiver.cc
@@ -4,6 +4,8 @@
#include "media/cast/test/utility/in_process_receiver.h"
+#include <utility>
+
#include "base/bind_helpers.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
@@ -104,7 +106,7 @@ void InProcessReceiver::GotAudioFrame(scoped_ptr<AudioBus> audio_frame,
bool is_continuous) {
DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
if (audio_frame.get())
- OnAudioFrame(audio_frame.Pass(), playout_time, is_continuous);
+ OnAudioFrame(std::move(audio_frame), playout_time, is_continuous);
PullNextAudioFrame();
}
@@ -133,7 +135,7 @@ void InProcessReceiver::PullNextVideoFrame() {
void InProcessReceiver::ReceivePacket(scoped_ptr<Packet> packet) {
// TODO(Hubbe): Make an InsertPacket method instead.
- cast_receiver_->ReceivePacket(packet.Pass());
+ cast_receiver_->ReceivePacket(std::move(packet));
}
} // namespace cast
diff --git a/media/cast/test/utility/tap_proxy.cc b/media/cast/test/utility/tap_proxy.cc
index c0d8b3a..57166a8 100644
--- a/media/cast/test/utility/tap_proxy.cc
+++ b/media/cast/test/utility/tap_proxy.cc
@@ -17,9 +17,9 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-
#include <deque>
#include <map>
+#include <utility>
#include "base/at_exit.h"
#include "base/bind.h"
@@ -70,21 +70,17 @@ class SendToFDPipe : public PacketPipe {
class QueueManager : public base::MessageLoopForIO::Watcher {
public:
- QueueManager(int input_fd,
- int output_fd,
- scoped_ptr<PacketPipe> pipe) :
- input_fd_(input_fd),
- packet_pipe_(pipe.Pass()) {
-
+ QueueManager(int input_fd, int output_fd, scoped_ptr<PacketPipe> pipe)
+ : input_fd_(input_fd), packet_pipe_(std::move(pipe)) {
CHECK(base::MessageLoopForIO::current()->WatchFileDescriptor(
input_fd_, true, base::MessageLoopForIO::WATCH_READ,
&read_socket_watcher_, this));
scoped_ptr<PacketPipe> tmp(new SendToFDPipe(output_fd));
if (packet_pipe_) {
- packet_pipe_->AppendToPipe(tmp.Pass());
+ packet_pipe_->AppendToPipe(std::move(tmp));
} else {
- packet_pipe_ = tmp.Pass();
+ packet_pipe_ = std::move(tmp);
}
packet_pipe_->InitOnIOThread(base::ThreadTaskRunnerHandle::Get(),
&tick_clock_);
@@ -105,7 +101,7 @@ class QueueManager : public base::MessageLoopForIO::Watcher {
}
if (nread == 0) return;
packet->resize(nread);
- packet_pipe_->Send(packet.Pass());
+ packet_pipe_->Send(std::move(packet));
}
void OnFileCanWriteWithoutBlocking(int fd) final { NOTREACHED(); }
@@ -176,7 +172,7 @@ class ByteCounterPipe : public media::cast::test::PacketPipe {
ByteCounterPipe(ByteCounter* counter) : counter_(counter) {}
void Send(scoped_ptr<media::cast::Packet> packet) final {
counter_->Increment(packet->size());
- pipe_->Send(packet.Pass());
+ pipe_->Send(std::move(packet));
}
private:
ByteCounter* counter_;
@@ -187,10 +183,9 @@ void SetupByteCounters(scoped_ptr<media::cast::test::PacketPipe>* pipe,
ByteCounter* pipe_output_counter) {
media::cast::test::PacketPipe* new_pipe =
new ByteCounterPipe(pipe_input_counter);
- new_pipe->AppendToPipe(pipe->Pass());
- new_pipe->AppendToPipe(
- scoped_ptr<media::cast::test::PacketPipe>(
- new ByteCounterPipe(pipe_output_counter)).Pass());
+ new_pipe->AppendToPipe(std::move(*pipe));
+ new_pipe->AppendToPipe(scoped_ptr<media::cast::test::PacketPipe>(
+ new ByteCounterPipe(pipe_output_counter)));
pipe->reset(new_pipe);
}
@@ -286,17 +281,17 @@ int main(int argc, char **argv) {
if (network_type == "perfect") {
// No action needed.
} else if (network_type == "good") {
- in_pipe = media::cast::test::GoodNetwork().Pass();
- out_pipe = media::cast::test::GoodNetwork().Pass();
+ in_pipe = media::cast::test::GoodNetwork();
+ out_pipe = media::cast::test::GoodNetwork();
} else if (network_type == "wifi") {
- in_pipe = media::cast::test::WifiNetwork().Pass();
- out_pipe = media::cast::test::WifiNetwork().Pass();
+ in_pipe = media::cast::test::WifiNetwork();
+ out_pipe = media::cast::test::WifiNetwork();
} else if (network_type == "bad") {
- in_pipe = media::cast::test::BadNetwork().Pass();
- out_pipe = media::cast::test::BadNetwork().Pass();
+ in_pipe = media::cast::test::BadNetwork();
+ out_pipe = media::cast::test::BadNetwork();
} else if (network_type == "evil") {
- in_pipe = media::cast::test::EvilNetwork().Pass();
- out_pipe = media::cast::test::EvilNetwork().Pass();
+ in_pipe = media::cast::test::EvilNetwork();
+ out_pipe = media::cast::test::EvilNetwork();
} else {
fprintf(stderr, "Unknown network type.\n");
exit(1);
@@ -311,8 +306,8 @@ int main(int argc, char **argv) {
base::MessageLoopForIO message_loop;
last_printout = base::TimeTicks::Now();
- media::cast::test::QueueManager qm1(fd1, fd2, in_pipe.Pass());
- media::cast::test::QueueManager qm2(fd2, fd1, out_pipe.Pass());
+ media::cast::test::QueueManager qm1(fd1, fd2, std::move(in_pipe));
+ media::cast::test::QueueManager qm2(fd2, fd1, std::move(out_pipe));
CheckByteCounters();
printf("Press Ctrl-C when done.\n");
message_loop.Run();
diff --git a/media/cast/test/utility/udp_proxy.cc b/media/cast/test/utility/udp_proxy.cc
index c5c54e5..1e5c4fa 100644
--- a/media/cast/test/utility/udp_proxy.cc
+++ b/media/cast/test/utility/udp_proxy.cc
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "media/cast/test/utility/udp_proxy.h"
+
#include <math.h>
#include <stdlib.h>
+#include <utility>
#include <vector>
-#include "media/cast/test/utility/udp_proxy.h"
-
#include "base/logging.h"
#include "base/macros.h"
#include "base/rand_util.h"
@@ -38,9 +39,9 @@ void PacketPipe::InitOnIOThread(
}
void PacketPipe::AppendToPipe(scoped_ptr<PacketPipe> pipe) {
if (pipe_) {
- pipe_->AppendToPipe(pipe.Pass());
+ pipe_->AppendToPipe(std::move(pipe));
} else {
- pipe_ = pipe.Pass();
+ pipe_ = std::move(pipe);
}
}
@@ -94,7 +95,7 @@ class Buffer : public PacketPipe {
bytes_to_send -= packet->size();
buffer_size_ -= packet->size();
buffer_.pop_front();
- pipe_->Send(packet.Pass());
+ pipe_->Send(std::move(packet));
}
if (!buffer_.empty()) {
Schedule();
@@ -110,7 +111,7 @@ class Buffer : public PacketPipe {
};
scoped_ptr<PacketPipe> NewBuffer(size_t buffer_size, double bandwidth) {
- return scoped_ptr<PacketPipe>(new Buffer(buffer_size, bandwidth)).Pass();
+ return scoped_ptr<PacketPipe>(new Buffer(buffer_size, bandwidth));
}
class RandomDrop : public PacketPipe {
@@ -120,7 +121,7 @@ class RandomDrop : public PacketPipe {
void Send(scoped_ptr<Packet> packet) final {
if (rand() > drop_fraction_) {
- pipe_->Send(packet.Pass());
+ pipe_->Send(std::move(packet));
}
}
@@ -129,7 +130,7 @@ class RandomDrop : public PacketPipe {
};
scoped_ptr<PacketPipe> NewRandomDrop(double drop_fraction) {
- return scoped_ptr<PacketPipe>(new RandomDrop(drop_fraction)).Pass();
+ return scoped_ptr<PacketPipe>(new RandomDrop(drop_fraction));
}
class SimpleDelayBase : public PacketPipe {
@@ -150,7 +151,7 @@ class SimpleDelayBase : public PacketPipe {
private:
virtual void SendInternal(scoped_ptr<Packet> packet) {
- pipe_->Send(packet.Pass());
+ pipe_->Send(std::move(packet));
}
base::WeakPtrFactory<SimpleDelayBase> weak_factory_;
@@ -166,7 +167,7 @@ class ConstantDelay : public SimpleDelayBase {
};
scoped_ptr<PacketPipe> NewConstantDelay(double delay_seconds) {
- return scoped_ptr<PacketPipe>(new ConstantDelay(delay_seconds)).Pass();
+ return scoped_ptr<PacketPipe>(new ConstantDelay(delay_seconds));
}
class RandomUnsortedDelay : public SimpleDelayBase {
@@ -180,7 +181,7 @@ class RandomUnsortedDelay : public SimpleDelayBase {
};
scoped_ptr<PacketPipe> NewRandomUnsortedDelay(double random_delay) {
- return scoped_ptr<PacketPipe>(new RandomUnsortedDelay(random_delay)).Pass();
+ return scoped_ptr<PacketPipe>(new RandomUnsortedDelay(random_delay));
}
class DuplicateAndDelay : public RandomUnsortedDelay {
@@ -192,7 +193,7 @@ class DuplicateAndDelay : public RandomUnsortedDelay {
}
void Send(scoped_ptr<Packet> packet) final {
pipe_->Send(scoped_ptr<Packet>(new Packet(*packet.get())));
- RandomUnsortedDelay::Send(packet.Pass());
+ RandomUnsortedDelay::Send(std::move(packet));
}
double GetDelay() final {
return RandomUnsortedDelay::GetDelay() + delay_min_;
@@ -203,8 +204,7 @@ class DuplicateAndDelay : public RandomUnsortedDelay {
scoped_ptr<PacketPipe> NewDuplicateAndDelay(double delay_min,
double random_delay) {
- return scoped_ptr<PacketPipe>(
- new DuplicateAndDelay(delay_min, random_delay)).Pass();
+ return scoped_ptr<PacketPipe>(new DuplicateAndDelay(delay_min, random_delay));
}
class RandomSortedDelay : public PacketPipe {
@@ -262,7 +262,7 @@ class RandomSortedDelay : public PacketPipe {
base::TimeTicks now = clock_->NowTicks();
while (!buffer_.empty() && next_send_ <= now) {
scoped_ptr<Packet> packet(buffer_.front().release());
- pipe_->Send(packet.Pass());
+ pipe_->Send(std::move(packet));
buffer_.pop_front();
next_send_ += base::TimeDelta::FromSecondsD(
@@ -291,10 +291,8 @@ scoped_ptr<PacketPipe> NewRandomSortedDelay(
double random_delay,
double extra_delay,
double seconds_between_extra_delay) {
- return scoped_ptr<PacketPipe>(
- new RandomSortedDelay(
- random_delay, extra_delay, seconds_between_extra_delay))
- .Pass();
+ return scoped_ptr<PacketPipe>(new RandomSortedDelay(
+ random_delay, extra_delay, seconds_between_extra_delay));
}
class NetworkGlitchPipe : public PacketPipe {
@@ -314,7 +312,7 @@ class NetworkGlitchPipe : public PacketPipe {
void Send(scoped_ptr<Packet> packet) final {
if (works_) {
- pipe_->Send(packet.Pass());
+ pipe_->Send(std::move(packet));
}
}
@@ -339,8 +337,7 @@ class NetworkGlitchPipe : public PacketPipe {
scoped_ptr<PacketPipe> NewNetworkGlitchPipe(double average_work_time,
double average_outage_time) {
return scoped_ptr<PacketPipe>(
- new NetworkGlitchPipe(average_work_time, average_outage_time))
- .Pass();
+ new NetworkGlitchPipe(average_work_time, average_outage_time));
}
@@ -380,7 +377,7 @@ class InterruptedPoissonProcess::InternalBuffer : public PacketPipe {
stored_size_ -= packet->size();
buffer_.pop_front();
buffer_time_.pop_front();
- pipe_->Send(packet.Pass());
+ pipe_->Send(std::move(packet));
DCHECK(buffer_.size() == buffer_time_.size());
}
@@ -447,7 +444,7 @@ scoped_ptr<PacketPipe> InterruptedPoissonProcess::NewBuffer(size_t size) {
scoped_ptr<InternalBuffer> buffer(
new InternalBuffer(weak_factory_.GetWeakPtr(), size));
send_buffers_.push_back(buffer->GetWeakPtr());
- return buffer.Pass();
+ return std::move(buffer);
}
base::TimeDelta InterruptedPoissonProcess::NextEvent(double rate) {
@@ -559,7 +556,7 @@ class PacketSender : public PacketPipe {
namespace {
void BuildPipe(scoped_ptr<PacketPipe>* pipe, PacketPipe* next) {
if (*pipe) {
- (*pipe)->AppendToPipe(scoped_ptr<PacketPipe>(next).Pass());
+ (*pipe)->AppendToPipe(scoped_ptr<PacketPipe>(next));
} else {
pipe->reset(next);
}
@@ -574,7 +571,7 @@ scoped_ptr<PacketPipe> GoodNetwork() {
BuildPipe(&pipe, new RandomSortedDelay(1E-3, 2E-3, 3));
// This represents the buffer on the receiving device.
BuildPipe(&pipe, new Buffer(2 << 20, 50));
- return pipe.Pass();
+ return pipe;
}
scoped_ptr<PacketPipe> WifiNetwork() {
@@ -591,7 +588,7 @@ scoped_ptr<PacketPipe> WifiNetwork() {
BuildPipe(&pipe, new RandomDrop(0.005));
// This represents the buffer on the receiving device.
BuildPipe(&pipe, new Buffer(256 << 10, 20));
- return pipe.Pass();
+ return pipe;
}
scoped_ptr<PacketPipe> BadNetwork() {
@@ -608,7 +605,7 @@ scoped_ptr<PacketPipe> BadNetwork() {
BuildPipe(&pipe, new RandomUnsortedDelay(5E-3));
// This represents the buffer on the receiving device.
BuildPipe(&pipe, new Buffer(64 << 10, 5)); // 64 kb buf, 5mbit/s
- return pipe.Pass();
+ return pipe;
}
@@ -626,7 +623,7 @@ scoped_ptr<PacketPipe> EvilNetwork() {
BuildPipe(&pipe, new RandomUnsortedDelay(20E-3));
// This represents the buffer on the receiving device.
BuildPipe(&pipe, new Buffer(4 << 10, 2)); // 4 kb buf, 2mbit/s
- return pipe.Pass();
+ return pipe;
}
scoped_ptr<InterruptedPoissonProcess> DefaultInterruptedPoissonProcess() {
@@ -660,7 +657,7 @@ scoped_ptr<InterruptedPoissonProcess> DefaultInterruptedPoissonProcess() {
scoped_ptr<InterruptedPoissonProcess> ipp(
new InterruptedPoissonProcess(
average_rates, burstiness, variance, 0));
- return ipp.Pass();
+ return ipp;
}
class UDPProxyImpl : public UDPProxy {
@@ -674,8 +671,8 @@ class UDPProxyImpl : public UDPProxy {
destination_(destination),
destination_is_mutable_(destination.address().empty()),
proxy_thread_("media::cast::test::UdpProxy Thread"),
- to_dest_pipe_(to_dest_pipe.Pass()),
- from_dest_pipe_(from_dest_pipe.Pass()),
+ to_dest_pipe_(std::move(to_dest_pipe)),
+ from_dest_pipe_(std::move(from_dest_pipe)),
blocked_(false),
weak_factory_(this) {
proxy_thread_.StartWithOptions(
@@ -778,12 +775,12 @@ class UDPProxyImpl : public UDPProxy {
}
if (recv_address_ == destination_) {
set_destination_next_ = false;
- from_dest_pipe_->Send(packet_.Pass());
+ from_dest_pipe_->Send(std::move(packet_));
} else {
set_destination_next_ = true;
VLOG(1) << "Return address = " << recv_address_.ToString();
return_address_ = recv_address_;
- to_dest_pipe_->Send(packet_.Pass());
+ to_dest_pipe_->Send(std::move(packet_));
}
}
@@ -842,7 +839,7 @@ class UDPProxyImpl : public UDPProxy {
};
void PacketSender::Send(scoped_ptr<Packet> packet) {
- udp_proxy_->Send(packet.Pass(), *destination_);
+ udp_proxy_->Send(std::move(packet), *destination_);
}
scoped_ptr<UDPProxy> UDPProxy::Create(
@@ -851,12 +848,10 @@ scoped_ptr<UDPProxy> UDPProxy::Create(
scoped_ptr<PacketPipe> to_dest_pipe,
scoped_ptr<PacketPipe> from_dest_pipe,
net::NetLog* net_log) {
- scoped_ptr<UDPProxy> ret(new UDPProxyImpl(local_port,
- destination,
- to_dest_pipe.Pass(),
- from_dest_pipe.Pass(),
- net_log));
- return ret.Pass();
+ scoped_ptr<UDPProxy> ret(
+ new UDPProxyImpl(local_port, destination, std::move(to_dest_pipe),
+ std::move(from_dest_pipe), net_log));
+ return ret;
}
} // namespace test
diff --git a/media/cast/test/utility/udp_proxy_main.cc b/media/cast/test/utility/udp_proxy_main.cc
index bfa4e48..8877300 100644
--- a/media/cast/test/utility/udp_proxy_main.cc
+++ b/media/cast/test/utility/udp_proxy_main.cc
@@ -3,11 +3,11 @@
// found in the LICENSE file.
#include <stdint.h>
-
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <string>
+#include <utility>
#include "base/at_exit.h"
#include "base/bind.h"
@@ -81,7 +81,7 @@ class ByteCounterPipe : public media::cast::test::PacketPipe {
ByteCounterPipe(ByteCounter* counter) : counter_(counter) {}
void Send(scoped_ptr<media::cast::Packet> packet) final {
counter_->Increment(packet->size());
- pipe_->Send(packet.Pass());
+ pipe_->Send(std::move(packet));
}
private:
ByteCounter* counter_;
@@ -92,10 +92,9 @@ void SetupByteCounters(scoped_ptr<media::cast::test::PacketPipe>* pipe,
ByteCounter* pipe_output_counter) {
media::cast::test::PacketPipe* new_pipe =
new ByteCounterPipe(pipe_input_counter);
- new_pipe->AppendToPipe(pipe->Pass());
- new_pipe->AppendToPipe(
- scoped_ptr<media::cast::test::PacketPipe>(
- new ByteCounterPipe(pipe_output_counter)).Pass());
+ new_pipe->AppendToPipe(std::move(*pipe));
+ new_pipe->AppendToPipe(scoped_ptr<media::cast::test::PacketPipe>(
+ new ByteCounterPipe(pipe_output_counter)));
pipe->reset(new_pipe);
}
@@ -173,17 +172,17 @@ int main(int argc, char** argv) {
if (network_type == "perfect") {
// No action needed.
} else if (network_type == "wifi") {
- in_pipe = media::cast::test::WifiNetwork().Pass();
- out_pipe = media::cast::test::WifiNetwork().Pass();
+ in_pipe = media::cast::test::WifiNetwork();
+ out_pipe = media::cast::test::WifiNetwork();
} else if (network_type == "bad") {
- in_pipe = media::cast::test::BadNetwork().Pass();
- out_pipe = media::cast::test::BadNetwork().Pass();
+ in_pipe = media::cast::test::BadNetwork();
+ out_pipe = media::cast::test::BadNetwork();
} else if (network_type == "evil") {
- in_pipe = media::cast::test::EvilNetwork().Pass();
- out_pipe = media::cast::test::EvilNetwork().Pass();
+ in_pipe = media::cast::test::EvilNetwork();
+ out_pipe = media::cast::test::EvilNetwork();
} else if (network_type == "poisson-wifi") {
- in_pipe = ipp->NewBuffer(128 * 1024).Pass();
- out_pipe = ipp->NewBuffer(128 * 1024).Pass();
+ in_pipe = ipp->NewBuffer(128 * 1024);
+ out_pipe = ipp->NewBuffer(128 * 1024);
} else {
fprintf(stderr, "Unknown network type.\n");
exit(1);
@@ -197,11 +196,9 @@ int main(int argc, char** argv) {
printf("Press Ctrl-C when done.\n");
scoped_ptr<media::cast::test::UDPProxy> proxy(
- media::cast::test::UDPProxy::Create(local_endpoint,
- remote_endpoint,
- in_pipe.Pass(),
- out_pipe.Pass(),
- NULL));
+ media::cast::test::UDPProxy::Create(local_endpoint, remote_endpoint,
+ std::move(in_pipe),
+ std::move(out_pipe), NULL));
base::MessageLoop message_loop;
g_counter.Get().last_printout = base::TimeTicks::Now();
CheckByteCounters();