Replace VideoSendStream::Config with new rtclog::StreamConfig in RtcEventLog.

BUG=webrtc:7538

Review-Url: https://codereview.webrtc.org/2857933002
Cr-Commit-Position: refs/heads/master@{#18221}
This commit is contained in:
perkj 2017-05-22 04:08:28 -07:00 committed by Commit bot
parent 09e71daec5
commit c0876aab46
12 changed files with 115 additions and 142 deletions

View File

@ -107,6 +107,23 @@ rtclog::StreamConfig CreateRtcLogStreamConfig(
return rtclog_config;
}
rtclog::StreamConfig CreateRtcLogStreamConfig(
const VideoSendStream::Config& config,
size_t ssrc_index) {
rtclog::StreamConfig rtclog_config;
rtclog_config.local_ssrc = config.rtp.ssrcs[ssrc_index];
if (ssrc_index < config.rtp.rtx.ssrcs.size()) {
rtclog_config.rtx_ssrc = config.rtp.rtx.ssrcs[ssrc_index];
}
rtclog_config.rtcp_mode = config.rtp.rtcp_mode;
rtclog_config.rtp_extensions = config.rtp.extensions;
rtclog_config.codecs.emplace_back(config.encoder_settings.payload_name,
config.encoder_settings.payload_type,
config.rtp.rtx.payload_type);
return rtclog_config;
}
} // namespace
namespace internal {
@ -638,7 +655,11 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
video_send_delay_stats_->AddSsrcs(config);
event_log_->LogVideoSendStreamConfig(config);
for (size_t ssrc_index = 0; ssrc_index < config.rtp.ssrcs.size();
++ssrc_index) {
event_log_->LogVideoSendStreamConfig(
CreateRtcLogStreamConfig(config, ssrc_index));
}
// TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
// the call has already started.

View File

@ -33,7 +33,7 @@ class MockRtcEventLog : public RtcEventLog {
void(const rtclog::StreamConfig& config));
MOCK_METHOD1(LogVideoSendStreamConfig,
void(const webrtc::VideoSendStream::Config& config));
void(const rtclog::StreamConfig& config));
MOCK_METHOD1(LogAudioReceiveStreamConfig,
void(const webrtc::AudioReceiveStream::Config& config));

View File

