DCHECKS added to GetSimulcastConfig.
GetSimulcastConfig should never return an empty vector of VideoStreams, because lower layers in the code expect atleast one VideoStream. It should also never be given input of max_streams equal to 0. Bug: webrtc:8648 Change-Id: I60f59b3b267a732f07001e4c8a7fa64963802887 Reviewed-on: https://webrtc-review.googlesource.com/38061 Commit-Queue: Erik Språng <sprang@webrtc.org> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21545}
This commit is contained in:
parent
7e60de2c0e
commit
438663e7fc
@ -69,31 +69,23 @@ void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32_t>* ssrcs) {
|
||||
}
|
||||
}
|
||||
|
||||
void MaybeExchangeWidthHeight(int* width, int* height) {
|
||||
// |kSimulcastFormats| assumes |width| >= |height|. If not, exchange them
|
||||
// before comparing.
|
||||
if (*width < *height) {
|
||||
int temp = *width;
|
||||
*width = *height;
|
||||
*height = temp;
|
||||
}
|
||||
}
|
||||
|
||||
int FindSimulcastFormatIndex(int width, int height) {
|
||||
MaybeExchangeWidthHeight(&width, &height);
|
||||
|
||||
RTC_DCHECK_GE(width, 0);
|
||||
RTC_DCHECK_GE(height, 0);
|
||||
for (uint32_t i = 0; i < arraysize(kSimulcastFormats); ++i) {
|
||||
if (width * height >=
|
||||
kSimulcastFormats[i].width * kSimulcastFormats[i].height) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
RTC_NOTREACHED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
int FindSimulcastFormatIndex(int width, int height, size_t max_layers) {
|
||||
MaybeExchangeWidthHeight(&width, &height);
|
||||
|
||||
RTC_DCHECK_GE(width, 0);
|
||||
RTC_DCHECK_GE(height, 0);
|
||||
RTC_DCHECK_GT(max_layers, 0);
|
||||
for (uint32_t i = 0; i < arraysize(kSimulcastFormats); ++i) {
|
||||
if (width * height >=
|
||||
kSimulcastFormats[i].width * kSimulcastFormats[i].height &&
|
||||
@ -101,6 +93,7 @@ int FindSimulcastFormatIndex(int width, int height, size_t max_layers) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
RTC_NOTREACHED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -113,51 +106,30 @@ int NormalizeSimulcastSize(int size, size_t simulcast_layers) {
|
||||
|
||||
size_t FindSimulcastMaxLayers(int width, int height) {
|
||||
int index = FindSimulcastFormatIndex(width, height);
|
||||
if (index == -1) {
|
||||
return -1;
|
||||
}
|
||||
return kSimulcastFormats[index].max_layers;
|
||||
}
|
||||
|
||||
// TODO(marpan): Investigate if we should return 0 instead of -1 in
|
||||
// FindSimulcast[Max/Target/Min]Bitrate functions below, since the
|
||||
// codec struct max/min/targeBitrates are unsigned.
|
||||
int FindSimulcastMaxBitrateBps(int width, int height) {
|
||||
const int format_index = FindSimulcastFormatIndex(width, height);
|
||||
if (format_index == -1) {
|
||||
return -1;
|
||||
}
|
||||
return kSimulcastFormats[format_index].max_bitrate_kbps * 1000;
|
||||
}
|
||||
|
||||
int FindSimulcastTargetBitrateBps(int width, int height) {
|
||||
const int format_index = FindSimulcastFormatIndex(width, height);
|
||||
if (format_index == -1) {
|
||||
return -1;
|
||||
}
|
||||
return kSimulcastFormats[format_index].target_bitrate_kbps * 1000;
|
||||
}
|
||||
|
||||
int FindSimulcastMinBitrateBps(int width, int height) {
|
||||
const int format_index = FindSimulcastFormatIndex(width, height);
|
||||
if (format_index == -1) {
|
||||
return -1;
|
||||
}
|
||||
return kSimulcastFormats[format_index].min_bitrate_kbps * 1000;
|
||||
}
|
||||
|
||||
bool SlotSimulcastMaxResolution(size_t max_layers, int* width, int* height) {
|
||||
void SlotSimulcastMaxResolution(size_t max_layers, int* width, int* height) {
|
||||
int index = FindSimulcastFormatIndex(*width, *height, max_layers);
|
||||
if (index == -1) {
|
||||
RTC_LOG(LS_ERROR) << "SlotSimulcastMaxResolution";
|
||||
return false;
|
||||
}
|
||||
|
||||
*width = kSimulcastFormats[index].width;
|
||||
*height = kSimulcastFormats[index].height;
|
||||
RTC_LOG(LS_INFO) << "SlotSimulcastMaxResolution to width:" << *width
|
||||
<< " height:" << *height;
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetTotalMaxBitrateBps(const std::vector<webrtc::VideoStream>& streams) {
|
||||
@ -206,9 +178,7 @@ std::vector<webrtc::VideoStream> GetSimulcastConfig(size_t max_streams,
|
||||
// If the number of SSRCs in the group differs from our target
|
||||
// number of simulcast streams for current resolution, switch down
|
||||
// to a resolution that matches our number of SSRCs.
|
||||
if (!SlotSimulcastMaxResolution(max_streams, &width, &height)) {
|
||||
return std::vector<webrtc::VideoStream>();
|
||||
}
|
||||
SlotSimulcastMaxResolution(max_streams, &width, &height);
|
||||
num_simulcast_layers = max_streams;
|
||||
}
|
||||
std::vector<webrtc::VideoStream> streams;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user