Use std::vector in the PayloadRouter interface.
Prevents copying a vector to a list that gets copied back to a vector, which makes calling code a bit easier. BUG=webrtc:5494 R=danilchap@webrtc.org Review URL: https://codereview.webrtc.org/1686323003 . Cr-Commit-Position: refs/heads/master@{#11589}
This commit is contained in:
parent
8fb3557052
commit
404686a337
@ -27,13 +27,9 @@ size_t PayloadRouter::DefaultMaxPayloadLength() {
|
||||
}
|
||||
|
||||
void PayloadRouter::SetSendingRtpModules(
|
||||
const std::list<RtpRtcp*>& rtp_modules) {
|
||||
const std::vector<RtpRtcp*>& rtp_modules) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
rtp_modules_.clear();
|
||||
rtp_modules_.reserve(rtp_modules.size());
|
||||
for (auto* rtp_module : rtp_modules) {
|
||||
rtp_modules_.push_back(rtp_module);
|
||||
}
|
||||
rtp_modules_ = rtp_modules;
|
||||
}
|
||||
|
||||
void PayloadRouter::set_active(bool active) {
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#ifndef WEBRTC_VIDEO_PAYLOAD_ROUTER_H_
|
||||
#define WEBRTC_VIDEO_PAYLOAD_ROUTER_H_
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
@ -37,7 +36,7 @@ class PayloadRouter {
|
||||
static size_t DefaultMaxPayloadLength();
|
||||
|
||||
// Rtp modules are assumed to be sorted in simulcast index order.
|
||||
void SetSendingRtpModules(const std::list<RtpRtcp*>& rtp_modules);
|
||||
void SetSendingRtpModules(const std::vector<RtpRtcp*>& rtp_modules);
|
||||
|
||||
// PayloadRouter will only route packets if being active, all packets will be
|
||||
// dropped otherwise.
|
||||
|
||||
@ -8,9 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
@ -35,7 +32,7 @@ class PayloadRouterTest : public ::testing::Test {
|
||||
|
||||
TEST_F(PayloadRouterTest, SendOnOneModule) {
|
||||
MockRtpRtcp rtp;
|
||||
std::list<RtpRtcp*> modules(1, &rtp);
|
||||
std::vector<RtpRtcp*> modules(1, &rtp);
|
||||
|
||||
payload_router_->SetSendingRtpModules(modules);
|
||||
|
||||
@ -82,7 +79,7 @@ TEST_F(PayloadRouterTest, SendOnOneModule) {
|
||||
TEST_F(PayloadRouterTest, SendSimulcast) {
|
||||
MockRtpRtcp rtp_1;
|
||||
MockRtpRtcp rtp_2;
|
||||
std::list<RtpRtcp*> modules;
|
||||
std::vector<RtpRtcp*> modules;
|
||||
modules.push_back(&rtp_1);
|
||||
modules.push_back(&rtp_2);
|
||||
|
||||
@ -147,7 +144,7 @@ TEST_F(PayloadRouterTest, MaxPayloadLength) {
|
||||
|
||||
MockRtpRtcp rtp_1;
|
||||
MockRtpRtcp rtp_2;
|
||||
std::list<RtpRtcp*> modules;
|
||||
std::vector<RtpRtcp*> modules;
|
||||
modules.push_back(&rtp_1);
|
||||
modules.push_back(&rtp_2);
|
||||
payload_router_->SetSendingRtpModules(modules);
|
||||
@ -175,7 +172,7 @@ TEST_F(PayloadRouterTest, MaxPayloadLength) {
|
||||
TEST_F(PayloadRouterTest, SetTargetSendBitrates) {
|
||||
MockRtpRtcp rtp_1;
|
||||
MockRtpRtcp rtp_2;
|
||||
std::list<RtpRtcp*> modules;
|
||||
std::vector<RtpRtcp*> modules;
|
||||
modules.push_back(&rtp_1);
|
||||
modules.push_back(&rtp_2);
|
||||
payload_router_->SetSendingRtpModules(modules);
|
||||
|
||||
@ -155,8 +155,8 @@ int32_t ViEChannel::Init() {
|
||||
}
|
||||
packet_router_->AddRtpModule(rtp_rtcp_modules_[0], sender_);
|
||||
if (sender_) {
|
||||
std::list<RtpRtcp*> send_rtp_modules(1, rtp_rtcp_modules_[0]);
|
||||
send_payload_router_->SetSendingRtpModules(send_rtp_modules);
|
||||
send_payload_router_->SetSendingRtpModules(
|
||||
std::vector<RtpRtcp*>(1, rtp_rtcp_modules_[0]));
|
||||
RTC_DCHECK(!send_payload_router_->active());
|
||||
} else {
|
||||
if (vcm_->RegisterReceiveCallback(this) != 0) {
|
||||
@ -177,7 +177,7 @@ ViEChannel::~ViEChannel() {
|
||||
module_process_thread_->DeRegisterModule(
|
||||
vie_receiver_.GetReceiveStatistics());
|
||||
if (sender_) {
|
||||
send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>());
|
||||
send_payload_router_->SetSendingRtpModules(std::vector<RtpRtcp*>());
|
||||
} else {
|
||||
module_process_thread_->DeRegisterModule(&vie_sync_);
|
||||
}
|
||||
@ -345,7 +345,7 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
|
||||
bool is_sending = rtp_rtcp_modules_[0]->Sending();
|
||||
bool router_was_active = send_payload_router_->active();
|
||||
send_payload_router_->set_active(false);
|
||||
send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>());
|
||||
send_payload_router_->SetSendingRtpModules(std::vector<RtpRtcp*>());
|
||||
|
||||
std::vector<RtpRtcp*> registered_modules;
|
||||
std::vector<RtpRtcp*> deregistered_modules;
|
||||
@ -386,12 +386,7 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
|
||||
vie_receiver_.RegisterRtpRtcpModules(registered_modules);
|
||||
|
||||
// Update the packet and payload routers with the sending RtpRtcp modules.
|
||||
if (sender_) {
|
||||
std::list<RtpRtcp*> active_send_modules;
|
||||
for (RtpRtcp* rtp_rtcp : registered_modules)
|
||||
active_send_modules.push_back(rtp_rtcp);
|
||||
send_payload_router_->SetSendingRtpModules(active_send_modules);
|
||||
}
|
||||
send_payload_router_->SetSendingRtpModules(registered_modules);
|
||||
|
||||
if (router_was_active)
|
||||
send_payload_router_->set_active(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user