@ -63,7 +63,7 @@ class RtcEventLogImpl final : public RtcEventLog {
int64_t max_size_bytes) override;
void StopLogging() override;
void LogVideoReceiveStreamConfig(const rtclog::StreamConfig& config) override;
void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override;
void LogVideoSendStreamConfig(const rtclog::StreamConfig& config) override;
void LogAudioReceiveStreamConfig(
const AudioReceiveStream::Config& config) override;
void LogAudioSendStreamConfig(const AudioSendStream::Config& config) override;
@ -312,32 +312,41 @@ void RtcEventLogImpl::LogVideoReceiveStreamConfig(
}
void RtcEventLogImpl::LogVideoSendStreamConfig(
const VideoSendStream::Config& config) {
const rtclog::StreamConfig& config) {
std::unique_ptr<rtclog::Event> event(new rtclog::Event());
event->set_timestamp_us(rtc::TimeMicros());
event->set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT);
rtclog::VideoSendConfig* sender_config = event->mutable_video_sender_config();
for (const auto& ssrc : config.rtp.ssrcs) {
sender_config->add_ssrcs(ssrc);
// TODO(perkj): rtclog::VideoSendConfig should only contain one SSRC.
sender_config->add_ssrcs(config.local_ssrc);
if (config.rtx_ssrc != 0) {
sender_config->add_rtx_ssrcs(config.rtx_ssrc);
}
for (const auto& e : config.rtp.extensions) {
for (const auto& e : config.rtp_extensions) {
rtclog::RtpHeaderExtension* extension =
sender_config->add_header_extensions();
extension->set_name(e.uri);
extension->set_id(e.id);
}
for (const auto& rtx_ssrc : config.rtp.rtx.ssrcs) {
sender_config->add_rtx_ssrcs(rtx_ssrc);
}
sender_config->set_rtx_payload_type(config.rtp.rtx.payload_type);
// TODO(perkj): rtclog::VideoSendConfig should contain many possible codec
// configurations.
for (const auto& codec : config.codecs) {
sender_config->set_rtx_payload_type(codec.rtx_payload_type);
rtclog::EncoderConfig* encoder = sender_config->mutable_encoder();
encoder->set_name(codec.payload_name);
encoder->set_payload_type(codec.payload_type);
if (config.codecs.size() > 1) {
LOG(WARNING) << "LogVideoSendStreamConfig currently only supports one "
<< "codec. Logging codec :" << codec.payload_name;
break;
}
}
rtclog::EncoderConfig* encoder = sender_config->mutable_encoder();
encoder->set_name(config.encoder_settings.payload_name);
encoder->set_payload_type(config.encoder_settings.payload_type);
StoreEvent(&event);
}

View File

@ -112,13 +112,12 @@ class RtcEventLog {
// Stops logging to file and waits until the thread has finished.
virtual void StopLogging() = 0;
// Logs configuration information for video receive stream.
// Logs configuration information for a video receive stream.
virtual void LogVideoReceiveStreamConfig(
const rtclog::StreamConfig& config) = 0;
// Logs configuration information for webrtc::VideoSendStream.
virtual void LogVideoSendStreamConfig(
const webrtc::VideoSendStream::Config& config) = 0;
// Logs configuration information for a video send stream.
virtual void LogVideoSendStreamConfig(const rtclog::StreamConfig& config) = 0;
// Logs configuration information for webrtc::AudioReceiveStream.
virtual void LogAudioReceiveStreamConfig(
@ -201,8 +200,7 @@ class RtcEventLogNullImpl final : public RtcEventLog {
void StopLogging() override {}
void LogVideoReceiveStreamConfig(
const rtclog::StreamConfig& config) override {}
void LogVideoSendStreamConfig(
const VideoSendStream::Config& config) override {}
void LogVideoSendStreamConfig(const rtclog::StreamConfig& config) override {}
void LogAudioReceiveStreamConfig(
const AudioReceiveStream::Config& config) override {}
void LogAudioSendStreamConfig(

View File

@ -382,26 +382,18 @@ int main(int argc, char* argv[]) {
}
if (parsed_stream.GetEventType(i) ==
webrtc::ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) {
webrtc::VideoSendStream::Config config(nullptr);
webrtc::rtclog::StreamConfig config;
parsed_stream.GetVideoSendConfig(i, &config);
global_streams.emplace_back(config.local_ssrc, webrtc::MediaType::VIDEO,
webrtc::kOutgoingPacket);
for (uint32_t ssrc : config.rtp.ssrcs) {
global_streams.emplace_back(ssrc, webrtc::MediaType::VIDEO,
webrtc::kOutgoingPacket);
}
for (uint32_t ssrc : config.rtp.rtx.ssrcs) {
global_streams.emplace_back(ssrc, webrtc::MediaType::VIDEO,
webrtc::kOutgoingPacket);
}
global_streams.emplace_back(config.rtx_ssrc, webrtc::MediaType::VIDEO,
webrtc::kOutgoingPacket);
if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_nooutgoing) {
std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_SEND_CONFIG";
std::cout << "\tssrcs=";
for (const auto& ssrc : config.rtp.ssrcs)
std::cout << ssrc << ',';
std::cout << "\trtx_ssrcs=";
for (const auto& ssrc : config.rtp.rtx.ssrcs)
std::cout << ssrc << ',';
std::cout << "\tssrcs=" << config.local_ssrc;
std::cout << "\trtx_ssrcs=" << config.rtx_ssrc;
std::cout << std::endl;
}
}

View File

@ -378,9 +378,8 @@ void ParsedRtcEventLog::GetVideoReceiveConfig(
}
}
void ParsedRtcEventLog::GetVideoSendConfig(
size_t index,
VideoSendStream::Config* config) const {
void ParsedRtcEventLog::GetVideoSendConfig(size_t index,
rtclog::StreamConfig* config) const {
RTC_CHECK_LT(index, GetNumberOfEvents());
const rtclog::Event& event = events_[index];
RTC_CHECK(config != nullptr);
@ -389,32 +388,31 @@ void ParsedRtcEventLog::GetVideoSendConfig(
RTC_CHECK(event.has_video_sender_config());
const rtclog::VideoSendConfig& sender_config = event.video_sender_config();
// Get SSRCs.
config->rtp.ssrcs.clear();
for (int i = 0; i < sender_config.ssrcs_size(); i++) {
config->rtp.ssrcs.push_back(sender_config.ssrcs(i));
}
// Get header extensions.
GetHeaderExtensions(&config->rtp.extensions,
sender_config.header_extensions());
// Get RTX settings.
config->rtp.rtx.ssrcs.clear();
for (int i = 0; i < sender_config.rtx_ssrcs_size(); i++) {
config->rtp.rtx.ssrcs.push_back(sender_config.rtx_ssrcs(i));
if (sender_config.ssrcs_size() > 0) {
config->local_ssrc = sender_config.ssrcs(0);
if (sender_config.ssrcs().size() > 1) {
LOG(WARNING) << "VideoSendConfig contains multiple ssrcs.";
}
}
if (sender_config.rtx_ssrcs_size() > 0) {
RTC_CHECK(sender_config.has_rtx_payload_type());
config->rtp.rtx.payload_type = sender_config.rtx_payload_type();
} else {
// Reset RTX payload type default value if no RTX SSRCs are used.
config->rtp.rtx.payload_type = -1;
config->rtx_ssrc = sender_config.rtx_ssrcs(0);
if (sender_config.rtx_ssrcs_size() > 1) {
LOG(WARNING) << "VideoSendConfig contains multiple rtx ssrcs.";
}
}
// Get encoder.
// Get header extensions.
GetHeaderExtensions(&config->rtp_extensions,
sender_config.header_extensions());
// Get the codec.
RTC_CHECK(sender_config.has_encoder());
RTC_CHECK(sender_config.encoder().has_name());
RTC_CHECK(sender_config.encoder().has_payload_type());
config->encoder_settings.payload_name = sender_config.encoder().name();
config->encoder_settings.payload_type =
sender_config.encoder().payload_type();
config->codecs.emplace_back(
sender_config.encoder().name(), sender_config.encoder().payload_type(),
sender_config.has_rtx_payload_type() ? sender_config.rtx_payload_type()
: 0);
}
void ParsedRtcEventLog::GetAudioReceiveConfig(

View File

@ -118,9 +118,9 @@ class ParsedRtcEventLog {
// Only the fields that are stored in the protobuf will be written.
void GetVideoReceiveConfig(size_t index, rtclog::StreamConfig* config) const;
// Reads a config event to a (non-NULL) VideoSendStream::Config struct.
// Reads a config event to a (non-NULL) StreamConfig struct.
// Only the fields that are stored in the protobuf will be written.
void GetVideoSendConfig(size_t index, VideoSendStream::Config* config) const;
void GetVideoSendConfig(size_t index, rtclog::StreamConfig* config) const;
// Reads a config event to a (non-NULL) AudioReceiveStream::Config struct.
// Only the fields that are stored in the protobuf will be written.

View File

@ -175,20 +175,16 @@ void GenerateVideoReceiveConfig(uint32_t extensions_bitvector,
}
void GenerateVideoSendConfig(uint32_t extensions_bitvector,
VideoSendStream::Config* config,
rtclog::StreamConfig* config,
Random* prng) {
// Create a map from a payload type to an encoder name.
config->encoder_settings.payload_type = prng->Rand(0, 127);
config->encoder_settings.payload_name = (prng->Rand<bool>() ? "VP8" : "H264");
// Add SSRCs for the stream.
config->rtp.ssrcs.push_back(prng->Rand<uint32_t>());
// Add a map from a payload type to new ssrcs and a new payload type for RTX.
config->rtp.rtx.ssrcs.push_back(prng->Rand<uint32_t>());
config->rtp.rtx.payload_type = prng->Rand(0, 127);
config->codecs.emplace_back(prng->Rand<bool>() ? "VP8" : "H264",
prng->Rand(1, 127), prng->Rand(1, 127));
config->local_ssrc = prng->Rand<uint32_t>();
config->rtx_ssrc = prng->Rand<uint32_t>();
// Add header extensions.
for (unsigned i = 0; i < kNumExtensions; i++) {
if (extensions_bitvector & (1u << i)) {
config->rtp.extensions.push_back(
config->rtp_extensions.push_back(
RtpExtension(kExtensionNames[i], prng->Rand<int>()));
}
}
@ -253,7 +249,7 @@ void LogSessionAndReadBack(size_t rtp_count,
std::vector<std::pair<int32_t, uint8_t> > bwe_loss_updates;
rtclog::StreamConfig receiver_config;
VideoSendStream::Config sender_config(nullptr);
rtclog::StreamConfig sender_config;
Random prng(random_seed);
@ -826,7 +822,7 @@ class VideoReceiveConfigReadWriteTest : public ConfigReadWriteTest {
class VideoSendConfigReadWriteTest : public ConfigReadWriteTest {
public:
VideoSendConfigReadWriteTest() : config(nullptr) {}
VideoSendConfigReadWriteTest() {}
void GenerateConfig(uint32_t extensions_bitvector) override {
GenerateVideoSendConfig(extensions_bitvector, &config, &prng);
}
@ -838,7 +834,7 @@ class VideoSendConfigReadWriteTest : public ConfigReadWriteTest {
RtcEventLogTestHelper::VerifyVideoSendStreamConfig(parsed_log, index,
config);
}
VideoSendStream::Config config;
rtclog::StreamConfig config;
};
class AudioNetworkAdaptationReadWriteTest : public ConfigReadWriteTest {

View File

@ -259,73 +259,41 @@ void RtcEventLogTestHelper::VerifyVideoReceiveStreamConfig(
void RtcEventLogTestHelper::VerifyVideoSendStreamConfig(
const ParsedRtcEventLog& parsed_log,
size_t index,
const VideoSendStream::Config& config) {
const rtclog::StreamConfig& config) {
const rtclog::Event& event = parsed_log.events_[index];
ASSERT_TRUE(IsValidBasicEvent(event));
ASSERT_EQ(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT, event.type());
const rtclog::VideoSendConfig& sender_config = event.video_sender_config();
// Check SSRCs.
ASSERT_EQ(static_cast<int>(config.rtp.ssrcs.size()),
sender_config.ssrcs_size());
for (int i = 0; i < sender_config.ssrcs_size(); i++) {
EXPECT_EQ(config.rtp.ssrcs[i], sender_config.ssrcs(i));
}
EXPECT_EQ(config.local_ssrc, sender_config.ssrcs(0));
EXPECT_EQ(config.rtx_ssrc, sender_config.rtx_ssrcs(0));
// Check header extensions.
ASSERT_EQ(static_cast<int>(config.rtp.extensions.size()),
ASSERT_EQ(static_cast<int>(config.rtp_extensions.size()),
sender_config.header_extensions_size());
for (int i = 0; i < sender_config.header_extensions_size(); i++) {
ASSERT_TRUE(sender_config.header_extensions(i).has_name());
ASSERT_TRUE(sender_config.header_extensions(i).has_id());
const std::string& name = sender_config.header_extensions(i).name();
int id = sender_config.header_extensions(i).id();
EXPECT_EQ(config.rtp.extensions[i].id, id);
EXPECT_EQ(config.rtp.extensions[i].uri, name);
}
// Check RTX settings.
ASSERT_EQ(static_cast<int>(config.rtp.rtx.ssrcs.size()),
sender_config.rtx_ssrcs_size());
for (int i = 0; i < sender_config.rtx_ssrcs_size(); i++) {
EXPECT_EQ(config.rtp.rtx.ssrcs[i], sender_config.rtx_ssrcs(i));
}
if (sender_config.rtx_ssrcs_size() > 0) {
ASSERT_TRUE(sender_config.has_rtx_payload_type());
EXPECT_EQ(config.rtp.rtx.payload_type, sender_config.rtx_payload_type());
EXPECT_EQ(config.rtp_extensions[i].id, id);
EXPECT_EQ(config.rtp_extensions[i].uri, name);
}
// Check encoder.
ASSERT_TRUE(sender_config.has_encoder());
ASSERT_TRUE(sender_config.encoder().has_name());
ASSERT_TRUE(sender_config.encoder().has_payload_type());
EXPECT_EQ(config.encoder_settings.payload_name,
sender_config.encoder().name());
EXPECT_EQ(config.encoder_settings.payload_type,
EXPECT_EQ(config.codecs[0].payload_name, sender_config.encoder().name());
EXPECT_EQ(config.codecs[0].payload_type,
sender_config.encoder().payload_type());
EXPECT_EQ(config.codecs[0].rtx_payload_type,
sender_config.rtx_payload_type());
// Check consistency of the parser.
VideoSendStream::Config parsed_config(nullptr);
rtclog::StreamConfig parsed_config;
parsed_log.GetVideoSendConfig(index, &parsed_config);
// Check SSRCs
EXPECT_EQ(config.rtp.ssrcs.size(), parsed_config.rtp.ssrcs.size());
for (size_t i = 0; i < config.rtp.ssrcs.size(); i++) {
EXPECT_EQ(config.rtp.ssrcs[i], parsed_config.rtp.ssrcs[i]);
}
// Check header extensions.
EXPECT_EQ(config.rtp.extensions.size(), parsed_config.rtp.extensions.size());
for (size_t i = 0; i < parsed_config.rtp.extensions.size(); i++) {
EXPECT_EQ(config.rtp.extensions[i].uri,
parsed_config.rtp.extensions[i].uri);
EXPECT_EQ(config.rtp.extensions[i].id, parsed_config.rtp.extensions[i].id);
}
// Check RTX settings.
EXPECT_EQ(config.rtp.rtx.ssrcs.size(), parsed_config.rtp.rtx.ssrcs.size());
for (size_t i = 0; i < config.rtp.rtx.ssrcs.size(); i++) {
EXPECT_EQ(config.rtp.rtx.ssrcs[i], parsed_config.rtp.rtx.ssrcs[i]);
}
EXPECT_EQ(config.rtp.rtx.payload_type, parsed_config.rtp.rtx.payload_type);
// Check encoder.
EXPECT_EQ(config.encoder_settings.payload_name,
parsed_config.encoder_settings.payload_name);
EXPECT_EQ(config.encoder_settings.payload_type,
parsed_config.encoder_settings.payload_type);
VerifyStreamConfigsAreEqual(config, parsed_config);
}
void RtcEventLogTestHelper::VerifyAudioReceiveStreamConfig(

View File

@ -22,10 +22,9 @@ class RtcEventLogTestHelper {
const ParsedRtcEventLog& parsed_log,
size_t index,
const rtclog::StreamConfig& config);
static void VerifyVideoSendStreamConfig(
const ParsedRtcEventLog& parsed_log,
size_t index,
const VideoSendStream::Config& config);
static void VerifyVideoSendStreamConfig(const ParsedRtcEventLog& parsed_log,
size_t index,
const rtclog::StreamConfig& config);
static void VerifyAudioReceiveStreamConfig(
const ParsedRtcEventLog& parsed_log,
size_t index,

View File

@ -344,20 +344,16 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log)
break;
}
case ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT: {
VideoSendStream::Config config(nullptr);
rtclog::StreamConfig config;
parsed_log_.GetVideoSendConfig(i, &config);
for (auto ssrc : config.rtp.ssrcs) {
StreamId stream(ssrc, kOutgoingPacket);
extension_maps[stream] = RtpHeaderExtensionMap(config.rtp.extensions);
video_ssrcs_.insert(stream);
}
for (auto ssrc : config.rtp.rtx.ssrcs) {
StreamId rtx_stream(ssrc, kOutgoingPacket);
extension_maps[rtx_stream] =
RtpHeaderExtensionMap(config.rtp.extensions);
video_ssrcs_.insert(rtx_stream);
rtx_ssrcs_.insert(rtx_stream);
}
StreamId stream(config.local_ssrc, kOutgoingPacket);
extension_maps[stream] = RtpHeaderExtensionMap(config.rtp_extensions);
video_ssrcs_.insert(stream);
StreamId rtx_stream(config.rtx_ssrc, kOutgoingPacket);
extension_maps[rtx_stream] =
RtpHeaderExtensionMap(config.rtp_extensions);
video_ssrcs_.insert(rtx_stream);
rtx_ssrcs_.insert(rtx_stream);
break;
}
case ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT: {

View File

@ -80,12 +80,8 @@ class RtcEventLogProxy final : public webrtc::RtcEventLog {
RTC_NOTREACHED();
}
void LogVideoSendStreamConfig(
const webrtc::VideoSendStream::Config& config) override {
rtc::CritScope lock(&crit_);
if (event_log_) {
event_log_->LogVideoSendStreamConfig(config);
}
void LogVideoSendStreamConfig(const webrtc::rtclog::StreamConfig&) override {
RTC_NOTREACHED();
}
void LogAudioReceiveStreamConfig(