aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/rtp_rtcp/include
diff options
context:
space:
mode:
Diffstat (limited to 'webrtc/modules/rtp_rtcp/include')
-rw-r--r--webrtc/modules/rtp_rtcp/include/fec_receiver.h46
-rw-r--r--webrtc/modules/rtp_rtcp/include/receive_statistics.h102
-rw-r--r--webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h51
-rw-r--r--webrtc/modules/rtp_rtcp/include/rtp_cvo.h54
-rw-r--r--webrtc/modules/rtp_rtcp/include/rtp_header_parser.h44
-rw-r--r--webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h203
-rw-r--r--webrtc/modules/rtp_rtcp/include/rtp_receiver.h103
-rw-r--r--webrtc/modules/rtp_rtcp/include/rtp_rtcp.h653
-rw-r--r--webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h416
9 files changed, 1672 insertions, 0 deletions
diff --git a/webrtc/modules/rtp_rtcp/include/fec_receiver.h b/webrtc/modules/rtp_rtcp/include/fec_receiver.h
new file mode 100644
index 0000000000..65e85ad7a5
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/include/fec_receiver.h
@@ -0,0 +1,46 @@
+/*
+ * 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_INCLUDE_FEC_RECEIVER_H_
+#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_FEC_RECEIVER_H_
+
+#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
+#include "webrtc/typedefs.h"
+
+namespace webrtc {
+
+struct FecPacketCounter {
+ FecPacketCounter()
+ : num_packets(0),
+ num_fec_packets(0),
+ num_recovered_packets(0) {}
+
+ size_t num_packets; // Number of received packets.
+ size_t num_fec_packets; // Number of received FEC packets.
+ size_t num_recovered_packets; // Number of recovered media packets using FEC.
+};
+
+class FecReceiver {
+ public:
+ static FecReceiver* Create(RtpData* callback);
+
+ virtual ~FecReceiver() {}
+
+ virtual int32_t AddReceivedRedPacket(const RTPHeader& rtp_header,
+ const uint8_t* incoming_rtp_packet,
+ size_t packet_length,
+ uint8_t ulpfec_payload_type) = 0;
+
+ virtual int32_t ProcessReceivedFec() = 0;
+
+ virtual FecPacketCounter GetPacketCounter() const = 0;
+};
+} // namespace webrtc
+#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_FEC_RECEIVER_H_
diff --git a/webrtc/modules/rtp_rtcp/include/receive_statistics.h b/webrtc/modules/rtp_rtcp/include/receive_statistics.h
new file mode 100644
index 0000000000..b4a7cd0de2
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/include/receive_statistics.h
@@ -0,0 +1,102 @@
+/*
+ * 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_INCLUDE_RECEIVE_STATISTICS_H_
+#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_
+
+#include <map>
+
+#include "webrtc/modules/include/module.h"
+#include "webrtc/modules/include/module_common_types.h"
+#include "webrtc/typedefs.h"
+
+namespace webrtc {
+
+class Clock;
+
+class StreamStatistician {
+ public:
+ virtual ~StreamStatistician();
+
+ virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) = 0;
+ virtual void GetDataCounters(size_t* bytes_received,
+ uint32_t* packets_received) const = 0;
+
+ // Gets received stream data counters (includes reset counter values).
+ virtual void GetReceiveStreamDataCounters(
+ StreamDataCounters* data_counters) const = 0;
+
+ virtual uint32_t BitrateReceived() const = 0;
+
+ // Returns true if the packet with RTP header |header| is likely to be a
+ // retransmitted packet, false otherwise.
+ virtual bool IsRetransmitOfOldPacket(const RTPHeader& header,
+ int64_t min_rtt) const = 0;
+
+ // Returns true if |sequence_number| is received in order, false otherwise.
+ virtual bool IsPacketInOrder(uint16_t sequence_number) const = 0;
+};
+
+typedef std::map<uint32_t, StreamStatistician*> StatisticianMap;
+
+class ReceiveStatistics : public Module {
+ public:
+ virtual ~ReceiveStatistics() {}
+
+ static ReceiveStatistics* Create(Clock* clock);
+
+ // Updates the receive statistics with this packet.
+ virtual void IncomingPacket(const RTPHeader& rtp_header,
+ size_t packet_length,
+ bool retransmitted) = 0;
+
+ // Increment counter for number of FEC packets received.
+ virtual void FecPacketReceived(const RTPHeader& header,
+ size_t packet_length) = 0;
+
+ // Returns a map of all statisticians which have seen an incoming packet
+ // during the last two seconds.
+ virtual StatisticianMap GetActiveStatisticians() const = 0;
+
+ // Returns a pointer to the statistician of an ssrc.
+ virtual StreamStatistician* GetStatistician(uint32_t ssrc) const = 0;
+
+ // Sets the max reordering threshold in number of packets.
+ virtual void SetMaxReorderingThreshold(int max_reordering_threshold) = 0;
+
+ // Called on new RTCP stats creation.
+ virtual void RegisterRtcpStatisticsCallback(
+ RtcpStatisticsCallback* callback) = 0;
+
+ // Called on new RTP stats creation.
+ virtual void RegisterRtpStatisticsCallback(
+ StreamDataCountersCallback* callback) = 0;
+};
+
+class NullReceiveStatistics : public ReceiveStatistics {
+ public:
+ void IncomingPacket(const RTPHeader& rtp_header,
+ size_t packet_length,
+ bool retransmitted) override;
+ void FecPacketReceived(const RTPHeader& header,
+ size_t packet_length) override;
+ StatisticianMap GetActiveStatisticians() const override;
+ StreamStatistician* GetStatistician(uint32_t ssrc) const override;
+ int64_t TimeUntilNextProcess() override;
+ int32_t Process() override;
+ void SetMaxReorderingThreshold(int max_reordering_threshold) override;
+ void RegisterRtcpStatisticsCallback(
+ RtcpStatisticsCallback* callback) override;
+ void RegisterRtpStatisticsCallback(
+ StreamDataCountersCallback* callback) override;
+};
+
+} // namespace webrtc
+#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_
diff --git a/webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h b/webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h
new file mode 100644
index 0000000000..56c6e48691
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 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_INCLUDE_REMOTE_NTP_TIME_ESTIMATOR_H_
+#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_REMOTE_NTP_TIME_ESTIMATOR_H_
+
+#include "webrtc/base/scoped_ptr.h"
+#include "webrtc/system_wrappers/include/rtp_to_ntp.h"
+
+namespace webrtc {
+
+class Clock;
+class TimestampExtrapolator;
+
+// RemoteNtpTimeEstimator can be used to estimate a given RTP timestamp's NTP
+// time in local timebase.
+// Note that it needs to be trained with at least 2 RTCP SR (by calling
+// |UpdateRtcpTimestamp|) before it can be used.
+class RemoteNtpTimeEstimator {
+ public:
+ explicit RemoteNtpTimeEstimator(Clock* clock);
+
+ ~RemoteNtpTimeEstimator();
+
+ // Updates the estimator with round trip time |rtt|, NTP seconds |ntp_secs|,
+ // NTP fraction |ntp_frac| and RTP timestamp |rtcp_timestamp|.
+ bool UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac,
+ uint32_t rtp_timestamp);
+
+ // Estimates the NTP timestamp in local timebase from |rtp_timestamp|.
+ // Returns the NTP timestamp in ms when success. -1 if failed.
+ int64_t Estimate(uint32_t rtp_timestamp);
+
+ private:
+ Clock* clock_;
+ rtc::scoped_ptr<TimestampExtrapolator> ts_extrapolator_;
+ RtcpList rtcp_list_;
+ int64_t last_timing_log_ms_;
+ RTC_DISALLOW_COPY_AND_ASSIGN(RemoteNtpTimeEstimator);
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_REMOTE_NTP_TIME_ESTIMATOR_H_
diff --git a/webrtc/modules/rtp_rtcp/include/rtp_cvo.h b/webrtc/modules/rtp_rtcp/include/rtp_cvo.h
new file mode 100644
index 0000000000..2e30d898ec
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/include/rtp_cvo.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015 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_INCLUDE_RTP_CVO_H_
+#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
+
+#include "webrtc/common_video/rotation.h"
+
+namespace webrtc {
+
+// Please refer to http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/
+// 12.07.00_60/ts_126114v120700p.pdf Section 7.4.5. The rotation of a frame is
+// the clockwise angle the frames must be rotated in order to display the frames
+// correctly if the display is rotated in its natural orientation.
+inline uint8_t ConvertVideoRotationToCVOByte(VideoRotation rotation) {
+ switch (rotation) {
+ case kVideoRotation_0:
+ return 0;
+ case kVideoRotation_90:
+ return 1;
+ case kVideoRotation_180:
+ return 2;
+ case kVideoRotation_270:
+ return 3;
+ }
+ assert(false);
+ return 0;
+}
+
+inline VideoRotation ConvertCVOByteToVideoRotation(uint8_t rotation) {
+ switch (rotation) {
+ case 0:
+ return kVideoRotation_0;
+ case 1:
+ return kVideoRotation_90;
+ case 2:
+ return kVideoRotation_180;
+ break;
+ case 3:
+ return kVideoRotation_270;
+ default:
+ assert(false);
+ return kVideoRotation_0;
+ }
+}
+
+} // namespace webrtc
+#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
diff --git a/webrtc/modules/rtp_rtcp/include/rtp_header_parser.h b/webrtc/modules/rtp_rtcp/include/rtp_header_parser.h
new file mode 100644
index 0000000000..329de32611
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/include/rtp_header_parser.h
@@ -0,0 +1,44 @@
+/*
+ * 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_INCLUDE_RTP_HEADER_PARSER_H_
+#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_
+
+#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
+#include "webrtc/typedefs.h"
+
+namespace webrtc {
+
+struct RTPHeader;
+
+class RtpHeaderParser {
+ public:
+ static RtpHeaderParser* Create();
+ virtual ~RtpHeaderParser() {}
+
+ // Returns true if the packet is an RTCP packet, false otherwise.
+ static bool IsRtcp(const uint8_t* packet, size_t length);
+
+ // Parses the packet and stores the parsed packet in |header|. Returns true on
+ // success, false otherwise.
+ // This method is thread-safe in the sense that it can parse multiple packets
+ // at once.
+ virtual bool Parse(const uint8_t* packet,
+ size_t length,
+ RTPHeader* header) const = 0;
+
+ // Registers an RTP header extension and binds it to |id|.
+ virtual bool RegisterRtpHeaderExtension(RTPExtensionType type,
+ uint8_t id) = 0;
+
+ // De-registers an RTP header extension.
+ virtual bool DeregisterRtpHeaderExtension(RTPExtensionType type) = 0;
+};
+} // namespace webrtc
+#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_
diff --git a/webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h b/webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h
new file mode 100644
index 0000000000..fae864107f
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h
@@ -0,0 +1,203 @@
+/*
+ * 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_INCLUDE_RTP_PAYLOAD_REGISTRY_H_
+#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_
+
+#include <map>
+
+#include "webrtc/base/scoped_ptr.h"
+#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
+#include "webrtc/modules/rtp_rtcp/source/rtp_utility.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 RtpUtility::Payload& payload,
+ const uint32_t frequency,
+ const size_t channels,
+ const uint32_t rate) const = 0;
+
+ virtual void UpdatePayloadRate(RtpUtility::Payload* payload,
+ const uint32_t rate) const = 0;
+
+ virtual RtpUtility::Payload* CreatePayloadType(
+ const char payloadName[RTP_PAYLOAD_NAME_SIZE],
+ const int8_t payloadType,
+ const uint32_t frequency,
+ const size_t channels,
+ const uint32_t rate) const = 0;
+
+ virtual int GetPayloadTypeFrequency(
+ const RtpUtility::Payload& payload) const = 0;
+
+ static RTPPayloadStrategy* CreateStrategy(const bool handling_audio);
+
+ protected:
+ RTPPayloadStrategy() {}
+};
+
+class RTPPayloadRegistry {
+ public:
+ // The registry takes ownership of the strategy.
+ explicit RTPPayloadRegistry(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 size_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 size_t channels,
+ const uint32_t rate,
+ int8_t* payload_type) const;
+
+ bool RtxEnabled() const;
+
+ void SetRtxSsrc(uint32_t ssrc);
+
+ bool GetRtxSsrc(uint32_t* ssrc) const;
+
+ void SetRtxPayloadType(int payload_type, int associated_payload_type);
+
+ bool IsRtx(const RTPHeader& header) const;
+
+ // DEPRECATED. Use RestoreOriginalPacket below that takes a uint8_t*
+ // restored_packet, instead of a uint8_t**.
+ // TODO(noahric): Remove this when all callers have been updated.
+ bool RestoreOriginalPacket(uint8_t** restored_packet,
+ const uint8_t* packet,
+ size_t* packet_length,
+ uint32_t original_ssrc,
+ const RTPHeader& header) const;
+
+ bool RestoreOriginalPacket(uint8_t* restored_packet,
+ const uint8_t* packet,
+ size_t* packet_length,
+ uint32_t original_ssrc,
+ const RTPHeader& header) const;
+
+ bool IsRed(const RTPHeader& header) const;
+
+ // Returns true if the media of this RTP packet is encapsulated within an
+ // extra header, such as RTX or RED.
+ bool IsEncapsulated(const RTPHeader& header) const;
+
+ bool GetPayloadSpecifics(uint8_t payload_type, PayloadUnion* payload) const;
+
+ int GetPayloadTypeFrequency(uint8_t payload_type) const;
+
+ // DEPRECATED. Use PayloadTypeToPayload below that returns const Payload*
+ // instead of taking output parameter.
+ // TODO(danilchap): Remove this when all callers have been updated.
+ bool PayloadTypeToPayload(const uint8_t payload_type,
+ RtpUtility::Payload*& payload) const { // NOLINT
+ payload =
+ const_cast<RtpUtility::Payload*>(PayloadTypeToPayload(payload_type));
+ return payload != nullptr;
+ }
+ const RtpUtility::Payload* PayloadTypeToPayload(uint8_t payload_type) const;
+
+ void ResetLastReceivedPayloadTypes() {
+ CriticalSectionScoped cs(crit_sect_.get());
+ last_received_payload_type_ = -1;
+ last_received_media_payload_type_ = -1;
+ }
+
+ // This sets the payload type of the packets being received from the network
+ // on the media SSRC. For instance if packets are encapsulated with RED, this
+ // payload type will be the RED payload type.
+ void SetIncomingPayloadType(const RTPHeader& header);
+
+ // Returns true if the new media payload type has not changed.
+ bool ReportMediaPayloadType(uint8_t media_payload_type);
+
+ int8_t red_payload_type() const {
+ CriticalSectionScoped cs(crit_sect_.get());
+ return red_payload_type_;
+ }
+ int8_t ulpfec_payload_type() const {
+ CriticalSectionScoped cs(crit_sect_.get());
+ return ulpfec_payload_type_;
+ }
+ int8_t last_received_payload_type() const {
+ CriticalSectionScoped cs(crit_sect_.get());
+ return last_received_payload_type_;
+ }
+ void set_last_received_payload_type(int8_t last_received_payload_type) {
+ CriticalSectionScoped cs(crit_sect_.get());
+ last_received_payload_type_ = last_received_payload_type;
+ }
+
+ int8_t last_received_media_payload_type() const {
+ CriticalSectionScoped cs(crit_sect_.get());
+ return last_received_media_payload_type_;
+ }
+
+ bool use_rtx_payload_mapping_on_restore() const {
+ CriticalSectionScoped cs(crit_sect_.get());
+ return use_rtx_payload_mapping_on_restore_;
+ }
+
+ void set_use_rtx_payload_mapping_on_restore(bool val) {
+ CriticalSectionScoped cs(crit_sect_.get());
+ use_rtx_payload_mapping_on_restore_ = val;
+ }
+
+ 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 size_t channels,
+ const uint32_t rate);
+
+ bool IsRtxInternal(const RTPHeader& header) const;
+
+ rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
+ RtpUtility::PayloadTypeMap payload_type_map_;
+ rtc::scoped_ptr<RTPPayloadStrategy> rtp_payload_strategy_;
+ int8_t red_payload_type_;
+ int8_t ulpfec_payload_type_;
+ int8_t incoming_payload_type_;
+ int8_t last_received_payload_type_;
+ int8_t last_received_media_payload_type_;
+ bool rtx_;
+ // TODO(changbin): Remove rtx_payload_type_ once interop with old clients that
+ // only understand one RTX PT is no longer needed.
+ int rtx_payload_type_;
+ // Mapping rtx_payload_type_map_[rtx] = associated.
+ std::map<int, int> rtx_payload_type_map_;
+ // When true, use rtx_payload_type_map_ when restoring RTX packets to get the
+ // correct payload type.
+ bool use_rtx_payload_mapping_on_restore_;
+ uint32_t ssrc_rtx_;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_
diff --git a/webrtc/modules/rtp_rtcp/include/rtp_receiver.h b/webrtc/modules/rtp_rtcp/include/rtp_receiver.h
new file mode 100644
index 0000000000..0640d5cc19
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/include/rtp_receiver.h
@@ -0,0 +1,103 @@
+/*
+ * 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_INCLUDE_RTP_RECEIVER_H_
+#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_
+
+#include "webrtc/modules/rtp_rtcp/include/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(
+ Clock* clock,
+ RtpData* incoming_payload_callback,
+ RtpFeedback* incoming_messages_callback,
+ RTPPayloadRegistry* rtp_payload_registry);
+
+ // Creates an audio-enabled RTP receiver.
+ static RtpReceiver* CreateAudioReceiver(
+ 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 size_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(const RTPHeader& rtp_header,
+ const uint8_t* payload,
+ size_t payload_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 void SetNACKStatus(const NACKMethod method) = 0;
+
+ // Gets the last received timestamp. Returns true if a packet has been
+ // received, false otherwise.
+ virtual bool Timestamp(uint32_t* timestamp) const = 0;
+ // Gets the time in milliseconds when the last timestamp was received.
+ // Returns true if a packet has been received, false otherwise.
+ virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) 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;
+};
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_
diff --git a/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h b/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h
new file mode 100644
index 0000000000..6a7022a94c
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h
@@ -0,0 +1,653 @@
+/*
+ * 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_INCLUDE_RTP_RTCP_H_
+#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
+
+#include <set>
+#include <utility>
+#include <vector>
+
+#include "webrtc/modules/include/module.h"
+#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
+
+namespace webrtc {
+// Forward declarations.
+class ReceiveStatistics;
+class RemoteBitrateEstimator;
+class RtpReceiver;
+class Transport;
+namespace rtcp {
+class TransportFeedback;
+}
+
+class RtpRtcp : public Module {
+ public:
+ struct Configuration {
+ Configuration();
+
+ /* id - Unique identifier of this RTP/RTCP module object
+ * audio - True for a audio version of the RTP/RTCP module
+ * object false will create a video version
+ * clock - The clock to use to read time. If NULL object
+ * will be using the system clock.
+ * incoming_data - Callback object that will receive the incoming
+ * data. May not be NULL; default callback will do
+ * nothing.
+ * incoming_messages - Callback object that will receive the incoming
+ * RTP messages. May not be NULL; default callback
+ * will do nothing.
+ * outgoing_transport - Transport object that will be called when packets
+ * are ready to be sent out on the network
+ * intra_frame_callback - Called when the receiver request a intra frame.
+ * bandwidth_callback - Called when we receive a changed estimate from
+ * the receiver of out stream.
+ * audio_messages - Telephone events. May not be NULL; default
+ * callback will do nothing.
+ * remote_bitrate_estimator - Estimates the bandwidth available for a set of
+ * streams from the same client.
+ * paced_sender - Spread any bursts of packets into smaller
+ * bursts to minimize packet loss.
+ */
+ bool audio;
+ bool receiver_only;
+ Clock* clock;
+ ReceiveStatistics* receive_statistics;
+ Transport* outgoing_transport;
+ RtcpIntraFrameObserver* intra_frame_callback;
+ RtcpBandwidthObserver* bandwidth_callback;
+ TransportFeedbackObserver* transport_feedback_callback;
+ RtcpRttStats* rtt_stats;
+ RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer;
+ RtpAudioFeedback* audio_messages;
+ RemoteBitrateEstimator* remote_bitrate_estimator;
+ RtpPacketSender* paced_sender;
+ TransportSequenceNumberAllocator* transport_sequence_number_allocator;
+ BitrateStatisticsObserver* send_bitrate_observer;
+ FrameCountObserver* send_frame_count_observer;
+ SendSideDelayObserver* send_side_delay_observer;
+ };
+
+ /*
+ * Create a RTP/RTCP module object using the system clock.
+ *
+ * configuration - Configuration of the RTP/RTCP module.
+ */
+ static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
+
+ /**************************************************************************
+ *
+ * Receiver functions
+ *
+ ***************************************************************************/
+
+ virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
+ size_t incoming_packet_length) = 0;
+
+ virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
+
+ /**************************************************************************
+ *
+ * Sender
+ *
+ ***************************************************************************/
+
+ /*
+ * set MTU
+ *
+ * size - Max transfer unit in bytes, default is 1500
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
+
+ /*
+ * set transtport overhead
+ * default is IPv4 and UDP with no encryption
+ *
+ * TCP - true for TCP false UDP
+ * IPv6 - true for IP version 6 false for version 4
+ * authenticationOverhead - number of bytes to leave for an
+ * authentication header
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetTransportOverhead(
+ bool TCP,
+ bool IPV6,
+ uint8_t authenticationOverhead = 0) = 0;
+
+ /*
+ * Get max payload length
+ *
+ * A combination of the configuration MaxTransferUnit and
+ * TransportOverhead.
+ * Does not account FEC/ULP/RED overhead if FEC is enabled.
+ * Does not account for RTP headers
+ */
+ virtual uint16_t MaxPayloadLength() const = 0;
+
+ /*
+ * Get max data payload length
+ *
+ * A combination of the configuration MaxTransferUnit, headers and
+ * TransportOverhead.
+ * Takes into account FEC/ULP/RED overhead if FEC is enabled.
+ * Takes into account RTP headers
+ */
+ virtual uint16_t MaxDataPayloadLength() const = 0;
+
+ /*
+ * set codec name and payload type
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RegisterSendPayload(
+ const CodecInst& voiceCodec) = 0;
+
+ /*
+ * set codec name and payload type
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RegisterSendPayload(
+ const VideoCodec& videoCodec) = 0;
+
+ /*
+ * Unregister a send payload
+ *
+ * payloadType - payload type of codec
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t DeRegisterSendPayload(int8_t payloadType) = 0;
+
+ /*
+ * (De)register RTP header extension type and id.
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
+ uint8_t id) = 0;
+
+ virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
+
+ /*
+ * get start timestamp
+ */
+ virtual uint32_t StartTimestamp() const = 0;
+
+ /*
+ * configure start timestamp, default is a random number
+ *
+ * timestamp - start timestamp
+ */
+ virtual void SetStartTimestamp(uint32_t timestamp) = 0;
+
+ /*
+ * Get SequenceNumber
+ */
+ virtual uint16_t SequenceNumber() const = 0;
+
+ /*
+ * Set SequenceNumber, default is a random number
+ */
+ virtual void SetSequenceNumber(uint16_t seq) = 0;
+
+ // Returns true if the ssrc matched this module, false otherwise.
+ virtual bool SetRtpStateForSsrc(uint32_t ssrc,
+ const RtpState& rtp_state) = 0;
+ virtual bool GetRtpStateForSsrc(uint32_t ssrc, RtpState* rtp_state) = 0;
+
+ /*
+ * Get SSRC
+ */
+ virtual uint32_t SSRC() const = 0;
+
+ /*
+ * configure SSRC, default is a random number
+ */
+ virtual void SetSSRC(uint32_t ssrc) = 0;
+
+ /*
+ * Set CSRC
+ *
+ * csrcs - vector of CSRCs
+ */
+ virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
+
+ /*
+ * Turn on/off sending RTX (RFC 4588). The modes can be set as a combination
+ * of values of the enumerator RtxMode.
+ */
+ virtual void SetRtxSendStatus(int modes) = 0;
+
+ /*
+ * Get status of sending RTX (RFC 4588). The returned value can be
+ * a combination of values of the enumerator RtxMode.
+ */
+ virtual int RtxSendStatus() const = 0;
+
+ // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
+ // only the SSRC is set.
+ virtual void SetRtxSsrc(uint32_t ssrc) = 0;
+
+ // Sets the payload type to use when sending RTX packets. Note that this
+ // doesn't enable RTX, only the payload type is set.
+ virtual void SetRtxSendPayloadType(int payload_type,
+ int associated_payload_type) = 0;
+
+ // Gets the payload type pair of (RTX, associated) to use when sending RTX
+ // packets.
+ virtual std::pair<int, int> RtxSendPayloadType() const = 0;
+
+ /*
+ * sends kRtcpByeCode when going from true to false
+ *
+ * sending - on/off
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetSendingStatus(bool sending) = 0;
+
+ /*
+ * get send status
+ */
+ virtual bool Sending() const = 0;
+
+ /*
+ * Starts/Stops media packets, on by default
+ *
+ * sending - on/off
+ */
+ virtual void SetSendingMediaStatus(bool sending) = 0;
+
+ /*
+ * get send status
+ */
+ virtual bool SendingMedia() const = 0;
+
+ /*
+ * get sent bitrate in Kbit/s
+ */
+ virtual void BitrateSent(uint32_t* totalRate,
+ uint32_t* videoRate,
+ uint32_t* fecRate,
+ uint32_t* nackRate) const = 0;
+
+ /*
+ * Used by the codec module to deliver a video or audio frame for
+ * packetization.
+ *
+ * frameType - type of frame to send
+ * payloadType - payload type of frame to send
+ * timestamp - timestamp of frame to send
+ * payloadData - payload buffer of frame to send
+ * payloadSize - size of payload buffer to send
+ * fragmentation - fragmentation offset data for fragmented frames such
+ * as layers or RED
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SendOutgoingData(
+ FrameType frameType,
+ int8_t payloadType,
+ uint32_t timeStamp,
+ int64_t capture_time_ms,
+ const uint8_t* payloadData,
+ size_t payloadSize,
+ const RTPFragmentationHeader* fragmentation = NULL,
+ const RTPVideoHeader* rtpVideoHdr = NULL) = 0;
+
+ virtual bool TimeToSendPacket(uint32_t ssrc,
+ uint16_t sequence_number,
+ int64_t capture_time_ms,
+ bool retransmission) = 0;
+
+ virtual size_t TimeToSendPadding(size_t bytes) = 0;
+
+ // Called on generation of new statistics after an RTP send.
+ virtual void RegisterSendChannelRtpStatisticsCallback(
+ StreamDataCountersCallback* callback) = 0;
+ virtual StreamDataCountersCallback*
+ GetSendChannelRtpStatisticsCallback() const = 0;
+
+ /**************************************************************************
+ *
+ * RTCP
+ *
+ ***************************************************************************/
+
+ /*
+ * Get RTCP status
+ */
+ virtual RtcpMode RTCP() const = 0;
+
+ /*
+ * configure RTCP status i.e on(compound or non- compound)/off
+ *
+ * method - RTCP method to use
+ */
+ virtual void SetRTCPStatus(RtcpMode method) = 0;
+
+ /*
+ * Set RTCP CName (i.e unique identifier)
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetCNAME(const char* c_name) = 0;
+
+ /*
+ * Get remote CName
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RemoteCNAME(uint32_t remoteSSRC,
+ char cName[RTCP_CNAME_SIZE]) const = 0;
+
+ /*
+ * Get remote NTP
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RemoteNTP(
+ uint32_t *ReceivedNTPsecs,
+ uint32_t *ReceivedNTPfrac,
+ uint32_t *RTCPArrivalTimeSecs,
+ uint32_t *RTCPArrivalTimeFrac,
+ uint32_t *rtcp_timestamp) const = 0;
+
+ /*
+ * AddMixedCNAME
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t AddMixedCNAME(uint32_t SSRC, const char* c_name) = 0;
+
+ /*
+ * RemoveMixedCNAME
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RemoveMixedCNAME(uint32_t SSRC) = 0;
+
+ /*
+ * Get RoundTripTime
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RTT(uint32_t remoteSSRC,
+ int64_t* RTT,
+ int64_t* avgRTT,
+ int64_t* minRTT,
+ int64_t* maxRTT) const = 0;
+
+ /*
+ * Force a send of a RTCP packet
+ * periodic SR and RR are triggered via the process function
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SendRTCP(RTCPPacketType rtcpPacketType) = 0;
+
+ /*
+ * Force a send of a RTCP packet with more than one packet type.
+ * periodic SR and RR are triggered via the process function
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SendCompoundRTCP(
+ const std::set<RTCPPacketType>& rtcpPacketTypes) = 0;
+
+ /*
+ * Good state of RTP receiver inform sender
+ */
+ virtual int32_t SendRTCPReferencePictureSelection(
+ const uint64_t pictureID) = 0;
+
+ /*
+ * Send a RTCP Slice Loss Indication (SLI)
+ * 6 least significant bits of pictureID
+ */
+ virtual int32_t SendRTCPSliceLossIndication(uint8_t pictureID) = 0;
+
+ /*
+ * Statistics of the amount of data sent
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t DataCountersRTP(
+ size_t* bytesSent,
+ uint32_t* packetsSent) const = 0;
+
+ /*
+ * Get send statistics for the RTP and RTX stream.
+ */
+ virtual void GetSendStreamDataCounters(
+ StreamDataCounters* rtp_counters,
+ StreamDataCounters* rtx_counters) const = 0;
+
+ /*
+ * Get packet loss statistics for the RTP stream.
+ */
+ virtual void GetRtpPacketLossStats(
+ bool outgoing,
+ uint32_t ssrc,
+ struct RtpPacketLossStats* loss_stats) const = 0;
+
+ /*
+ * Get received RTCP sender info
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RemoteRTCPStat(RTCPSenderInfo* senderInfo) = 0;
+
+ /*
+ * Get received RTCP report block
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RemoteRTCPStat(
+ std::vector<RTCPReportBlock>* receiveBlocks) const = 0;
+
+ /*
+ * (APP) Application specific data
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetRTCPApplicationSpecificData(uint8_t subType,
+ uint32_t name,
+ const uint8_t* data,
+ uint16_t length) = 0;
+ /*
+ * (XR) VOIP metric
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetRTCPVoIPMetrics(
+ const RTCPVoIPMetric* VoIPMetric) = 0;
+
+ /*
+ * (XR) Receiver Reference Time Report
+ */
+ virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
+
+ virtual bool RtcpXrRrtrStatus() const = 0;
+
+ /*
+ * (REMB) Receiver Estimated Max Bitrate
+ */
+ virtual bool REMB() const = 0;
+
+ virtual void SetREMBStatus(bool enable) = 0;
+
+ virtual void SetREMBData(uint32_t bitrate,
+ const std::vector<uint32_t>& ssrcs) = 0;
+
+ /*
+ * (TMMBR) Temporary Max Media Bit Rate
+ */
+ virtual bool TMMBR() const = 0;
+
+ virtual void SetTMMBRStatus(bool enable) = 0;
+
+ /*
+ * (NACK)
+ */
+
+ /*
+ * TODO(holmer): Propagate this API to VideoEngine.
+ * Returns the currently configured selective retransmission settings.
+ */
+ virtual int SelectiveRetransmissions() const = 0;
+
+ /*
+ * TODO(holmer): Propagate this API to VideoEngine.
+ * Sets the selective retransmission settings, which will decide which
+ * packets will be retransmitted if NACKed. Settings are constructed by
+ * combining the constants in enum RetransmissionMode with bitwise OR.
+ * All packets are retransmitted if kRetransmitAllPackets is set, while no
+ * packets are retransmitted if kRetransmitOff is set.
+ * By default all packets except FEC packets are retransmitted. For VP8
+ * with temporal scalability only base layer packets are retransmitted.
+ *
+ * Returns -1 on failure, otherwise 0.
+ */
+ virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
+
+ /*
+ * Send a Negative acknowledgement packet
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SendNACK(const uint16_t* nackList, uint16_t size) = 0;
+
+ /*
+ * Store the sent packets, needed to answer to a Negative acknowledgement
+ * requests
+ */
+ virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
+
+ // Returns true if the module is configured to store packets.
+ virtual bool StorePackets() const = 0;
+
+ // Called on receipt of RTCP report block from remote side.
+ virtual void RegisterRtcpStatisticsCallback(
+ RtcpStatisticsCallback* callback) = 0;
+ virtual RtcpStatisticsCallback*
+ GetRtcpStatisticsCallback() = 0;
+ // BWE feedback packets.
+ virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
+
+ /**************************************************************************
+ *
+ * Audio
+ *
+ ***************************************************************************/
+
+ /*
+ * set audio packet size, used to determine when it's time to send a DTMF
+ * packet in silence (CNG)
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetAudioPacketSize(uint16_t packetSizeSamples) = 0;
+
+ /*
+ * Send a TelephoneEvent tone using RFC 2833 (4733)
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SendTelephoneEventOutband(uint8_t key,
+ uint16_t time_ms,
+ uint8_t level) = 0;
+
+ /*
+ * Set payload type for Redundant Audio Data RFC 2198
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetSendREDPayloadType(int8_t payloadType) = 0;
+
+ /*
+ * Get payload type for Redundant Audio Data RFC 2198
+ *
+ * return -1 on failure else 0
+ */
+ // DEPRECATED. Use SendREDPayloadType below that takes output parameter
+ // by pointer instead of by reference.
+ // TODO(danilchap): Remove this when all callers have been updated.
+ int32_t SendREDPayloadType(int8_t& payloadType) const { // NOLINT
+ return SendREDPayloadType(&payloadType);
+ }
+ virtual int32_t SendREDPayloadType(int8_t* payload_type) const = 0;
+ /*
+ * Store the audio level in dBov for header-extension-for-audio-level-
+ * indication.
+ * This API shall be called before transmision of an RTP packet to ensure
+ * that the |level| part of the extended RTP header is updated.
+ *
+ * return -1 on failure else 0.
+ */
+ virtual int32_t SetAudioLevel(uint8_t level_dBov) = 0;
+
+ /**************************************************************************
+ *
+ * Video
+ *
+ ***************************************************************************/
+
+ /*
+ * Set the target send bitrate
+ */
+ virtual void SetTargetSendBitrate(uint32_t bitrate_bps) = 0;
+
+ /*
+ * Turn on/off generic FEC
+ */
+ virtual void SetGenericFECStatus(bool enable,
+ uint8_t payload_type_red,
+ uint8_t payload_type_fec) = 0;
+
+ /*
+ * Get generic FEC setting
+ */
+ // DEPRECATED. Use GenericFECStatus below that takes output parameters
+ // by pointers instead of by references.
+ // TODO(danilchap): Remove this when all callers have been updated.
+ void GenericFECStatus(bool& enable, // NOLINT
+ uint8_t& payloadTypeRED, // NOLINT
+ uint8_t& payloadTypeFEC) { // NOLINT
+ GenericFECStatus(&enable, &payloadTypeRED, &payloadTypeFEC);
+ }
+ virtual void GenericFECStatus(bool* enable,
+ uint8_t* payload_type_red,
+ uint8_t* payload_type_fec) = 0;
+
+ virtual int32_t SetFecParameters(
+ const FecProtectionParams* delta_params,
+ const FecProtectionParams* key_params) = 0;
+
+ /*
+ * Set method for requestion a new key frame
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
+
+ /*
+ * send a request for a keyframe
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t RequestKeyFrame() = 0;
+};
+} // namespace webrtc
+#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
diff --git a/webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h
new file mode 100644
index 0000000000..fad97f19cc
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h
@@ -0,0 +1,416 @@
+/*
+ * 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_INCLUDE_RTP_RTCP_DEFINES_H_
+#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_
+
+#include <stddef.h>
+#include <list>
+
+#include "webrtc/modules/include/module_common_types.h"
+#include "webrtc/system_wrappers/include/clock.h"
+#include "webrtc/typedefs.h"
+
+#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 rtcp {
+class TransportFeedback;
+}
+
+const int kVideoPayloadTypeFrequency = 90000;
+
+// Minimum RTP header size in bytes.
+const uint8_t kRtpHeaderSize = 12;
+
+struct AudioPayload {
+ uint32_t frequency;
+ size_t channels;
+ uint32_t rate;
+};
+
+struct VideoPayload {
+ RtpVideoCodecTypes videoCodecType;
+ uint32_t maxRate;
+};
+
+union PayloadUnion {
+ AudioPayload Audio;
+ VideoPayload Video;
+};
+
+enum RTPAliveType { kRtpDead = 0, kRtpNoRtp = 1, kRtpAlive = 2 };
+
+enum ProtectionType {
+ kUnprotectedPacket,
+ kProtectedPacket
+};
+
+enum StorageType {
+ kDontRetransmit,
+ kAllowRetransmission
+};
+
+enum RTPExtensionType {
+ kRtpExtensionNone,
+ kRtpExtensionTransmissionTimeOffset,
+ kRtpExtensionAudioLevel,
+ kRtpExtensionAbsoluteSendTime,
+ kRtpExtensionVideoRotation,
+ kRtpExtensionTransportSequenceNumber,
+};
+
+enum RTCPAppSubTypes { kAppSubtypeBwe = 0x00 };
+
+// TODO(sprang): Make this an enum class once rtcp_receiver has been cleaned up.
+enum RTCPPacketType : uint32_t {
+ kRtcpReport = 0x0001,
+ kRtcpSr = 0x0002,
+ kRtcpRr = 0x0004,
+ kRtcpSdes = 0x0008,
+ kRtcpBye = 0x0010,
+ kRtcpPli = 0x0020,
+ kRtcpNack = 0x0040,
+ kRtcpFir = 0x0080,
+ kRtcpTmmbr = 0x0100,
+ kRtcpTmmbn = 0x0200,
+ kRtcpSrReq = 0x0400,
+ kRtcpXrVoipMetric = 0x0800,
+ kRtcpApp = 0x1000,
+ kRtcpSli = 0x4000,
+ kRtcpRpsi = 0x8000,
+ kRtcpRemb = 0x10000,
+ kRtcpTransmissionTimeOffset = 0x20000,
+ kRtcpXrReceiverReferenceTime = 0x40000,
+ kRtcpXrDlrrReportBlock = 0x80000,
+ kRtcpTransportFeedback = 0x100000,
+};
+
+enum KeyFrameRequestMethod { kKeyFrameReqPliRtcp, kKeyFrameReqFirRtcp };
+
+enum RtpRtcpPacketType { kPacketRtp = 0, kPacketKeepAlive = 1 };
+
+enum NACKMethod { kNackOff = 0, kNackRtcp = 2 };
+
+enum RetransmissionMode : uint8_t {
+ kRetransmitOff = 0x0,
+ kRetransmitFECPackets = 0x1,
+ kRetransmitBaseLayer = 0x2,
+ kRetransmitHigherLayers = 0x4,
+ kRetransmitAllPackets = 0xFF
+};
+
+enum RtxMode {
+ kRtxOff = 0x0,
+ kRtxRetransmitted = 0x1, // Only send retransmissions over RTX.
+ kRtxRedundantPayloads = 0x2 // Preventively send redundant payloads
+ // instead of padding.
+};
+
+const size_t kRtxHeaderSize = 2;
+
+struct RTCPSenderInfo {
+ uint32_t NTPseconds;
+ uint32_t NTPfraction;
+ uint32_t RTPtimeStamp;
+ uint32_t sendPacketCount;
+ uint32_t sendOctetCount;
+};
+
+struct RTCPReportBlock {
+ RTCPReportBlock()
+ : remoteSSRC(0), sourceSSRC(0), fractionLost(0), cumulativeLost(0),
+ extendedHighSeqNum(0), jitter(0), lastSR(0),
+ delaySinceLastSR(0) {}
+
+ RTCPReportBlock(uint32_t remote_ssrc,
+ uint32_t source_ssrc,
+ uint8_t fraction_lost,
+ uint32_t cumulative_lost,
+ uint32_t extended_high_sequence_number,
+ uint32_t jitter,
+ uint32_t last_sender_report,
+ uint32_t delay_since_last_sender_report)
+ : remoteSSRC(remote_ssrc),
+ sourceSSRC(source_ssrc),
+ fractionLost(fraction_lost),
+ cumulativeLost(cumulative_lost),
+ extendedHighSeqNum(extended_high_sequence_number),
+ jitter(jitter),
+ lastSR(last_sender_report),
+ delaySinceLastSR(delay_since_last_sender_report) {}
+
+ // Fields as described by RFC 3550 6.4.2.
+ uint32_t remoteSSRC; // SSRC of sender of this report.
+ uint32_t sourceSSRC; // SSRC of the RTP packet sender.
+ uint8_t fractionLost;
+ uint32_t cumulativeLost; // 24 bits valid.
+ uint32_t extendedHighSeqNum;
+ uint32_t jitter;
+ uint32_t lastSR;
+ uint32_t delaySinceLastSR;
+};
+
+struct RtcpReceiveTimeInfo {
+ // Fields as described by RFC 3611 4.5.
+ uint32_t sourceSSRC;
+ uint32_t lastRR;
+ uint32_t delaySinceLastRR;
+};
+
+typedef std::list<RTCPReportBlock> ReportBlockList;
+
+struct RtpState {
+ RtpState()
+ : sequence_number(0),
+ start_timestamp(0),
+ timestamp(0),
+ capture_time_ms(-1),
+ last_timestamp_time_ms(-1),
+ media_has_been_sent(false) {}
+ uint16_t sequence_number;
+ uint32_t start_timestamp;
+ uint32_t timestamp;
+ int64_t capture_time_ms;
+ int64_t last_timestamp_time_ms;
+ bool media_has_been_sent;
+};
+
+class RtpData {
+ public:
+ virtual ~RtpData() {}
+
+ virtual int32_t OnReceivedPayloadData(const uint8_t* payloadData,
+ const size_t payloadSize,
+ const WebRtcRTPHeader* rtpHeader) = 0;
+
+ virtual bool OnRecoveredPacket(const uint8_t* packet,
+ size_t packet_length) = 0;
+};
+
+class RtpFeedback {
+ public:
+ virtual ~RtpFeedback() {}
+
+ // Receiving payload change or SSRC change. (return success!)
+ /*
+ * channels - number of channels in codec (1 = mono, 2 = stereo)
+ */
+ virtual int32_t OnInitializeDecoder(
+ const int8_t payloadType,
+ const char payloadName[RTP_PAYLOAD_NAME_SIZE],
+ const int frequency,
+ const size_t channels,
+ const uint32_t rate) = 0;
+
+ virtual void OnIncomingSSRCChanged(const uint32_t ssrc) = 0;
+
+ virtual void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) = 0;
+};
+
+class RtpAudioFeedback {
+ public:
+ virtual void OnPlayTelephoneEvent(const uint8_t event,
+ const uint16_t lengthMs,
+ const uint8_t volume) = 0;
+
+ protected:
+ virtual ~RtpAudioFeedback() {}
+};
+
+class RtcpIntraFrameObserver {
+ public:
+ virtual void OnReceivedIntraFrameRequest(uint32_t ssrc) = 0;
+
+ virtual void OnReceivedSLI(uint32_t ssrc,
+ uint8_t picture_id) = 0;
+
+ virtual void OnReceivedRPSI(uint32_t ssrc,
+ uint64_t picture_id) = 0;
+
+ virtual void OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) = 0;
+
+ virtual ~RtcpIntraFrameObserver() {}
+};
+
+class RtcpBandwidthObserver {
+ public:
+ // REMB or TMMBR
+ virtual void OnReceivedEstimatedBitrate(uint32_t bitrate) = 0;
+
+ virtual void OnReceivedRtcpReceiverReport(
+ const ReportBlockList& report_blocks,
+ int64_t rtt,
+ int64_t now_ms) = 0;
+
+ virtual ~RtcpBandwidthObserver() {}
+};
+
+struct PacketInfo {
+ PacketInfo(int64_t arrival_time_ms, uint16_t sequence_number)
+ : PacketInfo(-1, arrival_time_ms, -1, sequence_number, 0, false) {}
+
+ PacketInfo(int64_t arrival_time_ms,
+ int64_t send_time_ms,
+ uint16_t sequence_number,
+ size_t payload_size,
+ bool was_paced)
+ : PacketInfo(-1,
+ arrival_time_ms,
+ send_time_ms,
+ sequence_number,
+ payload_size,
+ was_paced) {}
+
+ PacketInfo(int64_t creation_time_ms,
+ int64_t arrival_time_ms,
+ int64_t send_time_ms,
+ uint16_t sequence_number,
+ size_t payload_size,
+ bool was_paced)
+ : creation_time_ms(creation_time_ms),
+ arrival_time_ms(arrival_time_ms),
+ send_time_ms(send_time_ms),
+ sequence_number(sequence_number),
+ payload_size(payload_size),
+ was_paced(was_paced) {}
+
+ // Time corresponding to when this object was created.
+ int64_t creation_time_ms;
+ // Time corresponding to when the packet was received. Timestamped with the
+ // receiver's clock.
+ int64_t arrival_time_ms;
+ // Time corresponding to when the packet was sent, timestamped with the
+ // sender's clock.
+ int64_t send_time_ms;
+ // Packet identifier, incremented with 1 for every packet generated by the
+ // sender.
+ uint16_t sequence_number;
+ // Size of the packet excluding RTP headers.
+ size_t payload_size;
+ // True if the packet was paced out by the pacer.
+ bool was_paced;
+};
+
+class TransportFeedbackObserver {
+ public:
+ TransportFeedbackObserver() {}
+ virtual ~TransportFeedbackObserver() {}
+
+ // Note: Transport-wide sequence number as sequence number. Arrival time
+ // must be set to 0.
+ virtual void AddPacket(uint16_t sequence_number,
+ size_t length,
+ bool was_paced) = 0;
+
+ virtual void OnTransportFeedback(const rtcp::TransportFeedback& feedback) = 0;
+};
+
+class RtcpRttStats {
+ public:
+ virtual void OnRttUpdate(int64_t rtt) = 0;
+
+ virtual int64_t LastProcessedRtt() const = 0;
+
+ virtual ~RtcpRttStats() {}
+};
+
+// Null object version of RtpFeedback.
+class NullRtpFeedback : public RtpFeedback {
+ public:
+ virtual ~NullRtpFeedback() {}
+
+ int32_t OnInitializeDecoder(const int8_t payloadType,
+ const char payloadName[RTP_PAYLOAD_NAME_SIZE],
+ const int frequency,
+ const size_t channels,
+ const uint32_t rate) override {
+ return 0;
+ }
+
+ void OnIncomingSSRCChanged(const uint32_t ssrc) override {}
+ void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {}
+};
+
+// Null object version of RtpData.
+class NullRtpData : public RtpData {
+ public:
+ virtual ~NullRtpData() {}
+
+ int32_t OnReceivedPayloadData(const uint8_t* payloadData,
+ const size_t payloadSize,
+ const WebRtcRTPHeader* rtpHeader) override {
+ return 0;
+ }
+
+ bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override {
+ return true;
+ }
+};
+
+// Null object version of RtpAudioFeedback.
+class NullRtpAudioFeedback : public RtpAudioFeedback {
+ public:
+ virtual ~NullRtpAudioFeedback() {}
+
+ void OnPlayTelephoneEvent(const uint8_t event,
+ const uint16_t lengthMs,
+ const uint8_t volume) override {}
+};
+
+// Statistics about packet loss for a single directional connection. All values
+// are totals since the connection initiated.
+struct RtpPacketLossStats {
+ // The number of packets lost in events where no adjacent packets were also
+ // lost.
+ uint64_t single_packet_loss_count;
+ // The number of events in which more than one adjacent packet was lost.
+ uint64_t multiple_packet_loss_event_count;
+ // The number of packets lost in events where more than one adjacent packet
+ // was lost.
+ uint64_t multiple_packet_loss_packet_count;
+};
+
+class RtpPacketSender {
+ public:
+ RtpPacketSender() {}
+ virtual ~RtpPacketSender() {}
+
+ enum Priority {
+ kHighPriority = 0, // Pass through; will be sent immediately.
+ kNormalPriority = 2, // Put in back of the line.
+ kLowPriority = 3, // Put in back of the low priority line.
+ };
+ // Low priority packets are mixed with the normal priority packets
+ // while we are paused.
+
+ // Returns true if we send the packet now, else it will add the packet
+ // information to the queue and call TimeToSendPacket when it's time to send.
+ virtual void InsertPacket(Priority priority,
+ uint32_t ssrc,
+ uint16_t sequence_number,
+ int64_t capture_time_ms,
+ size_t bytes,
+ bool retransmission) = 0;
+};
+
+class TransportSequenceNumberAllocator {
+ public:
+ TransportSequenceNumberAllocator() {}
+ virtual ~TransportSequenceNumberAllocator() {}
+
+ virtual uint16_t AllocateSequenceNumber() = 0;
+};
+
+} // namespace webrtc
+#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_