Revert 5229 "Make VideoSendStreamTest::MaxPacketSize test a whol..."
> Make VideoSendStreamTest::MaxPacketSize test a whole range of frame sizes, to make sure all corner cases are covered. > > BUG=2428 > R=pbos@webrtc.org, phoglund@webrtc.org, stefan@webrtc.org > > Review URL: https://webrtc-codereview.appspot.com/4849004 It caused a failure in video_engine_tests on the Linux Tsan bot. TBR=sprang@webrtc.org Review URL: https://webrtc-codereview.appspot.com/5269004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5240 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
863b536100
commit
797522f9f2
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "webrtc/test/configurable_frame_size_encoder.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "webrtc/common_video/interface/video_image.h"
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
namespace test {
|
|
||||||
|
|
||||||
ConfigurableFrameSizeEncoder::ConfigurableFrameSizeEncoder(
|
|
||||||
uint32_t max_frame_size)
|
|
||||||
: callback_(NULL),
|
|
||||||
max_frame_size_(max_frame_size),
|
|
||||||
current_frame_size_(max_frame_size),
|
|
||||||
buffer_(new uint8_t[max_frame_size]) {
|
|
||||||
memset(buffer_.get(), 0, max_frame_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigurableFrameSizeEncoder::~ConfigurableFrameSizeEncoder() {}
|
|
||||||
|
|
||||||
int32_t ConfigurableFrameSizeEncoder::InitEncode(
|
|
||||||
const VideoCodec* codec_settings,
|
|
||||||
int32_t number_of_cores,
|
|
||||||
uint32_t max_payload_size) {
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ConfigurableFrameSizeEncoder::Encode(
|
|
||||||
const I420VideoFrame& inputImage,
|
|
||||||
const CodecSpecificInfo* codecSpecificInfo,
|
|
||||||
const std::vector<VideoFrameType>* frame_types) {
|
|
||||||
EncodedImage encodedImage(
|
|
||||||
buffer_.get(), current_frame_size_, max_frame_size_);
|
|
||||||
encodedImage._completeFrame = true;
|
|
||||||
encodedImage._encodedHeight = inputImage.height();
|
|
||||||
encodedImage._encodedWidth = inputImage.width();
|
|
||||||
encodedImage._frameType = kKeyFrame;
|
|
||||||
encodedImage._timeStamp = inputImage.timestamp();
|
|
||||||
encodedImage.capture_time_ms_ = inputImage.render_time_ms();
|
|
||||||
RTPFragmentationHeader* fragmentation = NULL;
|
|
||||||
callback_->Encoded(encodedImage, codecSpecificInfo, fragmentation);
|
|
||||||
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ConfigurableFrameSizeEncoder::RegisterEncodeCompleteCallback(
|
|
||||||
EncodedImageCallback* callback) {
|
|
||||||
callback_ = callback;
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ConfigurableFrameSizeEncoder::Release() {
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ConfigurableFrameSizeEncoder::SetChannelParameters(uint32_t packet_loss,
|
|
||||||
int rtt) {
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ConfigurableFrameSizeEncoder::SetRates(uint32_t new_bit_rate,
|
|
||||||
uint32_t frame_rate) {
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ConfigurableFrameSizeEncoder::SetPeriodicKeyFrames(bool enable) {
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ConfigurableFrameSizeEncoder::CodecConfigParameters(uint8_t* buffer,
|
|
||||||
int32_t size) {
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ConfigurableFrameSizeEncoder::SetFrameSize(uint32_t size) {
|
|
||||||
assert(size <= max_frame_size_);
|
|
||||||
current_frame_size_ = size;
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace test
|
|
||||||
} // namespace webrtc
|
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WEBRTC_TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_
|
|
||||||
#define WEBRTC_TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
|
||||||
#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
namespace test {
|
|
||||||
|
|
||||||
class ConfigurableFrameSizeEncoder : public VideoEncoder {
|
|
||||||
public:
|
|
||||||
explicit ConfigurableFrameSizeEncoder(uint32_t max_frame_size);
|
|
||||||
virtual ~ConfigurableFrameSizeEncoder();
|
|
||||||
|
|
||||||
virtual int32_t InitEncode(const VideoCodec* codec_settings,
|
|
||||||
int32_t number_of_cores,
|
|
||||||
uint32_t max_payload_size) OVERRIDE;
|
|
||||||
|
|
||||||
virtual int32_t Encode(const I420VideoFrame& input_image,
|
|
||||||
const CodecSpecificInfo* codec_specific_info,
|
|
||||||
const std::vector<VideoFrameType>* frame_types)
|
|
||||||
OVERRIDE;
|
|
||||||
|
|
||||||
virtual int32_t RegisterEncodeCompleteCallback(EncodedImageCallback* callback)
|
|
||||||
OVERRIDE;
|
|
||||||
|
|
||||||
virtual int32_t Release() OVERRIDE;
|
|
||||||
|
|
||||||
virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE;
|
|
||||||
|
|
||||||
virtual int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) OVERRIDE;
|
|
||||||
|
|
||||||
virtual int32_t SetPeriodicKeyFrames(bool enable) OVERRIDE;
|
|
||||||
|
|
||||||
virtual int32_t CodecConfigParameters(uint8_t* buffer, int32_t size) OVERRIDE;
|
|
||||||
|
|
||||||
int32_t SetFrameSize(uint32_t size);
|
|
||||||
|
|
||||||
private:
|
|
||||||
EncodedImageCallback* callback_;
|
|
||||||
const uint32_t max_frame_size_;
|
|
||||||
uint32_t current_frame_size_;
|
|
||||||
scoped_ptr<uint8_t[]> buffer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace test
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // WEBRTC_TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_
|
|
@ -14,8 +14,6 @@
|
|||||||
'target_name': 'webrtc_test_common',
|
'target_name': 'webrtc_test_common',
|
||||||
'type': 'static_library',
|
'type': 'static_library',
|
||||||
'sources': [
|
'sources': [
|
||||||
'configurable_frame_size_encoder.cc',
|
|
||||||
'configurable_frame_size_encoder.h',
|
|
||||||
'direct_transport.cc',
|
'direct_transport.cc',
|
||||||
'direct_transport.h',
|
'direct_transport.h',
|
||||||
'fake_audio_device.cc',
|
'fake_audio_device.cc',
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||||
#include "webrtc/test/direct_transport.h"
|
#include "webrtc/test/direct_transport.h"
|
||||||
#include "webrtc/test/fake_encoder.h"
|
#include "webrtc/test/fake_encoder.h"
|
||||||
#include "webrtc/test/configurable_frame_size_encoder.h"
|
|
||||||
#include "webrtc/test/frame_generator_capturer.h"
|
#include "webrtc/test/frame_generator_capturer.h"
|
||||||
#include "webrtc/test/null_transport.h"
|
#include "webrtc/test/null_transport.h"
|
||||||
#include "webrtc/test/rtp_rtcp_observer.h"
|
#include "webrtc/test/rtp_rtcp_observer.h"
|
||||||
@ -529,23 +528,11 @@ TEST_F(VideoSendStreamTest, RetransmitsNackOverRtxWithPacing) {
|
|||||||
TestNackRetransmission(kSendRtxSsrc, kSendRtxPayloadType, true);
|
TestNackRetransmission(kSendRtxSsrc, kSendRtxPayloadType, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(VideoSendStreamTest, FragmentsAccordingToMaxPacketSize) {
|
TEST_F(VideoSendStreamTest, MaxPacketSize) {
|
||||||
// Observer that verifies that the expected number of packets and bytes
|
class PacketSizeObserver : public test::RtpRtcpObserver {
|
||||||
// arrive for each frame size, then increases frame size by one until
|
|
||||||
// stop_size has been reached.
|
|
||||||
class FrameFragmentationObserver : public test::RtpRtcpObserver {
|
|
||||||
public:
|
public:
|
||||||
FrameFragmentationObserver(size_t max_length,
|
PacketSizeObserver(size_t max_length) : RtpRtcpObserver(30 * 1000),
|
||||||
uint32_t start_size,
|
max_length_(max_length), accumulated_size_(0) {}
|
||||||
uint32_t stop_size,
|
|
||||||
test::ConfigurableFrameSizeEncoder* encoder)
|
|
||||||
: RtpRtcpObserver(30 * 1000),
|
|
||||||
max_length_(max_length),
|
|
||||||
accumulated_size_(0),
|
|
||||||
accumulated_payload_(0),
|
|
||||||
stop_size_(stop_size),
|
|
||||||
current_size_(start_size),
|
|
||||||
encoder_(encoder) {}
|
|
||||||
|
|
||||||
virtual Action OnSendRtp(const uint8_t* packet, size_t length) OVERRIDE {
|
virtual Action OnSendRtp(const uint8_t* packet, size_t length) OVERRIDE {
|
||||||
RTPHeader header;
|
RTPHeader header;
|
||||||
@ -555,25 +542,15 @@ TEST_F(VideoSendStreamTest, FragmentsAccordingToMaxPacketSize) {
|
|||||||
EXPECT_LE(length, max_length_);
|
EXPECT_LE(length, max_length_);
|
||||||
|
|
||||||
accumulated_size_ += length;
|
accumulated_size_ += length;
|
||||||
// Payload size = packet size - minus RTP header, padding and one byte
|
|
||||||
// generic header.
|
|
||||||
accumulated_payload_ +=
|
|
||||||
length - (header.headerLength + header.paddingLength + 1);
|
|
||||||
|
|
||||||
// Marker bit set indicates last packet of a frame.
|
// Marker bit set indicates last fragment of a packet
|
||||||
if (header.markerBit) {
|
if (header.markerBit) {
|
||||||
EXPECT_GE(accumulated_size_, current_size_);
|
if (accumulated_size_ + length > max_length_) {
|
||||||
EXPECT_EQ(accumulated_payload_, current_size_);
|
// The packet was fragmented, total size was larger than max size,
|
||||||
|
// but size of individual fragments were within size limit => pass!
|
||||||
if (current_size_ == stop_size_) {
|
|
||||||
EXPECT_GE(current_size_, max_length_);
|
|
||||||
observation_complete_->Set();
|
observation_complete_->Set();
|
||||||
} else {
|
|
||||||
// Last packet of frame; reset and increase frame size.
|
|
||||||
accumulated_size_ = 0;
|
|
||||||
accumulated_payload_ = 0;
|
|
||||||
encoder_->SetFrameSize(++current_size_);
|
|
||||||
}
|
}
|
||||||
|
accumulated_size_ = 0; // Last fragment, reset packet size
|
||||||
}
|
}
|
||||||
|
|
||||||
return SEND_PACKET;
|
return SEND_PACKET;
|
||||||
@ -582,28 +559,15 @@ TEST_F(VideoSendStreamTest, FragmentsAccordingToMaxPacketSize) {
|
|||||||
private:
|
private:
|
||||||
size_t max_length_;
|
size_t max_length_;
|
||||||
size_t accumulated_size_;
|
size_t accumulated_size_;
|
||||||
size_t accumulated_payload_;
|
|
||||||
|
|
||||||
uint32_t stop_size_;
|
|
||||||
uint32_t current_size_;
|
|
||||||
test::ConfigurableFrameSizeEncoder* encoder_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Use a fake encoder to output a frame of every size in the range [90, 290],
|
|
||||||
// for each size making sure that the exact number of payload bytes received
|
|
||||||
// is correct and that packets are fragmented to respect max packet size.
|
|
||||||
static const uint32_t kMaxPacketSize = 128;
|
static const uint32_t kMaxPacketSize = 128;
|
||||||
static const uint32_t start = 90;
|
|
||||||
static const uint32_t stop = 290;
|
|
||||||
|
|
||||||
test::ConfigurableFrameSizeEncoder encoder(stop);
|
PacketSizeObserver observer(kMaxPacketSize);
|
||||||
encoder.SetFrameSize(start);
|
|
||||||
FrameFragmentationObserver observer(kMaxPacketSize, start, stop, &encoder);
|
|
||||||
Call::Config call_config(observer.SendTransport());
|
Call::Config call_config(observer.SendTransport());
|
||||||
scoped_ptr<Call> call(Call::Create(call_config));
|
scoped_ptr<Call> call(Call::Create(call_config));
|
||||||
|
|
||||||
VideoSendStream::Config send_config = GetSendTestConfig(call.get(), 1);
|
VideoSendStream::Config send_config = GetSendTestConfig(call.get(), 1);
|
||||||
send_config.encoder = &encoder;
|
|
||||||
send_config.rtp.max_packet_size = kMaxPacketSize;
|
send_config.rtp.max_packet_size = kMaxPacketSize;
|
||||||
|
|
||||||
RunSendTest(call.get(), send_config, &observer);
|
RunSendTest(call.get(), send_config, &observer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user