Move kUsedBufferSize to header
Bug: webrtc:11633 Change-Id: I14e5bf8b48dc0d0f6faef68458b06cf760f33904 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176365 Reviewed-by: Artem Titov <titovartem@webrtc.org> Commit-Queue: Andrey Logvin <landrey@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31400}
This commit is contained in:

committed by
Commit Bot

parent
45bb717a28
commit
a0f5e475c5
@ -19,13 +19,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
namespace webrtc_pc_e2e {
|
||||
namespace {
|
||||
|
||||
// Number of bytes from the beginning of the EncodedImage buffer that will be
|
||||
// used to store frame id and sub id.
|
||||
constexpr size_t kUsedBufferSize = 3;
|
||||
|
||||
} // namespace
|
||||
|
||||
SingleProcessEncodedImageDataInjector::SingleProcessEncodedImageDataInjector() =
|
||||
default;
|
||||
@ -37,12 +30,13 @@ EncodedImage SingleProcessEncodedImageDataInjector::InjectData(
|
||||
bool discard,
|
||||
const EncodedImage& source,
|
||||
int coding_entity_id) {
|
||||
RTC_CHECK(source.size() >= kUsedBufferSize);
|
||||
RTC_CHECK(source.size() >= ExtractionInfo::kUsedBufferSize);
|
||||
|
||||
ExtractionInfo info;
|
||||
info.discard = discard;
|
||||
size_t insertion_pos = source.size() - kUsedBufferSize;
|
||||
memcpy(info.origin_data, &source.data()[insertion_pos], kUsedBufferSize);
|
||||
size_t insertion_pos = source.size() - ExtractionInfo::kUsedBufferSize;
|
||||
memcpy(info.origin_data, &source.data()[insertion_pos],
|
||||
ExtractionInfo::kUsedBufferSize);
|
||||
{
|
||||
rtc::CritScope crit(&lock_);
|
||||
// Will create new one if missed.
|
||||
@ -87,7 +81,8 @@ EncodedImageExtractionResult SingleProcessEncodedImageDataInjector::ExtractData(
|
||||
bool discard = true;
|
||||
std::vector<ExtractionInfo> extraction_infos;
|
||||
for (size_t frame_size : frame_sizes) {
|
||||
size_t insertion_pos = prev_frames_size + frame_size - kUsedBufferSize;
|
||||
size_t insertion_pos =
|
||||
prev_frames_size + frame_size - ExtractionInfo::kUsedBufferSize;
|
||||
// Extract frame id from first 2 bytes starting from insertion pos.
|
||||
uint16_t next_id = buffer[insertion_pos] + (buffer[insertion_pos + 1] << 8);
|
||||
// Extract frame sub id from second 3 byte starting from insertion pos.
|
||||
@ -144,8 +139,8 @@ EncodedImageExtractionResult SingleProcessEncodedImageDataInjector::ExtractData(
|
||||
out.SetSpatialLayerFrameSize(frame_sl_index[frame_index], 0);
|
||||
size -= frame_size;
|
||||
} else {
|
||||
memcpy(&buffer[pos + frame_size - kUsedBufferSize], info.origin_data,
|
||||
kUsedBufferSize);
|
||||
memcpy(&buffer[pos + frame_size - ExtractionInfo::kUsedBufferSize],
|
||||
info.origin_data, ExtractionInfo::kUsedBufferSize);
|
||||
pos += frame_size;
|
||||
}
|
||||
}
|
||||
|
@ -57,13 +57,16 @@ class SingleProcessEncodedImageDataInjector : public EncodedImageDataInjector,
|
||||
// Contains data required to extract frame id from EncodedImage and restore
|
||||
// original buffer.
|
||||
struct ExtractionInfo {
|
||||
// Number of bytes from the beginning of the EncodedImage buffer that will
|
||||
// be used to store frame id and sub id.
|
||||
const static size_t kUsedBufferSize = 3;
|
||||
// Frame sub id to distinguish encoded images for different spatial layers.
|
||||
uint8_t sub_id;
|
||||
// Flag to show is this encoded images should be discarded by analyzing
|
||||
// decoder because of not required spatial layer/simulcast stream.
|
||||
bool discard;
|
||||
// Data from first 3 bytes of origin encoded image's payload.
|
||||
uint8_t origin_data[3];
|
||||
uint8_t origin_data[ExtractionInfo::kUsedBufferSize];
|
||||
};
|
||||
|
||||
struct ExtractionInfoVector {
|
||||
|
Reference in New Issue
Block a user