2011-10-06 06:44:54 +00:00
|
|
|
/*
|
2012-02-09 09:01:51 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-10-06 06:44:54 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2011-12-08 07:42:18 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_VIDEO_CODING_CODECS_TEST_PACKET_MANIPULATOR_H_
|
|
|
|
|
#define MODULES_VIDEO_CODING_CODECS_TEST_PACKET_MANIPULATOR_H_
|
2011-10-06 06:44:54 +00:00
|
|
|
|
2013-08-05 16:22:53 +00:00
|
|
|
#include <stdlib.h>
|
2011-10-06 06:44:54 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/include/video_codec_interface.h"
|
|
|
|
|
#include "rtc_base/criticalsection.h"
|
|
|
|
|
#include "test/testsupport/packet_reader.h"
|
2011-10-06 06:44:54 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
// Which mode the packet loss shall be performed according to.
|
|
|
|
|
enum PacketLossMode {
|
|
|
|
|
// Drops packets with a configured probability independently for each packet
|
|
|
|
|
kUniform,
|
|
|
|
|
// Drops packets similar to uniform but when a packet is being dropped,
|
|
|
|
|
// the number of lost packets in a row is equal to the configured burst
|
|
|
|
|
// length.
|
|
|
|
|
kBurst
|
|
|
|
|
};
|
2011-10-07 06:50:22 +00:00
|
|
|
// Returns a string representation of the enum value.
|
|
|
|
|
const char* PacketLossModeToStr(PacketLossMode e);
|
2011-10-06 06:44:54 +00:00
|
|
|
|
|
|
|
|
// Contains configurations related to networking and simulation of
|
|
|
|
|
// scenarios caused by network interference.
|
|
|
|
|
struct NetworkingConfig {
|
|
|
|
|
NetworkingConfig()
|
2015-12-21 03:04:49 -08:00
|
|
|
: packet_size_in_bytes(1500),
|
|
|
|
|
max_payload_size_in_bytes(1440),
|
|
|
|
|
packet_loss_mode(kUniform),
|
|
|
|
|
packet_loss_probability(0.0),
|
|
|
|
|
packet_loss_burst_length(1) {}
|
2011-10-06 06:44:54 +00:00
|
|
|
|
|
|
|
|
// Packet size in bytes. Default: 1500 bytes.
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t packet_size_in_bytes;
|
2011-10-06 06:44:54 +00:00
|
|
|
|
|
|
|
|
// Encoder specific setting of maximum size in bytes of each payload.
|
|
|
|
|
// Default: 1440 bytes.
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t max_payload_size_in_bytes;
|
2011-10-06 06:44:54 +00:00
|
|
|
|
|
|
|
|
// Packet loss mode. Two different packet loss models are supported:
|
|
|
|
|
// uniform or burst. This setting has no effect unless
|
|
|
|
|
// packet_loss_probability is >0.
|
|
|
|
|
// Default: uniform.
|
|
|
|
|
PacketLossMode packet_loss_mode;
|
|
|
|
|
|
|
|
|
|
// Packet loss probability. A value between 0.0 and 1.0 that defines the
|
|
|
|
|
// probability of a packet being lost. 0.1 means 10% and so on.
|
|
|
|
|
// Default: 0 (no loss).
|
|
|
|
|
double packet_loss_probability;
|
|
|
|
|
|
|
|
|
|
// Packet loss burst length. Defines how many packets will be lost in a burst
|
|
|
|
|
// when a packet has been decided to be lost. Must be >=1. Default: 1.
|
|
|
|
|
int packet_loss_burst_length;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Class for simulating packet loss on the encoded frame data.
|
|
|
|
|
// When a packet loss has occurred in a frame, the remaining data in that
|
|
|
|
|
// frame is lost (even if burst length is only a single packet).
|
|
|
|
|
// TODO(kjellander): Support discarding only individual packets in the frame
|
|
|
|
|
// when CL 172001 has been submitted. This also requires a correct
|
|
|
|
|
// fragmentation header to be passed to the decoder.
|
|
|
|
|
//
|
2012-02-09 09:01:51 +00:00
|
|
|
// To get a repeatable packet drop pattern, re-initialize the random seed
|
|
|
|
|
// using InitializeRandomSeed before each test run.
|
2011-10-06 06:44:54 +00:00
|
|
|
class PacketManipulator {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~PacketManipulator() {}
|
|
|
|
|
|
|
|
|
|
// Manipulates the data of the encoded_image to simulate parts being lost
|
|
|
|
|
// during transport.
|
|
|
|
|
// If packets are dropped from frame data, the completedFrame field will be
|
|
|
|
|
// set to false.
|
|
|
|
|
// Returns the number of packets being dropped.
|
2014-12-01 15:23:21 +00:00
|
|
|
virtual int ManipulatePackets(webrtc::EncodedImage* encoded_image) = 0;
|
2011-10-06 06:44:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PacketManipulatorImpl : public PacketManipulator {
|
|
|
|
|
public:
|
|
|
|
|
PacketManipulatorImpl(PacketReader* packet_reader,
|
2012-02-09 09:01:51 +00:00
|
|
|
const NetworkingConfig& config,
|
|
|
|
|
bool verbose);
|
2017-03-31 02:03:55 -07:00
|
|
|
~PacketManipulatorImpl() = default;
|
2015-03-04 12:58:35 +00:00
|
|
|
int ManipulatePackets(webrtc::EncodedImage* encoded_image) override;
|
2012-02-09 09:01:51 +00:00
|
|
|
virtual void InitializeRandomSeed(unsigned int seed);
|
2015-12-21 03:04:49 -08:00
|
|
|
|
2011-11-02 16:34:52 +00:00
|
|
|
protected:
|
2011-10-06 06:44:54 +00:00
|
|
|
// Returns a uniformly distributed random value between 0.0 and 1.0
|
2011-11-02 16:34:52 +00:00
|
|
|
virtual double RandomUniform();
|
2015-12-21 03:04:49 -08:00
|
|
|
|
2011-11-02 16:34:52 +00:00
|
|
|
private:
|
2011-10-06 06:44:54 +00:00
|
|
|
PacketReader* packet_reader_;
|
|
|
|
|
const NetworkingConfig& config_;
|
|
|
|
|
// Used to simulate a burst over several frames.
|
|
|
|
|
int active_burst_packets_;
|
2017-03-31 02:03:55 -07:00
|
|
|
rtc::CriticalSection critsect_;
|
2012-02-09 09:01:51 +00:00
|
|
|
unsigned int random_seed_;
|
2011-12-08 07:42:18 +00:00
|
|
|
bool verbose_;
|
2011-10-06 06:44:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_VIDEO_CODING_CODECS_TEST_PACKET_MANIPULATOR_H_
|