Add new peer to injector when adding it to analyzer. Removed unused injector
Bug: webrtc:12247 Change-Id: I735f2b69a8239633bfddca48efd45fe4886c1598 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/203820 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33072}
This commit is contained in:
parent
4f3a2eba6b
commit
c57089a97a
@ -13,7 +13,6 @@ if (!build_with_chromium) {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
":default_encoded_image_data_injector",
|
||||
":encoded_image_data_injector_api",
|
||||
":example_video_quality_analyzer",
|
||||
":id_generator",
|
||||
@ -35,7 +34,6 @@ if (!build_with_chromium) {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
":default_encoded_image_data_injector_unittest",
|
||||
":default_video_quality_analyzer_test",
|
||||
":multi_head_queue_test",
|
||||
":peer_connection_e2e_smoke_test",
|
||||
@ -73,23 +71,6 @@ if (!build_with_chromium) {
|
||||
deps = [ "../../../api/video:encoded_image" ]
|
||||
}
|
||||
|
||||
rtc_library("default_encoded_image_data_injector") {
|
||||
visibility = [ "*" ]
|
||||
testonly = true
|
||||
sources = [
|
||||
"analyzer/video/default_encoded_image_data_injector.cc",
|
||||
"analyzer/video/default_encoded_image_data_injector.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":encoded_image_data_injector_api",
|
||||
"../../../api/video:encoded_image",
|
||||
"../../../rtc_base:checks",
|
||||
"../../../rtc_base:criticalsection",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/memory" ]
|
||||
}
|
||||
|
||||
rtc_library("single_process_encoded_image_data_injector") {
|
||||
visibility = [ "*" ]
|
||||
testonly = true
|
||||
@ -427,18 +408,6 @@ if (!build_with_chromium) {
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("default_encoded_image_data_injector_unittest") {
|
||||
testonly = true
|
||||
sources =
|
||||
[ "analyzer/video/default_encoded_image_data_injector_unittest.cc" ]
|
||||
deps = [
|
||||
":default_encoded_image_data_injector",
|
||||
"../../../api/video:encoded_image",
|
||||
"../../../rtc_base:rtc_base_approved",
|
||||
"../../../test:test_support",
|
||||
]
|
||||
}
|
||||
|
||||
peer_connection_e2e_smoke_test_resources = [
|
||||
"../../../resources/pc_quality_smoke_test_alice_source.wav",
|
||||
"../../../resources/pc_quality_smoke_test_bob_source.wav",
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 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 "test/pc/e2e/analyzer/video/default_encoded_image_data_injector.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace webrtc_pc_e2e {
|
||||
namespace {
|
||||
|
||||
// The amount on which encoded image buffer will be expanded to inject frame id.
|
||||
// This is 2 bytes for uint16_t frame id itself and 4 bytes for original length
|
||||
// of the buffer.
|
||||
constexpr int kEncodedImageBufferExpansion = 6;
|
||||
|
||||
struct ExtractionInfo {
|
||||
size_t length;
|
||||
bool discard;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
DefaultEncodedImageDataInjector::DefaultEncodedImageDataInjector() = default;
|
||||
DefaultEncodedImageDataInjector::~DefaultEncodedImageDataInjector() = default;
|
||||
|
||||
EncodedImage DefaultEncodedImageDataInjector::InjectData(
|
||||
uint16_t id,
|
||||
bool discard,
|
||||
const EncodedImage& source,
|
||||
int /*coding_entity_id*/) {
|
||||
auto buffer =
|
||||
EncodedImageBuffer::Create(source.size() + kEncodedImageBufferExpansion);
|
||||
memcpy(buffer->data(), source.data(), source.size());
|
||||
|
||||
size_t insertion_pos = source.size();
|
||||
buffer->data()[insertion_pos] = id & 0x00ff;
|
||||
buffer->data()[insertion_pos + 1] = (id & 0xff00) >> 8;
|
||||
buffer->data()[insertion_pos + 2] = source.size() & 0x000000ff;
|
||||
buffer->data()[insertion_pos + 3] = (source.size() & 0x0000ff00) >> 8;
|
||||
buffer->data()[insertion_pos + 4] = (source.size() & 0x00ff0000) >> 16;
|
||||
buffer->data()[insertion_pos + 5] = (source.size() & 0xff000000) >> 24;
|
||||
|
||||
// We will store discard flag in the high bit of high byte of the size.
|
||||
RTC_CHECK_LT(source.size(), 1U << 31) << "High bit is already in use";
|
||||
buffer->data()[insertion_pos + 5] =
|
||||
buffer->data()[insertion_pos + 5] | ((discard ? 1 : 0) << 7);
|
||||
|
||||
EncodedImage out = source;
|
||||
out.SetEncodedData(buffer);
|
||||
return out;
|
||||
}
|
||||
|
||||
EncodedImageExtractionResult DefaultEncodedImageDataInjector::ExtractData(
|
||||
const EncodedImage& source,
|
||||
int /*coding_entity_id*/) {
|
||||
auto buffer = EncodedImageBuffer::Create(source.size());
|
||||
EncodedImage out = source;
|
||||
out.SetEncodedData(buffer);
|
||||
|
||||
size_t source_pos = source.size() - 1;
|
||||
absl::optional<uint16_t> id = absl::nullopt;
|
||||
bool discard = true;
|
||||
std::vector<ExtractionInfo> extraction_infos;
|
||||
// First make a reverse pass through whole buffer to populate frame id,
|
||||
// discard flags and concatenated encoded images length.
|
||||
while (true) {
|
||||
size_t insertion_pos = source_pos - kEncodedImageBufferExpansion + 1;
|
||||
RTC_CHECK_GE(insertion_pos, 0);
|
||||
RTC_CHECK_LE(insertion_pos + kEncodedImageBufferExpansion, source.size());
|
||||
uint16_t next_id =
|
||||
source.data()[insertion_pos] + (source.data()[insertion_pos + 1] << 8);
|
||||
RTC_CHECK(!id || id.value() == next_id)
|
||||
<< "Different frames encoded into single encoded image: " << id.value()
|
||||
<< " vs " << next_id;
|
||||
id = next_id;
|
||||
uint32_t length = source.data()[insertion_pos + 2] +
|
||||
(source.data()[insertion_pos + 3] << 8) +
|
||||
(source.data()[insertion_pos + 4] << 16) +
|
||||
((source.data()[insertion_pos + 5] << 24) & 0b01111111);
|
||||
bool current_discard = (source.data()[insertion_pos + 5] & 0b10000000) != 0;
|
||||
extraction_infos.push_back({length, current_discard});
|
||||
// Extraction result is discarded only if all encoded partitions are
|
||||
// discarded.
|
||||
discard = discard && current_discard;
|
||||
if (source_pos < length + kEncodedImageBufferExpansion) {
|
||||
break;
|
||||
}
|
||||
source_pos -= length + kEncodedImageBufferExpansion;
|
||||
}
|
||||
RTC_CHECK(id);
|
||||
std::reverse(extraction_infos.begin(), extraction_infos.end());
|
||||
if (discard) {
|
||||
out.set_size(0);
|
||||
return EncodedImageExtractionResult{*id, out, true};
|
||||
}
|
||||
|
||||
// Now basing on populated data make a forward pass to copy required pieces
|
||||
// of data to the output buffer.
|
||||
source_pos = 0;
|
||||
size_t out_pos = 0;
|
||||
auto extraction_infos_it = extraction_infos.begin();
|
||||
while (source_pos < source.size()) {
|
||||
const ExtractionInfo& info = *extraction_infos_it;
|
||||
RTC_CHECK_LE(source_pos + kEncodedImageBufferExpansion + info.length,
|
||||
source.size());
|
||||
if (!info.discard) {
|
||||
// Copy next encoded image payload from concatenated buffer only if it is
|
||||
// not discarded.
|
||||
memcpy(&buffer->data()[out_pos], &source.data()[source_pos], info.length);
|
||||
out_pos += info.length;
|
||||
}
|
||||
source_pos += info.length + kEncodedImageBufferExpansion;
|
||||
++extraction_infos_it;
|
||||
}
|
||||
out.set_size(out_pos);
|
||||
|
||||
return EncodedImageExtractionResult{id.value(), out, discard};
|
||||
}
|
||||
|
||||
} // namespace webrtc_pc_e2e
|
||||
} // namespace webrtc
|
||||
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 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 TEST_PC_E2E_ANALYZER_VIDEO_DEFAULT_ENCODED_IMAGE_DATA_INJECTOR_H_
|
||||
#define TEST_PC_E2E_ANALYZER_VIDEO_DEFAULT_ENCODED_IMAGE_DATA_INJECTOR_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "test/pc/e2e/analyzer/video/encoded_image_data_injector.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace webrtc_pc_e2e {
|
||||
|
||||
// Injects frame id and discard flag into EncodedImage payload buffer. The
|
||||
// payload buffer will be appended in the injector with 2 bytes frame id and 4
|
||||
// bytes original buffer length. Discarded flag will be put into the highest bit
|
||||
// of the length. It is assumed, that frame's data can't be more then 2^31
|
||||
// bytes. In the decoder, frame id and discard flag will be extracted and the
|
||||
// length will be used to restore original buffer. We can't put this data in the
|
||||
// beginning of the payload, because first bytes are used in different parts of
|
||||
// WebRTC pipeline.
|
||||
//
|
||||
// The data in the EncodedImage on encoder side after injection will look like
|
||||
// this:
|
||||
// 4 bytes frame length + discard flag
|
||||
// _________________ _ _ _↓_ _ _
|
||||
// | original buffer | | |
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯↑¯ ¯ ¯ ¯ ¯
|
||||
// 2 bytes frame id
|
||||
//
|
||||
// But on decoder side multiple payloads can be concatenated into single
|
||||
// EncodedImage in jitter buffer and its payload will look like this:
|
||||
// _________ _ _ _ _ _ _ _________ _ _ _ _ _ _ _________ _ _ _ _ _ _
|
||||
// buf: | payload | | | payload | | | payload | | |
|
||||
// ¯¯¯¯¯¯¯¯¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯¯¯¯¯¯¯¯¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯¯¯¯¯¯¯¯¯ ¯ ¯ ¯ ¯ ¯ ¯
|
||||
// To correctly restore such images we will extract id by this algorithm:
|
||||
// 1. Make a pass from end to begin of the buffer to restore origin lengths,
|
||||
// frame ids and discard flags from length high bit.
|
||||
// 2. If all discard flags are true - discard this encoded image
|
||||
// 3. Make a pass from begin to end copying data to the output basing on
|
||||
// previously extracted length
|
||||
// Also it will check, that all extracted ids are equals.
|
||||
class DefaultEncodedImageDataInjector : public EncodedImageDataInjector,
|
||||
public EncodedImageDataExtractor {
|
||||
public:
|
||||
DefaultEncodedImageDataInjector();
|
||||
~DefaultEncodedImageDataInjector() override;
|
||||
|
||||
EncodedImage InjectData(uint16_t id,
|
||||
bool discard,
|
||||
const EncodedImage& source,
|
||||
int /*coding_entity_id*/) override;
|
||||
|
||||
void Start(int expected_receivers_count) override {}
|
||||
EncodedImageExtractionResult ExtractData(const EncodedImage& source,
|
||||
int coding_entity_id) override;
|
||||
};
|
||||
|
||||
} // namespace webrtc_pc_e2e
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TEST_PC_E2E_ANALYZER_VIDEO_DEFAULT_ENCODED_IMAGE_DATA_INJECTOR_H_
|
||||
@ -1,190 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 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 "test/pc/e2e/analyzer/video/default_encoded_image_data_injector.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "rtc_base/buffer.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace webrtc_pc_e2e {
|
||||
namespace {
|
||||
|
||||
rtc::scoped_refptr<EncodedImageBuffer>
|
||||
CreateEncodedImageBufferOfSizeNFilledWithValuesFromX(size_t n, uint8_t x) {
|
||||
auto buffer = EncodedImageBuffer::Create(n);
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
buffer->data()[i] = static_cast<uint8_t>(x + i);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
EncodedImage CreateEncodedImageOfSizeNFilledWithValuesFromX(size_t n,
|
||||
uint8_t x) {
|
||||
EncodedImage image;
|
||||
image.SetEncodedData(
|
||||
CreateEncodedImageBufferOfSizeNFilledWithValuesFromX(n, x));
|
||||
return image;
|
||||
}
|
||||
|
||||
TEST(DefaultEncodedImageDataInjector, InjectExtractDiscardFalse) {
|
||||
DefaultEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
EncodedImage source = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 1);
|
||||
source.SetTimestamp(123456789);
|
||||
|
||||
EncodedImageExtractionResult out =
|
||||
injector.ExtractData(injector.InjectData(512, false, source, 1), 2);
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 10ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DefaultEncodedImageDataInjector, InjectExtractDiscardTrue) {
|
||||
DefaultEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
EncodedImage source = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 1);
|
||||
source.SetTimestamp(123456789);
|
||||
|
||||
EncodedImageExtractionResult out =
|
||||
injector.ExtractData(injector.InjectData(512, true, source, 1), 2);
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_TRUE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 0ul);
|
||||
}
|
||||
|
||||
TEST(DefaultEncodedImageDataInjector, Inject3Extract3) {
|
||||
DefaultEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
// 1st frame
|
||||
EncodedImage source1 = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 1);
|
||||
source1.SetTimestamp(123456710);
|
||||
// 2nd frame 1st spatial layer
|
||||
EncodedImage source2 = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 11);
|
||||
source2.SetTimestamp(123456720);
|
||||
// 2nd frame 2nd spatial layer
|
||||
EncodedImage source3 = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 21);
|
||||
source3.SetTimestamp(123456720);
|
||||
|
||||
EncodedImage intermediate1 = injector.InjectData(510, false, source1, 1);
|
||||
EncodedImage intermediate2 = injector.InjectData(520, true, source2, 1);
|
||||
EncodedImage intermediate3 = injector.InjectData(520, false, source3, 1);
|
||||
|
||||
// Extract ids in different order.
|
||||
EncodedImageExtractionResult out3 = injector.ExtractData(intermediate3, 2);
|
||||
EncodedImageExtractionResult out1 = injector.ExtractData(intermediate1, 2);
|
||||
EncodedImageExtractionResult out2 = injector.ExtractData(intermediate2, 2);
|
||||
|
||||
EXPECT_EQ(out1.id, 510);
|
||||
EXPECT_FALSE(out1.discard);
|
||||
EXPECT_EQ(out1.image.size(), 10ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out1.image.data()[i], i + 1);
|
||||
}
|
||||
EXPECT_EQ(out2.id, 520);
|
||||
EXPECT_TRUE(out2.discard);
|
||||
EXPECT_EQ(out2.image.size(), 0ul);
|
||||
EXPECT_EQ(out3.id, 520);
|
||||
EXPECT_FALSE(out3.discard);
|
||||
EXPECT_EQ(out3.image.size(), 10ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out3.image.data()[i], i + 21);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DefaultEncodedImageDataInjector, InjectExtractFromConcatenated) {
|
||||
DefaultEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
EncodedImage source1 = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 1);
|
||||
source1.SetTimestamp(123456710);
|
||||
EncodedImage source2 = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 11);
|
||||
source2.SetTimestamp(123456710);
|
||||
EncodedImage source3 = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 21);
|
||||
source3.SetTimestamp(123456710);
|
||||
|
||||
// Inject id into 3 images with same frame id.
|
||||
EncodedImage intermediate1 = injector.InjectData(512, false, source1, 1);
|
||||
EncodedImage intermediate2 = injector.InjectData(512, true, source2, 1);
|
||||
EncodedImage intermediate3 = injector.InjectData(512, false, source3, 1);
|
||||
|
||||
// Concatenate them into single encoded image, like it can be done in jitter
|
||||
// buffer.
|
||||
size_t concatenated_length =
|
||||
intermediate1.size() + intermediate2.size() + intermediate3.size();
|
||||
rtc::Buffer concatenated_buffer;
|
||||
concatenated_buffer.AppendData(intermediate1.data(), intermediate1.size());
|
||||
concatenated_buffer.AppendData(intermediate2.data(), intermediate2.size());
|
||||
concatenated_buffer.AppendData(intermediate3.data(), intermediate3.size());
|
||||
EncodedImage concatenated;
|
||||
concatenated.SetEncodedData(EncodedImageBuffer::Create(
|
||||
concatenated_buffer.data(), concatenated_length));
|
||||
|
||||
// Extract frame id from concatenated image
|
||||
EncodedImageExtractionResult out = injector.ExtractData(concatenated, 2);
|
||||
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 2 * 10ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
EXPECT_EQ(out.image.data()[i + 10], i + 21);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DefaultEncodedImageDataInjector,
|
||||
InjectExtractFromConcatenatedAllDiscarded) {
|
||||
DefaultEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
EncodedImage source1 = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 1);
|
||||
source1.SetTimestamp(123456710);
|
||||
EncodedImage source2 = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 11);
|
||||
source2.SetTimestamp(123456710);
|
||||
EncodedImage source3 = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 21);
|
||||
source3.SetTimestamp(123456710);
|
||||
|
||||
// Inject id into 3 images with same frame id.
|
||||
EncodedImage intermediate1 = injector.InjectData(512, true, source1, 1);
|
||||
EncodedImage intermediate2 = injector.InjectData(512, true, source2, 1);
|
||||
EncodedImage intermediate3 = injector.InjectData(512, true, source3, 1);
|
||||
|
||||
// Concatenate them into single encoded image, like it can be done in jitter
|
||||
// buffer.
|
||||
size_t concatenated_length =
|
||||
intermediate1.size() + intermediate2.size() + intermediate3.size();
|
||||
rtc::Buffer concatenated_buffer;
|
||||
concatenated_buffer.AppendData(intermediate1.data(), intermediate1.size());
|
||||
concatenated_buffer.AppendData(intermediate2.data(), intermediate2.size());
|
||||
concatenated_buffer.AppendData(intermediate3.data(), intermediate3.size());
|
||||
EncodedImage concatenated;
|
||||
concatenated.SetEncodedData(EncodedImageBuffer::Create(
|
||||
concatenated_buffer.data(), concatenated_length));
|
||||
|
||||
// Extract frame id from concatenated image
|
||||
EncodedImageExtractionResult out = injector.ExtractData(concatenated, 2);
|
||||
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_TRUE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 0ul);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace webrtc_pc_e2e
|
||||
} // namespace webrtc
|
||||
@ -52,6 +52,10 @@ class EncodedImageDataExtractor {
|
||||
// encoded image.
|
||||
virtual void Start(int expected_receivers_count) = 0;
|
||||
|
||||
// Invoked by framework when it is required to add one more receiver for
|
||||
// frames. Will be invoked before that receiver will start receive data.
|
||||
virtual void AddParticipantInCall() = 0;
|
||||
|
||||
// Returns encoded image id, extracted from payload and also encoded image
|
||||
// with its original payload. For concatenated spatial layers it should be the
|
||||
// same id. |coding_entity_id| is unique id of decoder or encoder.
|
||||
|
||||
@ -55,6 +55,11 @@ EncodedImage SingleProcessEncodedImageDataInjector::InjectData(
|
||||
return out;
|
||||
}
|
||||
|
||||
void SingleProcessEncodedImageDataInjector::AddParticipantInCall() {
|
||||
MutexLock crit(&lock_);
|
||||
expected_receivers_count_++;
|
||||
}
|
||||
|
||||
EncodedImageExtractionResult SingleProcessEncodedImageDataInjector::ExtractData(
|
||||
const EncodedImage& source,
|
||||
int coding_entity_id) {
|
||||
|
||||
@ -55,6 +55,7 @@ class SingleProcessEncodedImageDataInjector : public EncodedImageDataInjector,
|
||||
MutexLock crit(&lock_);
|
||||
expected_receivers_count_ = expected_receivers_count;
|
||||
}
|
||||
void AddParticipantInCall() override;
|
||||
EncodedImageExtractionResult ExtractData(const EncodedImage& source,
|
||||
int coding_entity_id) override;
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ EncodedImage CreateEncodedImageOfSizeNFilledWithValuesFromX(size_t n,
|
||||
return image;
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjector, InjectExtractDiscardFalse) {
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest, InjectExtractDiscardFalse) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
@ -55,7 +55,7 @@ TEST(SingleProcessEncodedImageDataInjector, InjectExtractDiscardFalse) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjector, InjectExtractDiscardTrue) {
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest, InjectExtractDiscardTrue) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
@ -70,7 +70,8 @@ TEST(SingleProcessEncodedImageDataInjector, InjectExtractDiscardTrue) {
|
||||
EXPECT_EQ(out.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjector, InjectWithUnsetSpatialLayerSizes) {
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest,
|
||||
InjectWithUnsetSpatialLayerSizes) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
@ -93,7 +94,8 @@ TEST(SingleProcessEncodedImageDataInjector, InjectWithUnsetSpatialLayerSizes) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjector, InjectWithZeroSpatialLayerSizes) {
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest,
|
||||
InjectWithZeroSpatialLayerSizes) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
@ -119,7 +121,7 @@ TEST(SingleProcessEncodedImageDataInjector, InjectWithZeroSpatialLayerSizes) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjector, Inject3Extract3) {
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest, Inject3Extract3) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
@ -162,7 +164,7 @@ TEST(SingleProcessEncodedImageDataInjector, Inject3Extract3) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjector, InjectExtractFromConcatenated) {
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest, InjectExtractFromConcatenated) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(1);
|
||||
|
||||
@ -255,7 +257,7 @@ TEST(SingleProcessEncodedImageDataInjector,
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjector, InjectOnceExtractTwice) {
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest, InjectOnceExtractTwice) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(2);
|
||||
|
||||
@ -286,6 +288,52 @@ TEST(SingleProcessEncodedImageDataInjector, InjectOnceExtractTwice) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest, Add1stReceiverAfterStart) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(0);
|
||||
|
||||
EncodedImage source = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 1);
|
||||
source.SetTimestamp(123456789);
|
||||
EncodedImage modified_image = injector.InjectData(
|
||||
/*id=*/512, /*discard=*/false, source, /*coding_entity_id=*/1);
|
||||
|
||||
injector.AddParticipantInCall();
|
||||
EncodedImageExtractionResult out =
|
||||
injector.ExtractData(modified_image, /*coding_entity_id=*/2);
|
||||
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 10ul);
|
||||
EXPECT_EQ(out.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest, Add3rdReceiverAfterStart) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(2);
|
||||
|
||||
EncodedImage source = CreateEncodedImageOfSizeNFilledWithValuesFromX(10, 1);
|
||||
source.SetTimestamp(123456789);
|
||||
EncodedImage modified_image = injector.InjectData(
|
||||
/*id=*/512, /*discard=*/false, source, /*coding_entity_id=*/1);
|
||||
injector.ExtractData(modified_image, /*coding_entity_id=*/2);
|
||||
|
||||
injector.AddParticipantInCall();
|
||||
injector.ExtractData(modified_image, /*coding_entity_id=*/2);
|
||||
EncodedImageExtractionResult out =
|
||||
injector.ExtractData(modified_image, /*coding_entity_id=*/2);
|
||||
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 10ul);
|
||||
EXPECT_EQ(out.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Death tests.
|
||||
// Disabled on Android because death tests misbehave on Android, see
|
||||
// base/test/gtest_util.h.
|
||||
@ -296,7 +344,8 @@ EncodedImage DeepCopyEncodedImage(const EncodedImage& source) {
|
||||
return copy;
|
||||
}
|
||||
|
||||
TEST(SingleProcessEncodedImageDataInjector, InjectOnceExtractMoreThenExpected) {
|
||||
TEST(SingleProcessEncodedImageDataInjectorTest,
|
||||
InjectOnceExtractMoreThenExpected) {
|
||||
SingleProcessEncodedImageDataInjector injector;
|
||||
injector.Start(2);
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ class VideoQualityAnalyzerInjectionHelper : public StatsObserverInterface {
|
||||
// The method should be called before the participant is actually added.
|
||||
void RegisterParticipantInCall(absl::string_view peer_name) {
|
||||
analyzer_->RegisterParticipantInCall(peer_name);
|
||||
extractor_->AddParticipantInCall();
|
||||
}
|
||||
|
||||
// Wraps video encoder factory to give video quality analyzer access to frames
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user