Refactor registerable callbacks for FrameCountObserver from rtp_rtcp module into vie_channel.

R=stefan@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6649 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andresp@webrtc.org 2014-07-10 09:39:23 +00:00
parent 5bde66e913
commit 8f1512140e
8 changed files with 34 additions and 56 deletions

View File

@ -68,6 +68,7 @@ class RtpRtcp : public Module {
RemoteBitrateEstimator* remote_bitrate_estimator;
PacedSender* paced_sender;
BitrateStatisticsObserver* send_bitrate_observer;
FrameCountObserver* send_frame_count_observer;
};
/*
@ -340,10 +341,6 @@ class RtpRtcp : public Module {
virtual int TimeToSendPadding(int bytes) = 0;
virtual void RegisterSendFrameCountObserver(
FrameCountObserver* observer) = 0;
virtual FrameCountObserver* GetSendFrameCountObserver() const = 0;
virtual bool GetSendSideDelay(int* avg_send_delay_ms,
int* max_send_delay_ms) const = 0;

View File

@ -38,7 +38,8 @@ RtpRtcp::Configuration::Configuration()
audio_messages(NullObjectRtpAudioFeedback()),
remote_bitrate_estimator(NULL),
paced_sender(NULL),
send_bitrate_observer(NULL) {
send_bitrate_observer(NULL),
send_frame_count_observer(NULL) {
}
RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) {
@ -62,7 +63,8 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
configuration.outgoing_transport,
configuration.audio_messages,
configuration.paced_sender,
configuration.send_bitrate_observer),
configuration.send_bitrate_observer,
configuration.send_frame_count_observer),
rtcp_sender_(configuration.id,
configuration.audio,
configuration.clock,
@ -1350,15 +1352,6 @@ StreamDataCountersCallback*
return rtp_sender_.GetRtpStatisticsCallback();
}
void ModuleRtpRtcpImpl::RegisterSendFrameCountObserver(
FrameCountObserver* observer) {
rtp_sender_.RegisterFrameCountObserver(observer);
}
FrameCountObserver* ModuleRtpRtcpImpl::GetSendFrameCountObserver() const {
return rtp_sender_.GetFrameCountObserver();
}
bool ModuleRtpRtcpImpl::IsDefaultModule() const {
CriticalSectionScoped cs(critical_section_module_ptrs_.get());
return !child_modules_.empty();

View File

@ -373,10 +373,6 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
void OnRequestSendReport();
virtual void RegisterSendFrameCountObserver(
FrameCountObserver* observer) OVERRIDE;
virtual FrameCountObserver* GetSendFrameCountObserver() const OVERRIDE;
protected:
void RegisterChildModule(RtpRtcp* module);

View File

@ -46,7 +46,8 @@ RTPSender::RTPSender(const int32_t id,
Transport* transport,
RtpAudioFeedback* audio_feedback,
PacedSender* paced_sender,
BitrateStatisticsObserver* bitrate_callback)
BitrateStatisticsObserver* bitrate_callback,
FrameCountObserver* frame_count_observer)
: clock_(clock),
bitrate_sent_(clock, this),
id_(id),
@ -71,9 +72,9 @@ RTPSender::RTPSender(const int32_t id,
packet_history_(clock),
// Statistics
statistics_crit_(CriticalSectionWrapper::CreateCriticalSection()),
frame_count_observer_(NULL),
rtp_stats_callback_(NULL),
bitrate_callback_(bitrate_callback),
frame_count_observer_(frame_count_observer),
// RTP variables
start_timestamp_forced_(false),
start_timestamp_(0),
@ -1664,16 +1665,6 @@ void RTPSender::BuildRtxPacket(uint8_t* buffer, uint16_t* length,
*length += 2;
}
void RTPSender::RegisterFrameCountObserver(FrameCountObserver* observer) {
CriticalSectionScoped cs(statistics_crit_.get());
frame_count_observer_ = observer;
}
FrameCountObserver* RTPSender::GetFrameCountObserver() const {
CriticalSectionScoped cs(statistics_crit_.get());
return frame_count_observer_;
}
void RTPSender::RegisterRtpStatisticsCallback(
StreamDataCountersCallback* callback) {
CriticalSectionScoped cs(statistics_crit_.get());

View File

@ -70,7 +70,8 @@ class RTPSender : public RTPSenderInterface, public Bitrate::Observer {
RTPSender(const int32_t id, const bool audio, Clock *clock,
Transport *transport, RtpAudioFeedback *audio_feedback,
PacedSender *paced_sender,
BitrateStatisticsObserver* bitrate_callback);
BitrateStatisticsObserver* bitrate_callback,
FrameCountObserver* frame_count_observer);
virtual ~RTPSender();
void ProcessBitrate();
@ -265,9 +266,6 @@ class RTPSender : public RTPSenderInterface, public Bitrate::Observer {
int32_t SetFecParameters(const FecProtectionParams *delta_params,
const FecProtectionParams *key_params);
virtual void RegisterFrameCountObserver(FrameCountObserver* observer);
virtual FrameCountObserver* GetFrameCountObserver() const;
int SendPadData(int payload_type, uint32_t timestamp, int64_t capture_time_ms,
int32_t bytes, StorageType store,
bool force_full_size_packets, bool only_pad_after_markerbit);
@ -373,11 +371,11 @@ class RTPSender : public RTPSenderInterface, public Bitrate::Observer {
scoped_ptr<CriticalSectionWrapper> statistics_crit_;
SendDelayMap send_delays_ GUARDED_BY(statistics_crit_);
std::map<FrameType, uint32_t> frame_counts_ GUARDED_BY(statistics_crit_);
FrameCountObserver* frame_count_observer_ GUARDED_BY(statistics_crit_);
StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_);
StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_);
StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_);
BitrateStatisticsObserver* const bitrate_callback_;
FrameCountObserver* const frame_count_observer_;
// RTP variables
bool start_timestamp_forced_ GUARDED_BY(send_critsect_);

View File

@ -94,7 +94,7 @@ class RtpSenderTest : public ::testing::Test {
virtual void SetUp() {
rtp_sender_.reset(new RTPSender(0, false, &fake_clock_, &transport_, NULL,
&mock_paced_sender_, NULL));
&mock_paced_sender_, NULL, NULL));
rtp_sender_->SetSequenceNumber(kSeqNum);
}
@ -672,7 +672,7 @@ TEST_F(RtpSenderTest, SendPadding) {
TEST_F(RtpSenderTest, SendRedundantPayloads) {
MockTransport transport;
rtp_sender_.reset(new RTPSender(0, false, &fake_clock_, &transport, NULL,
&mock_paced_sender_, NULL));
&mock_paced_sender_, NULL, NULL));
rtp_sender_->SetSequenceNumber(kSeqNum);
// Make all packets go through the pacer.
EXPECT_CALL(mock_paced_sender_,
@ -817,6 +817,9 @@ TEST_F(RtpSenderTest, FrameCountCallbacks) {
uint32_t delta_frames_;
} callback;
rtp_sender_.reset(new RTPSender(0, false, &fake_clock_, &transport_, NULL,
&mock_paced_sender_, NULL, &callback));
char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC";
const uint8_t payload_type = 127;
ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 90000,
@ -825,8 +828,6 @@ TEST_F(RtpSenderTest, FrameCountCallbacks) {
rtp_sender_->SetStorePacketsStatus(true, 1);
uint32_t ssrc = rtp_sender_->SSRC();
rtp_sender_->RegisterFrameCountObserver(&callback);
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234,
4321, payload, sizeof(payload),
NULL));
@ -845,7 +846,7 @@ TEST_F(RtpSenderTest, FrameCountCallbacks) {
EXPECT_EQ(1U, callback.key_frames_);
EXPECT_EQ(1U, callback.delta_frames_);
rtp_sender_->RegisterFrameCountObserver(NULL);
rtp_sender_.reset();
}
TEST_F(RtpSenderTest, BitrateCallbacks) {
@ -866,7 +867,7 @@ TEST_F(RtpSenderTest, BitrateCallbacks) {
BitrateStatistics bitrate_;
} callback;
rtp_sender_.reset(new RTPSender(0, false, &fake_clock_, &transport_, NULL,
&mock_paced_sender_, &callback));
&mock_paced_sender_, &callback, NULL));
// Simulate kNumPackets sent with kPacketInterval ms intervals.
const uint32_t kNumPackets = 15;
@ -922,7 +923,7 @@ class RtpSenderAudioTest : public RtpSenderTest {
virtual void SetUp() {
payload_ = kAudioPayload;
rtp_sender_.reset(new RTPSender(0, true, &fake_clock_, &transport_, NULL,
&mock_paced_sender_, NULL));
&mock_paced_sender_, NULL, NULL));
rtp_sender_->SetSequenceNumber(kSeqNum);
}
};

View File

@ -117,6 +117,7 @@ ViEChannel::ViEChannel(int32_t channel_id,
configuration.paced_sender = paced_sender;
configuration.receive_statistics = vie_receiver_.GetReceiveStatistics();
configuration.send_bitrate_observer = &send_bitrate_observer_;
configuration.send_frame_count_observer = &send_frame_count_observer_;
rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(configuration));
vie_receiver_.SetRtpRtcpModule(rtp_rtcp_.get());
@ -298,7 +299,6 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
module_process_thread_.DeRegisterModule(rtp_rtcp);
rtp_rtcp->SetSendingStatus(false);
rtp_rtcp->SetSendingMediaStatus(false);
rtp_rtcp->RegisterSendFrameCountObserver(NULL);
rtp_rtcp->RegisterSendChannelRtcpStatisticsCallback(NULL);
rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(NULL);
simulcast_rtp_rtcp_.pop_back();
@ -346,8 +346,6 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
rtp_rtcp->DeregisterSendRtpHeaderExtension(
kRtpExtensionAbsoluteSendTime);
}
rtp_rtcp->RegisterSendFrameCountObserver(
rtp_rtcp_->GetSendFrameCountObserver());
rtp_rtcp->RegisterSendChannelRtcpStatisticsCallback(
rtp_rtcp_->GetSendChannelRtcpStatisticsCallback());
rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(
@ -362,7 +360,6 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
module_process_thread_.DeRegisterModule(rtp_rtcp);
rtp_rtcp->SetSendingStatus(false);
rtp_rtcp->SetSendingMediaStatus(false);
rtp_rtcp->RegisterSendFrameCountObserver(NULL);
rtp_rtcp->RegisterSendChannelRtcpStatisticsCallback(NULL);
rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(NULL);
simulcast_rtp_rtcp_.pop_back();
@ -1524,7 +1521,6 @@ void ViEChannel::ReserveRtpRtcpModules(size_t num_modules) {
RtpRtcp* rtp_rtcp = CreateRtpRtcpModule();
rtp_rtcp->SetSendingStatus(false);
rtp_rtcp->SetSendingMediaStatus(false);
rtp_rtcp->RegisterSendFrameCountObserver(NULL);
rtp_rtcp->RegisterSendChannelRtcpStatisticsCallback(NULL);
rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(NULL);
removed_rtp_rtcp_.push_back(rtp_rtcp);
@ -1714,13 +1710,7 @@ void ViEChannel::ResetStatistics(uint32_t ssrc) {
void ViEChannel::RegisterSendFrameCountObserver(
FrameCountObserver* observer) {
rtp_rtcp_->RegisterSendFrameCountObserver(observer);
CriticalSectionScoped cs(rtp_rtcp_cs_.get());
for (std::list<RtpRtcp*>::iterator it = simulcast_rtp_rtcp_.begin();
it != simulcast_rtp_rtcp_.end();
it++) {
(*it)->RegisterSendFrameCountObserver(observer);
}
send_frame_count_observer_.Set(observer);
}
void ViEChannel::ReceivedBWEPacket(int64_t arrival_time_ms,

View File

@ -411,7 +411,8 @@ class ViEChannel
DISALLOW_COPY_AND_ASSIGN(RegisterableCallback);
};
class : public RegisterableCallback<BitrateStatisticsObserver> {
class RegisterableBitrateStatisticsObserver:
public RegisterableCallback<BitrateStatisticsObserver> {
virtual void Notify(const BitrateStatistics& stats, uint32_t ssrc) {
CriticalSectionScoped cs(critsect_.get());
if (callback_)
@ -420,6 +421,17 @@ class ViEChannel
}
send_bitrate_observer_;
class RegisterableFrameCountObserver
: public RegisterableCallback<FrameCountObserver> {
virtual void FrameCountUpdated(FrameType frame_type,
uint32_t frame_count,
const unsigned int ssrc) {
CriticalSectionScoped cs(critsect_.get());
if (callback_)
callback_->FrameCountUpdated(frame_type, frame_count, ssrc);
}
} send_frame_count_observer_;
int32_t channel_id_;
int32_t engine_id_;
uint32_t number_of_cores_;