Remove decoder-thread instantiation for senders.

Reduces number of running (high-priority) threads, even though the
thread was practically blocked all the time.

Also adding DCHECKs to make sure we're not trying to use certain
sender-only methods on receivers and vice versa.

BUG=webrtc:1675, webrtc:1695
R=stefan@webrtc.org

Review URL: https://codereview.webrtc.org/1222193003

Cr-Commit-Position: refs/heads/master@{#9534}
This commit is contained in:
pbos 2015-07-02 06:32:17 -07:00 committed by Commit bot
parent db0cf7624e
commit cd4a9bd225
2 changed files with 23 additions and 31 deletions

View File

@ -347,9 +347,7 @@ void ViEChannel::UpdateHistogramsAtStopSend() {
int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
bool new_stream) {
if (!sender_) {
return 0;
}
DCHECK(sender_);
if (video_codec.codecType == kVideoCodecRED ||
video_codec.codecType == kVideoCodecULPFEC) {
LOG_F(LS_ERROR) << "Not a valid send codec " << video_codec.codecType;
@ -571,6 +569,7 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
}
int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) {
DCHECK(!sender_);
if (!vie_receiver_.SetReceiveCodec(video_codec)) {
return -1;
}
@ -604,6 +603,7 @@ int32_t ViEChannel::RegisterExternalDecoder(const uint8_t pl_type,
VideoDecoder* decoder,
bool buffered_rendering,
int32_t render_delay) {
DCHECK(!sender_);
int32_t result;
result = vcm_->RegisterExternalDecoder(decoder, pl_type, buffered_rendering);
if (result != VCM_OK) {
@ -613,6 +613,7 @@ int32_t ViEChannel::RegisterExternalDecoder(const uint8_t pl_type,
}
int32_t ViEChannel::DeRegisterExternalDecoder(const uint8_t pl_type) {
DCHECK(!sender_);
VideoCodec current_receive_codec;
int32_t result = 0;
result = vcm_->ReceiveCodec(&current_receive_codec);
@ -1368,20 +1369,18 @@ bool ViEChannel::Sending() {
return rtp_rtcp_->Sending();
}
int32_t ViEChannel::StartReceive() {
if (StartDecodeThread() != 0) {
vie_receiver_.StopReceive();
return -1;
}
void ViEChannel::StartReceive() {
if (!sender_)
StartDecodeThread();
vie_receiver_.StartReceive();
return 0;
}
int32_t ViEChannel::StopReceive() {
void ViEChannel::StopReceive() {
vie_receiver_.StopReceive();
StopDecodeThread();
vcm_->ResetDecoder();
return 0;
if (!sender_) {
StopDecodeThread();
vcm_->ResetDecoder();
}
}
int32_t ViEChannel::ReceivedRTPPacket(const void* rtp_packet,
@ -1530,8 +1529,6 @@ bool ViEChannel::ChannelDecodeThreadFunction(void* obj) {
}
bool ViEChannel::ChannelDecodeProcess() {
// TODO(pbos): Make sure the decoder thread doesn't run for send-only
// channels.
vcm_->Decode(kMaxDecodeWaitTimeMs);
return true;
}
@ -1628,30 +1625,25 @@ RtpRtcp* ViEChannel::CreateRtpRtcpModule() {
return RtpRtcp::CreateRtpRtcp(CreateRtpRtcpConfiguration());
}
int32_t ViEChannel::StartDecodeThread() {
void ViEChannel::StartDecodeThread() {
DCHECK(!sender_);
// Start the decode thread
if (decode_thread_) {
// Already started.
return 0;
}
if (decode_thread_)
return;
decode_thread_ = ThreadWrapper::CreateThread(ChannelDecodeThreadFunction,
this, "DecodingThread");
decode_thread_->Start();
decode_thread_->SetPriority(kHighestPriority);
return 0;
}
int32_t ViEChannel::StopDecodeThread() {
if (!decode_thread_) {
return 0;
}
void ViEChannel::StopDecodeThread() {
if (!decode_thread_)
return;
vcm_->TriggerDecoderShutdown();
decode_thread_->Stop();
decode_thread_.reset();
return 0;
}
int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id,

View File

@ -265,8 +265,8 @@ class ViEChannel : public VCMFrameTypeCallback,
int32_t StartSend();
int32_t StopSend();
bool Sending();
int32_t StartReceive();
int32_t StopReceive();
void StartReceive();
void StopReceive();
int32_t ReceivedRTPPacket(const void* rtp_packet,
const size_t rtp_packet_length,
@ -363,8 +363,8 @@ class ViEChannel : public VCMFrameTypeCallback,
RtpRtcp::Configuration CreateRtpRtcpConfiguration();
RtpRtcp* CreateRtpRtcpModule();
// Assumed to be protected.
int32_t StartDecodeThread();
int32_t StopDecodeThread();
void StartDecodeThread();
void StopDecodeThread();
int32_t ProcessNACKRequest(const bool enable);
int32_t ProcessFECRequest(const bool enable,