Piping AutoMuter interface through to ViE API

This is a piece of the AutoMuter effort. A second CL will follow containing modifications to the new API, and tests.

BUG=2436
R=mflodman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2331004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4899 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2013-10-02 13:34:26 +00:00
parent 8469f7b328
commit 7ea4f24ea5
7 changed files with 63 additions and 2 deletions

View File

@ -35,6 +35,12 @@ class WEBRTC_DLLEXPORT ViEEncoderObserver {
virtual void OutgoingRate(const int video_channel,
const unsigned int framerate,
const unsigned int bitrate) = 0;
// This method is called whenever the state of the AutoMuter changes, i.e.,
// when |is_muted| toggles.
// TODO(hlundin): Remove the default implementation when possible.
virtual void VideoAutoMuted(bool is_muted) {};
protected:
virtual ~ViEEncoderObserver() {}
};
@ -177,6 +183,13 @@ class WEBRTC_DLLEXPORT ViECodec {
// Disables recording of debugging information.
virtual int StopDebugRecording(int video_channel) = 0;
// Enables AutoMuter to turn off video when the rate drops below
// |threshold_bps|, and turns back on when the rate goes back up above
// |threshold_bps| + |window_bps|.
// This is under development; not tested.
virtual void EnableAutoMuting(int video_channel, int threshold_bps,
int window_bps) = 0;
protected:
ViECodec() {}
virtual ~ViECodec() {}

View File

@ -44,6 +44,7 @@ class TestCodecObserver
unsigned int last_outgoing_bitrate_;
unsigned int last_incoming_framerate_;
unsigned int last_incoming_bitrate_;
unsigned int video_auto_muted_called_;
webrtc::VideoCodec incoming_codec_;
@ -57,7 +58,8 @@ class TestCodecObserver
last_outgoing_framerate_(0),
last_outgoing_bitrate_(0),
last_incoming_framerate_(0),
last_incoming_bitrate_(0) {
last_incoming_bitrate_(0),
video_auto_muted_called_(0) {
memset(&incoming_codec_, 0, sizeof(incoming_codec_));
}
virtual void IncomingCodecChanged(const int video_channel,
@ -86,6 +88,10 @@ class TestCodecObserver
last_outgoing_bitrate_ += bitrate;
}
virtual void VideoAutoMuted(bool is_muted) {
video_auto_muted_called_++;
}
virtual void RequestNewKeyFrame(const int video_channel) {
}
};

View File

@ -72,6 +72,10 @@ class ViEAutotestEncoderObserver : public webrtc::ViEEncoderObserver {
std::cout << "Send FR: " << framerate
<< " BR: " << bitrate << std::endl;
}
virtual void VideoAutoMuted(bool is_muted) {
std::cout << "VideoAutoMuted: " << is_muted << std::endl;
}
};
class ViEAutotestDecoderObserver : public webrtc::ViEDecoderObserver {

View File

@ -715,6 +715,19 @@ int ViECodecImpl::StopDebugRecording(int video_channel) {
return vie_encoder->StopDebugRecording();
}
void ViECodecImpl::EnableAutoMuting(int video_channel, int threshold_bps,
int window_bps) {
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No encoder %d", __FUNCTION__, video_channel);
return;
}
return vie_encoder->EnableAutoMuting(threshold_bps, window_bps);
}
bool ViECodecImpl::CodecValid(const VideoCodec& video_codec) {
// Check pl_name matches codec_type.
if (video_codec.codecType == kVideoCodecRED) {

View File

@ -70,6 +70,8 @@ class ViECodecImpl
virtual int StartDebugRecording(int video_channel,
const char* file_name_utf8);
virtual int StopDebugRecording(int video_channel);
virtual void EnableAutoMuting(int video_channel, int threshold_bps,
int window_bps);
protected:
explicit ViECodecImpl(ViESharedData* shared_data);

View File

@ -158,7 +158,8 @@ ViEEncoder::ViEEncoder(int32_t engine_id,
picture_id_sli_(0),
has_received_rpsi_(false),
picture_id_rpsi_(0),
qm_callback_(NULL) {
qm_callback_(NULL),
video_auto_muted_(false) {
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo,
ViEId(engine_id, channel_id),
"%s(engine_id: %d) 0x%p - Constructor", __FUNCTION__, engine_id,
@ -1034,6 +1035,7 @@ void ViEEncoder::OnNetworkChanged(const uint32_t bitrate_bps,
__FUNCTION__, bitrate_bps, fraction_lost, round_trip_time_ms);
vcm_.SetChannelParameters(bitrate_bps, fraction_lost, round_trip_time_ms);
bool video_is_muted = vcm_.VideoMuted();
int bitrate_kbps = bitrate_bps / 1000;
VideoCodec send_codec;
if (vcm_.SendCodec(&send_codec) != 0) {
@ -1069,6 +1071,17 @@ void ViEEncoder::OnNetworkChanged(const uint32_t bitrate_bps,
max_padding_bitrate_kbps,
pad_up_to_bitrate_kbps);
default_rtp_rtcp_->SetTargetSendBitrate(stream_bitrates);
if (video_is_muted != video_auto_muted_) {
// State changed now. Send callback to inform about that.
video_auto_muted_ = video_is_muted;
if (codec_observer_) {
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo,
ViEId(engine_id_, channel_id_),
"%s: video_auto_muted_ changed to %i",
__FUNCTION__, video_auto_muted_);
codec_observer_->VideoAutoMuted(video_auto_muted_);
}
}
}
PacedSender* ViEEncoder::GetPacedSender() {
@ -1110,6 +1123,10 @@ int ViEEncoder::StopDebugRecording() {
return vcm_.StopDebugRecording();
}
void ViEEncoder::EnableAutoMuting(int threshold_bps, int window_bps) {
vcm_.EnableAutoMuting(threshold_bps, window_bps);
}
QMVideoSettingsCallback::QMVideoSettingsCallback(VideoProcessingModule* vpm)
: vpm_(vpm) {
}

View File

@ -162,6 +162,11 @@ class ViEEncoder
// Disables recording of debugging information.
virtual int StopDebugRecording();
// Enables AutoMuter to turn off video when the rate drops below
// |threshold_bps|, and turns back on when the rate goes back up above
// |threshold_bps| + |window_bps|.
virtual void EnableAutoMuting(int threshold_bps, int window_bps);
int channel_id() const { return channel_id_; }
protected:
// Called by BitrateObserver.
@ -216,6 +221,7 @@ class ViEEncoder
// Quality modes callback
QMVideoSettingsCallback* qm_callback_;
bool video_auto_muted_;
};
} // namespace webrtc