Remove ViEChannel simulcast lock.
Since the number of streams is now known on construction we can initialize all RTP modules on construction. They are internally locked so we don't nede a simulcast lock anymore. BUG=1695 R=mflodman@webrtc.org, stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/52639004 . Cr-Commit-Position: refs/heads/master@{#9577}
This commit is contained in:
parent
4988ca50df
commit
d6f1a38165
@ -472,10 +472,7 @@ int32_t ModuleRtpRtcpImpl::SetTransportOverhead(
|
||||
}
|
||||
|
||||
int32_t ModuleRtpRtcpImpl::SetMaxTransferUnit(const uint16_t mtu) {
|
||||
if (mtu > IP_PACKET_SIZE) {
|
||||
LOG(LS_ERROR) << "Invalid mtu: " << mtu;
|
||||
return -1;
|
||||
}
|
||||
DCHECK_LE(mtu, IP_PACKET_SIZE) << "Invalid mtu: " << mtu;
|
||||
return rtp_sender_.SetMaxPayloadLength(mtu - packet_overhead_,
|
||||
packet_overhead_);
|
||||
}
|
||||
|
||||
@ -355,10 +355,8 @@ int RTPSender::SendPayloadFrequency() const {
|
||||
int32_t RTPSender::SetMaxPayloadLength(size_t max_payload_length,
|
||||
uint16_t packet_over_head) {
|
||||
// Sanity check.
|
||||
if (max_payload_length < 100 || max_payload_length > IP_PACKET_SIZE) {
|
||||
LOG(LS_ERROR) << "Invalid max payload length: " << max_payload_length;
|
||||
return -1;
|
||||
}
|
||||
DCHECK(max_payload_length >= 100 && max_payload_length <= IP_PACKET_SIZE)
|
||||
<< "Invalid max payload length: " << max_payload_length;
|
||||
CriticalSectionScoped cs(send_critsect_.get());
|
||||
max_payload_length_ = max_payload_length;
|
||||
packet_over_head_ = packet_over_head;
|
||||
@ -504,7 +502,7 @@ int32_t RTPSender::SendOutgoingData(FrameType frame_type,
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t ret_val;
|
||||
int32_t ret_val;
|
||||
if (audio_configured_) {
|
||||
TRACE_EVENT_ASYNC_STEP1("webrtc", "Audio", capture_timestamp,
|
||||
"Send", "type", FrameTypeToString(frame_type));
|
||||
|
||||
@ -125,8 +125,6 @@ TEST_F(RtpRtcpAPITest, Basic) {
|
||||
}
|
||||
|
||||
TEST_F(RtpRtcpAPITest, MTU) {
|
||||
EXPECT_EQ(-1, module_->SetMaxTransferUnit(10));
|
||||
EXPECT_EQ(-1, module_->SetMaxTransferUnit(IP_PACKET_SIZE + 1));
|
||||
EXPECT_EQ(0, module_->SetMaxTransferUnit(1234));
|
||||
EXPECT_EQ(1234 - 20 - 8, module_->MaxPayloadLength());
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@ Call::Call(const Call::Config& config)
|
||||
// TODO(pbos): Remove base channel when CreateReceiveChannel no longer
|
||||
// requires one.
|
||||
CHECK(channel_group_->CreateSendChannel(
|
||||
base_channel_id_, 0, &transport_adapter_, num_cpu_cores_, true));
|
||||
base_channel_id_, 0, &transport_adapter_, num_cpu_cores_, 1, true));
|
||||
|
||||
if (config.overuse_callback) {
|
||||
overuse_observer_proxy_.reset(
|
||||
|
||||
@ -62,7 +62,6 @@ class ReceiveStatisticsProxy : public ViEDecoderObserver,
|
||||
int jitter_buffer_ms,
|
||||
int min_playout_delay_ms,
|
||||
int render_delay_ms) override;
|
||||
void RequestNewKeyFrame(const int video_channel) override {}
|
||||
|
||||
// Overrides RtcpStatisticsCallback.
|
||||
void StatisticsUpdated(const webrtc::RtcpStatistics& statistics,
|
||||
|
||||
@ -119,13 +119,13 @@ VideoSendStream::VideoSendStream(
|
||||
channel_id_(channel_id),
|
||||
use_config_bitrate_(true),
|
||||
stats_proxy_(Clock::GetRealTimeClock(), config) {
|
||||
DCHECK(!config_.rtp.ssrcs.empty());
|
||||
CHECK(channel_group->CreateSendChannel(channel_id_, 0, &transport_adapter_,
|
||||
num_cpu_cores, true));
|
||||
num_cpu_cores,
|
||||
config_.rtp.ssrcs.size(), true));
|
||||
vie_channel_ = channel_group_->GetChannel(channel_id_);
|
||||
vie_encoder_ = channel_group_->GetEncoder(channel_id_);
|
||||
|
||||
DCHECK(!config_.rtp.ssrcs.empty());
|
||||
|
||||
for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) {
|
||||
const std::string& extension = config_.rtp.extensions[i].name;
|
||||
int id = config_.rtp.extensions[i].id;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -83,10 +83,6 @@ class ViEDecoderObserver {
|
||||
int min_playout_delay_ms,
|
||||
int render_delay_ms) = 0;
|
||||
|
||||
// This method is called when the decoder needs a new key frame from encoder
|
||||
// on the sender.
|
||||
virtual void RequestNewKeyFrame(const int video_channel) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~ViEDecoderObserver() {}
|
||||
};
|
||||
@ -105,13 +101,14 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
uint32_t number_of_cores,
|
||||
const Config& config,
|
||||
Transport* transport,
|
||||
ProcessThread& module_process_thread,
|
||||
ProcessThread* module_process_thread,
|
||||
RtcpIntraFrameObserver* intra_frame_observer,
|
||||
RtcpBandwidthObserver* bandwidth_observer,
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator,
|
||||
RtcpRttStats* rtt_stats,
|
||||
PacedSender* paced_sender,
|
||||
PacketRouter* packet_router,
|
||||
size_t max_rtp_streams,
|
||||
bool sender,
|
||||
bool disable_default_encoder);
|
||||
~ViEChannel();
|
||||
@ -139,9 +136,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
// Returns the estimated delay in milliseconds.
|
||||
int ReceiveDelay() const;
|
||||
|
||||
// Only affects calls to SetReceiveCodec done after this call.
|
||||
int32_t WaitForKeyFrame(bool wait);
|
||||
|
||||
// If enabled, a key frame request will be sent as soon as there are lost
|
||||
// packets. If |only_key_frames| are set, requests are only sent for loss in
|
||||
// key frames.
|
||||
@ -169,7 +163,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
void SetRtcpXrRrtrStatus(bool enable);
|
||||
void SetTransmissionSmoothingStatus(bool enable);
|
||||
void EnableTMMBR(bool enable);
|
||||
int32_t EnableKeyFrameRequestCallback(const bool enable);
|
||||
|
||||
// Sets SSRC for outgoing stream.
|
||||
int32_t SetSSRC(const uint32_t SSRC,
|
||||
@ -185,9 +178,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
int SetRtxSendPayloadType(int payload_type, int associated_payload_type);
|
||||
void SetRtxReceivePayloadType(int payload_type, int associated_payload_type);
|
||||
|
||||
// Sets the starting sequence number, must be called before StartSend.
|
||||
int32_t SetStartSequenceNumber(uint16_t sequence_number);
|
||||
|
||||
void SetRtpStateForSsrc(uint32_t ssrc, const RtpState& rtp_state);
|
||||
RtpState GetRtpStateForSsrc(uint32_t ssrc);
|
||||
|
||||
@ -196,11 +186,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
|
||||
// Gets the CName of the incoming stream.
|
||||
int32_t GetRemoteRTCPCName(char rtcp_cname[]);
|
||||
int32_t SendApplicationDefinedRTCPPacket(
|
||||
const uint8_t sub_type,
|
||||
uint32_t name,
|
||||
const uint8_t* data,
|
||||
uint16_t data_length_in_bytes);
|
||||
|
||||
// Returns statistics reported by the remote client in an RTCP packet.
|
||||
// TODO(pbos): Remove this along with VideoSendStream::GetRtt().
|
||||
@ -277,12 +262,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
// IP, UDP and RTP headers.
|
||||
int32_t SetMTU(uint16_t mtu);
|
||||
|
||||
// Returns maximum allowed payload size, i.e. the maximum allowed size of
|
||||
// encoded data in each packet.
|
||||
uint16_t MaxDataPayloadLength() const;
|
||||
int32_t SetMaxPacketBurstSize(uint16_t max_number_of_packets);
|
||||
int32_t SetPacketBurstSpreadState(bool enable, const uint16_t frame_periodMS);
|
||||
|
||||
// Gets the modules used by the channel.
|
||||
RtpRtcp* rtp_rtcp();
|
||||
rtc::scoped_refptr<PayloadRouter> send_payload_router();
|
||||
@ -323,8 +302,8 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
const uint64_t picture_id);
|
||||
|
||||
// Implements VideoPacketRequestCallback.
|
||||
virtual int32_t ResendPackets(const uint16_t* sequence_numbers,
|
||||
uint16_t length);
|
||||
int32_t ResendPackets(const uint16_t* sequence_numbers,
|
||||
uint16_t length) override;
|
||||
|
||||
int32_t SetVoiceChannel(int32_t ve_channel_id,
|
||||
VoEVideoSync* ve_sync_interface);
|
||||
@ -355,12 +334,22 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
uint32_t* sent_fec_rate_bps);
|
||||
|
||||
private:
|
||||
void ReserveRtpRtcpModules(size_t total_modules)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(rtp_rtcp_cs_);
|
||||
RtpRtcp* GetRtpRtcpModule(size_t simulcast_idx) const
|
||||
EXCLUSIVE_LOCKS_REQUIRED(rtp_rtcp_cs_);
|
||||
RtpRtcp::Configuration CreateRtpRtcpConfiguration();
|
||||
RtpRtcp* CreateRtpRtcpModule();
|
||||
static std::vector<RtpRtcp*> CreateRtpRtcpModules(
|
||||
int32_t id,
|
||||
bool receiver_only,
|
||||
ReceiveStatistics* receive_statistics,
|
||||
Transport* outgoing_transport,
|
||||
RtcpIntraFrameObserver* intra_frame_callback,
|
||||
RtcpBandwidthObserver* bandwidth_callback,
|
||||
RtcpRttStats* rtt_stats,
|
||||
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator,
|
||||
PacedSender* paced_sender,
|
||||
BitrateStatisticsObserver* send_bitrate_observer,
|
||||
FrameCountObserver* send_frame_count_observer,
|
||||
SendSideDelayObserver* send_side_delay_observer,
|
||||
size_t num_modules);
|
||||
|
||||
// Assumed to be protected.
|
||||
void StartDecodeThread();
|
||||
void StopDecodeThread();
|
||||
@ -461,19 +450,17 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
GUARDED_BY(critsect_);
|
||||
} rtcp_packet_type_counter_observer_;
|
||||
|
||||
int32_t channel_id_;
|
||||
int32_t engine_id_;
|
||||
uint32_t number_of_cores_;
|
||||
uint8_t num_socket_threads_;
|
||||
const int32_t channel_id_;
|
||||
const int32_t engine_id_;
|
||||
const uint32_t number_of_cores_;
|
||||
const bool sender_;
|
||||
|
||||
ProcessThread* const module_process_thread_;
|
||||
|
||||
// Used for all registered callbacks except rendering.
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> callback_cs_;
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> rtp_rtcp_cs_;
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> crit_;
|
||||
|
||||
// Owned modules/classes.
|
||||
rtc::scoped_ptr<RtpRtcp> rtp_rtcp_;
|
||||
std::list<RtpRtcp*> simulcast_rtp_rtcp_;
|
||||
std::list<RtpRtcp*> removed_rtp_rtcp_;
|
||||
rtc::scoped_refptr<PayloadRouter> send_payload_router_;
|
||||
rtc::scoped_ptr<ViEChannelProtectionCallback> vcm_protection_callback_;
|
||||
|
||||
@ -486,41 +473,34 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
|
||||
// Not owned.
|
||||
VCMReceiveStatisticsCallback* vcm_receive_stats_callback_
|
||||
GUARDED_BY(callback_cs_);
|
||||
FrameCounts receive_frame_counts_ GUARDED_BY(callback_cs_);
|
||||
IncomingVideoStream* incoming_video_stream_ GUARDED_BY(callback_cs_);
|
||||
ProcessThread& module_process_thread_;
|
||||
ViEDecoderObserver* codec_observer_;
|
||||
bool do_key_frame_callbackRequest_;
|
||||
RtcpIntraFrameObserver* intra_frame_observer_;
|
||||
RtcpRttStats* rtt_stats_;
|
||||
PacedSender* paced_sender_;
|
||||
PacketRouter* packet_router_;
|
||||
GUARDED_BY(crit_);
|
||||
FrameCounts receive_frame_counts_ GUARDED_BY(crit_);
|
||||
IncomingVideoStream* incoming_video_stream_ GUARDED_BY(crit_);
|
||||
ViEDecoderObserver* codec_observer_ GUARDED_BY(crit_);
|
||||
RtcpIntraFrameObserver* const intra_frame_observer_;
|
||||
RtcpRttStats* const rtt_stats_;
|
||||
PacedSender* const paced_sender_;
|
||||
PacketRouter* const packet_router_;
|
||||
|
||||
rtc::scoped_ptr<RtcpBandwidthObserver> bandwidth_observer_;
|
||||
int send_timestamp_extension_id_;
|
||||
int absolute_send_time_extension_id_;
|
||||
int video_rotation_extension_id_;
|
||||
const rtc::scoped_ptr<RtcpBandwidthObserver> bandwidth_observer_;
|
||||
|
||||
Transport* const transport_;
|
||||
|
||||
bool decoder_reset_;
|
||||
bool decoder_reset_ GUARDED_BY(crit_);
|
||||
// Current receive codec used for codec change callback.
|
||||
VideoCodec receive_codec_;
|
||||
bool wait_for_key_frame_;
|
||||
VideoCodec receive_codec_ GUARDED_BY(crit_);
|
||||
rtc::scoped_ptr<ThreadWrapper> decode_thread_;
|
||||
|
||||
// User set MTU, -1 if not set.
|
||||
uint16_t mtu_;
|
||||
const bool sender_;
|
||||
// Used to skip default encoder in the new API.
|
||||
const bool disable_default_encoder_;
|
||||
|
||||
int nack_history_size_sender_;
|
||||
int max_nack_reordering_threshold_;
|
||||
I420FrameCallback* pre_render_callback_;
|
||||
I420FrameCallback* pre_render_callback_ GUARDED_BY(crit_);
|
||||
|
||||
rtc::scoped_ptr<ReportBlockStats> report_block_stats_sender_;
|
||||
const rtc::scoped_ptr<ReportBlockStats> report_block_stats_sender_;
|
||||
|
||||
// RtpRtcp modules, declared last as they use other members on construction.
|
||||
const std::vector<RtpRtcp*> rtp_rtcp_modules_;
|
||||
size_t num_active_rtp_rtcp_modules_ GUARDED_BY(crit_);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -193,7 +193,9 @@ bool ChannelGroup::CreateSendChannel(int channel_id,
|
||||
int engine_id,
|
||||
Transport* transport,
|
||||
int number_of_cores,
|
||||
size_t max_rtp_streams,
|
||||
bool disable_default_encoder) {
|
||||
DCHECK_GT(max_rtp_streams, 0u);
|
||||
rtc::scoped_ptr<ViEEncoder> vie_encoder(
|
||||
new ViEEncoder(channel_id, number_of_cores, *config_.get(),
|
||||
*process_thread_, pacer_.get(), bitrate_allocator_.get(),
|
||||
@ -203,7 +205,8 @@ bool ChannelGroup::CreateSendChannel(int channel_id,
|
||||
}
|
||||
ViEEncoder* encoder = vie_encoder.get();
|
||||
if (!CreateChannel(channel_id, engine_id, transport, number_of_cores,
|
||||
vie_encoder.release(), true, disable_default_encoder)) {
|
||||
vie_encoder.release(), max_rtp_streams, true,
|
||||
disable_default_encoder)) {
|
||||
return false;
|
||||
}
|
||||
ViEChannel* channel = channel_map_[channel_id];
|
||||
@ -230,7 +233,7 @@ bool ChannelGroup::CreateReceiveChannel(int channel_id,
|
||||
bool disable_default_encoder) {
|
||||
ViEEncoder* encoder = GetEncoder(base_channel_id);
|
||||
return CreateChannel(channel_id, engine_id, transport, number_of_cores,
|
||||
encoder, false, disable_default_encoder);
|
||||
encoder, 1, false, disable_default_encoder);
|
||||
}
|
||||
|
||||
bool ChannelGroup::CreateChannel(int channel_id,
|
||||
@ -238,16 +241,18 @@ bool ChannelGroup::CreateChannel(int channel_id,
|
||||
Transport* transport,
|
||||
int number_of_cores,
|
||||
ViEEncoder* vie_encoder,
|
||||
size_t max_rtp_streams,
|
||||
bool sender,
|
||||
bool disable_default_encoder) {
|
||||
DCHECK(vie_encoder);
|
||||
|
||||
rtc::scoped_ptr<ViEChannel> channel(new ViEChannel(
|
||||
channel_id, engine_id, number_of_cores, *config_.get(), transport,
|
||||
*process_thread_, encoder_state_feedback_->GetRtcpIntraFrameObserver(),
|
||||
process_thread_, encoder_state_feedback_->GetRtcpIntraFrameObserver(),
|
||||
bitrate_controller_->CreateRtcpBandwidthObserver(),
|
||||
remote_bitrate_estimator_.get(), call_stats_->rtcp_rtt_stats(),
|
||||
pacer_.get(), packet_router_.get(), sender, disable_default_encoder));
|
||||
pacer_.get(), packet_router_.get(), max_rtp_streams, sender,
|
||||
disable_default_encoder));
|
||||
if (channel->Init() != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -46,6 +46,7 @@ class ChannelGroup : public BitrateObserver {
|
||||
int engine_id,
|
||||
Transport* transport,
|
||||
int number_of_cores,
|
||||
size_t max_rtp_streams,
|
||||
bool disable_default_encoder);
|
||||
bool CreateReceiveChannel(int channel_id,
|
||||
int engine_id,
|
||||
@ -89,6 +90,7 @@ class ChannelGroup : public BitrateObserver {
|
||||
Transport* transport,
|
||||
int number_of_cores,
|
||||
ViEEncoder* vie_encoder,
|
||||
size_t max_rtp_streams,
|
||||
bool sender,
|
||||
bool disable_default_encoder);
|
||||
ViEChannel* PopChannel(int channel_id);
|
||||
|
||||
@ -147,16 +147,14 @@ RtpReceiver* ViEReceiver::GetRtpReceiver() const {
|
||||
return rtp_receiver_.get();
|
||||
}
|
||||
|
||||
void ViEReceiver::RegisterSimulcastRtpRtcpModules(
|
||||
const std::list<RtpRtcp*>& rtp_modules) {
|
||||
void ViEReceiver::RegisterRtpRtcpModules(
|
||||
const std::vector<RtpRtcp*>& rtp_modules) {
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
rtp_rtcp_simulcast_.clear();
|
||||
|
||||
if (!rtp_modules.empty()) {
|
||||
rtp_rtcp_simulcast_.insert(rtp_rtcp_simulcast_.begin(),
|
||||
rtp_modules.begin(),
|
||||
rtp_modules.end());
|
||||
}
|
||||
// Only change the "simulcast" modules, the base module can be accessed
|
||||
// without a lock whereas the simulcast modules require locking as they can be
|
||||
// changed in runtime.
|
||||
rtp_rtcp_simulcast_ =
|
||||
std::vector<RtpRtcp*>(rtp_modules.begin() + 1, rtp_modules.end());
|
||||
}
|
||||
|
||||
bool ViEReceiver::SetReceiveTimestampOffsetStatus(bool enable, int id) {
|
||||
@ -398,11 +396,8 @@ int ViEReceiver::InsertRTCPPacket(const uint8_t* rtcp_packet,
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::list<RtpRtcp*>::iterator it = rtp_rtcp_simulcast_.begin();
|
||||
while (it != rtp_rtcp_simulcast_.end()) {
|
||||
RtpRtcp* rtp_rtcp = *it++;
|
||||
for (RtpRtcp* rtp_rtcp : rtp_rtcp_simulcast_)
|
||||
rtp_rtcp->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
|
||||
}
|
||||
}
|
||||
assert(rtp_rtcp_); // Should be set by owner at construction time.
|
||||
int ret = rtp_rtcp_->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
|
||||
|
||||
@ -58,7 +58,7 @@ class ViEReceiver : public RtpData {
|
||||
|
||||
RtpReceiver* GetRtpReceiver() const;
|
||||
|
||||
void RegisterSimulcastRtpRtcpModules(const std::list<RtpRtcp*>& rtp_modules);
|
||||
void RegisterRtpRtcpModules(const std::vector<RtpRtcp*>& rtp_modules);
|
||||
|
||||
bool SetReceiveTimestampOffsetStatus(bool enable, int id);
|
||||
bool SetReceiveAbsoluteSendTimeStatus(bool enable, int id);
|
||||
@ -102,10 +102,10 @@ class ViEReceiver : public RtpData {
|
||||
rtc::scoped_ptr<RtpHeaderParser> rtp_header_parser_;
|
||||
rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_;
|
||||
rtc::scoped_ptr<RtpReceiver> rtp_receiver_;
|
||||
rtc::scoped_ptr<ReceiveStatistics> rtp_receive_statistics_;
|
||||
const rtc::scoped_ptr<ReceiveStatistics> rtp_receive_statistics_;
|
||||
rtc::scoped_ptr<FecReceiver> fec_receiver_;
|
||||
RtpRtcp* rtp_rtcp_;
|
||||
std::list<RtpRtcp*> rtp_rtcp_simulcast_;
|
||||
std::vector<RtpRtcp*> rtp_rtcp_simulcast_;
|
||||
VideoCodingModule* vcm_;
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator_;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user