Update talk to 50918584.

Together with Stefan's http://review.webrtc.org/1960004/.

R=mallinath@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4556 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
wu@webrtc.org
2013-08-15 23:38:54 +00:00
parent dde7d4c6ed
commit 822fbd8b68
108 changed files with 2926 additions and 4301 deletions

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2013 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_INTERFACE_RECEIVE_STATISTICS_H_
#define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RECEIVE_STATISTICS_H_
#include "webrtc/modules/interface/module.h"
#include "webrtc/modules/interface/module_common_types.h"
#include "webrtc/typedefs.h"
namespace webrtc {
class Clock;
class ReceiveStatistics : public Module {
public:
struct RtpReceiveStatistics {
uint8_t fraction_lost;
uint32_t cumulative_lost;
uint32_t extended_max_sequence_number;
uint32_t jitter;
uint32_t max_jitter;
};
virtual ~ReceiveStatistics() {}
static ReceiveStatistics* Create(Clock* clock);
virtual void IncomingPacket(const RTPHeader& rtp_header, size_t bytes,
bool retransmitted, bool in_order) = 0;
virtual bool Statistics(RtpReceiveStatistics* statistics, bool reset) = 0;
virtual bool Statistics(RtpReceiveStatistics* statistics, int32_t* missing,
bool reset) = 0;
virtual void GetDataCounters(uint32_t* bytes_received,
uint32_t* packets_received) const = 0;
virtual uint32_t BitrateReceived() = 0;
virtual void ResetStatistics() = 0;
virtual void ResetDataCounters() = 0;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RECEIVE_STATISTICS_H_

View File

@ -0,0 +1,126 @@
/*
* Copyright (c) 2013 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_INTERFACE_RTP_PAYLOAD_REGISTRY_H_
#define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_PAYLOAD_REGISTRY_H_
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
namespace webrtc {
// This strategy deals with the audio/video-specific aspects
// of payload handling.
class RTPPayloadStrategy {
public:
virtual ~RTPPayloadStrategy() {}
virtual bool CodecsMustBeUnique() const = 0;
virtual bool PayloadIsCompatible(
const ModuleRTPUtility::Payload& payload,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate) const = 0;
virtual void UpdatePayloadRate(
ModuleRTPUtility::Payload* payload,
const uint32_t rate) const = 0;
virtual ModuleRTPUtility::Payload* CreatePayloadType(
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const int8_t payloadType,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate) const = 0;
virtual int GetPayloadTypeFrequency(
const ModuleRTPUtility::Payload& payload) const = 0;
static RTPPayloadStrategy* CreateStrategy(const bool handling_audio);
protected:
RTPPayloadStrategy() {}
};
class RTPPayloadRegistry {
public:
// The registry takes ownership of the strategy.
RTPPayloadRegistry(const int32_t id,
RTPPayloadStrategy* rtp_payload_strategy);
~RTPPayloadRegistry();
int32_t RegisterReceivePayload(
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int8_t payload_type,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate,
bool* created_new_payload_type);
int32_t DeRegisterReceivePayload(
const int8_t payload_type);
int32_t ReceivePayloadType(
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate,
int8_t* payload_type) const;
bool GetPayloadSpecifics(uint8_t payload_type, PayloadUnion* payload) const;
int GetPayloadTypeFrequency(uint8_t payload_type) const;
bool PayloadTypeToPayload(
const uint8_t payload_type,
ModuleRTPUtility::Payload*& payload) const;
void ResetLastReceivedPayloadTypes() {
last_received_payload_type_ = -1;
last_received_media_payload_type_ = -1;
}
// Returns true if the new media payload type has not changed.
bool ReportMediaPayloadType(uint8_t media_payload_type);
int8_t red_payload_type() const { return red_payload_type_; }
int8_t last_received_payload_type() const {
return last_received_payload_type_;
}
void set_last_received_payload_type(int8_t last_received_payload_type) {
last_received_payload_type_ = last_received_payload_type;
}
int8_t last_received_media_payload_type() const {
return last_received_media_payload_type_;
};
private:
// Prunes the payload type map of the specific payload type, if it exists.
void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const size_t payload_name_length,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate);
ModuleRTPUtility::PayloadTypeMap payload_type_map_;
int32_t id_;
scoped_ptr<RTPPayloadStrategy> rtp_payload_strategy_;
int8_t red_payload_type_;
int8_t last_received_payload_type_;
int8_t last_received_media_payload_type_;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_PAYLOAD_REGISTRY_H_

View File

@ -0,0 +1,120 @@
/*
* 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_INTERFACE_RTP_RECEIVER_H_
#define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RECEIVER_H_
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/typedefs.h"
namespace webrtc {
class RTPPayloadRegistry;
class TelephoneEventHandler {
public:
virtual ~TelephoneEventHandler() {}
// The following three methods implement the TelephoneEventHandler interface.
// Forward DTMFs to decoder for playout.
virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0;
// Is forwarding of outband telephone events turned on/off?
virtual bool TelephoneEventForwardToDecoder() const = 0;
// Is TelephoneEvent configured with payload type payload_type
virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0;
};
class RtpReceiver {
public:
// Creates a video-enabled RTP receiver.
static RtpReceiver* CreateVideoReceiver(
int id, Clock* clock,
RtpData* incoming_payload_callback,
RtpFeedback* incoming_messages_callback,
RTPPayloadRegistry* rtp_payload_registry);
// Creates an audio-enabled RTP receiver.
static RtpReceiver* CreateAudioReceiver(
int id, Clock* clock,
RtpAudioFeedback* incoming_audio_feedback,
RtpData* incoming_payload_callback,
RtpFeedback* incoming_messages_callback,
RTPPayloadRegistry* rtp_payload_registry);
virtual ~RtpReceiver() {}
// Returns a TelephoneEventHandler if available.
virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
// Registers a receive payload in the payload registry and notifies the media
// receiver strategy.
virtual int32_t RegisterReceivePayload(
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int8_t payload_type,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate) = 0;
// De-registers |payload_type| from the payload registry.
virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0;
// Parses the media specific parts of an RTP packet and updates the receiver
// state. This for instance means that any changes in SSRC and payload type is
// detected and acted upon.
virtual bool IncomingRtpPacket(RTPHeader* rtp_header,
const uint8_t* incoming_rtp_packet,
int incoming_rtp_packet_length,
PayloadUnion payload_specific,
bool in_order) = 0;
// Returns the currently configured NACK method.
virtual NACKMethod NACK() const = 0;
// Turn negative acknowledgement (NACK) requests on/off.
virtual int32_t SetNACKStatus(const NACKMethod method,
int max_reordering_threshold) = 0;
// Returns the last received timestamp.
virtual uint32_t Timestamp() const = 0;
// Returns the time in milliseconds when the last timestamp was received.
virtual int32_t LastReceivedTimeMs() const = 0;
// Returns the remote SSRC of the currently received RTP stream.
virtual uint32_t SSRC() const = 0;
// Returns the current remote CSRCs.
virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
// Returns the current energy of the RTP stream received.
virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0;
// Enable/disable RTX and set the SSRC to be used.
virtual void SetRTXStatus(bool enable, uint32_t ssrc) = 0;
// Returns the current RTX status and the SSRC and payload type used.
virtual void RTXStatus(bool* enable, uint32_t* ssrc,
int* payload_type) const = 0;
// Sets the RTX payload type.
virtual void SetRtxPayloadType(int payload_type) = 0;
// Returns true if the packet with RTP header |header| is likely to be a
// retransmitted packet, false otherwise.
virtual bool RetransmitOfOldPacket(const RTPHeader& header, int jitter,
int min_rtt) const = 0;
// Returns true if |sequence_number| is received in order, false otherwise.
virtual bool InOrderPacket(const uint16_t sequence_number) const = 0;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RECEIVER_H_

View File

@ -19,8 +19,9 @@
namespace webrtc {
// Forward declarations.
class PacedSender;
class ReceiveStatistics;
class RemoteBitrateEstimator;
class RemoteBitrateObserver;
class RtpReceiver;
class Transport;
class RtpRtcp : public Module {
@ -57,8 +58,7 @@ class RtpRtcp : public Module {
bool audio;
Clock* clock;
RtpRtcp* default_module;
RtpData* incoming_data;
RtpFeedback* incoming_messages;
ReceiveStatistics* receive_statistics;
Transport* outgoing_transport;
RtcpFeedback* rtcp_feedback;
RtcpIntraFrameObserver* intra_frame_callback;
@ -68,6 +68,7 @@ class RtpRtcp : public Module {
RemoteBitrateEstimator* remote_bitrate_estimator;
PacedSender* paced_sender;
};
/*
* Create a RTP/RTCP module object using the system clock.
*
@ -81,174 +82,11 @@ class RtpRtcp : public Module {
*
***************************************************************************/
/*
* configure a RTP packet timeout value
*
* RTPtimeoutMS - time in milliseconds after last received RTP packet
* RTCPtimeoutMS - time in milliseconds after last received RTCP packet
*
* return -1 on failure else 0
*/
virtual int32_t SetPacketTimeout(
const uint32_t RTPtimeoutMS,
const uint32_t RTCPtimeoutMS) = 0;
/*
* Set periodic dead or alive notification
*
* enable - turn periodic dead or alive notification on/off
* sampleTimeSeconds - sample interval in seconds for dead or alive
* notifications
*
* return -1 on failure else 0
*/
virtual int32_t SetPeriodicDeadOrAliveStatus(
const bool enable,
const uint8_t sampleTimeSeconds) = 0;
/*
* Get periodic dead or alive notification status
*
* enable - periodic dead or alive notification on/off
* sampleTimeSeconds - sample interval in seconds for dead or alive
* notifications
*
* return -1 on failure else 0
*/
virtual int32_t PeriodicDeadOrAliveStatus(
bool& enable,
uint8_t& sampleTimeSeconds) = 0;
/*
* set voice codec name and payload type
*
* return -1 on failure else 0
*/
virtual int32_t RegisterReceivePayload(
const CodecInst& voiceCodec) = 0;
/*
* set video codec name and payload type
*
* return -1 on failure else 0
*/
virtual int32_t RegisterReceivePayload(
const VideoCodec& videoCodec) = 0;
/*
* get payload type for a voice codec
*
* return -1 on failure else 0
*/
virtual int32_t ReceivePayloadType(
const CodecInst& voiceCodec,
int8_t* plType) = 0;
/*
* get payload type for a video codec
*
* return -1 on failure else 0
*/
virtual int32_t ReceivePayloadType(
const VideoCodec& videoCodec,
int8_t* plType) = 0;
/*
* Remove a registered payload type from list of accepted payloads
*
* payloadType - payload type of codec
*
* return -1 on failure else 0
*/
virtual int32_t DeRegisterReceivePayload(
const int8_t payloadType) = 0;
/*
* Get last received remote timestamp
*/
virtual uint32_t RemoteTimestamp() const = 0;
/*
* Get the local time of the last received remote timestamp
*/
virtual int64_t LocalTimeOfRemoteTimeStamp() const = 0;
/*
* Get the current estimated remote timestamp
*
* timestamp - estimated timestamp
*
* return -1 on failure else 0
*/
virtual int32_t EstimatedRemoteTimeStamp(
uint32_t& timestamp) const = 0;
/*
* Get incoming SSRC
*/
virtual uint32_t RemoteSSRC() const = 0;
/*
* Get remote CSRC
*
* arrOfCSRC - array that will receive the CSRCs
*
* return -1 on failure else the number of valid entries in the list
*/
virtual int32_t RemoteCSRCs(
uint32_t arrOfCSRC[kRtpCsrcSize]) const = 0;
/*
* get the currently configured SSRC filter
*
* allowedSSRC - SSRC that will be allowed through
*
* return -1 on failure else 0
*/
virtual int32_t SSRCFilter(uint32_t& allowedSSRC) const = 0;
/*
* set a SSRC to be used as a filter for incoming RTP streams
*
* allowedSSRC - SSRC that will be allowed through
*
* return -1 on failure else 0
*/
virtual int32_t SetSSRCFilter(const bool enable,
const uint32_t allowedSSRC) = 0;
/*
* Turn on/off receiving RTX (RFC 4588) on a specific SSRC.
*/
virtual int32_t SetRTXReceiveStatus(bool enable, uint32_t SSRC) = 0;
// Sets the payload type to expected for received RTX packets. Note
// that this doesn't enable RTX, only the payload type is set.
virtual void SetRtxReceivePayloadType(int payload_type) = 0;
/*
* Get status of receiving RTX (RFC 4588) on a specific SSRC.
*/
virtual int32_t RTXReceiveStatus(bool* enable,
uint32_t* SSRC,
int* payloadType) const = 0;
/*
* called by the network module when we receive a packet
*
* incomingPacket - incoming packet buffer
* packetLength - length of incoming buffer
* parsed_rtp_header - the parsed RTP header
*
* return -1 on failure else 0
*/
virtual int32_t IncomingRtpPacket(const uint8_t* incomingPacket,
const uint16_t packetLength,
const RTPHeader& parsed_rtp_header) = 0;
virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
uint16_t incoming_packet_length) = 0;
virtual void SetRemoteSSRC(const uint32_t ssrc) = 0;
/**************************************************************************
*
* Sender
@ -608,32 +446,6 @@ class RtpRtcp : public Module {
virtual int32_t SendRTCPSliceLossIndication(
const uint8_t pictureID) = 0;
/*
* Reset RTP statistics
*
* return -1 on failure else 0
*/
virtual int32_t ResetStatisticsRTP() = 0;
/*
* statistics of our localy created statistics of the received RTP stream
*
* return -1 on failure else 0
*/
virtual int32_t StatisticsRTP(
uint8_t* fraction_lost, // scale 0 to 255
uint32_t* cum_lost, // number of lost packets
uint32_t* ext_max, // highest sequence number received
uint32_t* jitter,
uint32_t* max_jitter = NULL) const = 0;
/*
* Reset RTP data counters for the receiving side
*
* return -1 on failure else 0
*/
virtual int32_t ResetReceiveDataCountersRTP() = 0;
/*
* Reset RTP data counters for the sending side
*
@ -648,9 +460,7 @@ class RtpRtcp : public Module {
*/
virtual int32_t DataCountersRTP(
uint32_t* bytesSent,
uint32_t* packetsSent,
uint32_t* bytesReceived,
uint32_t* packetsReceived) const = 0;
uint32_t* packetsSent) const = 0;
/*
* Get received RTCP sender info
*
@ -731,18 +541,6 @@ class RtpRtcp : public Module {
/*
* (NACK)
*/
virtual NACKMethod NACK() const = 0;
/*
* Turn negative acknowledgement requests on/off
* |max_reordering_threshold| should be set to how much a retransmitted
* packet can be expected to be reordered (in sequence numbers) compared to
* a packet which has not been retransmitted.
*
* return -1 on failure else 0
*/
virtual int32_t SetNACKStatus(const NACKMethod method,
int max_reordering_threshold) = 0;
/*
* TODO(holmer): Propagate this API to VideoEngine.
@ -782,6 +580,9 @@ class RtpRtcp : public Module {
const bool enable,
const uint16_t numberToStore) = 0;
// Returns true if the module is configured to store packets.
virtual bool StorePackets() const = 0;
/**************************************************************************
*
* Audio
@ -797,19 +598,6 @@ class RtpRtcp : public Module {
virtual int32_t SetAudioPacketSize(
const uint16_t packetSizeSamples) = 0;
/*
* Forward DTMF to decoder for playout.
*
* return -1 on failure else 0
*/
virtual int SetTelephoneEventForwardToDecoder(bool forwardToDecoder) = 0;
/*
* Returns true if received DTMF events are forwarded to the decoder using
* the OnPlayTelephoneEvent callback.
*/
virtual bool TelephoneEventForwardToDecoder() const = 0;
/*
* SendTelephoneEventActive
*

View File

@ -11,22 +11,39 @@
#ifndef WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RTCP_DEFINES_H_
#define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RTCP_DEFINES_H_
#include <stddef.h>
#include "webrtc/modules/interface/module_common_types.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/typedefs.h"
#ifndef NULL
#define NULL 0
#endif
#define RTCP_CNAME_SIZE 256 // RFC 3550 page 44, including null termination
#define IP_PACKET_SIZE 1500 // we assume ethernet
#define MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS 10
#define TIMEOUT_SEI_MESSAGES_MS 30000 // in milliseconds
namespace webrtc{
namespace webrtc {
const int32_t kDefaultVideoFrequency = 90000;
const int kVideoPayloadTypeFrequency = 90000;
struct AudioPayload
{
uint32_t frequency;
uint8_t channels;
uint32_t rate;
};
struct VideoPayload
{
RtpVideoCodecTypes videoCodecType;
uint32_t maxRate;
};
union PayloadUnion
{
AudioPayload Audio;
VideoPayload Video;
};
enum RTCPMethod
{
@ -145,6 +162,9 @@ public:
const uint8_t* payloadData,
const uint16_t payloadSize,
const WebRtcRTPHeader* rtpHeader) = 0;
virtual bool OnRecoveredPacket(const uint8_t* packet,
int packet_length) = 0;
protected:
virtual ~RtpData() {}
};
@ -162,8 +182,6 @@ public:
const int32_t /*id*/,
const RTCPVoIPMetric* /*metric*/) {};
virtual void OnRTCPPacketTimeout(const int32_t /*id*/) {};
virtual void OnReceiveReportReceived(const int32_t id,
const uint32_t senderSSRC) {};
@ -186,14 +204,6 @@ public:
const uint8_t channels,
const uint32_t rate) = 0;
virtual void OnPacketTimeout(const int32_t id) = 0;
virtual void OnReceivedPacket(const int32_t id,
const RtpRtcpPacketType packetType) = 0;
virtual void OnPeriodicDeadOrAlive(const int32_t id,
const RTPAliveType alive) = 0;
virtual void OnIncomingSSRCChanged( const int32_t id,
const uint32_t SSRC) = 0;
@ -201,6 +211,8 @@ public:
const uint32_t CSRC,
const bool added) = 0;
virtual void ResetStatistics() = 0;
protected:
virtual ~RtpFeedback() {}
};
@ -268,32 +280,32 @@ class NullRtpFeedback : public RtpFeedback {
return 0;
}
virtual void OnPacketTimeout(const int32_t id) OVERRIDE {}
virtual void OnReceivedPacket(const int32_t id,
const RtpRtcpPacketType packetType) OVERRIDE {}
virtual void OnPeriodicDeadOrAlive(const int32_t id,
const RTPAliveType alive) OVERRIDE {}
virtual void OnIncomingSSRCChanged(const int32_t id,
const uint32_t SSRC) OVERRIDE {}
virtual void OnIncomingSSRCChanged(const int32_t id,
const uint32_t SSRC) OVERRIDE {}
virtual void OnIncomingCSRCChanged(const int32_t id,
const uint32_t CSRC,
const bool added) OVERRIDE {}
virtual void ResetStatistics() OVERRIDE {}
};
// Null object version of RtpData.
class NullRtpData : public RtpData {
public:
virtual ~NullRtpData() {}
virtual int32_t OnReceivedPayloadData(
const uint8_t* payloadData,
const uint16_t payloadSize,
const WebRtcRTPHeader* rtpHeader) OVERRIDE {
return 0;
}
return 0;
}
virtual bool OnRecoveredPacket(const uint8_t* packet,
int packet_length) {
return true;
}
};
// Null object version of RtpAudioFeedback.