Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender.h

Issue 1247293002: Add support for transport wide sequence numbers (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 20 #include "webrtc/modules/pacing/include/paced_sender.h"
21 #include "webrtc/modules/pacing/include/packet_router.h"
21 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" 22 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
22 #include "webrtc/modules/rtp_rtcp/source/bitrate.h" 23 #include "webrtc/modules/rtp_rtcp/source/bitrate.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" 24 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
24 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" 25 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" 26 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
26 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 27 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
27 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" 28 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h"
28 29
29 #define MAX_INIT_RTP_SEQ_NUMBER 32767 // 2^15 -1. 30 #define MAX_INIT_RTP_SEQ_NUMBER 32767 // 2^15 -1.
30 31
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 }; 85 };
85 86
86 class RTPSender : public RTPSenderInterface { 87 class RTPSender : public RTPSenderInterface {
87 public: 88 public:
88 RTPSender(int32_t id, 89 RTPSender(int32_t id,
89 bool audio, 90 bool audio,
90 Clock* clock, 91 Clock* clock,
91 Transport* transport, 92 Transport* transport,
92 RtpAudioFeedback* audio_feedback, 93 RtpAudioFeedback* audio_feedback,
93 PacedSender* paced_sender, 94 PacedSender* paced_sender,
95 PacketRouter* packet_router,
94 BitrateStatisticsObserver* bitrate_callback, 96 BitrateStatisticsObserver* bitrate_callback,
95 FrameCountObserver* frame_count_observer, 97 FrameCountObserver* frame_count_observer,
96 SendSideDelayObserver* send_side_delay_observer); 98 SendSideDelayObserver* send_side_delay_observer);
97 virtual ~RTPSender(); 99 virtual ~RTPSender();
98 100
99 void ProcessBitrate(); 101 void ProcessBitrate();
100 102
101 uint16_t ActualSendBitrateKbit() const override; 103 uint16_t ActualSendBitrateKbit() const override;
102 104
103 uint32_t VideoBitrateSent() const; 105 uint32_t VideoBitrateSent() const;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 int32_t DeregisterRtpHeaderExtension(RTPExtensionType type); 166 int32_t DeregisterRtpHeaderExtension(RTPExtensionType type);
165 167
166 size_t RtpHeaderExtensionTotalLength() const; 168 size_t RtpHeaderExtensionTotalLength() const;
167 169
168 uint16_t BuildRTPHeaderExtension(uint8_t* data_buffer, bool marker_bit) const; 170 uint16_t BuildRTPHeaderExtension(uint8_t* data_buffer, bool marker_bit) const;
169 171
170 uint8_t BuildTransmissionTimeOffsetExtension(uint8_t *data_buffer) const; 172 uint8_t BuildTransmissionTimeOffsetExtension(uint8_t *data_buffer) const;
171 uint8_t BuildAudioLevelExtension(uint8_t* data_buffer) const; 173 uint8_t BuildAudioLevelExtension(uint8_t* data_buffer) const;
172 uint8_t BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const; 174 uint8_t BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const;
173 uint8_t BuildVideoRotationExtension(uint8_t* data_buffer) const; 175 uint8_t BuildVideoRotationExtension(uint8_t* data_buffer) const;
174 uint8_t BuildTransportSequenceNumberExtension(uint8_t* data_buffer) const; 176 uint8_t BuildTransportSequenceNumberExtension(uint8_t* data_buffer,
177 uint16_t sequence_number) const;
178
179 // Verifies that the specified extension is registered, and that it is
180 // present in rtp packet. If extension is not registered kNotRegistered is
181 // returned. If extension cannot be found in the rtp header, or if it is
182 // malformed, kError is returned. Otherwise *extension_offset is set to the
183 // offset of the extension from the beginning of the rtp packet and kOk is
184 // returned.
185 enum class ExtensionStatus {
186 kNotRegistered,
187 kOk,
188 kError,
189 };
190 ExtensionStatus VerifyExtension(RTPExtensionType extension_type,
191 uint8_t* rtp_packet,
192 size_t rtp_packet_length,
193 const RTPHeader& rtp_header,
194 size_t extension_length_bytes,
195 size_t* extension_offset) const
196 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_.get());
175 197
176 bool UpdateAudioLevel(uint8_t* rtp_packet, 198 bool UpdateAudioLevel(uint8_t* rtp_packet,
177 size_t rtp_packet_length, 199 size_t rtp_packet_length,
178 const RTPHeader& rtp_header, 200 const RTPHeader& rtp_header,
179 bool is_voiced, 201 bool is_voiced,
180 uint8_t dBov) const; 202 uint8_t dBov) const;
181 203
182 virtual bool UpdateVideoRotation(uint8_t* rtp_packet, 204 virtual bool UpdateVideoRotation(uint8_t* rtp_packet,
183 size_t rtp_packet_length, 205 size_t rtp_packet_length,
184 const RTPHeader& rtp_header, 206 const RTPHeader& rtp_header,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 size_t* position) const; 360 size_t* position) const;
339 361
340 void UpdateTransmissionTimeOffset(uint8_t* rtp_packet, 362 void UpdateTransmissionTimeOffset(uint8_t* rtp_packet,
341 size_t rtp_packet_length, 363 size_t rtp_packet_length,
342 const RTPHeader& rtp_header, 364 const RTPHeader& rtp_header,
343 int64_t time_diff_ms) const; 365 int64_t time_diff_ms) const;
344 void UpdateAbsoluteSendTime(uint8_t* rtp_packet, 366 void UpdateAbsoluteSendTime(uint8_t* rtp_packet,
345 size_t rtp_packet_length, 367 size_t rtp_packet_length,
346 const RTPHeader& rtp_header, 368 const RTPHeader& rtp_header,
347 int64_t now_ms) const; 369 int64_t now_ms) const;
370 // Update the transport sequence number of the packet using a new sequence
371 // number allocated by PacketRouter. Returns the assigned sequence number,
372 // or 0 if extension could not be updated.
373 uint16_t UpdateTransportSequenceNumber(uint8_t* rtp_packet,
374 size_t rtp_packet_length,
375 const RTPHeader& rtp_header) const;
348 376
349 void UpdateRtpStats(const uint8_t* buffer, 377 void UpdateRtpStats(const uint8_t* buffer,
350 size_t packet_length, 378 size_t packet_length,
351 const RTPHeader& header, 379 const RTPHeader& header,
352 bool is_rtx, 380 bool is_rtx,
353 bool is_retransmit); 381 bool is_retransmit);
354 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const; 382 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const;
355 383
356 Clock* clock_; 384 Clock* clock_;
357 int64_t clock_delta_ms_; 385 int64_t clock_delta_ms_;
358 386
359 rtc::scoped_ptr<BitrateAggregator> bitrates_; 387 rtc::scoped_ptr<BitrateAggregator> bitrates_;
360 Bitrate total_bitrate_sent_; 388 Bitrate total_bitrate_sent_;
361 389
362 int32_t id_; 390 int32_t id_;
363 391
364 const bool audio_configured_; 392 const bool audio_configured_;
365 rtc::scoped_ptr<RTPSenderAudio> audio_; 393 rtc::scoped_ptr<RTPSenderAudio> audio_;
366 rtc::scoped_ptr<RTPSenderVideo> video_; 394 rtc::scoped_ptr<RTPSenderVideo> video_;
367 395
368 PacedSender *paced_sender_; 396 PacedSender* const paced_sender_;
397 PacketRouter* const packet_router_;
369 int64_t last_capture_time_ms_sent_; 398 int64_t last_capture_time_ms_sent_;
370 rtc::scoped_ptr<CriticalSectionWrapper> send_critsect_; 399 rtc::scoped_ptr<CriticalSectionWrapper> send_critsect_;
371 400
372 Transport *transport_; 401 Transport *transport_;
373 bool sending_media_ GUARDED_BY(send_critsect_); 402 bool sending_media_ GUARDED_BY(send_critsect_);
374 403
375 size_t max_payload_length_; 404 size_t max_payload_length_;
376 uint16_t packet_over_head_; 405 uint16_t packet_over_head_;
377 406
378 int8_t payload_type_ GUARDED_BY(send_critsect_); 407 int8_t payload_type_ GUARDED_BY(send_critsect_);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // SetTargetBitrateKbps or GetTargetBitrateKbps. Also remember 459 // SetTargetBitrateKbps or GetTargetBitrateKbps. Also remember
431 // that by the time the function returns there is no guarantee 460 // that by the time the function returns there is no guarantee
432 // that the target bitrate is still valid. 461 // that the target bitrate is still valid.
433 rtc::scoped_ptr<CriticalSectionWrapper> target_bitrate_critsect_; 462 rtc::scoped_ptr<CriticalSectionWrapper> target_bitrate_critsect_;
434 uint32_t target_bitrate_ GUARDED_BY(target_bitrate_critsect_); 463 uint32_t target_bitrate_ GUARDED_BY(target_bitrate_critsect_);
435 }; 464 };
436 465
437 } // namespace webrtc 466 } // namespace webrtc
438 467
439 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ 468 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698