Wire up DSCP support in WebRtcVideoEngine2.

R=stefan@webrtc.org
BUG=1788

Review URL: https://webrtc-codereview.appspot.com/24249004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7669 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc
index 74f34cd..338a098 100644
--- a/talk/media/webrtc/webrtcvideoengine2.cc
+++ b/talk/media/webrtc/webrtcvideoengine2.cc
@@ -747,6 +747,7 @@
 
 void WebRtcVideoChannel2::SetDefaultOptions() {
   options_.cpu_overuse_detection.Set(false);
+  options_.dscp.Set(false);
   options_.suspend_below_min_bitrate.Set(false);
   options_.use_payload_padding.Set(false);
   options_.video_noise_reduction.Set(true);
@@ -1319,6 +1320,10 @@
     // No new options to set.
     return true;
   }
+  rtc::DiffServCodePoint dscp = options_.dscp.GetWithDefaultIfUnset(false)
+                                    ? rtc::DSCP_AF41
+                                    : rtc::DSCP_DEFAULT;
+  MediaChannel::SetDscp(dscp);
   rtc::CritScope stream_lock(&stream_crit_);
   for (std::map<uint32, WebRtcVideoSendStream*>::iterator it =
            send_streams_.begin();
diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc
index afea370..8e0a785 100644
--- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc
+++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc
@@ -1698,10 +1698,6 @@
   }
 }
 
-TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetVieSendCodecOnNewFrameSize) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) {
   std::vector<cricket::VideoCodec> codecs;
   codecs.push_back(kVp8Codec);
@@ -1850,12 +1846,23 @@
       << "Send stream created after SetSend(true) not sending initially.";
 }
 
-TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetDscpOptions) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithMaxBitrate) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
+// This test verifies DSCP settings are properly applied on video media channel.
+TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) {
+  rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface(
+      new cricket::FakeNetworkInterface);
+  channel_->SetInterface(network_interface.get());
+  cricket::VideoOptions options;
+  options.dscp.Set(true);
+  EXPECT_TRUE(channel_->SetOptions(options));
+  EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp());
+  // Verify previous value is not modified if dscp option is not set.
+  cricket::VideoOptions options1;
+  EXPECT_TRUE(channel_->SetOptions(options1));
+  EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp());
+  options.dscp.Set(false);
+  EXPECT_TRUE(channel_->SetOptions(options));
+  EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
+  channel_->SetInterface(NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) {