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

Side by Side Diff: webrtc/video/rtp_stream_receiver.h

Issue 1929313002: Removed all RTP dependencies from ViEChannel and renamed class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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_VIDEO_RTP_STREAM_RECEIVER_H_ 11 #ifndef WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_
12 #define WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ 12 #define WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_
13 13
14 #include <list> 14 #include <list>
15 #include <memory> 15 #include <memory>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/constructormagic.h" 19 #include "webrtc/base/constructormagic.h"
20 #include "webrtc/base/criticalsection.h" 20 #include "webrtc/base/criticalsection.h"
21 #include "webrtc/engine_configurations.h" 21 #include "webrtc/engine_configurations.h"
22 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" 22 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
23 #include "webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h" 23 #include "webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" 24 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
27 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
27 #include "webrtc/typedefs.h" 28 #include "webrtc/typedefs.h"
29 #include "webrtc/video_receive_stream.h"
28 30
29 namespace webrtc { 31 namespace webrtc {
30 32
31 class FecReceiver; 33 class FecReceiver;
32 class PacedSender; 34 class PacedSender;
33 class PacketRouter; 35 class PacketRouter;
34 class RemoteNtpTimeEstimator; 36 class RemoteNtpTimeEstimator;
35 class ReceiveStatistics; 37 class ReceiveStatistics;
36 class RemoteBitrateEstimator; 38 class RemoteBitrateEstimator;
39 class RtcpPacketTypeCounterObserver;
37 class RtcpRttStats; 40 class RtcpRttStats;
41 class RtcpStatisticsCallback;
38 class RtpHeaderParser; 42 class RtpHeaderParser;
39 class RTPPayloadRegistry; 43 class RTPPayloadRegistry;
40 class RtpReceiver; 44 class RtpReceiver;
45 class StreamDataCountersCallback;
41 class Transport; 46 class Transport;
42 47
43 namespace vcm { 48 namespace vcm {
44 class VideoReceiver; 49 class VideoReceiver;
45 } // namespace vcm 50 } // namespace vcm
46 51
47 class RtpStreamReceiver : public RtpData, public RtpFeedback { 52 class RtpStreamReceiver : public RtpData, public RtpFeedback,
53 public VCMFrameTypeCallback,
54 public VCMPacketRequestCallback {
48 public: 55 public:
49 RtpStreamReceiver(vcm::VideoReceiver* video_receiver, 56 RtpStreamReceiver(vcm::VideoReceiver* video_receiver,
50 RemoteBitrateEstimator* remote_bitrate_estimator, 57 RemoteBitrateEstimator* remote_bitrate_estimator,
51 Transport* transport, 58 Transport* transport,
52 RtcpRttStats* rtt_stats, 59 RtcpRttStats* rtt_stats,
53 PacedSender* paced_sender, 60 PacedSender* paced_sender,
54 PacketRouter* packet_router); 61 PacketRouter* packet_router,
62 const VideoReceiveStream::Config& config,
63 StreamDataCountersCallback* stream_data_counters_callback,
64 RtcpStatisticsCallback* rtcp_statistics_callback,
65 RtcpPacketTypeCounterObserver* rtcp_counter_observer);
55 ~RtpStreamReceiver(); 66 ~RtpStreamReceiver();
56 67
57 bool SetReceiveCodec(const VideoCodec& video_codec); 68 bool SetReceiveCodec(const VideoCodec& video_codec);
58 69
59 void SetNackStatus(bool enable, int max_nack_reordering_threshold);
60 void SetRtxPayloadType(int payload_type, int associated_payload_type); 70 void SetRtxPayloadType(int payload_type, int associated_payload_type);
61 // If set to true, the RTX payload type mapping supplied in 71 // If set to true, the RTX payload type mapping supplied in
62 // |SetRtxPayloadType| will be used when restoring RTX packets. Without it, 72 // |SetRtxPayloadType| will be used when restoring RTX packets. Without it,
63 // RTX packets will always be restored to the last non-RTX packet payload type 73 // RTX packets will always be restored to the last non-RTX packet payload type
64 // received. 74 // received.
65 void SetUseRtxPayloadMappingOnRestore(bool val); 75 void SetUseRtxPayloadMappingOnRestore(bool val);
66 void SetRtxSsrc(uint32_t ssrc); 76 void SetRtxSsrc(uint32_t ssrc);
67 bool GetRtxSsrc(uint32_t* ssrc) const; 77 bool GetRtxSsrc(uint32_t* ssrc) const;
68 78
69 bool IsFecEnabled() const; 79 bool IsFecEnabled() const;
70 80
71 uint32_t GetRemoteSsrc() const; 81 uint32_t GetRemoteSsrc() const;
72 int GetCsrcs(uint32_t* csrcs) const; 82 int GetCsrcs(uint32_t* csrcs) const;
73 83
74 RtpReceiver* GetRtpReceiver() const; 84 RtpReceiver* GetRtpReceiver() const;
75 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_.get(); } 85 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_.get(); }
76 86
77 void EnableReceiveRtpHeaderExtension(const std::string& extension, int id); 87 void EnableReceiveRtpHeaderExtension(const std::string& extension, int id);
78 void RegisterRtcpPacketTypeCounterObserver(
79 RtcpPacketTypeCounterObserver* observer);
80 88
81 void StartReceive(); 89 void StartReceive();
82 void StopReceive(); 90 void StopReceive();
83 91
84 bool DeliverRtp(const uint8_t* rtp_packet, 92 bool DeliverRtp(const uint8_t* rtp_packet,
85 size_t rtp_packet_length, 93 size_t rtp_packet_length,
86 const PacketTime& packet_time); 94 const PacketTime& packet_time);
87 bool DeliverRtcp(const uint8_t* rtcp_packet, size_t rtcp_packet_length); 95 bool DeliverRtcp(const uint8_t* rtcp_packet, size_t rtcp_packet_length);
88 96
89 // Implements RtpData. 97 // Implements RtpData.
90 int32_t OnReceivedPayloadData(const uint8_t* payload_data, 98 int32_t OnReceivedPayloadData(const uint8_t* payload_data,
91 const size_t payload_size, 99 const size_t payload_size,
92 const WebRtcRTPHeader* rtp_header) override; 100 const WebRtcRTPHeader* rtp_header) override;
93 bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override; 101 bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override;
94 102
95 // Implements RtpFeedback. 103 // Implements RtpFeedback.
96 int32_t OnInitializeDecoder(const int8_t payload_type, 104 int32_t OnInitializeDecoder(const int8_t payload_type,
97 const char payload_name[RTP_PAYLOAD_NAME_SIZE], 105 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
98 const int frequency, 106 const int frequency,
99 const size_t channels, 107 const size_t channels,
100 const uint32_t rate) override; 108 const uint32_t rate) override;
101 void OnIncomingSSRCChanged(const uint32_t ssrc) override; 109 void OnIncomingSSRCChanged(const uint32_t ssrc) override;
102 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {} 110 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {}
103 111
112 // Implements VCMFrameTypeCallback.
113 int32_t RequestKeyFrame() override;
114 int32_t SliceLossIndicationRequest(const uint64_t picture_id) override;
115
116 // Implements VCMPacketRequestCallback.
117 int32_t ResendPackets(const uint16_t* sequenceNumbers,
118 uint16_t length) override;
119
104 ReceiveStatistics* GetReceiveStatistics() const; 120 ReceiveStatistics* GetReceiveStatistics() const;
105 121
106 template <class T>
107 class RegisterableCallback : public T {
108 public:
109 RegisterableCallback() : callback_(nullptr) {}
110
111 void Set(T* callback) {
112 rtc::CritScope lock(&critsect_);
113 callback_ = callback;
114 }
115
116 protected:
117 // Note: this should be implemented with a RW-lock to allow simultaneous
118 // calls into the callback. However that doesn't seem to be needed for the
119 // current type of callbacks covered by this class.
120 rtc::CriticalSection critsect_;
121 T* callback_ GUARDED_BY(critsect_);
122
123 private:
124 RTC_DISALLOW_COPY_AND_ASSIGN(RegisterableCallback);
125 };
126
127 class RegisterableRtcpPacketTypeCounterObserver
128 : public RegisterableCallback<RtcpPacketTypeCounterObserver> {
129 public:
130 void RtcpPacketTypesCounterUpdated(
131 uint32_t ssrc,
132 const RtcpPacketTypeCounter& packet_counter) override {
133 rtc::CritScope lock(&critsect_);
134 if (callback_)
135 callback_->RtcpPacketTypesCounterUpdated(ssrc, packet_counter);
136 }
137
138 private:
139 } rtcp_packet_type_counter_observer_;
140
141 private: 122 private:
142 bool ReceivePacket(const uint8_t* packet, 123 bool ReceivePacket(const uint8_t* packet,
143 size_t packet_length, 124 size_t packet_length,
144 const RTPHeader& header, 125 const RTPHeader& header,
145 bool in_order); 126 bool in_order);
146 // Parses and handles for instance RTX and RED headers. 127 // Parses and handles for instance RTX and RED headers.
147 // This function assumes that it's being called from only one thread. 128 // This function assumes that it's being called from only one thread.
148 bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet, 129 bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
149 size_t packet_length, 130 size_t packet_length,
150 const RTPHeader& header); 131 const RTPHeader& header);
(...skipping 20 matching lines...) Expand all
171 uint8_t restored_packet_[IP_PACKET_SIZE] GUARDED_BY(receive_cs_); 152 uint8_t restored_packet_[IP_PACKET_SIZE] GUARDED_BY(receive_cs_);
172 bool restored_packet_in_use_ GUARDED_BY(receive_cs_); 153 bool restored_packet_in_use_ GUARDED_BY(receive_cs_);
173 int64_t last_packet_log_ms_ GUARDED_BY(receive_cs_); 154 int64_t last_packet_log_ms_ GUARDED_BY(receive_cs_);
174 155
175 const std::unique_ptr<RtpRtcp> rtp_rtcp_; 156 const std::unique_ptr<RtpRtcp> rtp_rtcp_;
176 }; 157 };
177 158
178 } // namespace webrtc 159 } // namespace webrtc
179 160
180 #endif // WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ 161 #endif // WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698