summaryrefslogtreecommitdiffstats
path: root/media/cast
diff options
context:
space:
mode:
authorhubbe <hubbe@chromium.org>2014-09-23 14:25:54 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-23 21:26:08 +0000
commit693959c4726d968b0396345918a84bc284aea510 (patch)
treeb208ed5c122104e704c4253629098f4e3d6bffb9 /media/cast
parent37c078080a860d121443e657eb4089b784469162 (diff)
downloadchromium_src-693959c4726d968b0396345918a84bc284aea510.zip
chromium_src-693959c4726d968b0396345918a84bc284aea510.tar.gz
chromium_src-693959c4726d968b0396345918a84bc284aea510.tar.bz2
Cast: Allow extension to control wifi options on windows
This allows the cast extension to turn off wifi scan while streaming is in progress, and also set the "media streaming mode" further experimentation is need to see if these options are actually useful. BUG=410500 Review URL: https://codereview.chromium.org/566243005 Cr-Commit-Position: refs/heads/master@{#296253}
Diffstat (limited to 'media/cast')
-rw-r--r--media/cast/net/cast_transport_sender_impl.cc10
-rw-r--r--media/cast/net/cast_transport_sender_impl.h7
-rw-r--r--media/cast/net/cast_transport_sender_impl_unittest.cc28
3 files changed, 44 insertions, 1 deletions
diff --git a/media/cast/net/cast_transport_sender_impl.cc b/media/cast/net/cast_transport_sender_impl.cc
index 466c3a5..6c746f4 100644
--- a/media/cast/net/cast_transport_sender_impl.cc
+++ b/media/cast/net/cast_transport_sender_impl.cc
@@ -106,6 +106,16 @@ CastTransportSenderImpl::CastTransportSenderImpl(
transport_->StartReceiving(
base::Bind(&CastTransportSenderImpl::OnReceivedPacket,
weak_factory_.GetWeakPtr()));
+ int wifi_options = 0;
+ if (options->HasKey("disable_wifi_scan")) {
+ wifi_options |= net::WIFI_OPTIONS_DISABLE_SCAN;
+ }
+ if (options->HasKey("media_streaming_mode")) {
+ wifi_options |= net::WIFI_OPTIONS_MEDIA_STREAMING_MODE;
+ }
+ if (wifi_options) {
+ wifi_options_autoreset_ = net::SetWifiOptions(wifi_options);
+ }
}
}
diff --git a/media/cast/net/cast_transport_sender_impl.h b/media/cast/net/cast_transport_sender_impl.h
index 1eb8bca..cff5561 100644
--- a/media/cast/net/cast_transport_sender_impl.h
+++ b/media/cast/net/cast_transport_sender_impl.h
@@ -56,11 +56,14 @@ class CastTransportSenderImpl : public CastTransportSender {
// |raw_events_callback| is a null callback.
// |options| contains optional settings for the transport, possible
// keys are:
- // "DSCP" (value doesn't matter) - turns DSCP on
+ // "DSCP" (value ignored) - turns DSCP on
// "pacer_target_burst_size": int - specifies how many packets to send
// per 10 ms ideally.
// "pacer_max_burst_size": int - specifies how many pakcets to send
// per 10 ms, max
+ // "disable_wifi_scan" (value ignored) - disable wifi scans while streaming
+ // "media_streaming_mode" (value ignored) - turn media streaming mode on
+ // Note, these options may be ignored on some platforms.
CastTransportSenderImpl(
net::NetLog* net_log,
base::TickClock* clock,
@@ -165,6 +168,8 @@ class CastTransportSenderImpl : public CastTransportSender {
// audio packet.
int64 last_byte_acked_for_audio_;
+ scoped_ptr<net::ScopedWifiOptions> wifi_options_autoreset_;
+
base::WeakPtrFactory<CastTransportSenderImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CastTransportSenderImpl);
diff --git a/media/cast/net/cast_transport_sender_impl_unittest.cc b/media/cast/net/cast_transport_sender_impl_unittest.cc
index 3ba40d2..fa9ec47 100644
--- a/media/cast/net/cast_transport_sender_impl_unittest.cc
+++ b/media/cast/net/cast_transport_sender_impl_unittest.cc
@@ -9,6 +9,7 @@
#include "base/bind_helpers.h"
#include "base/memory/scoped_ptr.h"
#include "base/test/simple_test_tick_clock.h"
+#include "base/values.h"
#include "media/cast/cast_config.h"
#include "media/cast/net/cast_transport_config.h"
#include "media/cast/net/cast_transport_sender_impl.h"
@@ -90,6 +91,27 @@ class CastTransportSenderImplTest : public ::testing::Test {
task_runner_->RunTasks();
}
+ void InitWithOptions() {
+ scoped_ptr<base::DictionaryValue> options(
+ new base::DictionaryValue);
+ options->SetBoolean("DHCP", true);
+ options->SetBoolean("disable_wifi_scan", true);
+ options->SetBoolean("media_streaming_mode", true);
+ options->SetInteger("pacer_target_burst_size", 20);
+ options->SetInteger("pacer_max_burst_size", 100);
+ transport_sender_.reset(
+ new CastTransportSenderImpl(NULL,
+ &testing_clock_,
+ net::IPEndPoint(),
+ options.Pass(),
+ base::Bind(&UpdateCastTransportStatus),
+ BulkRawEventsCallback(),
+ base::TimeDelta(),
+ task_runner_,
+ &transport_));
+ task_runner_->RunTasks();
+ }
+
void InitWithLogging() {
transport_sender_.reset(new CastTransportSenderImpl(
NULL,
@@ -152,6 +174,12 @@ TEST_F(CastTransportSenderImplTest, InitWithLogging) {
EXPECT_EQ(5, num_times_callback_called_);
}
+TEST_F(CastTransportSenderImplTest, InitWithOptions) {
+ InitWithOptions();
+ task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50));
+ EXPECT_EQ(0, num_times_callback_called_);
+}
+
TEST_F(CastTransportSenderImplTest, NacksCancelRetransmits) {
InitWithoutLogging();
InitializeVideo();