pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2004 Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #include <map> |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 29 | #include <vector> |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 30 | |
| 31 | #include "talk/base/gunit.h" |
| 32 | #include "talk/media/base/testutils.h" |
| 33 | #include "talk/media/base/videoengine_unittest.h" |
| 34 | #include "talk/media/webrtc/webrtcvideoengine2.h" |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 35 | #include "talk/media/webrtc/webrtcvideoengine2_unittest.h" |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 36 | #include "talk/media/webrtc/webrtcvideochannelfactory.h" |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 37 | |
| 38 | namespace { |
| 39 | static const cricket::VideoCodec kVp8Codec720p(100, "VP8", 1280, 720, 30, 0); |
| 40 | static const cricket::VideoCodec kVp8Codec360p(100, "VP8", 640, 360, 30, 0); |
| 41 | static const cricket::VideoCodec kVp8Codec270p(100, "VP8", 480, 270, 30, 0); |
| 42 | static const cricket::VideoCodec kVp8Codec180p(100, "VP8", 320, 180, 30, 0); |
| 43 | |
| 44 | static const cricket::VideoCodec kVp8Codec(100, "VP8", 640, 400, 30, 0); |
| 45 | static const cricket::VideoCodec kVp9Codec(101, "VP9", 640, 400, 30, 0); |
| 46 | static const cricket::VideoCodec kRedCodec(116, "red", 0, 0, 0, 0); |
| 47 | static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0, 0); |
| 48 | |
| 49 | static const uint32 kSsrcs1[] = {1}; |
| 50 | static const uint32 kRtxSsrcs1[] = {4}; |
pbos@webrtc.org | aa77587 | 2014-06-13 12:27:38 +0000 | [diff] [blame^] | 51 | |
| 52 | void VerifyCodecHasDefaultFeedbackParams(const cricket::VideoCodec& codec) { |
| 53 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 54 | cricket::kRtcpFbParamNack, cricket::kParamValueEmpty))); |
| 55 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 56 | cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli))); |
| 57 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 58 | cricket::kRtcpFbParamRemb, cricket::kParamValueEmpty))); |
| 59 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 60 | cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir))); |
| 61 | } |
| 62 | |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 63 | } // namespace |
| 64 | |
| 65 | namespace cricket { |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 66 | FakeVideoSendStream::FakeVideoSendStream( |
| 67 | const webrtc::VideoSendStream::Config& config, |
| 68 | const std::vector<webrtc::VideoStream>& video_streams) |
| 69 | : sending_(false), config_(config), video_streams_(video_streams) { |
| 70 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 71 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 72 | webrtc::VideoSendStream::Config FakeVideoSendStream::GetConfig() { |
| 73 | return config_; |
| 74 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 75 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 76 | std::vector<webrtc::VideoStream> FakeVideoSendStream::GetVideoStreams() { |
| 77 | return video_streams_; |
| 78 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 79 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 80 | bool FakeVideoSendStream::IsSending() { |
| 81 | return sending_; |
| 82 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 83 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 84 | webrtc::VideoSendStream::Stats FakeVideoSendStream::GetStats() const { |
| 85 | return webrtc::VideoSendStream::Stats(); |
| 86 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 87 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 88 | bool FakeVideoSendStream::ReconfigureVideoEncoder( |
| 89 | const std::vector<webrtc::VideoStream>& streams, |
| 90 | const void* encoder_specific) { |
| 91 | video_streams_ = streams; |
| 92 | return true; |
| 93 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 94 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 95 | webrtc::VideoSendStreamInput* FakeVideoSendStream::Input() { |
| 96 | // TODO(pbos): Fix. |
| 97 | return NULL; |
| 98 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 99 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 100 | void FakeVideoSendStream::Start() { |
| 101 | sending_ = true; |
| 102 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 103 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 104 | void FakeVideoSendStream::Stop() { |
| 105 | sending_ = false; |
| 106 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 107 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 108 | FakeVideoReceiveStream::FakeVideoReceiveStream( |
| 109 | const webrtc::VideoReceiveStream::Config& config) |
| 110 | : config_(config), receiving_(false) { |
| 111 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 112 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 113 | webrtc::VideoReceiveStream::Config FakeVideoReceiveStream::GetConfig() { |
| 114 | return config_; |
| 115 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 116 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 117 | webrtc::VideoReceiveStream::Stats FakeVideoReceiveStream::GetStats() const { |
| 118 | return webrtc::VideoReceiveStream::Stats(); |
| 119 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 120 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 121 | void FakeVideoReceiveStream::Start() { |
| 122 | receiving_ = true; |
| 123 | } |
| 124 | void FakeVideoReceiveStream::Stop() { |
| 125 | receiving_ = false; |
| 126 | } |
| 127 | void FakeVideoReceiveStream::GetCurrentReceiveCodec(webrtc::VideoCodec* codec) { |
| 128 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 129 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 130 | FakeCall::FakeCall() { SetVideoCodecs(GetDefaultVideoCodecs()); } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 131 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 132 | FakeCall::~FakeCall() { |
| 133 | EXPECT_EQ(0u, video_send_streams_.size()); |
| 134 | EXPECT_EQ(0u, video_receive_streams_.size()); |
| 135 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 136 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 137 | void FakeCall::SetVideoCodecs(const std::vector<webrtc::VideoCodec> codecs) { |
| 138 | codecs_ = codecs; |
| 139 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 140 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 141 | std::vector<FakeVideoSendStream*> FakeCall::GetVideoSendStreams() { |
| 142 | return video_send_streams_; |
| 143 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 144 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 145 | std::vector<FakeVideoReceiveStream*> FakeCall::GetVideoReceiveStreams() { |
| 146 | return video_receive_streams_; |
| 147 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 148 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 149 | webrtc::VideoCodec FakeCall::GetEmptyVideoCodec() { |
| 150 | webrtc::VideoCodec codec; |
| 151 | codec.minBitrate = 300; |
| 152 | codec.startBitrate = 800; |
| 153 | codec.maxBitrate = 1500; |
| 154 | codec.maxFramerate = 10; |
| 155 | codec.width = 640; |
| 156 | codec.height = 480; |
| 157 | codec.qpMax = 56; |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 158 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 159 | return codec; |
| 160 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 161 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 162 | webrtc::VideoCodec FakeCall::GetVideoCodecVp8() { |
| 163 | webrtc::VideoCodec vp8_codec = GetEmptyVideoCodec(); |
| 164 | vp8_codec.codecType = webrtc::kVideoCodecVP8; |
| 165 | strcpy(vp8_codec.plName, kVp8Codec.name.c_str()); |
| 166 | vp8_codec.plType = kVp8Codec.id; |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 167 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 168 | return vp8_codec; |
| 169 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 170 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 171 | webrtc::VideoCodec FakeCall::GetVideoCodecVp9() { |
| 172 | webrtc::VideoCodec vp9_codec = GetEmptyVideoCodec(); |
| 173 | // TODO(pbos): Add a correct codecType when webrtc has one. |
| 174 | vp9_codec.codecType = webrtc::kVideoCodecVP8; |
| 175 | strcpy(vp9_codec.plName, kVp9Codec.name.c_str()); |
| 176 | vp9_codec.plType = kVp9Codec.id; |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 177 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 178 | return vp9_codec; |
| 179 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 180 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 181 | std::vector<webrtc::VideoCodec> FakeCall::GetDefaultVideoCodecs() { |
| 182 | std::vector<webrtc::VideoCodec> codecs; |
| 183 | codecs.push_back(GetVideoCodecVp8()); |
| 184 | // codecs.push_back(GetVideoCodecVp9()); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 185 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 186 | return codecs; |
| 187 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 188 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 189 | webrtc::VideoSendStream::Config FakeCall::GetDefaultSendConfig() { |
| 190 | webrtc::VideoSendStream::Config config; |
| 191 | // TODO(pbos): Encoder settings. |
| 192 | // config.codec = GetVideoCodecVp8(); |
| 193 | return config; |
| 194 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 195 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 196 | webrtc::VideoSendStream* FakeCall::CreateVideoSendStream( |
| 197 | const webrtc::VideoSendStream::Config& config, |
| 198 | const std::vector<webrtc::VideoStream>& video_streams, |
| 199 | const void* encoder_settings) { |
| 200 | FakeVideoSendStream* fake_stream = |
| 201 | new FakeVideoSendStream(config, video_streams); |
| 202 | video_send_streams_.push_back(fake_stream); |
| 203 | return fake_stream; |
| 204 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 205 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 206 | void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { |
| 207 | FakeVideoSendStream* fake_stream = |
| 208 | static_cast<FakeVideoSendStream*>(send_stream); |
| 209 | for (size_t i = 0; i < video_send_streams_.size(); ++i) { |
| 210 | if (video_send_streams_[i] == fake_stream) { |
| 211 | delete video_send_streams_[i]; |
| 212 | video_send_streams_.erase(video_send_streams_.begin() + i); |
| 213 | return; |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 214 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 215 | } |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 216 | ADD_FAILURE() << "DestroyVideoSendStream called with unknown paramter."; |
| 217 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 218 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 219 | webrtc::VideoReceiveStream::Config FakeCall::GetDefaultReceiveConfig() { |
| 220 | return webrtc::VideoReceiveStream::Config(); |
| 221 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 222 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 223 | webrtc::VideoReceiveStream* FakeCall::CreateVideoReceiveStream( |
| 224 | const webrtc::VideoReceiveStream::Config& config) { |
| 225 | video_receive_streams_.push_back(new FakeVideoReceiveStream(config)); |
| 226 | return video_receive_streams_[video_receive_streams_.size() - 1]; |
| 227 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 228 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 229 | void FakeCall::DestroyVideoReceiveStream( |
| 230 | webrtc::VideoReceiveStream* receive_stream) { |
| 231 | FakeVideoReceiveStream* fake_stream = |
| 232 | static_cast<FakeVideoReceiveStream*>(receive_stream); |
| 233 | for (size_t i = 0; i < video_receive_streams_.size(); ++i) { |
| 234 | if (video_receive_streams_[i] == fake_stream) { |
| 235 | delete video_receive_streams_[i]; |
| 236 | video_receive_streams_.erase(video_receive_streams_.begin() + i); |
| 237 | return; |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 238 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 239 | } |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 240 | ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown paramter."; |
| 241 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 242 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 243 | webrtc::PacketReceiver* FakeCall::Receiver() { |
| 244 | // TODO(pbos): Fix this. |
| 245 | return NULL; |
| 246 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 247 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 248 | uint32_t FakeCall::SendBitrateEstimate() { |
| 249 | return 0; |
| 250 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 251 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 252 | uint32_t FakeCall::ReceiveBitrateEstimate() { |
| 253 | return 0; |
| 254 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 255 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 256 | FakeWebRtcVideoChannel2::FakeWebRtcVideoChannel2( |
| 257 | FakeCall* call, |
| 258 | WebRtcVideoEngine2* engine, |
| 259 | VoiceMediaChannel* voice_channel) |
| 260 | : WebRtcVideoChannel2(call, engine, engine->GetVideoEncoderFactory()), |
| 261 | fake_call_(call), |
| 262 | voice_channel_(voice_channel) { |
| 263 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 264 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 265 | FakeWebRtcVideoChannel2::~FakeWebRtcVideoChannel2() { |
| 266 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 267 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 268 | VoiceMediaChannel* FakeWebRtcVideoChannel2::GetVoiceChannel() { |
| 269 | return voice_channel_; |
| 270 | } |
| 271 | FakeCall* FakeWebRtcVideoChannel2::GetFakeCall() { |
| 272 | return fake_call_; |
| 273 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 274 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 275 | FakeWebRtcVideoChannel2* FakeWebRtcVideoMediaChannelFactory::GetFakeChannel( |
| 276 | VideoMediaChannel* channel) { |
| 277 | return channel_map_[channel]; |
| 278 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 279 | |
pbos@webrtc.org | 1ef658d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 280 | WebRtcVideoChannel2* FakeWebRtcVideoMediaChannelFactory::Create( |
| 281 | WebRtcVideoEngine2* engine, |
| 282 | VoiceMediaChannel* voice_channel) { |
| 283 | FakeWebRtcVideoChannel2* channel = |
| 284 | new FakeWebRtcVideoChannel2(new FakeCall(), engine, voice_channel); |
| 285 | channel_map_[channel] = channel; |
| 286 | return channel; |
| 287 | } |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 288 | |
| 289 | class WebRtcVideoEngine2Test : public testing::Test { |
| 290 | public: |
pbos@webrtc.org | 6bb6290 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 291 | WebRtcVideoEngine2Test() : engine_(&factory_) { |
| 292 | std::vector<VideoCodec> engine_codecs = engine_.codecs(); |
| 293 | assert(!engine_codecs.empty()); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 294 | bool codec_set = false; |
pbos@webrtc.org | 6bb6290 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 295 | for (size_t i = 0; i < engine_codecs.size(); ++i) { |
| 296 | if (engine_codecs[i].name == "red") { |
| 297 | default_red_codec_ = engine_codecs[i]; |
| 298 | } else if (engine_codecs[i].name == "ulpfec") { |
| 299 | default_ulpfec_codec_ = engine_codecs[i]; |
| 300 | } else if (engine_codecs[i].name == "rtx") { |
| 301 | default_rtx_codec_ = engine_codecs[i]; |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 302 | } else if (!codec_set) { |
pbos@webrtc.org | 6bb6290 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 303 | default_codec_ = engine_codecs[i]; |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 304 | codec_set = true; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | assert(codec_set); |
| 309 | } |
| 310 | |
| 311 | protected: |
| 312 | FakeWebRtcVideoMediaChannelFactory factory_; |
| 313 | WebRtcVideoEngine2 engine_; |
| 314 | VideoCodec default_codec_; |
| 315 | VideoCodec default_red_codec_; |
| 316 | VideoCodec default_ulpfec_codec_; |
| 317 | VideoCodec default_rtx_codec_; |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 318 | }; |
| 319 | |
| 320 | TEST_F(WebRtcVideoEngine2Test, CreateChannel) { |
| 321 | talk_base::scoped_ptr<VideoMediaChannel> channel(engine_.CreateChannel(NULL)); |
| 322 | ASSERT_TRUE(channel.get() != NULL) << "Could not create channel."; |
| 323 | EXPECT_TRUE(factory_.GetFakeChannel(channel.get()) != NULL) |
| 324 | << "Channel not created through factory."; |
| 325 | } |
| 326 | |
| 327 | TEST_F(WebRtcVideoEngine2Test, CreateChannelWithVoiceEngine) { |
| 328 | VoiceMediaChannel* voice_channel = reinterpret_cast<VoiceMediaChannel*>(0x42); |
| 329 | talk_base::scoped_ptr<VideoMediaChannel> channel( |
| 330 | engine_.CreateChannel(voice_channel)); |
| 331 | ASSERT_TRUE(channel.get() != NULL) << "Could not create channel."; |
| 332 | |
| 333 | FakeWebRtcVideoChannel2* fake_channel = |
| 334 | factory_.GetFakeChannel(channel.get()); |
| 335 | ASSERT_TRUE(fake_channel != NULL) << "Channel not created through factory."; |
| 336 | |
| 337 | EXPECT_TRUE(fake_channel->GetVoiceChannel() != NULL) |
| 338 | << "VoiceChannel not set."; |
| 339 | EXPECT_EQ(voice_channel, fake_channel->GetVoiceChannel()) |
| 340 | << "Different VoiceChannel set than the provided one."; |
| 341 | } |
| 342 | |
pbos@webrtc.org | 2352cb3 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 343 | TEST_F(WebRtcVideoEngine2Test, FindCodec) { |
| 344 | const std::vector<cricket::VideoCodec>& c = engine_.codecs(); |
| 345 | EXPECT_EQ(4U, c.size()); |
| 346 | |
| 347 | cricket::VideoCodec vp8(104, "VP8", 320, 200, 30, 0); |
| 348 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 349 | |
| 350 | cricket::VideoCodec vp8_ci(104, "vp8", 320, 200, 30, 0); |
| 351 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 352 | |
| 353 | cricket::VideoCodec vp8_diff_fr_diff_pref(104, "VP8", 320, 200, 50, 50); |
| 354 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_fr_diff_pref)); |
| 355 | |
| 356 | cricket::VideoCodec vp8_diff_id(95, "VP8", 320, 200, 30, 0); |
| 357 | EXPECT_FALSE(engine_.FindCodec(vp8_diff_id)); |
| 358 | vp8_diff_id.id = 97; |
| 359 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_id)); |
| 360 | |
| 361 | cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0); |
| 362 | EXPECT_FALSE(engine_.FindCodec(vp8_diff_res)); |
| 363 | |
| 364 | // PeerConnection doesn't negotiate the resolution at this point. |
| 365 | // Test that FindCodec can handle the case when width/height is 0. |
| 366 | cricket::VideoCodec vp8_zero_res(104, "VP8", 0, 0, 30, 0); |
| 367 | EXPECT_TRUE(engine_.FindCodec(vp8_zero_res)); |
| 368 | |
| 369 | cricket::VideoCodec red(101, "RED", 0, 0, 30, 0); |
| 370 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 371 | |
| 372 | cricket::VideoCodec red_ci(101, "red", 0, 0, 30, 0); |
| 373 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 374 | |
| 375 | cricket::VideoCodec fec(102, "ULPFEC", 0, 0, 30, 0); |
| 376 | EXPECT_TRUE(engine_.FindCodec(fec)); |
| 377 | |
| 378 | cricket::VideoCodec fec_ci(102, "ulpfec", 0, 0, 30, 0); |
| 379 | EXPECT_TRUE(engine_.FindCodec(fec)); |
| 380 | |
| 381 | cricket::VideoCodec rtx(96, "rtx", 0, 0, 30, 0); |
| 382 | EXPECT_TRUE(engine_.FindCodec(rtx)); |
| 383 | } |
| 384 | |
| 385 | TEST_F(WebRtcVideoEngine2Test, DefaultRtxCodecHasAssociatedPayloadTypeSet) { |
| 386 | std::vector<VideoCodec> engine_codecs = engine_.codecs(); |
| 387 | for (size_t i = 0; i < engine_codecs.size(); ++i) { |
| 388 | if (engine_codecs[i].name != kRtxCodecName) |
| 389 | continue; |
| 390 | int associated_payload_type; |
| 391 | EXPECT_TRUE(engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType, |
| 392 | &associated_payload_type)); |
| 393 | EXPECT_EQ(default_codec_.id, associated_payload_type); |
| 394 | return; |
| 395 | } |
| 396 | FAIL() << "No RTX codec found among default codecs."; |
| 397 | } |
| 398 | |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 399 | class WebRtcVideoChannel2BaseTest |
| 400 | : public VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> { |
| 401 | protected: |
| 402 | virtual cricket::VideoCodec DefaultCodec() OVERRIDE { return kVp8Codec; } |
| 403 | typedef VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> Base; |
| 404 | }; |
| 405 | |
| 406 | // TODO(pbos): Fix WebRtcVideoEngine2BaseTest, where we want CheckCoInitialize. |
| 407 | #if 0 |
| 408 | // TODO(juberti): Figure out why ViE is munging the COM refcount. |
| 409 | #ifdef WIN32 |
| 410 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_CheckCoInitialize) { |
| 411 | Base::CheckCoInitialize(); |
| 412 | } |
| 413 | #endif |
| 414 | #endif |
| 415 | |
| 416 | TEST_F(WebRtcVideoChannel2BaseTest, SetSend) { Base::SetSend(); } |
| 417 | |
| 418 | TEST_F(WebRtcVideoChannel2BaseTest, SetSendWithoutCodecs) { |
| 419 | Base::SetSendWithoutCodecs(); |
| 420 | } |
| 421 | |
| 422 | TEST_F(WebRtcVideoChannel2BaseTest, SetSendSetsTransportBufferSizes) { |
| 423 | Base::SetSendSetsTransportBufferSizes(); |
| 424 | } |
| 425 | |
| 426 | // TODO(juberti): Fix this test to tolerate missing stats. |
| 427 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_GetStats) { Base::GetStats(); } |
| 428 | |
| 429 | // TODO(juberti): Fix this test to tolerate missing stats. |
| 430 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_GetStatsMultipleRecvStreams) { |
| 431 | Base::GetStatsMultipleRecvStreams(); |
| 432 | } |
| 433 | |
| 434 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_GetStatsMultipleSendStreams) { |
| 435 | Base::GetStatsMultipleSendStreams(); |
| 436 | } |
| 437 | |
| 438 | TEST_F(WebRtcVideoChannel2BaseTest, SetSendBandwidth) { |
| 439 | Base::SetSendBandwidth(); |
| 440 | } |
| 441 | TEST_F(WebRtcVideoChannel2BaseTest, SetSendSsrc) { Base::SetSendSsrc(); } |
| 442 | TEST_F(WebRtcVideoChannel2BaseTest, SetSendSsrcAfterSetCodecs) { |
| 443 | Base::SetSendSsrcAfterSetCodecs(); |
| 444 | } |
| 445 | |
| 446 | TEST_F(WebRtcVideoChannel2BaseTest, SetRenderer) { Base::SetRenderer(); } |
| 447 | |
| 448 | TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveRecvStreams) { |
| 449 | Base::AddRemoveRecvStreams(); |
| 450 | } |
| 451 | |
| 452 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_AddRemoveRecvStreamAndRender) { |
| 453 | Base::AddRemoveRecvStreamAndRender(); |
| 454 | } |
| 455 | |
| 456 | TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveRecvStreamsNoConference) { |
| 457 | Base::AddRemoveRecvStreamsNoConference(); |
| 458 | } |
| 459 | |
| 460 | TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveSendStreams) { |
| 461 | Base::AddRemoveSendStreams(); |
| 462 | } |
| 463 | |
| 464 | TEST_F(WebRtcVideoChannel2BaseTest, SimulateConference) { |
| 465 | Base::SimulateConference(); |
| 466 | } |
| 467 | |
| 468 | TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveCapturer) { |
| 469 | Base::AddRemoveCapturer(); |
| 470 | } |
| 471 | |
| 472 | TEST_F(WebRtcVideoChannel2BaseTest, RemoveCapturerWithoutAdd) { |
| 473 | Base::RemoveCapturerWithoutAdd(); |
| 474 | } |
| 475 | |
| 476 | TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveCapturerMultipleSources) { |
| 477 | Base::AddRemoveCapturerMultipleSources(); |
| 478 | } |
| 479 | |
| 480 | // TODO(pbos): Figure out why this fails so often. |
| 481 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_HighAspectHighHeightCapturer) { |
| 482 | Base::HighAspectHighHeightCapturer(); |
| 483 | } |
| 484 | |
| 485 | TEST_F(WebRtcVideoChannel2BaseTest, RejectEmptyStreamParams) { |
| 486 | Base::RejectEmptyStreamParams(); |
| 487 | } |
| 488 | |
| 489 | TEST_F(WebRtcVideoChannel2BaseTest, AdaptResolution16x10) { |
| 490 | Base::AdaptResolution16x10(); |
| 491 | } |
| 492 | |
| 493 | TEST_F(WebRtcVideoChannel2BaseTest, AdaptResolution4x3) { |
| 494 | Base::AdaptResolution4x3(); |
| 495 | } |
| 496 | |
| 497 | TEST_F(WebRtcVideoChannel2BaseTest, MuteStream) { Base::MuteStream(); } |
| 498 | |
| 499 | TEST_F(WebRtcVideoChannel2BaseTest, MultipleSendStreams) { |
| 500 | Base::MultipleSendStreams(); |
| 501 | } |
| 502 | |
| 503 | // TODO(juberti): Restore this test once we support sending 0 fps. |
| 504 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_AdaptDropAllFrames) { |
| 505 | Base::AdaptDropAllFrames(); |
| 506 | } |
| 507 | // TODO(juberti): Understand why we get decode errors on this test. |
| 508 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_AdaptFramerate) { |
| 509 | Base::AdaptFramerate(); |
| 510 | } |
| 511 | |
| 512 | TEST_F(WebRtcVideoChannel2BaseTest, SetSendStreamFormat0x0) { |
| 513 | Base::SetSendStreamFormat0x0(); |
| 514 | } |
| 515 | |
| 516 | // TODO(zhurunz): Fix the flakey test. |
| 517 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_SetSendStreamFormat) { |
| 518 | Base::SetSendStreamFormat(); |
| 519 | } |
| 520 | |
| 521 | TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) { |
| 522 | Base::TwoStreamsSendAndReceive(kVp8Codec); |
| 523 | } |
| 524 | |
| 525 | TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsReUseFirstStream) { |
| 526 | Base::TwoStreamsReUseFirstStream(kVp8Codec); |
| 527 | } |
| 528 | |
| 529 | class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { |
| 530 | public: |
| 531 | virtual void SetUp() OVERRIDE { |
| 532 | channel_.reset(engine_.CreateChannel(NULL)); |
| 533 | fake_channel_ = factory_.GetFakeChannel(channel_.get()); |
| 534 | last_ssrc_ = 123; |
| 535 | ASSERT_TRUE(fake_channel_ != NULL) |
| 536 | << "Channel not created through factory."; |
| 537 | } |
| 538 | |
| 539 | protected: |
| 540 | FakeVideoSendStream* AddSendStream() { |
| 541 | return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++)); |
| 542 | } |
| 543 | |
| 544 | FakeVideoSendStream* AddSendStream(const StreamParams& sp) { |
| 545 | size_t num_streams = |
| 546 | fake_channel_->GetFakeCall()->GetVideoSendStreams().size(); |
| 547 | EXPECT_TRUE(channel_->AddSendStream(sp)); |
| 548 | std::vector<FakeVideoSendStream*> streams = |
| 549 | fake_channel_->GetFakeCall()->GetVideoSendStreams(); |
| 550 | EXPECT_EQ(num_streams + 1, streams.size()); |
| 551 | return streams[streams.size() - 1]; |
| 552 | } |
| 553 | |
| 554 | std::vector<FakeVideoSendStream*> GetFakeSendStreams() { |
| 555 | return fake_channel_->GetFakeCall()->GetVideoSendStreams(); |
| 556 | } |
| 557 | |
| 558 | FakeVideoReceiveStream* AddRecvStream() { |
| 559 | return AddRecvStream(StreamParams::CreateLegacy(last_ssrc_++)); |
| 560 | } |
| 561 | |
| 562 | FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { |
| 563 | size_t num_streams = |
| 564 | fake_channel_->GetFakeCall()->GetVideoReceiveStreams().size(); |
| 565 | EXPECT_TRUE(channel_->AddRecvStream(sp)); |
| 566 | std::vector<FakeVideoReceiveStream*> streams = |
| 567 | fake_channel_->GetFakeCall()->GetVideoReceiveStreams(); |
| 568 | EXPECT_EQ(num_streams + 1, streams.size()); |
| 569 | return streams[streams.size() - 1]; |
| 570 | } |
| 571 | |
| 572 | void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate, |
| 573 | const char* max_bitrate) { |
| 574 | std::vector<VideoCodec> codecs; |
| 575 | codecs.push_back(kVp8Codec); |
| 576 | codecs[0].params[kCodecParamMinBitrate] = min_bitrate; |
| 577 | codecs[0].params[kCodecParamMaxBitrate] = max_bitrate; |
| 578 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 579 | |
| 580 | FakeVideoSendStream* stream = AddSendStream(); |
| 581 | |
pbos@webrtc.org | 7254487 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 582 | std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
| 583 | ASSERT_EQ(1u, video_streams.size()); |
| 584 | EXPECT_EQ(atoi(min_bitrate), video_streams.back().min_bitrate_bps / 1000); |
| 585 | EXPECT_EQ(atoi(max_bitrate), video_streams.back().max_bitrate_bps / 1000); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 586 | |
| 587 | VideoCodec codec; |
| 588 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 589 | EXPECT_EQ(min_bitrate, codec.params[kCodecParamMinBitrate]); |
| 590 | EXPECT_EQ(max_bitrate, codec.params[kCodecParamMaxBitrate]); |
| 591 | } |
| 592 | |
| 593 | void ExpectEqualCodecs(const VideoCodec video_codec, |
| 594 | const webrtc::VideoCodec& webrtc_codec) { |
| 595 | EXPECT_STREQ(video_codec.name.c_str(), webrtc_codec.plName); |
| 596 | EXPECT_EQ(video_codec.id, webrtc_codec.plType); |
| 597 | EXPECT_EQ(video_codec.width, webrtc_codec.width); |
| 598 | EXPECT_EQ(video_codec.height, webrtc_codec.height); |
| 599 | EXPECT_EQ(video_codec.framerate, webrtc_codec.maxFramerate); |
| 600 | } |
| 601 | talk_base::scoped_ptr<VideoMediaChannel> channel_; |
| 602 | FakeWebRtcVideoChannel2* fake_channel_; |
| 603 | uint32 last_ssrc_; |
| 604 | }; |
| 605 | |
| 606 | TEST_F(WebRtcVideoChannel2Test, DISABLED_MaxBitrateResetsWithConferenceMode) { |
| 607 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 608 | } |
| 609 | |
| 610 | TEST_F(WebRtcVideoChannel2Test, DISABLED_StartSendBitrate) { |
| 611 | // TODO(pbos): Is this test testing vie_ ? this is confusing. No API to set |
| 612 | // start send bitrate from outside? Add defaults here that should be kept? |
| 613 | std::vector<cricket::VideoCodec> codec_list; |
| 614 | codec_list.push_back(kVp8Codec); |
| 615 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 616 | const unsigned int kVideoMinSendBitrateKbps = 50; |
| 617 | const unsigned int kVideoTargetSendBitrateKbps = 300; |
| 618 | const unsigned int kVideoMaxSendBitrateKbps = 2000; |
| 619 | FakeVideoSendStream* stream = AddSendStream(); |
pbos@webrtc.org | 7254487 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 620 | std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
| 621 | ASSERT_EQ(1u, video_streams.size()); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 622 | EXPECT_EQ(kVideoMinSendBitrateKbps, |
pbos@webrtc.org | 7254487 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 623 | video_streams.back().min_bitrate_bps / 1000); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 624 | EXPECT_EQ(kVideoTargetSendBitrateKbps, |
pbos@webrtc.org | 7254487 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 625 | video_streams.back().target_bitrate_bps / 1000); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 626 | EXPECT_EQ(kVideoMaxSendBitrateKbps, |
pbos@webrtc.org | 7254487 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 627 | video_streams.back().max_bitrate_bps / 1000); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 628 | #if 0 |
| 629 | // TODO(pbos): un-#if |
| 630 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 631 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 632 | kVideoDefaultStartSendBitrateKbps); |
| 633 | EXPECT_EQ(0, vie_.StartSend(send_channel)); |
| 634 | |
| 635 | // Increase the send bitrate and verify it is used as start bitrate. |
| 636 | const unsigned int kVideoSendBitrateBps = 768000; |
| 637 | vie_.SetSendBitrates(send_channel, kVideoSendBitrateBps, 0, 0); |
| 638 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 639 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 640 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 641 | kVideoSendBitrateBps / 1000); |
| 642 | |
| 643 | // Never set a start bitrate higher than the max bitrate. |
| 644 | vie_.SetSendBitrates(send_channel, kVideoMaxSendBitrateKbps + 500, 0, 0); |
| 645 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 646 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 647 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 648 | kVideoDefaultStartSendBitrateKbps); |
| 649 | |
| 650 | // Use the default start bitrate if the send bitrate is lower. |
| 651 | vie_.SetSendBitrates(send_channel, kVideoDefaultStartSendBitrateKbps - 50, 0, |
| 652 | 0); |
| 653 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 654 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 655 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 656 | kVideoDefaultStartSendBitrateKbps); |
| 657 | #endif |
| 658 | } |
| 659 | |
| 660 | TEST_F(WebRtcVideoChannel2Test, DISABLED_RtcpEnabled) { |
| 661 | // Note(pbos): This is a receiver-side setting, dumbo. |
| 662 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 663 | } |
| 664 | |
| 665 | TEST_F(WebRtcVideoChannel2Test, DISABLED_KeyFrameRequestEnabled) { |
| 666 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 667 | } |
| 668 | |
| 669 | TEST_F(WebRtcVideoChannel2Test, RembIsEnabledByDefault) { |
| 670 | FakeVideoReceiveStream* stream = AddRecvStream(); |
| 671 | EXPECT_TRUE(stream->GetConfig().rtp.remb); |
| 672 | } |
| 673 | |
| 674 | TEST_F(WebRtcVideoChannel2Test, DISABLED_RembEnabledOnReceiveChannels) { |
| 675 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 676 | } |
| 677 | |
pbos@webrtc.org | 2352cb3 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 678 | TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 679 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 680 | EXPECT_TRUE(channel_->SetSend(true)); |
| 681 | cricket::VideoOptions options; |
| 682 | options.conference_mode.Set(true); |
| 683 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 684 | |
| 685 | // Send side. |
| 686 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 687 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 688 | FakeVideoSendStream* send_stream = AddSendStream( |
| 689 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 690 | |
| 691 | ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); |
| 692 | for (size_t i = 0; i < rtx_ssrcs.size(); ++i) |
| 693 | EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); |
| 694 | |
| 695 | // Receiver side. |
| 696 | FakeVideoReceiveStream* recv_stream = AddRecvStream( |
| 697 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 698 | ASSERT_GT(recv_stream->GetConfig().rtp.rtx.size(), 0u) |
| 699 | << "No SSRCs for RTX configured by AddRecvStream."; |
| 700 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size()) |
| 701 | << "This test only works with one receive codec. Please update the test."; |
| 702 | EXPECT_EQ(rtx_ssrcs[0], |
| 703 | recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc); |
| 704 | // TODO(pbos): Make sure we set the RTX for correct payloads etc. |
| 705 | } |
| 706 | |
pbos@webrtc.org | 2352cb3 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 707 | TEST_F(WebRtcVideoChannel2Test, RecvStreamWithRtx) { |
| 708 | // Setup one channel with an associated RTX stream. |
| 709 | cricket::StreamParams params = |
| 710 | cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
| 711 | params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); |
| 712 | FakeVideoReceiveStream* recv_stream = AddRecvStream(params); |
| 713 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size()); |
| 714 | EXPECT_EQ(kRtxSsrcs1[0], |
| 715 | recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 716 | } |
| 717 | |
pbos@webrtc.org | 2352cb3 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 718 | TEST_F(WebRtcVideoChannel2Test, RecvStreamNoRtx) { |
| 719 | // Setup one channel without an associated RTX stream. |
| 720 | cricket::StreamParams params = |
| 721 | cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
| 722 | FakeVideoReceiveStream* recv_stream = AddRecvStream(params); |
| 723 | ASSERT_TRUE(recv_stream->GetConfig().rtp.rtx.empty()); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | TEST_F(WebRtcVideoChannel2Test, DISABLED_RtpTimestampOffsetHeaderExtensions) { |
| 727 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 728 | } |
| 729 | |
| 730 | TEST_F(WebRtcVideoChannel2Test, DISABLED_AbsoluteSendTimeHeaderExtensions) { |
| 731 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 732 | } |
| 733 | |
| 734 | TEST_F(WebRtcVideoChannel2Test, DISABLED_LeakyBucketTest) { |
| 735 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 736 | } |
| 737 | |
| 738 | TEST_F(WebRtcVideoChannel2Test, DISABLED_BufferedModeLatency) { |
| 739 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 740 | } |
| 741 | |
| 742 | TEST_F(WebRtcVideoChannel2Test, DISABLED_AdditiveVideoOptions) { |
| 743 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 744 | } |
| 745 | |
| 746 | TEST_F(WebRtcVideoChannel2Test, AddRecvStreamOnlyUsesOneReceiveStream) { |
| 747 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 748 | EXPECT_EQ(1u, fake_channel_->GetFakeCall()->GetVideoReceiveStreams().size()); |
| 749 | } |
| 750 | |
| 751 | TEST_F(WebRtcVideoChannel2Test, DISABLED_NoRembChangeAfterAddRecvStream) { |
| 752 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 753 | } |
| 754 | |
| 755 | TEST_F(WebRtcVideoChannel2Test, DISABLED_RembOnOff) { |
| 756 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 757 | } |
| 758 | |
pbos@webrtc.org | aa77587 | 2014-06-13 12:27:38 +0000 | [diff] [blame^] | 759 | TEST_F(WebRtcVideoChannel2Test, NackIsEnabledByDefault) { |
| 760 | VerifyCodecHasDefaultFeedbackParams(default_codec_); |
| 761 | |
pbos@webrtc.org | 84f5e34 | 2014-05-30 07:35:47 +0000 | [diff] [blame] | 762 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 763 | EXPECT_TRUE(channel_->SetSend(true)); |
| 764 | |
| 765 | // Send side. |
| 766 | FakeVideoSendStream* send_stream = |
| 767 | AddSendStream(cricket::StreamParams::CreateLegacy(1)); |
| 768 | EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
| 769 | |
| 770 | // Receiver side. |
| 771 | FakeVideoReceiveStream* recv_stream = |
| 772 | AddRecvStream(cricket::StreamParams::CreateLegacy(1)); |
| 773 | EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
| 774 | |
| 775 | // Nack history size should match between sender and receiver. |
| 776 | EXPECT_EQ(send_stream->GetConfig().rtp.nack.rtp_history_ms, |
| 777 | recv_stream->GetConfig().rtp.nack.rtp_history_ms); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 778 | } |
| 779 | |
pbos@webrtc.org | aa77587 | 2014-06-13 12:27:38 +0000 | [diff] [blame^] | 780 | TEST_F(WebRtcVideoChannel2Test, NackCanBeDisabled) { |
| 781 | std::vector<VideoCodec> codecs; |
| 782 | codecs.push_back(kVp8Codec); |
| 783 | |
| 784 | // Send side. |
| 785 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 786 | FakeVideoSendStream* send_stream = |
| 787 | AddSendStream(cricket::StreamParams::CreateLegacy(1)); |
| 788 | EXPECT_EQ(0, send_stream->GetConfig().rtp.nack.rtp_history_ms); |
| 789 | |
| 790 | // Receiver side. |
| 791 | ASSERT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 792 | FakeVideoReceiveStream* recv_stream = |
| 793 | AddRecvStream(cricket::StreamParams::CreateLegacy(1)); |
| 794 | EXPECT_EQ(0, recv_stream->GetConfig().rtp.nack.rtp_history_ms); |
| 795 | } |
| 796 | |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 797 | TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInterop) { |
| 798 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 799 | } |
| 800 | |
| 801 | TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInteropReversed) { |
| 802 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 803 | } |
| 804 | |
| 805 | TEST_F(WebRtcVideoChannel2Test, DISABLED_HybridNackFecConference) { |
| 806 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 807 | } |
| 808 | |
| 809 | TEST_F(WebRtcVideoChannel2Test, DISABLED_AddRemoveRecvStreamConference) { |
| 810 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 811 | } |
| 812 | |
| 813 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRender) { |
| 814 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 815 | } |
| 816 | |
| 817 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAuto) { |
| 818 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 819 | } |
| 820 | |
| 821 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAutoCapped) { |
| 822 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 823 | } |
| 824 | |
| 825 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthFixed) { |
| 826 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 827 | } |
| 828 | |
| 829 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) { |
| 830 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 831 | } |
| 832 | |
| 833 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthScreencast) { |
| 834 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 835 | } |
| 836 | |
| 837 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetSendSsrcAndCname) { |
| 838 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 839 | } |
| 840 | |
| 841 | TEST_F(WebRtcVideoChannel2Test, |
| 842 | DISABLED_SetSendSsrcAfterCreatingReceiveChannel) { |
| 843 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 844 | } |
| 845 | |
| 846 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithDenoising) { |
| 847 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 848 | } |
| 849 | |
| 850 | TEST_F(WebRtcVideoChannel2Test, DISABLED_MultipleSendStreamsWithOneCapturer) { |
| 851 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 852 | } |
| 853 | |
| 854 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DISABLED_SendReceiveBitratesStats) { |
| 855 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 856 | } |
| 857 | |
| 858 | TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetAdaptInputToCpuUsage) { |
| 859 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 860 | } |
| 861 | |
| 862 | TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetCpuThreshold) { |
| 863 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 864 | } |
| 865 | |
| 866 | TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetInvalidCpuThreshold) { |
| 867 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 868 | } |
| 869 | |
| 870 | TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldLog) { |
| 871 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 872 | } |
| 873 | |
| 874 | TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldNotLog) { |
| 875 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 876 | } |
| 877 | |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 878 | TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { |
pbos@webrtc.org | 6bb6290 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 879 | ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 880 | |
| 881 | VideoCodec codec; |
| 882 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
pbos@webrtc.org | 6bb6290 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 883 | EXPECT_TRUE(codec.Matches(engine_.codecs()[0])); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 884 | |
| 885 | // Using a RTX setup to verify that the default RTX payload type is good. |
| 886 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 887 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 888 | FakeVideoSendStream* stream = AddSendStream( |
| 889 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 890 | webrtc::VideoSendStream::Config config = stream->GetConfig(); |
| 891 | // TODO(pbos): Replace ExpectEqualCodecs. |
pbos@webrtc.org | 6bb6290 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 892 | // ExpectEqualCodecs(engine_.codecs()[0], config.codec); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 893 | |
| 894 | // Make sure NACK and FEC are enabled on the correct payload types. |
| 895 | EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms); |
| 896 | EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.fec.ulpfec_payload_type); |
| 897 | EXPECT_EQ(default_red_codec_.id, config.rtp.fec.red_payload_type); |
| 898 | // TODO(pbos): Verify that the rtx ssrc is set, correct, not taken by anything |
| 899 | // else. |
| 900 | // ASSERT_EQ(1u, config.rtp.rtx.ssrcs.size()); |
| 901 | EXPECT_EQ(static_cast<int>(default_rtx_codec_.id), |
| 902 | config.rtp.rtx.payload_type); |
| 903 | // TODO(juberti): Check RTCP, PLI, TMMBR. |
| 904 | } |
| 905 | |
| 906 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { |
| 907 | std::vector<VideoCodec> codecs; |
| 908 | codecs.push_back(kVp8Codec); |
| 909 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 910 | |
| 911 | FakeVideoSendStream* stream = AddSendStream(); |
| 912 | webrtc::VideoSendStream::Config config = stream->GetConfig(); |
| 913 | |
| 914 | EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type); |
| 915 | EXPECT_EQ(-1, config.rtp.fec.red_payload_type); |
| 916 | } |
| 917 | |
| 918 | TEST_F(WebRtcVideoChannel2Test, |
| 919 | DISABLED_SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { |
| 920 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 921 | } |
| 922 | |
| 923 | TEST_F(WebRtcVideoChannel2Test, |
| 924 | DISABLED_SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { |
| 925 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 926 | } |
| 927 | |
| 928 | TEST_F(WebRtcVideoChannel2Test, |
| 929 | DISABLED_SetCodecsWithoutFecDisablesCurrentFec) { |
| 930 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 931 | } |
| 932 | |
| 933 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetSendCodecsChangesExistingStreams) { |
| 934 | FAIL(); // TODO(pbos): Implement, make sure that it's changing running |
| 935 | // streams. Should it? |
| 936 | } |
| 937 | |
| 938 | TEST_F(WebRtcVideoChannel2Test, |
| 939 | DISABLED_ConstrainsSetCodecsAccordingToEncoderConfig) { |
| 940 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 941 | } |
| 942 | |
| 943 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMinMaxBitrate) { |
| 944 | SetSendCodecsShouldWorkForBitrates("10", "20"); |
| 945 | } |
| 946 | |
| 947 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { |
pbos@webrtc.org | 6bb6290 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 948 | std::vector<VideoCodec> video_codecs = engine_.codecs(); |
| 949 | video_codecs[0].params[kCodecParamMinBitrate] = "30"; |
| 950 | video_codecs[0].params[kCodecParamMaxBitrate] = "20"; |
| 951 | EXPECT_FALSE(channel_->SetSendCodecs(video_codecs)); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptLargeMinMaxBitrate) { |
| 955 | SetSendCodecsShouldWorkForBitrates("1000", "2000"); |
| 956 | } |
| 957 | |
| 958 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { |
| 959 | static const char* kMaxQuantization = "21"; |
| 960 | std::vector<VideoCodec> codecs; |
| 961 | codecs.push_back(kVp8Codec); |
| 962 | codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; |
| 963 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
pbos@webrtc.org | 7254487 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 964 | EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)), |
| 965 | AddSendStream()->GetVideoStreams().back().max_qp); |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 966 | |
| 967 | VideoCodec codec; |
| 968 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 969 | EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]); |
| 970 | } |
| 971 | |
| 972 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadDimensions) { |
| 973 | std::vector<cricket::VideoCodec> codecs; |
| 974 | codecs.push_back(kVp8Codec); |
| 975 | |
| 976 | codecs[0].width = 0; |
| 977 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 978 | << "Codec set though codec width is zero."; |
| 979 | |
| 980 | codecs[0].width = kVp8Codec.width; |
| 981 | codecs[0].height = 0; |
| 982 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 983 | << "Codec set though codec height is zero."; |
| 984 | } |
| 985 | |
| 986 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) { |
| 987 | // TODO(pbos): Should we only allow the dynamic range? |
| 988 | static const size_t kNumIncorrectPayloads = 4; |
| 989 | static const int kIncorrectPayloads[kNumIncorrectPayloads] = {-2, -1, 128, |
| 990 | 129}; |
| 991 | std::vector<cricket::VideoCodec> codecs; |
| 992 | codecs.push_back(kVp8Codec); |
| 993 | for (size_t i = 0; i < kNumIncorrectPayloads; ++i) { |
| 994 | int payload_type = kIncorrectPayloads[i]; |
| 995 | codecs[0].id = payload_type; |
| 996 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 997 | << "Bad payload type '" << payload_type << "' accepted."; |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptAllValidPayloadTypes) { |
| 1002 | std::vector<cricket::VideoCodec> codecs; |
| 1003 | codecs.push_back(kVp8Codec); |
| 1004 | for (int payload_type = 0; payload_type <= 127; ++payload_type) { |
| 1005 | codecs[0].id = payload_type; |
| 1006 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)) |
| 1007 | << "Payload type '" << payload_type << "' rejected."; |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetVieSendCodecOnNewFrameSize) { |
| 1012 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1013 | } |
| 1014 | |
| 1015 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { |
| 1016 | std::vector<cricket::VideoCodec> codecs; |
| 1017 | codecs.push_back(kVp8Codec); |
| 1018 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1019 | } |
| 1020 | |
pbos@webrtc.org | 2352cb3 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 1021 | // Test that we set our inbound RTX codecs properly. |
| 1022 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { |
| 1023 | std::vector<cricket::VideoCodec> codecs; |
| 1024 | codecs.push_back(kVp8Codec); |
| 1025 | cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); |
| 1026 | codecs.push_back(rtx_codec); |
| 1027 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) |
| 1028 | << "RTX codec without associated payload should be rejected."; |
| 1029 | |
| 1030 | codecs[1].SetParam("apt", kVp8Codec.id + 1); |
| 1031 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) |
| 1032 | << "RTX codec with invalid associated payload type should be rejected."; |
| 1033 | |
| 1034 | codecs[1].SetParam("apt", kVp8Codec.id); |
| 1035 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1036 | |
| 1037 | cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0, 0); |
| 1038 | rtx_codec2.SetParam("apt", rtx_codec.id); |
| 1039 | codecs.push_back(rtx_codec2); |
| 1040 | |
| 1041 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) << "RTX codec with another RTX " |
| 1042 | "as associated payload type " |
| 1043 | "should be rejected."; |
| 1044 | } |
| 1045 | |
pbos@webrtc.org | 87e1f97 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1046 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { |
| 1047 | std::vector<cricket::VideoCodec> codecs; |
| 1048 | codecs.push_back(kVp8Codec); |
| 1049 | codecs[0].id = 99; |
| 1050 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1051 | } |
| 1052 | |
| 1053 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRecvCodecsAcceptDefaultCodecs) { |
| 1054 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
| 1055 | // (I've added this one.) Make sure they propagate down to VideoReceiveStream! |
| 1056 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1057 | } |
| 1058 | |
| 1059 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { |
| 1060 | std::vector<VideoCodec> codecs; |
| 1061 | codecs.push_back(kVp8Codec); |
| 1062 | codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30, 0)); |
| 1063 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 1064 | } |
| 1065 | |
| 1066 | // TODO(pbos): Enable VP9 through external codec support |
| 1067 | TEST_F(WebRtcVideoChannel2Test, |
| 1068 | DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) { |
| 1069 | std::vector<VideoCodec> codecs; |
| 1070 | codecs.push_back(kVp8Codec); |
| 1071 | codecs.push_back(kVp9Codec); |
| 1072 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1073 | } |
| 1074 | |
| 1075 | TEST_F(WebRtcVideoChannel2Test, |
| 1076 | DISABLED_SetRecvCodecsSetsFecForAllVideoCodecs) { |
| 1077 | std::vector<VideoCodec> codecs; |
| 1078 | codecs.push_back(kVp8Codec); |
| 1079 | codecs.push_back(kVp9Codec); |
| 1080 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1081 | FAIL(); // TODO(pbos): Verify that the FEC parameters are set for all codecs. |
| 1082 | } |
| 1083 | |
| 1084 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { |
| 1085 | std::vector<VideoCodec> codecs; |
| 1086 | codecs.push_back(kVp8Codec); |
| 1087 | codecs.push_back(kRedCodec); |
| 1088 | codecs[1].id = codecs[0].id; |
| 1089 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 1090 | } |
| 1091 | |
| 1092 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) { |
| 1093 | std::vector<VideoCodec> codecs; |
| 1094 | codecs.push_back(kVp8Codec); |
| 1095 | codecs.push_back(kVp9Codec); |
| 1096 | codecs[1].id = codecs[0].id; |
| 1097 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 1098 | } |
| 1099 | |
| 1100 | TEST_F(WebRtcVideoChannel2Test, |
| 1101 | SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) { |
| 1102 | std::vector<VideoCodec> codecs; |
| 1103 | codecs.push_back(kVp8Codec); |
| 1104 | codecs.push_back(kVp8Codec); |
| 1105 | codecs[1].id += 1; |
| 1106 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1107 | } |
| 1108 | |
| 1109 | TEST_F(WebRtcVideoChannel2Test, SendStreamNotSendingByDefault) { |
| 1110 | EXPECT_FALSE(AddSendStream()->IsSending()); |
| 1111 | } |
| 1112 | |
| 1113 | TEST_F(WebRtcVideoChannel2Test, DISABLED_ReceiveStreamReceivingByDefault) { |
| 1114 | // Is this test correct though? Auto-receive? Enable receive on first packet? |
| 1115 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1116 | } |
| 1117 | |
| 1118 | TEST_F(WebRtcVideoChannel2Test, SetSend) { |
| 1119 | AddSendStream(); |
| 1120 | EXPECT_FALSE(channel_->SetSend(true)) |
| 1121 | << "Channel should not start without codecs."; |
| 1122 | EXPECT_TRUE(channel_->SetSend(false)) |
| 1123 | << "Channel should be stoppable even without set codecs."; |
| 1124 | |
| 1125 | std::vector<cricket::VideoCodec> codecs; |
| 1126 | codecs.push_back(kVp8Codec); |
| 1127 | channel_->SetSendCodecs(codecs); |
| 1128 | std::vector<FakeVideoSendStream*> streams = GetFakeSendStreams(); |
| 1129 | ASSERT_EQ(1u, streams.size()); |
| 1130 | FakeVideoSendStream* stream = streams.back(); |
| 1131 | |
| 1132 | EXPECT_FALSE(stream->IsSending()); |
| 1133 | |
| 1134 | // false->true |
| 1135 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1136 | EXPECT_TRUE(stream->IsSending()); |
| 1137 | // true->true |
| 1138 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1139 | EXPECT_TRUE(stream->IsSending()); |
| 1140 | // true->false |
| 1141 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1142 | EXPECT_FALSE(stream->IsSending()); |
| 1143 | // false->false |
| 1144 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1145 | EXPECT_FALSE(stream->IsSending()); |
| 1146 | |
| 1147 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1148 | FakeVideoSendStream* new_stream = AddSendStream(); |
| 1149 | EXPECT_TRUE(new_stream->IsSending()) |
| 1150 | << "Send stream created after SetSend(true) not sending initially."; |
| 1151 | } |
| 1152 | |
| 1153 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveVp8Vga) { |
| 1154 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1155 | } |
| 1156 | |
| 1157 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveVp8Qvga) { |
| 1158 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1159 | } |
| 1160 | |
| 1161 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveH264SvcQqvga) { |
| 1162 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1163 | } |
| 1164 | |
| 1165 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SendManyResizeOnce) { |
| 1166 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1167 | } |
| 1168 | |
| 1169 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) { |
| 1170 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1171 | } |
| 1172 | |
| 1173 | TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetDscpOptions) { |
| 1174 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1175 | } |
| 1176 | |
| 1177 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithMaxBitrate) { |
| 1178 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1179 | } |
| 1180 | |
| 1181 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithLoweredBitrate) { |
| 1182 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1183 | } |
| 1184 | |
| 1185 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsSucceedsWhenSending) { |
| 1186 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1187 | } |
| 1188 | |
| 1189 | TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetCodecOnScreencast) { |
| 1190 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1191 | } |
| 1192 | |
| 1193 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontResetCodecOnSendFrame) { |
| 1194 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1195 | } |
| 1196 | |
| 1197 | TEST_F(WebRtcVideoChannel2Test, |
| 1198 | DISABLED_DontRegisterDecoderIfFactoryIsNotGiven) { |
| 1199 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1200 | } |
| 1201 | |
| 1202 | TEST_F(WebRtcVideoChannel2Test, DISABLED_RegisterDecoderIfFactoryIsGiven) { |
| 1203 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1204 | } |
| 1205 | |
| 1206 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderMultipleTimes) { |
| 1207 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1208 | } |
| 1209 | |
| 1210 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderForNonVP8) { |
| 1211 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1212 | } |
| 1213 | |
| 1214 | TEST_F(WebRtcVideoChannel2Test, |
| 1215 | DISABLED_DontRegisterEncoderIfFactoryIsNotGiven) { |
| 1216 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1217 | } |
| 1218 | |
| 1219 | TEST_F(WebRtcVideoChannel2Test, DISABLED_RegisterEncoderIfFactoryIsGiven) { |
| 1220 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1221 | } |
| 1222 | |
| 1223 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterEncoderMultipleTimes) { |
| 1224 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1225 | } |
| 1226 | |
| 1227 | TEST_F(WebRtcVideoChannel2Test, |
| 1228 | DISABLED_RegisterEncoderWithMultipleSendStreams) { |
| 1229 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1230 | } |
| 1231 | |
| 1232 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterEncoderForNonVP8) { |
| 1233 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1234 | } |
| 1235 | |
| 1236 | TEST_F(WebRtcVideoChannel2Test, DISABLED_FeedbackParamsForNonVP8) { |
| 1237 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1238 | } |
| 1239 | |
| 1240 | TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecAddedToTheEnd) { |
| 1241 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1242 | } |
| 1243 | |
| 1244 | TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecIgnored) { |
| 1245 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1246 | } |
| 1247 | |
| 1248 | TEST_F(WebRtcVideoChannel2Test, DISABLED_UpdateEncoderCodecsAfterSetFactory) { |
| 1249 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1250 | } |
| 1251 | |
| 1252 | TEST_F(WebRtcVideoChannel2Test, DISABLED_OnReadyToSend) { |
| 1253 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1254 | } |
| 1255 | |
| 1256 | TEST_F(WebRtcVideoChannel2Test, DISABLED_CaptureFrameTimestampToNtpTimestamp) { |
| 1257 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1258 | } |
| 1259 | } // namespace cricket |