| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
| 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 #include <math.h> | 14 #include <math.h> |
| 15 | 15 |
| 16 #include <map> | 16 #include <map> |
| 17 | 17 |
| 18 #include "webrtc/base/thread_annotations.h" | 18 #include "webrtc/base/thread_annotations.h" |
| 19 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
| 20 #include "webrtc/modules/pacing/include/paced_sender.h" | |
| 21 #include "webrtc/modules/pacing/include/packet_router.h" | |
| 22 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" | 20 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
| 23 #include "webrtc/modules/rtp_rtcp/source/bitrate.h" | 21 #include "webrtc/modules/rtp_rtcp/source/bitrate.h" |
| 24 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
| 25 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" |
| 26 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
| 27 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 28 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" | 26 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" |
| 29 | 27 |
| 30 #define MAX_INIT_RTP_SEQ_NUMBER 32767 // 2^15 -1. | 28 #define MAX_INIT_RTP_SEQ_NUMBER 32767 // 2^15 -1. |
| 31 | 29 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Returns the next sequence number to use for a packet and allocates | 62 // Returns the next sequence number to use for a packet and allocates |
| 65 // 'packets_to_send' number of sequence numbers. It's important all allocated | 63 // 'packets_to_send' number of sequence numbers. It's important all allocated |
| 66 // sequence numbers are used in sequence to avoid perceived packet loss. | 64 // sequence numbers are used in sequence to avoid perceived packet loss. |
| 67 virtual uint16_t AllocateSequenceNumber(uint16_t packets_to_send) = 0; | 65 virtual uint16_t AllocateSequenceNumber(uint16_t packets_to_send) = 0; |
| 68 virtual uint16_t SequenceNumber() const = 0; | 66 virtual uint16_t SequenceNumber() const = 0; |
| 69 virtual size_t MaxPayloadLength() const = 0; | 67 virtual size_t MaxPayloadLength() const = 0; |
| 70 virtual size_t MaxDataPayloadLength() const = 0; | 68 virtual size_t MaxDataPayloadLength() const = 0; |
| 71 virtual uint16_t PacketOverHead() const = 0; | 69 virtual uint16_t PacketOverHead() const = 0; |
| 72 virtual uint16_t ActualSendBitrateKbit() const = 0; | 70 virtual uint16_t ActualSendBitrateKbit() const = 0; |
| 73 | 71 |
| 74 virtual int32_t SendToNetwork( | 72 virtual int32_t SendToNetwork(uint8_t* data_buffer, |
| 75 uint8_t *data_buffer, size_t payload_length, size_t rtp_header_length, | 73 size_t payload_length, |
| 76 int64_t capture_time_ms, StorageType storage, | 74 size_t rtp_header_length, |
| 77 PacedSender::Priority priority) = 0; | 75 int64_t capture_time_ms, |
| 76 StorageType storage, |
| 77 RtpPacketSender::Priority priority) = 0; |
| 78 | 78 |
| 79 virtual bool UpdateVideoRotation(uint8_t* rtp_packet, | 79 virtual bool UpdateVideoRotation(uint8_t* rtp_packet, |
| 80 size_t rtp_packet_length, | 80 size_t rtp_packet_length, |
| 81 const RTPHeader& rtp_header, | 81 const RTPHeader& rtp_header, |
| 82 VideoRotation rotation) const = 0; | 82 VideoRotation rotation) const = 0; |
| 83 virtual bool IsRtpHeaderExtensionRegistered(RTPExtensionType type) = 0; | 83 virtual bool IsRtpHeaderExtensionRegistered(RTPExtensionType type) = 0; |
| 84 virtual CVOMode ActivateCVORtpHeaderExtension() = 0; | 84 virtual CVOMode ActivateCVORtpHeaderExtension() = 0; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 class RTPSender : public RTPSenderInterface { | 87 class RTPSender : public RTPSenderInterface { |
| 88 public: | 88 public: |
| 89 RTPSender(bool audio, | 89 RTPSender(bool audio, |
| 90 Clock* clock, | 90 Clock* clock, |
| 91 Transport* transport, | 91 Transport* transport, |
| 92 RtpAudioFeedback* audio_feedback, | 92 RtpAudioFeedback* audio_feedback, |
| 93 PacedSender* paced_sender, | 93 RtpPacketSender* paced_sender, |
| 94 PacketRouter* packet_router, | 94 SequenceNumberAllocator* sequence_number_allocator, |
| 95 TransportFeedbackObserver* transport_feedback_callback, | 95 TransportFeedbackObserver* transport_feedback_callback, |
| 96 BitrateStatisticsObserver* bitrate_callback, | 96 BitrateStatisticsObserver* bitrate_callback, |
| 97 FrameCountObserver* frame_count_observer, | 97 FrameCountObserver* frame_count_observer, |
| 98 SendSideDelayObserver* send_side_delay_observer); | 98 SendSideDelayObserver* send_side_delay_observer); |
| 99 virtual ~RTPSender(); | 99 virtual ~RTPSender(); |
| 100 | 100 |
| 101 void ProcessBitrate(); | 101 void ProcessBitrate(); |
| 102 | 102 |
| 103 uint16_t ActualSendBitrateKbit() const override; | 103 uint16_t ActualSendBitrateKbit() const override; |
| 104 | 104 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 // Current timestamp. | 251 // Current timestamp. |
| 252 uint32_t Timestamp() const override; | 252 uint32_t Timestamp() const override; |
| 253 uint32_t SSRC() const override; | 253 uint32_t SSRC() const override; |
| 254 | 254 |
| 255 int32_t SendToNetwork(uint8_t* data_buffer, | 255 int32_t SendToNetwork(uint8_t* data_buffer, |
| 256 size_t payload_length, | 256 size_t payload_length, |
| 257 size_t rtp_header_length, | 257 size_t rtp_header_length, |
| 258 int64_t capture_time_ms, | 258 int64_t capture_time_ms, |
| 259 StorageType storage, | 259 StorageType storage, |
| 260 PacedSender::Priority priority) override; | 260 RtpPacketSender::Priority priority) override; |
| 261 | 261 |
| 262 // Audio. | 262 // Audio. |
| 263 | 263 |
| 264 // Send a DTMF tone using RFC 2833 (4733). | 264 // Send a DTMF tone using RFC 2833 (4733). |
| 265 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); | 265 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); |
| 266 | 266 |
| 267 // Set audio packet size, used to determine when it's time to send a DTMF | 267 // Set audio packet size, used to determine when it's time to send a DTMF |
| 268 // packet in silence (CNG). | 268 // packet in silence (CNG). |
| 269 int32_t SetAudioPacketSize(uint16_t packet_size_samples); | 269 int32_t SetAudioPacketSize(uint16_t packet_size_samples); |
| 270 | 270 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 363 |
| 364 void UpdateTransmissionTimeOffset(uint8_t* rtp_packet, | 364 void UpdateTransmissionTimeOffset(uint8_t* rtp_packet, |
| 365 size_t rtp_packet_length, | 365 size_t rtp_packet_length, |
| 366 const RTPHeader& rtp_header, | 366 const RTPHeader& rtp_header, |
| 367 int64_t time_diff_ms) const; | 367 int64_t time_diff_ms) const; |
| 368 void UpdateAbsoluteSendTime(uint8_t* rtp_packet, | 368 void UpdateAbsoluteSendTime(uint8_t* rtp_packet, |
| 369 size_t rtp_packet_length, | 369 size_t rtp_packet_length, |
| 370 const RTPHeader& rtp_header, | 370 const RTPHeader& rtp_header, |
| 371 int64_t now_ms) const; | 371 int64_t now_ms) const; |
| 372 // Update the transport sequence number of the packet using a new sequence | 372 // Update the transport sequence number of the packet using a new sequence |
| 373 // number allocated by PacketRouter. Returns the assigned sequence number, | 373 // number allocated by SequenceNumberAllocator. Returns the assigned sequence |
| 374 // or 0 if extension could not be updated. | 374 // number, or 0 if extension could not be updated. |
| 375 uint16_t UpdateTransportSequenceNumber(uint8_t* rtp_packet, | 375 uint16_t UpdateTransportSequenceNumber(uint8_t* rtp_packet, |
| 376 size_t rtp_packet_length, | 376 size_t rtp_packet_length, |
| 377 const RTPHeader& rtp_header) const; | 377 const RTPHeader& rtp_header) const; |
| 378 | 378 |
| 379 void UpdateRtpStats(const uint8_t* buffer, | 379 void UpdateRtpStats(const uint8_t* buffer, |
| 380 size_t packet_length, | 380 size_t packet_length, |
| 381 const RTPHeader& header, | 381 const RTPHeader& header, |
| 382 bool is_rtx, | 382 bool is_rtx, |
| 383 bool is_retransmit); | 383 bool is_retransmit); |
| 384 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const; | 384 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const; |
| 385 | 385 |
| 386 Clock* clock_; | 386 Clock* clock_; |
| 387 int64_t clock_delta_ms_; | 387 int64_t clock_delta_ms_; |
| 388 | 388 |
| 389 rtc::scoped_ptr<BitrateAggregator> bitrates_; | 389 rtc::scoped_ptr<BitrateAggregator> bitrates_; |
| 390 Bitrate total_bitrate_sent_; | 390 Bitrate total_bitrate_sent_; |
| 391 | 391 |
| 392 const bool audio_configured_; | 392 const bool audio_configured_; |
| 393 rtc::scoped_ptr<RTPSenderAudio> audio_; | 393 rtc::scoped_ptr<RTPSenderAudio> audio_; |
| 394 rtc::scoped_ptr<RTPSenderVideo> video_; | 394 rtc::scoped_ptr<RTPSenderVideo> video_; |
| 395 | 395 |
| 396 PacedSender* const paced_sender_; | 396 RtpPacketSender* const paced_sender_; |
| 397 PacketRouter* const packet_router_; | 397 SequenceNumberAllocator* const sequence_number_allocator_; |
| 398 TransportFeedbackObserver* const transport_feedback_observer_; | 398 TransportFeedbackObserver* const transport_feedback_observer_; |
| 399 int64_t last_capture_time_ms_sent_; | 399 int64_t last_capture_time_ms_sent_; |
| 400 rtc::scoped_ptr<CriticalSectionWrapper> send_critsect_; | 400 rtc::scoped_ptr<CriticalSectionWrapper> send_critsect_; |
| 401 | 401 |
| 402 Transport *transport_; | 402 Transport *transport_; |
| 403 bool sending_media_ GUARDED_BY(send_critsect_); | 403 bool sending_media_ GUARDED_BY(send_critsect_); |
| 404 | 404 |
| 405 size_t max_payload_length_; | 405 size_t max_payload_length_; |
| 406 uint16_t packet_over_head_; | 406 uint16_t packet_over_head_; |
| 407 | 407 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // SetTargetBitrateKbps or GetTargetBitrateKbps. Also remember | 460 // SetTargetBitrateKbps or GetTargetBitrateKbps. Also remember |
| 461 // that by the time the function returns there is no guarantee | 461 // that by the time the function returns there is no guarantee |
| 462 // that the target bitrate is still valid. | 462 // that the target bitrate is still valid. |
| 463 rtc::scoped_ptr<CriticalSectionWrapper> target_bitrate_critsect_; | 463 rtc::scoped_ptr<CriticalSectionWrapper> target_bitrate_critsect_; |
| 464 uint32_t target_bitrate_ GUARDED_BY(target_bitrate_critsect_); | 464 uint32_t target_bitrate_ GUARDED_BY(target_bitrate_critsect_); |
| 465 }; | 465 }; |
| 466 | 466 |
| 467 } // namespace webrtc | 467 } // namespace webrtc |
| 468 | 468 |
| 469 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 469 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
| OLD | NEW |