Report encoded frame size in VideoSendStream.
Implements reporting transmitted frame size in WebRtcVideoEngine2. R=mflodman@webrtc.org, stefan@webrtc.org BUG=4033 Review URL: https://webrtc-codereview.appspot.com/33399004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7772 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -210,19 +210,14 @@ VCMEncodedFrameCallback::SetTransportCallback(VCMPacketizationCallback* transpor
|
||||
|
||||
int32_t
|
||||
VCMEncodedFrameCallback::Encoded(
|
||||
EncodedImage &encodedImage,
|
||||
const EncodedImage &encodedImage,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
const RTPFragmentationHeader* fragmentationHeader)
|
||||
{
|
||||
post_encode_callback_->Encoded(encodedImage);
|
||||
|
||||
FrameType frameType = VCMEncodedFrame::ConvertFrameType(encodedImage._frameType);
|
||||
|
||||
size_t encodedBytes = 0;
|
||||
if (_sendCallback != NULL)
|
||||
{
|
||||
encodedBytes = encodedImage._length;
|
||||
|
||||
#ifdef DEBUG_ENCODER_BIT_STREAM
|
||||
if (_bitStreamAfterEncoder != NULL)
|
||||
{
|
||||
@ -235,12 +230,8 @@ VCMEncodedFrameCallback::Encoded(
|
||||
CopyCodecSpecific(codecSpecificInfo, &rtpVideoHeaderPtr);
|
||||
|
||||
int32_t callbackReturn = _sendCallback->SendData(
|
||||
frameType,
|
||||
_payloadType,
|
||||
encodedImage._timeStamp,
|
||||
encodedImage.capture_time_ms_,
|
||||
encodedImage._buffer,
|
||||
encodedBytes,
|
||||
encodedImage,
|
||||
*fragmentationHeader,
|
||||
rtpVideoHeaderPtr);
|
||||
if (callbackReturn < 0)
|
||||
@ -253,12 +244,9 @@ VCMEncodedFrameCallback::Encoded(
|
||||
return VCM_UNINITIALIZED;
|
||||
}
|
||||
if (_mediaOpt != NULL) {
|
||||
_mediaOpt->UpdateWithEncodedData(encodedBytes, encodedImage._timeStamp,
|
||||
frameType);
|
||||
_mediaOpt->UpdateWithEncodedData(encodedImage);
|
||||
if (_internalSource)
|
||||
{
|
||||
return _mediaOpt->DropFrame(); // Signal to encoder to drop next frame
|
||||
}
|
||||
return _mediaOpt->DropFrame(); // Signal to encoder to drop next frame.
|
||||
}
|
||||
return VCM_OK;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ public:
|
||||
* Callback implementation - codec encode complete
|
||||
*/
|
||||
int32_t Encoded(
|
||||
EncodedImage& encodedImage,
|
||||
const EncodedImage& encodedImage,
|
||||
const CodecSpecificInfo* codecSpecificInfo = NULL,
|
||||
const RTPFragmentationHeader* fragmentationHeader = NULL);
|
||||
/*
|
||||
|
||||
@ -369,9 +369,10 @@ VCMFrameCount MediaOptimization::SentFrameCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
int32_t MediaOptimization::UpdateWithEncodedData(size_t encoded_length,
|
||||
uint32_t timestamp,
|
||||
FrameType encoded_frame_type) {
|
||||
int32_t MediaOptimization::UpdateWithEncodedData(
|
||||
const EncodedImage& encoded_image) {
|
||||
size_t encoded_length = encoded_image._length;
|
||||
uint32_t timestamp = encoded_image._timeStamp;
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
const int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
PurgeOldFrameSamples(now_ms);
|
||||
@ -389,7 +390,7 @@ int32_t MediaOptimization::UpdateWithEncodedData(size_t encoded_length,
|
||||
UpdateSentBitrate(now_ms);
|
||||
UpdateSentFramerate();
|
||||
if (encoded_length > 0) {
|
||||
const bool delta_frame = (encoded_frame_type != kVideoFrameKey);
|
||||
const bool delta_frame = encoded_image._frameType != kKeyFrame;
|
||||
|
||||
frame_dropper_->Fill(encoded_length, delta_frame);
|
||||
if (max_payload_size_ > 0 && encoded_length > 0) {
|
||||
@ -405,7 +406,7 @@ int32_t MediaOptimization::UpdateWithEncodedData(size_t encoded_length,
|
||||
|
||||
if (enable_qm_) {
|
||||
// Update quality select with encoded length.
|
||||
qm_resolution_->UpdateEncodedSize(encoded_length, encoded_frame_type);
|
||||
qm_resolution_->UpdateEncodedSize(encoded_length);
|
||||
}
|
||||
}
|
||||
if (!delta_frame && encoded_length > 0) {
|
||||
|
||||
@ -76,10 +76,8 @@ class MediaOptimization {
|
||||
|
||||
void UpdateContentData(const VideoContentMetrics* content_metrics);
|
||||
|
||||
// Informs Media Optimization of encoding output: Length and frame type.
|
||||
int32_t UpdateWithEncodedData(size_t encoded_length,
|
||||
uint32_t timestamp,
|
||||
FrameType encoded_frame_type);
|
||||
// Informs Media Optimization of encoded output.
|
||||
int32_t UpdateWithEncodedData(const EncodedImage& encoded_image);
|
||||
|
||||
uint32_t InputFrameRate();
|
||||
uint32_t SentFrameRate();
|
||||
|
||||
@ -35,8 +35,11 @@ class TestMediaOptimization : public ::testing::Test {
|
||||
EXPECT_EQ(expect_frame_drop, frame_dropped);
|
||||
if (!frame_dropped) {
|
||||
size_t bytes_per_frame = bitrate_bps * frame_time_ms_ / (8 * 1000);
|
||||
ASSERT_EQ(VCM_OK, media_opt_.UpdateWithEncodedData(
|
||||
bytes_per_frame, next_timestamp_, kVideoFrameDelta));
|
||||
EncodedImage encoded_image;
|
||||
encoded_image._length = bytes_per_frame;
|
||||
encoded_image._timeStamp = next_timestamp_;
|
||||
encoded_image._frameType = kKeyFrame;
|
||||
ASSERT_EQ(VCM_OK, media_opt_.UpdateWithEncodedData(encoded_image));
|
||||
}
|
||||
next_timestamp_ += frame_time_ms_ * kSampleRate / 1000;
|
||||
clock_.AdvanceTimeMilliseconds(frame_time_ms_);
|
||||
|
||||
@ -239,8 +239,7 @@ void VCMQmResolution::UpdateCodecParameters(float frame_rate, uint16_t width,
|
||||
}
|
||||
|
||||
// Update rate data after every encoded frame.
|
||||
void VCMQmResolution::UpdateEncodedSize(size_t encoded_size,
|
||||
FrameType encoded_frame_type) {
|
||||
void VCMQmResolution::UpdateEncodedSize(size_t encoded_size) {
|
||||
frame_cnt_++;
|
||||
// Convert to Kbps.
|
||||
float encoded_size_kbits = 8.0f * static_cast<float>(encoded_size) / 1000.0f;
|
||||
|
||||
@ -216,8 +216,7 @@ class VCMQmResolution : public VCMQmMethod {
|
||||
|
||||
// Update with actual bit rate (size of the latest encoded frame)
|
||||
// and frame type, after every encoded frame.
|
||||
void UpdateEncodedSize(size_t encoded_size,
|
||||
FrameType encoded_frame_type);
|
||||
void UpdateEncodedSize(size_t encoded_size);
|
||||
|
||||
// Update with new target bitrate, actual encoder sent rate, frame_rate,
|
||||
// loss rate: every ~1 sec from SetTargetRates in media_opt.
|
||||
|
||||
@ -1264,11 +1264,10 @@ void QmSelectTest::UpdateQmContentData(float motion_metric,
|
||||
|
||||
void QmSelectTest::UpdateQmEncodedFrame(size_t* encoded_size,
|
||||
size_t num_updates) {
|
||||
FrameType frame_type = kVideoFrameDelta;
|
||||
for (size_t i = 0; i < num_updates; ++i) {
|
||||
// Convert to bytes.
|
||||
size_t encoded_size_update = 1000 * encoded_size[i] / 8;
|
||||
qm_resolution_->UpdateEncodedSize(encoded_size_update, frame_type);
|
||||
qm_resolution_->UpdateEncodedSize(encoded_size_update);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ class EncodedImageCallbackWrapper : public EncodedImageCallback {
|
||||
}
|
||||
|
||||
// TODO(andresp): Change to void as return value is ignored.
|
||||
virtual int32_t Encoded(EncodedImage& encoded_image,
|
||||
virtual int32_t Encoded(const EncodedImage& encoded_image,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
CriticalSectionScoped cs(cs_.get());
|
||||
|
||||
@ -86,16 +86,12 @@ class PacketizationCallback : public VCMPacketizationCallback {
|
||||
|
||||
virtual ~PacketizationCallback() {}
|
||||
|
||||
virtual int32_t SendData(FrameType frame_type,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
int64_t capture_time_ms,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
virtual int32_t SendData(uint8_t payload_type,
|
||||
const EncodedImage& encoded_image,
|
||||
const RTPFragmentationHeader& fragmentation_header,
|
||||
const RTPVideoHeader* rtp_video_header) OVERRIDE {
|
||||
assert(rtp_video_header);
|
||||
frame_data_.push_back(FrameData(payload_size, *rtp_video_header));
|
||||
frame_data_.push_back(FrameData(encoded_image._length, *rtp_video_header));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user