Reformatted RTPReceiver.
This is a pure reformat patch, with the exception that I also fixed all comments and moved a constant. I did not change the types in this patch since I though that is more risky, so I'll do that in a separate patch later (perhaps we could purge the types from the whole module in one go?) BUG= TEST=Trybots, vie_ & voe_auto_test --automated Review URL: https://webrtc-codereview.appspot.com/998007 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3338 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -25,6 +25,8 @@
|
||||
|
||||
namespace webrtc{
|
||||
|
||||
const WebRtc_Word32 kDefaultVideoFrequency = 90000;
|
||||
|
||||
enum RTCPMethod
|
||||
{
|
||||
kRtcpOff = 0,
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_BITRATE_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_BITRATE_H_
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "rtp_rtcp_config.h" // misc. defines (e.g. MAX_PACKET_LENGTH)
|
||||
#include "common_types.h" // Transport
|
||||
#include <stdio.h>
|
||||
#include <list>
|
||||
|
||||
namespace webrtc {
|
||||
class RtpRtcpClock;
|
||||
|
||||
class Bitrate
|
||||
{
|
||||
public:
|
||||
Bitrate(RtpRtcpClock* clock);
|
||||
|
||||
// calculate rates
|
||||
void Process();
|
||||
|
||||
// update with a packet
|
||||
void Update(const WebRtc_Word32 bytes);
|
||||
|
||||
// packet rate last second, updated roughly every 100 ms
|
||||
WebRtc_UWord32 PacketRate() const;
|
||||
|
||||
// bitrate last second, updated roughly every 100 ms
|
||||
WebRtc_UWord32 BitrateLast() const;
|
||||
|
||||
// bitrate last second, updated now
|
||||
WebRtc_UWord32 BitrateNow() const;
|
||||
|
||||
protected:
|
||||
RtpRtcpClock& _clock;
|
||||
|
||||
private:
|
||||
WebRtc_UWord32 _packetRate;
|
||||
WebRtc_UWord32 _bitrate;
|
||||
WebRtc_UWord8 _bitrateNextIdx;
|
||||
WebRtc_Word64 _packetRateArray[10];
|
||||
WebRtc_Word64 _bitrateArray[10];
|
||||
WebRtc_Word64 _bitrateDiffMS[10];
|
||||
WebRtc_Word64 _timeLastRateUpdate;
|
||||
WebRtc_UWord32 _bytesCount;
|
||||
WebRtc_UWord32 _packetCount;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_BITRATE_H_
|
@ -8,94 +8,91 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "Bitrate.h"
|
||||
#include "rtp_utility.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/bitrate.h"
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
||||
|
||||
namespace webrtc {
|
||||
Bitrate::Bitrate(RtpRtcpClock* clock) :
|
||||
_clock(*clock),
|
||||
_packetRate(0),
|
||||
_bitrate(0),
|
||||
_bitrateNextIdx(0),
|
||||
_timeLastRateUpdate(0),
|
||||
_bytesCount(0),
|
||||
_packetCount(0)
|
||||
{
|
||||
memset(_packetRateArray, 0, sizeof(_packetRateArray));
|
||||
memset(_bitrateDiffMS, 0, sizeof(_bitrateDiffMS));
|
||||
memset(_bitrateArray, 0, sizeof(_bitrateArray));
|
||||
|
||||
Bitrate::Bitrate(RtpRtcpClock* clock)
|
||||
: clock_(*clock),
|
||||
packet_rate_(0),
|
||||
bitrate_(0),
|
||||
bitrate_next_idx_(0),
|
||||
time_last_rate_update_(0),
|
||||
bytes_count_(0),
|
||||
packet_count_(0) {
|
||||
memset(packet_rate_array_, 0, sizeof(packet_rate_array_));
|
||||
memset(bitrate_diff_ms_, 0, sizeof(bitrate_diff_ms_));
|
||||
memset(bitrate_array_, 0, sizeof(bitrate_array_));
|
||||
}
|
||||
|
||||
void
|
||||
Bitrate::Update(const WebRtc_Word32 bytes)
|
||||
{
|
||||
_bytesCount += bytes;
|
||||
_packetCount++;
|
||||
void Bitrate::Update(const WebRtc_Word32 bytes) {
|
||||
bytes_count_ += bytes;
|
||||
packet_count_++;
|
||||
}
|
||||
|
||||
WebRtc_UWord32
|
||||
Bitrate::PacketRate() const
|
||||
{
|
||||
return _packetRate;
|
||||
WebRtc_UWord32 Bitrate::PacketRate() const {
|
||||
return packet_rate_;
|
||||
}
|
||||
|
||||
WebRtc_UWord32 Bitrate::BitrateLast() const {
|
||||
return _bitrate;
|
||||
return bitrate_;
|
||||
}
|
||||
|
||||
WebRtc_UWord32 Bitrate::BitrateNow() const {
|
||||
WebRtc_Word64 now = _clock.GetTimeInMS();
|
||||
WebRtc_Word64 diffMS = now -_timeLastRateUpdate;
|
||||
WebRtc_Word64 now = clock_.GetTimeInMS();
|
||||
WebRtc_Word64 diff_ms = now - time_last_rate_update_;
|
||||
|
||||
if(diffMS > 10000) { // 10 sec
|
||||
// too high diff ignore
|
||||
return _bitrate; // bits/s
|
||||
if (diff_ms > 10000) { // 10 seconds.
|
||||
// Too high difference, ignore.
|
||||
return bitrate_;
|
||||
}
|
||||
WebRtc_Word64 bitsSinceLastRateUpdate = 8 * _bytesCount * 1000;
|
||||
WebRtc_Word64 bits_since_last_rate_update = 8 * bytes_count_ * 1000;
|
||||
|
||||
// have to consider the time when the measurement was done
|
||||
// ((bits/sec * sec) + (bits)) / sec
|
||||
WebRtc_Word64 bitrate = (static_cast<WebRtc_UWord64>(_bitrate) * 1000 +
|
||||
bitsSinceLastRateUpdate) / (1000 + diffMS);
|
||||
// We have to consider the time when the measurement was done:
|
||||
// ((bits/sec * sec) + (bits)) / sec.
|
||||
WebRtc_Word64 bitrate = (static_cast<WebRtc_UWord64>(bitrate_) * 1000 +
|
||||
bits_since_last_rate_update) / (1000 + diff_ms);
|
||||
return static_cast<WebRtc_UWord32>(bitrate);
|
||||
}
|
||||
|
||||
void Bitrate::Process() {
|
||||
// Triggered by timer.
|
||||
WebRtc_Word64 now = _clock.GetTimeInMS();
|
||||
WebRtc_Word64 diffMS = now -_timeLastRateUpdate;
|
||||
WebRtc_Word64 now = clock_.GetTimeInMS();
|
||||
WebRtc_Word64 diff_ms = now - time_last_rate_update_;
|
||||
|
||||
if (diffMS < 100) {
|
||||
if (diff_ms < 100) {
|
||||
// Not enough data, wait...
|
||||
return;
|
||||
}
|
||||
if (diffMS > 10000) { // 10 sec
|
||||
// too high diff ignore
|
||||
_timeLastRateUpdate = now;
|
||||
_bytesCount = 0;
|
||||
_packetCount = 0;
|
||||
if (diff_ms > 10000) { // 10 seconds.
|
||||
// Too high difference, ignore.
|
||||
time_last_rate_update_ = now;
|
||||
bytes_count_ = 0;
|
||||
packet_count_ = 0;
|
||||
return;
|
||||
}
|
||||
_packetRateArray[_bitrateNextIdx] = (_packetCount * 1000) / diffMS;
|
||||
_bitrateArray[_bitrateNextIdx] = 8 * ((_bytesCount * 1000) / diffMS);
|
||||
_bitrateDiffMS[_bitrateNextIdx] = diffMS;
|
||||
_bitrateNextIdx++;
|
||||
if (_bitrateNextIdx >= 10) {
|
||||
_bitrateNextIdx = 0;
|
||||
packet_rate_array_[bitrate_next_idx_] = (packet_count_ * 1000) / diff_ms;
|
||||
bitrate_array_[bitrate_next_idx_] = 8 * ((bytes_count_ * 1000) / diff_ms);
|
||||
bitrate_diff_ms_[bitrate_next_idx_] = diff_ms;
|
||||
bitrate_next_idx_++;
|
||||
if (bitrate_next_idx_ >= 10) {
|
||||
bitrate_next_idx_ = 0;
|
||||
}
|
||||
WebRtc_Word64 sumDiffMS = 0;
|
||||
WebRtc_Word64 sumBitrateMS = 0;
|
||||
WebRtc_Word64 sumPacketrateMS = 0;
|
||||
WebRtc_Word64 sum_diffMS = 0;
|
||||
WebRtc_Word64 sum_bitrateMS = 0;
|
||||
WebRtc_Word64 sum_packetrateMS = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
sumDiffMS += _bitrateDiffMS[i];
|
||||
sumBitrateMS += _bitrateArray[i] * _bitrateDiffMS[i];
|
||||
sumPacketrateMS += _packetRateArray[i] * _bitrateDiffMS[i];
|
||||
sum_diffMS += bitrate_diff_ms_[i];
|
||||
sum_bitrateMS += bitrate_array_[i] * bitrate_diff_ms_[i];
|
||||
sum_packetrateMS += packet_rate_array_[i] * bitrate_diff_ms_[i];
|
||||
}
|
||||
_timeLastRateUpdate = now;
|
||||
_bytesCount = 0;
|
||||
_packetCount = 0;
|
||||
_packetRate = static_cast<WebRtc_UWord32>(sumPacketrateMS / sumDiffMS);
|
||||
_bitrate = static_cast<WebRtc_UWord32>(sumBitrateMS / sumDiffMS);
|
||||
time_last_rate_update_ = now;
|
||||
bytes_count_ = 0;
|
||||
packet_count_ = 0;
|
||||
packet_rate_ = static_cast<WebRtc_UWord32>(sum_packetrateMS / sum_diffMS);
|
||||
bitrate_ = static_cast<WebRtc_UWord32>(sum_bitrateMS / sum_diffMS);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
} // namespace webrtc
|
||||
|
61
webrtc/modules/rtp_rtcp/source/bitrate.h
Normal file
61
webrtc/modules/rtp_rtcp/source/bitrate.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_BITRATE_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_BITRATE_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <list>
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class RtpRtcpClock;
|
||||
|
||||
class Bitrate {
|
||||
public:
|
||||
explicit Bitrate(RtpRtcpClock* clock);
|
||||
|
||||
// Calculates rates.
|
||||
void Process();
|
||||
|
||||
// Update with a packet.
|
||||
void Update(const WebRtc_Word32 bytes);
|
||||
|
||||
// Packet rate last second, updated roughly every 100 ms.
|
||||
WebRtc_UWord32 PacketRate() const;
|
||||
|
||||
// Bitrate last second, updated roughly every 100 ms.
|
||||
WebRtc_UWord32 BitrateLast() const;
|
||||
|
||||
// Bitrate last second, updated now.
|
||||
WebRtc_UWord32 BitrateNow() const;
|
||||
|
||||
protected:
|
||||
RtpRtcpClock& clock_;
|
||||
|
||||
private:
|
||||
WebRtc_UWord32 packet_rate_;
|
||||
WebRtc_UWord32 bitrate_;
|
||||
WebRtc_UWord8 bitrate_next_idx_;
|
||||
WebRtc_Word64 packet_rate_array_[10];
|
||||
WebRtc_Word64 bitrate_array_[10];
|
||||
WebRtc_Word64 bitrate_diff_ms_[10];
|
||||
WebRtc_Word64 time_last_rate_update_;
|
||||
WebRtc_UWord32 bytes_count_;
|
||||
WebRtc_UWord32 packet_count_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_BITRATE_H_
|
File diff suppressed because it is too large
Load Diff
@ -13,16 +13,16 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "rtp_utility.h"
|
||||
|
||||
#include "rtp_header_extension.h"
|
||||
#include "rtp_rtcp.h"
|
||||
#include "rtp_rtcp_defines.h"
|
||||
#include "rtcp_receiver_help.h"
|
||||
#include "Bitrate.h"
|
||||
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
|
||||
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/bitrate.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class RtpRtcpFeedback;
|
||||
class ModuleRtpRtcpImpl;
|
||||
class Trace;
|
||||
@ -30,241 +30,241 @@ class RTPReceiverAudio;
|
||||
class RTPReceiverVideo;
|
||||
class RTPReceiverStrategy;
|
||||
|
||||
const WebRtc_Word32 kDefaultVideoFrequency = 90000;
|
||||
class RTPReceiver : public Bitrate {
|
||||
public:
|
||||
RTPReceiver(const WebRtc_Word32 id,
|
||||
const bool audio,
|
||||
RtpRtcpClock* clock,
|
||||
ModuleRtpRtcpImpl* owner,
|
||||
RtpAudioFeedback* incoming_messages_callback);
|
||||
|
||||
class RTPReceiver : public Bitrate
|
||||
{
|
||||
public:
|
||||
RTPReceiver(const WebRtc_Word32 id,
|
||||
const bool audio,
|
||||
RtpRtcpClock* clock,
|
||||
ModuleRtpRtcpImpl* owner,
|
||||
RtpAudioFeedback* incomingMessagesCallback);
|
||||
virtual ~RTPReceiver();
|
||||
|
||||
virtual ~RTPReceiver();
|
||||
RtpVideoCodecTypes VideoCodecType() const;
|
||||
WebRtc_UWord32 MaxConfiguredBitrate() const;
|
||||
|
||||
RtpVideoCodecTypes VideoCodecType() const;
|
||||
WebRtc_UWord32 MaxConfiguredBitrate() const;
|
||||
WebRtc_Word32 SetPacketTimeout(const WebRtc_UWord32 timeout_ms);
|
||||
void PacketTimeout();
|
||||
|
||||
WebRtc_Word32 SetPacketTimeout(const WebRtc_UWord32 timeoutMS);
|
||||
void PacketTimeout();
|
||||
void ProcessDeadOrAlive(const bool RTCPalive, const WebRtc_Word64 now);
|
||||
|
||||
void ProcessDeadOrAlive(const bool RTCPalive, const WebRtc_Word64 now);
|
||||
void ProcessBitrate();
|
||||
|
||||
void ProcessBitrate();
|
||||
WebRtc_Word32 RegisterIncomingDataCallback(RtpData* incoming_data_callback);
|
||||
WebRtc_Word32 RegisterIncomingRTPCallback(
|
||||
RtpFeedback* incoming_messages_callback);
|
||||
|
||||
WebRtc_Word32 RegisterIncomingDataCallback(RtpData* incomingDataCallback);
|
||||
WebRtc_Word32 RegisterIncomingRTPCallback(RtpFeedback* incomingMessagesCallback);
|
||||
WebRtc_Word32 RegisterReceivePayload(
|
||||
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
const WebRtc_Word8 payload_type,
|
||||
const WebRtc_UWord32 frequency,
|
||||
const WebRtc_UWord8 channels,
|
||||
const WebRtc_UWord32 rate);
|
||||
|
||||
WebRtc_Word32 RegisterReceivePayload(
|
||||
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
const WebRtc_Word8 payloadType,
|
||||
const WebRtc_UWord32 frequency,
|
||||
const WebRtc_UWord8 channels,
|
||||
const WebRtc_UWord32 rate);
|
||||
WebRtc_Word32 DeRegisterReceivePayload(const WebRtc_Word8 payload_type);
|
||||
|
||||
WebRtc_Word32 DeRegisterReceivePayload(const WebRtc_Word8 payloadType);
|
||||
WebRtc_Word32 ReceivePayloadType(
|
||||
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
const WebRtc_UWord32 frequency,
|
||||
const WebRtc_UWord8 channels,
|
||||
const WebRtc_UWord32 rate,
|
||||
WebRtc_Word8* payload_type) const;
|
||||
|
||||
WebRtc_Word32 ReceivePayloadType(
|
||||
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
const WebRtc_UWord32 frequency,
|
||||
const WebRtc_UWord8 channels,
|
||||
const WebRtc_UWord32 rate,
|
||||
WebRtc_Word8* payloadType) const;
|
||||
WebRtc_Word32 ReceivePayload(const WebRtc_Word8 payload_type,
|
||||
char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
WebRtc_UWord32* frequency,
|
||||
WebRtc_UWord8* channels,
|
||||
WebRtc_UWord32* rate) const;
|
||||
|
||||
WebRtc_Word32 ReceivePayload(const WebRtc_Word8 payloadType,
|
||||
char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
WebRtc_UWord32* frequency,
|
||||
WebRtc_UWord8* channels,
|
||||
WebRtc_UWord32* rate) const;
|
||||
WebRtc_Word32 RemotePayload(char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
WebRtc_Word8* payload_type,
|
||||
WebRtc_UWord32* frequency,
|
||||
WebRtc_UWord8* channels) const;
|
||||
|
||||
WebRtc_Word32 RemotePayload(char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
WebRtc_Word8* payloadType,
|
||||
WebRtc_UWord32* frequency,
|
||||
WebRtc_UWord8* channels) const;
|
||||
WebRtc_Word32 IncomingRTPPacket(
|
||||
WebRtcRTPHeader* rtpheader,
|
||||
const WebRtc_UWord8* incoming_rtp_packet,
|
||||
const WebRtc_UWord16 incoming_rtp_packet_length);
|
||||
|
||||
WebRtc_Word32 IncomingRTPPacket(WebRtcRTPHeader* rtpheader,
|
||||
const WebRtc_UWord8* incomingRtpPacket,
|
||||
const WebRtc_UWord16 incomingRtpPacketLengt);
|
||||
NACKMethod NACK() const ;
|
||||
|
||||
NACKMethod NACK() const ;
|
||||
// Turn negative acknowledgement requests on/off.
|
||||
WebRtc_Word32 SetNACKStatus(const NACKMethod method);
|
||||
|
||||
// Turn negative acknowledgement requests on/off
|
||||
WebRtc_Word32 SetNACKStatus(const NACKMethod method);
|
||||
// Returns the last received timestamp.
|
||||
virtual WebRtc_UWord32 TimeStamp() const;
|
||||
int32_t LastReceivedTimeMs() const;
|
||||
virtual WebRtc_UWord16 SequenceNumber() const;
|
||||
|
||||
WebRtc_Word32 EstimatedRemoteTimeStamp(WebRtc_UWord32& timestamp) const;
|
||||
|
||||
// last received
|
||||
virtual WebRtc_UWord32 TimeStamp() const;
|
||||
int32_t LastReceivedTimeMs() const;
|
||||
virtual WebRtc_UWord16 SequenceNumber() const;
|
||||
WebRtc_UWord32 SSRC() const;
|
||||
|
||||
WebRtc_Word32 EstimatedRemoteTimeStamp(WebRtc_UWord32& timestamp) const;
|
||||
WebRtc_Word32 CSRCs(WebRtc_UWord32 array_of_csrc[kRtpCsrcSize]) const;
|
||||
|
||||
WebRtc_UWord32 SSRC() const;
|
||||
WebRtc_Word32 Energy(WebRtc_UWord8 array_of_energy[kRtpCsrcSize]) const;
|
||||
|
||||
WebRtc_Word32 CSRCs( WebRtc_UWord32 arrOfCSRC[kRtpCsrcSize]) const;
|
||||
// Get the currently configured SSRC filter.
|
||||
WebRtc_Word32 SSRCFilter(WebRtc_UWord32& allowed_ssrc) const;
|
||||
|
||||
WebRtc_Word32 Energy( WebRtc_UWord8 arrOfEnergy[kRtpCsrcSize]) const;
|
||||
// Set a SSRC to be used as a filter for incoming RTP streams.
|
||||
WebRtc_Word32 SetSSRCFilter(const bool enable,
|
||||
const WebRtc_UWord32 allowed_ssrc);
|
||||
|
||||
// get the currently configured SSRC filter
|
||||
WebRtc_Word32 SSRCFilter(WebRtc_UWord32& allowedSSRC) const;
|
||||
WebRtc_Word32 Statistics(WebRtc_UWord8* fraction_lost,
|
||||
WebRtc_UWord32* cum_lost,
|
||||
WebRtc_UWord32* ext_max,
|
||||
WebRtc_UWord32* jitter, // Will be moved from JB.
|
||||
WebRtc_UWord32* max_jitter,
|
||||
WebRtc_UWord32* jitter_transmission_time_offset,
|
||||
bool reset) const;
|
||||
|
||||
// set a SSRC to be used as a filter for incoming RTP streams
|
||||
WebRtc_Word32 SetSSRCFilter(const bool enable, const WebRtc_UWord32 allowedSSRC);
|
||||
WebRtc_Word32 Statistics(WebRtc_UWord8* fraction_lost,
|
||||
WebRtc_UWord32* cum_lost,
|
||||
WebRtc_UWord32* ext_max,
|
||||
WebRtc_UWord32* jitter, // Will be moved from JB.
|
||||
WebRtc_UWord32* max_jitter,
|
||||
WebRtc_UWord32* jitter_transmission_time_offset,
|
||||
WebRtc_Word32* missing,
|
||||
bool reset) const;
|
||||
|
||||
WebRtc_Word32 Statistics(WebRtc_UWord8 *fraction_lost,
|
||||
WebRtc_UWord32 *cum_lost,
|
||||
WebRtc_UWord32 *ext_max,
|
||||
WebRtc_UWord32 *jitter, // will be moved from JB
|
||||
WebRtc_UWord32 *max_jitter,
|
||||
WebRtc_UWord32 *jitter_transmission_time_offset,
|
||||
bool reset) const;
|
||||
WebRtc_Word32 DataCounters(WebRtc_UWord32* bytes_received,
|
||||
WebRtc_UWord32* packets_received) const;
|
||||
|
||||
WebRtc_Word32 Statistics(WebRtc_UWord8 *fraction_lost,
|
||||
WebRtc_UWord32 *cum_lost,
|
||||
WebRtc_UWord32 *ext_max,
|
||||
WebRtc_UWord32 *jitter, // will be moved from JB
|
||||
WebRtc_UWord32 *max_jitter,
|
||||
WebRtc_UWord32 *jitter_transmission_time_offset,
|
||||
WebRtc_Word32 *missing,
|
||||
bool reset) const;
|
||||
WebRtc_Word32 ResetStatistics();
|
||||
|
||||
WebRtc_Word32 DataCounters(WebRtc_UWord32 *bytesReceived,
|
||||
WebRtc_UWord32 *packetsReceived) const;
|
||||
WebRtc_Word32 ResetDataCounters();
|
||||
|
||||
WebRtc_Word32 ResetStatistics();
|
||||
WebRtc_UWord16 PacketOHReceived() const;
|
||||
|
||||
WebRtc_Word32 ResetDataCounters();
|
||||
WebRtc_UWord32 PacketCountReceived() const;
|
||||
|
||||
WebRtc_UWord16 PacketOHReceived() const;
|
||||
WebRtc_UWord32 ByteCountReceived() const;
|
||||
|
||||
WebRtc_UWord32 PacketCountReceived() const;
|
||||
WebRtc_Word32 RegisterRtpHeaderExtension(const RTPExtensionType type,
|
||||
const WebRtc_UWord8 id);
|
||||
|
||||
WebRtc_UWord32 ByteCountReceived() const;
|
||||
WebRtc_Word32 DeregisterRtpHeaderExtension(const RTPExtensionType type);
|
||||
|
||||
WebRtc_Word32 RegisterRtpHeaderExtension(const RTPExtensionType type,
|
||||
const WebRtc_UWord8 id);
|
||||
void GetHeaderExtensionMapCopy(RtpHeaderExtensionMap* map) const;
|
||||
|
||||
WebRtc_Word32 DeregisterRtpHeaderExtension(const RTPExtensionType type);
|
||||
virtual WebRtc_UWord32 PayloadTypeToPayload(
|
||||
const WebRtc_UWord8 payload_type,
|
||||
ModuleRTPUtility::Payload*& payload) const;
|
||||
|
||||
void GetHeaderExtensionMapCopy(RtpHeaderExtensionMap* map) const;
|
||||
// RTX.
|
||||
void SetRTXStatus(const bool enable, const WebRtc_UWord32 ssrc);
|
||||
|
||||
virtual WebRtc_UWord32 PayloadTypeToPayload(const WebRtc_UWord8 payloadType,
|
||||
ModuleRTPUtility::Payload*& payload) const;
|
||||
/*
|
||||
* RTX
|
||||
*/
|
||||
void SetRTXStatus(const bool enable, const WebRtc_UWord32 SSRC);
|
||||
void RTXStatus(bool* enable, WebRtc_UWord32* ssrc) const;
|
||||
|
||||
void RTXStatus(bool* enable, WebRtc_UWord32* SSRC) const;
|
||||
RTPReceiverAudio* GetAudioReceiver() const {
|
||||
return rtp_receiver_audio_;
|
||||
}
|
||||
|
||||
RTPReceiverAudio* GetAudioReceiver() const { return _rtpReceiverAudio; }
|
||||
virtual WebRtc_Word32 CallbackOfReceivedPayloadData(
|
||||
const WebRtc_UWord8* payload_data,
|
||||
const WebRtc_UWord16 payload_size,
|
||||
const WebRtcRTPHeader* rtp_header);
|
||||
|
||||
virtual WebRtc_Word32 CallbackOfReceivedPayloadData(
|
||||
const WebRtc_UWord8* payloadData,
|
||||
const WebRtc_UWord16 payloadSize,
|
||||
const WebRtcRTPHeader* rtpHeader);
|
||||
virtual WebRtc_Word8 REDPayloadType() const;
|
||||
|
||||
virtual WebRtc_Word8 REDPayloadType() const;
|
||||
bool HaveNotReceivedPackets() const;
|
||||
protected:
|
||||
|
||||
bool HaveNotReceivedPackets() const;
|
||||
protected:
|
||||
virtual bool RetransmitOfOldPacket(const WebRtc_UWord16 sequence_number,
|
||||
const WebRtc_UWord32 rtp_time_stamp) const;
|
||||
|
||||
virtual bool RetransmitOfOldPacket(const WebRtc_UWord16 sequenceNumber,
|
||||
const WebRtc_UWord32 rtpTimeStamp) const;
|
||||
void UpdateStatistics(const WebRtcRTPHeader* rtp_header,
|
||||
const WebRtc_UWord16 bytes,
|
||||
const bool old_packet);
|
||||
|
||||
private:
|
||||
// Returns whether RED is configured with payload_type.
|
||||
bool REDPayloadType(const WebRtc_Word8 payload_type) const;
|
||||
|
||||
void UpdateStatistics(const WebRtcRTPHeader* rtpHeader,
|
||||
const WebRtc_UWord16 bytes,
|
||||
const bool oldPacket);
|
||||
bool InOrderPacket(const WebRtc_UWord16 sequence_number) const;
|
||||
|
||||
private:
|
||||
// Is RED configured with payload type payloadType
|
||||
bool REDPayloadType(const WebRtc_Word8 payloadType) const;
|
||||
void CheckSSRCChanged(const WebRtcRTPHeader* rtp_header);
|
||||
void CheckCSRC(const WebRtcRTPHeader* rtp_header);
|
||||
WebRtc_Word32 CheckPayloadChanged(const WebRtcRTPHeader* rtp_header,
|
||||
const WebRtc_Word8 first_payload_byte,
|
||||
bool& isRED,
|
||||
ModuleRTPUtility::PayloadUnion* payload);
|
||||
|
||||
bool InOrderPacket(const WebRtc_UWord16 sequenceNumber) const;
|
||||
void UpdateNACKBitRate(WebRtc_Word32 bytes, WebRtc_UWord32 now);
|
||||
bool ProcessNACKBitRate(WebRtc_UWord32 now);
|
||||
|
||||
void CheckSSRCChanged(const WebRtcRTPHeader* rtpHeader);
|
||||
void CheckCSRC(const WebRtcRTPHeader* rtpHeader);
|
||||
WebRtc_Word32 CheckPayloadChanged(const WebRtcRTPHeader* rtpHeader,
|
||||
const WebRtc_Word8 firstPayloadByte,
|
||||
bool& isRED,
|
||||
ModuleRTPUtility::PayloadUnion* payload);
|
||||
private:
|
||||
RTPReceiverAudio* rtp_receiver_audio_;
|
||||
RTPReceiverVideo* rtp_receiver_video_;
|
||||
RTPReceiverStrategy* rtp_media_receiver_;
|
||||
|
||||
void UpdateNACKBitRate(WebRtc_Word32 bytes, WebRtc_UWord32 now);
|
||||
bool ProcessNACKBitRate(WebRtc_UWord32 now);
|
||||
WebRtc_Word32 id_;
|
||||
ModuleRtpRtcpImpl& rtp_rtcp_;
|
||||
|
||||
private:
|
||||
RTPReceiverAudio* _rtpReceiverAudio;
|
||||
RTPReceiverVideo* _rtpReceiverVideo;
|
||||
RTPReceiverStrategy* _rtpMediaReceiver;
|
||||
CriticalSectionWrapper* critical_section_cbs_;
|
||||
RtpFeedback* cb_rtp_feedback_;
|
||||
RtpData* cb_rtp_data_;
|
||||
|
||||
WebRtc_Word32 _id;
|
||||
ModuleRtpRtcpImpl& _rtpRtcp;
|
||||
CriticalSectionWrapper* critical_section_rtp_receiver_;
|
||||
mutable WebRtc_Word64 last_receive_time_;
|
||||
WebRtc_UWord16 last_received_payload_length_;
|
||||
WebRtc_Word8 last_received_payload_type_;
|
||||
WebRtc_Word8 last_received_media_payload_type_;
|
||||
|
||||
CriticalSectionWrapper* _criticalSectionCbs;
|
||||
RtpFeedback* _cbRtpFeedback;
|
||||
RtpData* _cbRtpData;
|
||||
WebRtc_UWord32 packet_timeout_ms_;
|
||||
WebRtc_Word8 red_payload_type_;
|
||||
|
||||
CriticalSectionWrapper* _criticalSectionRTPReceiver;
|
||||
mutable WebRtc_Word64 _lastReceiveTime;
|
||||
WebRtc_UWord16 _lastReceivedPayloadLength;
|
||||
WebRtc_Word8 _lastReceivedPayloadType;
|
||||
WebRtc_Word8 _lastReceivedMediaPayloadType;
|
||||
ModuleRTPUtility::PayloadTypeMap payload_type_map_;
|
||||
RtpHeaderExtensionMap rtp_header_extension_map_;
|
||||
|
||||
WebRtc_UWord32 _packetTimeOutMS;
|
||||
WebRtc_Word8 _redPayloadType;
|
||||
// SSRCs.
|
||||
WebRtc_UWord32 ssrc_;
|
||||
WebRtc_UWord8 num_csrcs_;
|
||||
WebRtc_UWord32 current_remote_csrc_[kRtpCsrcSize];
|
||||
WebRtc_UWord8 num_energy_;
|
||||
WebRtc_UWord8 current_remote_energy_[kRtpCsrcSize];
|
||||
|
||||
ModuleRTPUtility::PayloadTypeMap _payloadTypeMap;
|
||||
RtpHeaderExtensionMap _rtpHeaderExtensionMap;
|
||||
bool use_ssrc_filter_;
|
||||
WebRtc_UWord32 ssrc_filter_;
|
||||
|
||||
// SSRCs
|
||||
WebRtc_UWord32 _SSRC;
|
||||
WebRtc_UWord8 _numCSRCs;
|
||||
WebRtc_UWord32 _currentRemoteCSRC[kRtpCsrcSize];
|
||||
WebRtc_UWord8 _numEnergy;
|
||||
WebRtc_UWord8 _currentRemoteEnergy[kRtpCsrcSize];
|
||||
// Stats on received RTP packets.
|
||||
WebRtc_UWord32 jitter_q4_;
|
||||
mutable WebRtc_UWord32 jitter_max_q4_;
|
||||
mutable WebRtc_UWord32 cumulative_loss_;
|
||||
WebRtc_UWord32 jitter_q4_transmission_time_offset_;
|
||||
|
||||
bool _useSSRCFilter;
|
||||
WebRtc_UWord32 _SSRCFilter;
|
||||
WebRtc_UWord32 local_time_last_received_timestamp_;
|
||||
int64_t last_received_frame_time_ms_;
|
||||
WebRtc_UWord32 last_received_timestamp_;
|
||||
WebRtc_UWord16 last_received_sequence_number_;
|
||||
WebRtc_Word32 last_received_transmission_time_offset_;
|
||||
WebRtc_UWord16 received_seq_first_;
|
||||
WebRtc_UWord16 received_seq_max_;
|
||||
WebRtc_UWord16 received_seq_wraps_;
|
||||
|
||||
// stats on received RTP packets
|
||||
WebRtc_UWord32 _jitterQ4;
|
||||
mutable WebRtc_UWord32 _jitterMaxQ4;
|
||||
mutable WebRtc_UWord32 _cumulativeLoss;
|
||||
WebRtc_UWord32 _jitterQ4TransmissionTimeOffset;
|
||||
// Current counter values.
|
||||
WebRtc_UWord16 received_packet_oh_;
|
||||
WebRtc_UWord32 received_byte_count_;
|
||||
WebRtc_UWord32 received_old_packet_count_;
|
||||
WebRtc_UWord32 received_inorder_packet_count_;
|
||||
|
||||
WebRtc_UWord32 _localTimeLastReceivedTimestamp;
|
||||
int64_t _lastReceivedFrameTimeMs;
|
||||
WebRtc_UWord32 _lastReceivedTimestamp;
|
||||
WebRtc_UWord16 _lastReceivedSequenceNumber;
|
||||
WebRtc_Word32 _lastReceivedTransmissionTimeOffset;
|
||||
WebRtc_UWord16 _receivedSeqFirst;
|
||||
WebRtc_UWord16 _receivedSeqMax;
|
||||
WebRtc_UWord16 _receivedSeqWraps;
|
||||
// Counter values when we sent the last report.
|
||||
mutable WebRtc_UWord32 last_report_inorder_packets_;
|
||||
mutable WebRtc_UWord32 last_report_old_packets_;
|
||||
mutable WebRtc_UWord16 last_report_seq_max_;
|
||||
mutable WebRtc_UWord8 last_report_fraction_lost_;
|
||||
mutable WebRtc_UWord32 last_report_cumulative_lost_; // 24 bits valid.
|
||||
mutable WebRtc_UWord32 last_report_extended_high_seq_num_;
|
||||
mutable WebRtc_UWord32 last_report_jitter_;
|
||||
mutable WebRtc_UWord32 last_report_jitter_transmission_time_offset_;
|
||||
|
||||
// current counter values
|
||||
WebRtc_UWord16 _receivedPacketOH;
|
||||
WebRtc_UWord32 _receivedByteCount;
|
||||
WebRtc_UWord32 _receivedOldPacketCount;
|
||||
WebRtc_UWord32 _receivedInorderPacketCount;
|
||||
NACKMethod nack_method_;
|
||||
|
||||
// counter values when we sent the last report
|
||||
mutable WebRtc_UWord32 _lastReportInorderPackets;
|
||||
mutable WebRtc_UWord32 _lastReportOldPackets;
|
||||
mutable WebRtc_UWord16 _lastReportSeqMax;
|
||||
mutable WebRtc_UWord8 _lastReportFractionLost;
|
||||
mutable WebRtc_UWord32 _lastReportCumulativeLost; // 24 bits valid
|
||||
mutable WebRtc_UWord32 _lastReportExtendedHighSeqNum;
|
||||
mutable WebRtc_UWord32 _lastReportJitter;
|
||||
mutable WebRtc_UWord32 _lastReportJitterTransmissionTimeOffset;
|
||||
|
||||
NACKMethod _nackMethod;
|
||||
|
||||
bool _RTX;
|
||||
WebRtc_UWord32 _ssrcRTX;
|
||||
bool rtx_;
|
||||
WebRtc_UWord32 ssrc_rtx_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_H_
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_H_
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_VIDEO_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_VIDEO_H_
|
||||
|
||||
#include "Bitrate.h"
|
||||
#include "bitrate.h"
|
||||
#include "rtp_receiver.h"
|
||||
#include "rtp_receiver_strategy.h"
|
||||
#include "rtp_rtcp_defines.h"
|
||||
|
@ -31,7 +31,7 @@
|
||||
'../interface/rtp_rtcp.h',
|
||||
'../interface/rtp_rtcp_defines.h',
|
||||
'bitrate.cc',
|
||||
'Bitrate.h',
|
||||
'bitrate.h',
|
||||
'rtp_rtcp_config.h',
|
||||
'rtp_rtcp_impl.cc',
|
||||
'rtp_rtcp_impl.h',
|
||||
|
@ -75,14 +75,14 @@ RTPSender::RTPSender(const WebRtc_Word32 id,
|
||||
memset(_nackByteCount, 0, sizeof(_nackByteCount));
|
||||
memset(_CSRC, 0, sizeof(_CSRC));
|
||||
// We need to seed the random generator.
|
||||
srand( (WebRtc_UWord32)_clock.GetTimeInMS() );
|
||||
srand( (WebRtc_UWord32)clock_.GetTimeInMS() );
|
||||
_ssrc = _ssrcDB.CreateSSRC(); // Can't be 0.
|
||||
|
||||
if (audio) {
|
||||
_audio = new RTPSenderAudio(id, &_clock, this);
|
||||
_audio = new RTPSenderAudio(id, &clock_, this);
|
||||
_audio->RegisterAudioCallback(audio_feedback);
|
||||
} else {
|
||||
_video = new RTPSenderVideo(id, &_clock, this);
|
||||
_video = new RTPSenderVideo(id, &clock_, this);
|
||||
}
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id, "%s created", __FUNCTION__);
|
||||
}
|
||||
@ -576,7 +576,7 @@ int RTPSender::SetSelectiveRetransmissions(uint8_t settings) {
|
||||
void RTPSender::OnReceivedNACK(const WebRtc_UWord16 nackSequenceNumbersLength,
|
||||
const WebRtc_UWord16* nackSequenceNumbers,
|
||||
const WebRtc_UWord16 avgRTT) {
|
||||
const WebRtc_Word64 now = _clock.GetTimeInMS();
|
||||
const WebRtc_Word64 now = clock_.GetTimeInMS();
|
||||
WebRtc_UWord32 bytesReSent = 0;
|
||||
|
||||
// Enough bandwidth to send NACK?
|
||||
@ -700,7 +700,7 @@ void RTPSender::TimeToSendPacket(uint16_t sequence_number,
|
||||
WebRtcRTPHeader rtp_header;
|
||||
rtpParser.Parse(rtp_header);
|
||||
|
||||
int64_t diff_ms = _clock.GetTimeInMS() - capture_time_ms;
|
||||
int64_t diff_ms = clock_.GetTimeInMS() - capture_time_ms;
|
||||
if (UpdateTransmissionTimeOffset(data_buffer, length, rtp_header, diff_ms)) {
|
||||
// Update stored packet in case of receiving a re-transmission request.
|
||||
_packetHistory->ReplaceRTPHeader(data_buffer,
|
||||
@ -738,7 +738,7 @@ WebRtc_Word32 RTPSender::SendToNetwork(uint8_t* buffer,
|
||||
// TODO(holmer): This should be changed all over Video Engine so that negative
|
||||
// time is consider invalid, while 0 is considered a valid time.
|
||||
if (capture_time_ms > 0) {
|
||||
int64_t time_now = _clock.GetTimeInMS();
|
||||
int64_t time_now = clock_.GetTimeInMS();
|
||||
UpdateTransmissionTimeOffset(buffer, payload_length + rtp_header_length,
|
||||
rtp_header, time_now - capture_time_ms);
|
||||
}
|
||||
@ -1007,7 +1007,7 @@ bool RTPSender::UpdateTransmissionTimeOffset(
|
||||
|
||||
void RTPSender::SetSendingStatus(const bool enabled) {
|
||||
if (enabled) {
|
||||
WebRtc_UWord32 freq;
|
||||
WebRtc_UWord32 frequency_hz;
|
||||
if (_audioConfigured) {
|
||||
WebRtc_UWord32 frequency = _audio->AudioFrequency();
|
||||
|
||||
@ -1023,11 +1023,12 @@ void RTPSender::SetSendingStatus(const bool enabled) {
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
freq = frequency;
|
||||
frequency_hz = frequency;
|
||||
} else {
|
||||
freq = 90000; // 90 KHz for all video
|
||||
frequency_hz = kDefaultVideoFrequency;
|
||||
}
|
||||
WebRtc_UWord32 RTPtime = ModuleRTPUtility::GetCurrentRTP(&_clock, freq);
|
||||
WebRtc_UWord32 RTPtime = ModuleRTPUtility::GetCurrentRTP(&clock_,
|
||||
frequency_hz);
|
||||
|
||||
// will be ignored if it's already configured via API
|
||||
SetStartTimestamp(RTPtime, false);
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/Bitrate.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/bitrate.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/ssrc_database.h"
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "video_codec_information.h"
|
||||
#include "forward_error_correction.h"
|
||||
#include "Bitrate.h"
|
||||
#include "bitrate.h"
|
||||
#include "rtp_sender.h"
|
||||
#include "producer_fec.h"
|
||||
|
||||
|
Reference in New Issue
Block a user