OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Exponential Distribution. | 189 // Exponential Distribution. |
190 int Exponential(float lambda); | 190 int Exponential(float lambda); |
191 | 191 |
192 // TODO(solenberg): Random from histogram. | 192 // TODO(solenberg): Random from histogram. |
193 // template<typename T> int Distribution(const std::vector<T> histogram) { | 193 // template<typename T> int Distribution(const std::vector<T> histogram) { |
194 | 194 |
195 private: | 195 private: |
196 uint32_t a_; | 196 uint32_t a_; |
197 uint32_t b_; | 197 uint32_t b_; |
198 | 198 |
199 DISALLOW_IMPLICIT_CONSTRUCTORS(Random); | 199 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Random); |
200 }; | 200 }; |
201 | 201 |
202 bool IsTimeSorted(const Packets& packets); | 202 bool IsTimeSorted(const Packets& packets); |
203 | 203 |
204 class PacketProcessor; | 204 class PacketProcessor; |
205 | 205 |
206 enum ProcessorType { kSender, kReceiver, kRegular }; | 206 enum ProcessorType { kSender, kReceiver, kRegular }; |
207 | 207 |
208 class PacketProcessorListener { | 208 class PacketProcessorListener { |
209 public: | 209 public: |
(...skipping 28 matching lines...) Expand all Loading... |
238 uint32_t packets_per_second() const; | 238 uint32_t packets_per_second() const; |
239 uint32_t bits_per_second() const; | 239 uint32_t bits_per_second() const; |
240 | 240 |
241 protected: | 241 protected: |
242 RateCounter rate_counter_; | 242 RateCounter rate_counter_; |
243 | 243 |
244 private: | 244 private: |
245 PacketProcessorListener* listener_; | 245 PacketProcessorListener* listener_; |
246 const FlowIds flow_ids_; | 246 const FlowIds flow_ids_; |
247 | 247 |
248 DISALLOW_COPY_AND_ASSIGN(PacketProcessor); | 248 RTC_DISALLOW_COPY_AND_ASSIGN(PacketProcessor); |
249 }; | 249 }; |
250 | 250 |
251 class RateCounterFilter : public PacketProcessor { | 251 class RateCounterFilter : public PacketProcessor { |
252 public: | 252 public: |
253 RateCounterFilter(PacketProcessorListener* listener, | 253 RateCounterFilter(PacketProcessorListener* listener, |
254 int flow_id, | 254 int flow_id, |
255 const char* name, | 255 const char* name, |
256 const std::string& plot_name); | 256 const std::string& plot_name); |
257 RateCounterFilter(PacketProcessorListener* listener, | 257 RateCounterFilter(PacketProcessorListener* listener, |
258 const FlowIds& flow_ids, | 258 const FlowIds& flow_ids, |
(...skipping 12 matching lines...) Expand all Loading... |
271 virtual void RunFor(int64_t time_ms, Packets* in_out); | 271 virtual void RunFor(int64_t time_ms, Packets* in_out); |
272 | 272 |
273 private: | 273 private: |
274 Stats<double> packets_per_second_stats_; | 274 Stats<double> packets_per_second_stats_; |
275 Stats<double> kbps_stats_; | 275 Stats<double> kbps_stats_; |
276 std::string name_; | 276 std::string name_; |
277 int64_t start_plotting_time_ms_; | 277 int64_t start_plotting_time_ms_; |
278 // Algorithm name if single flow, Total link utilization if all flows. | 278 // Algorithm name if single flow, Total link utilization if all flows. |
279 std::string plot_name_; | 279 std::string plot_name_; |
280 | 280 |
281 DISALLOW_IMPLICIT_CONSTRUCTORS(RateCounterFilter); | 281 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RateCounterFilter); |
282 }; | 282 }; |
283 | 283 |
284 class LossFilter : public PacketProcessor { | 284 class LossFilter : public PacketProcessor { |
285 public: | 285 public: |
286 LossFilter(PacketProcessorListener* listener, int flow_id); | 286 LossFilter(PacketProcessorListener* listener, int flow_id); |
287 LossFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); | 287 LossFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); |
288 virtual ~LossFilter() {} | 288 virtual ~LossFilter() {} |
289 | 289 |
290 void SetLoss(float loss_percent); | 290 void SetLoss(float loss_percent); |
291 virtual void RunFor(int64_t time_ms, Packets* in_out); | 291 virtual void RunFor(int64_t time_ms, Packets* in_out); |
292 | 292 |
293 private: | 293 private: |
294 Random random_; | 294 Random random_; |
295 float loss_fraction_; | 295 float loss_fraction_; |
296 | 296 |
297 DISALLOW_IMPLICIT_CONSTRUCTORS(LossFilter); | 297 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(LossFilter); |
298 }; | 298 }; |
299 | 299 |
300 class DelayFilter : public PacketProcessor { | 300 class DelayFilter : public PacketProcessor { |
301 public: | 301 public: |
302 DelayFilter(PacketProcessorListener* listener, int flow_id); | 302 DelayFilter(PacketProcessorListener* listener, int flow_id); |
303 DelayFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); | 303 DelayFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); |
304 virtual ~DelayFilter() {} | 304 virtual ~DelayFilter() {} |
305 | 305 |
306 void SetOneWayDelayMs(int64_t one_way_delay_ms); | 306 void SetOneWayDelayMs(int64_t one_way_delay_ms); |
307 virtual void RunFor(int64_t time_ms, Packets* in_out); | 307 virtual void RunFor(int64_t time_ms, Packets* in_out); |
308 | 308 |
309 private: | 309 private: |
310 int64_t one_way_delay_us_; | 310 int64_t one_way_delay_us_; |
311 int64_t last_send_time_us_; | 311 int64_t last_send_time_us_; |
312 | 312 |
313 DISALLOW_IMPLICIT_CONSTRUCTORS(DelayFilter); | 313 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayFilter); |
314 }; | 314 }; |
315 | 315 |
316 class JitterFilter : public PacketProcessor { | 316 class JitterFilter : public PacketProcessor { |
317 public: | 317 public: |
318 JitterFilter(PacketProcessorListener* listener, int flow_id); | 318 JitterFilter(PacketProcessorListener* listener, int flow_id); |
319 JitterFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); | 319 JitterFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); |
320 virtual ~JitterFilter() {} | 320 virtual ~JitterFilter() {} |
321 | 321 |
322 void SetMaxJitter(int64_t stddev_jitter_ms); | 322 void SetMaxJitter(int64_t stddev_jitter_ms); |
323 virtual void RunFor(int64_t time_ms, Packets* in_out); | 323 virtual void RunFor(int64_t time_ms, Packets* in_out); |
324 void set_reorderdering(bool reordering) { reordering_ = reordering; } | 324 void set_reorderdering(bool reordering) { reordering_ = reordering; } |
325 int64_t MeanUs(); | 325 int64_t MeanUs(); |
326 | 326 |
327 private: | 327 private: |
328 Random random_; | 328 Random random_; |
329 int64_t stddev_jitter_us_; | 329 int64_t stddev_jitter_us_; |
330 int64_t last_send_time_us_; | 330 int64_t last_send_time_us_; |
331 bool reordering_; // False by default. | 331 bool reordering_; // False by default. |
332 | 332 |
333 DISALLOW_IMPLICIT_CONSTRUCTORS(JitterFilter); | 333 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(JitterFilter); |
334 }; | 334 }; |
335 | 335 |
336 // Reorders two consecutive packets with a probability of reorder_percent. | 336 // Reorders two consecutive packets with a probability of reorder_percent. |
337 class ReorderFilter : public PacketProcessor { | 337 class ReorderFilter : public PacketProcessor { |
338 public: | 338 public: |
339 ReorderFilter(PacketProcessorListener* listener, int flow_id); | 339 ReorderFilter(PacketProcessorListener* listener, int flow_id); |
340 ReorderFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); | 340 ReorderFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); |
341 virtual ~ReorderFilter() {} | 341 virtual ~ReorderFilter() {} |
342 | 342 |
343 void SetReorder(float reorder_percent); | 343 void SetReorder(float reorder_percent); |
344 virtual void RunFor(int64_t time_ms, Packets* in_out); | 344 virtual void RunFor(int64_t time_ms, Packets* in_out); |
345 | 345 |
346 private: | 346 private: |
347 Random random_; | 347 Random random_; |
348 float reorder_fraction_; | 348 float reorder_fraction_; |
349 | 349 |
350 DISALLOW_IMPLICIT_CONSTRUCTORS(ReorderFilter); | 350 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(ReorderFilter); |
351 }; | 351 }; |
352 | 352 |
353 // Apply a bitrate choke with an infinite queue on the packet stream. | 353 // Apply a bitrate choke with an infinite queue on the packet stream. |
354 class ChokeFilter : public PacketProcessor { | 354 class ChokeFilter : public PacketProcessor { |
355 public: | 355 public: |
356 ChokeFilter(PacketProcessorListener* listener, int flow_id); | 356 ChokeFilter(PacketProcessorListener* listener, int flow_id); |
357 ChokeFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); | 357 ChokeFilter(PacketProcessorListener* listener, const FlowIds& flow_ids); |
358 virtual ~ChokeFilter(); | 358 virtual ~ChokeFilter(); |
359 | 359 |
360 void set_capacity_kbps(uint32_t kbps); | 360 void set_capacity_kbps(uint32_t kbps); |
361 void set_max_delay_ms(int64_t max_queueing_delay_ms); | 361 void set_max_delay_ms(int64_t max_queueing_delay_ms); |
362 | 362 |
363 uint32_t capacity_kbps(); | 363 uint32_t capacity_kbps(); |
364 | 364 |
365 virtual void RunFor(int64_t time_ms, Packets* in_out); | 365 virtual void RunFor(int64_t time_ms, Packets* in_out); |
366 | 366 |
367 Stats<double> GetDelayStats() const; | 367 Stats<double> GetDelayStats() const; |
368 | 368 |
369 private: | 369 private: |
370 uint32_t capacity_kbps_; | 370 uint32_t capacity_kbps_; |
371 int64_t last_send_time_us_; | 371 int64_t last_send_time_us_; |
372 rtc::scoped_ptr<DelayCapHelper> delay_cap_helper_; | 372 rtc::scoped_ptr<DelayCapHelper> delay_cap_helper_; |
373 int64_t max_delay_us_; | 373 int64_t max_delay_us_; |
374 | 374 |
375 DISALLOW_IMPLICIT_CONSTRUCTORS(ChokeFilter); | 375 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(ChokeFilter); |
376 }; | 376 }; |
377 | 377 |
378 class TraceBasedDeliveryFilter : public PacketProcessor { | 378 class TraceBasedDeliveryFilter : public PacketProcessor { |
379 public: | 379 public: |
380 TraceBasedDeliveryFilter(PacketProcessorListener* listener, int flow_id); | 380 TraceBasedDeliveryFilter(PacketProcessorListener* listener, int flow_id); |
381 TraceBasedDeliveryFilter(PacketProcessorListener* listener, | 381 TraceBasedDeliveryFilter(PacketProcessorListener* listener, |
382 const FlowIds& flow_ids); | 382 const FlowIds& flow_ids); |
383 TraceBasedDeliveryFilter(PacketProcessorListener* listener, | 383 TraceBasedDeliveryFilter(PacketProcessorListener* listener, |
384 int flow_id, | 384 int flow_id, |
385 const char* name); | 385 const char* name); |
(...skipping 17 matching lines...) Expand all Loading... |
403 int64_t current_offset_us_; | 403 int64_t current_offset_us_; |
404 TimeList delivery_times_us_; | 404 TimeList delivery_times_us_; |
405 TimeList::const_iterator next_delivery_it_; | 405 TimeList::const_iterator next_delivery_it_; |
406 int64_t local_time_us_; | 406 int64_t local_time_us_; |
407 rtc::scoped_ptr<RateCounter> rate_counter_; | 407 rtc::scoped_ptr<RateCounter> rate_counter_; |
408 std::string name_; | 408 std::string name_; |
409 rtc::scoped_ptr<DelayCapHelper> delay_cap_helper_; | 409 rtc::scoped_ptr<DelayCapHelper> delay_cap_helper_; |
410 Stats<double> packets_per_second_stats_; | 410 Stats<double> packets_per_second_stats_; |
411 Stats<double> kbps_stats_; | 411 Stats<double> kbps_stats_; |
412 | 412 |
413 DISALLOW_COPY_AND_ASSIGN(TraceBasedDeliveryFilter); | 413 RTC_DISALLOW_COPY_AND_ASSIGN(TraceBasedDeliveryFilter); |
414 }; | 414 }; |
415 | 415 |
416 class VideoSource { | 416 class VideoSource { |
417 public: | 417 public: |
418 VideoSource(int flow_id, | 418 VideoSource(int flow_id, |
419 float fps, | 419 float fps, |
420 uint32_t kbps, | 420 uint32_t kbps, |
421 uint32_t ssrc, | 421 uint32_t ssrc, |
422 int64_t first_frame_offset_ms); | 422 int64_t first_frame_offset_ms); |
423 virtual ~VideoSource() {} | 423 virtual ~VideoSource() {} |
(...skipping 19 matching lines...) Expand all Loading... |
443 | 443 |
444 private: | 444 private: |
445 const int flow_id_; | 445 const int flow_id_; |
446 int64_t next_frame_ms_; | 446 int64_t next_frame_ms_; |
447 int64_t next_frame_rand_ms_; | 447 int64_t next_frame_rand_ms_; |
448 int64_t now_ms_; | 448 int64_t now_ms_; |
449 RTPHeader prototype_header_; | 449 RTPHeader prototype_header_; |
450 int64_t start_plotting_ms_; | 450 int64_t start_plotting_ms_; |
451 uint32_t previous_bitrate_bps_; | 451 uint32_t previous_bitrate_bps_; |
452 | 452 |
453 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoSource); | 453 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(VideoSource); |
454 }; | 454 }; |
455 | 455 |
456 class AdaptiveVideoSource : public VideoSource { | 456 class AdaptiveVideoSource : public VideoSource { |
457 public: | 457 public: |
458 AdaptiveVideoSource(int flow_id, | 458 AdaptiveVideoSource(int flow_id, |
459 float fps, | 459 float fps, |
460 uint32_t kbps, | 460 uint32_t kbps, |
461 uint32_t ssrc, | 461 uint32_t ssrc, |
462 int64_t first_frame_offset_ms); | 462 int64_t first_frame_offset_ms); |
463 virtual ~AdaptiveVideoSource() {} | 463 virtual ~AdaptiveVideoSource() {} |
464 | 464 |
465 void SetBitrateBps(int bitrate_bps) override; | 465 void SetBitrateBps(int bitrate_bps) override; |
466 | 466 |
467 private: | 467 private: |
468 DISALLOW_IMPLICIT_CONSTRUCTORS(AdaptiveVideoSource); | 468 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AdaptiveVideoSource); |
469 }; | 469 }; |
470 | 470 |
471 class PeriodicKeyFrameSource : public AdaptiveVideoSource { | 471 class PeriodicKeyFrameSource : public AdaptiveVideoSource { |
472 public: | 472 public: |
473 PeriodicKeyFrameSource(int flow_id, | 473 PeriodicKeyFrameSource(int flow_id, |
474 float fps, | 474 float fps, |
475 uint32_t kbps, | 475 uint32_t kbps, |
476 uint32_t ssrc, | 476 uint32_t ssrc, |
477 int64_t first_frame_offset_ms, | 477 int64_t first_frame_offset_ms, |
478 int key_frame_interval); | 478 int key_frame_interval); |
479 virtual ~PeriodicKeyFrameSource() {} | 479 virtual ~PeriodicKeyFrameSource() {} |
480 | 480 |
481 protected: | 481 protected: |
482 uint32_t NextFrameSize() override; | 482 uint32_t NextFrameSize() override; |
483 uint32_t NextPacketSize(uint32_t frame_size, | 483 uint32_t NextPacketSize(uint32_t frame_size, |
484 uint32_t remaining_payload) override; | 484 uint32_t remaining_payload) override; |
485 | 485 |
486 private: | 486 private: |
487 int key_frame_interval_; | 487 int key_frame_interval_; |
488 uint32_t frame_counter_; | 488 uint32_t frame_counter_; |
489 int compensation_bytes_; | 489 int compensation_bytes_; |
490 int compensation_per_frame_; | 490 int compensation_per_frame_; |
491 DISALLOW_IMPLICIT_CONSTRUCTORS(PeriodicKeyFrameSource); | 491 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PeriodicKeyFrameSource); |
492 }; | 492 }; |
493 } // namespace bwe | 493 } // namespace bwe |
494 } // namespace testing | 494 } // namespace testing |
495 } // namespace webrtc | 495 } // namespace webrtc |
496 | 496 |
497 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_TEST_FRAMEWORK_H_ | 497 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_TEST_FRAMEWORK_H_ |
OLD | NEW |