OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 enum Type { kMedia, kFeedback }; | 28 enum Type { kMedia, kFeedback }; |
29 | 29 |
30 Packet(); | 30 Packet(); |
31 Packet(int flow_id, int64_t send_time_us, size_t payload_size); | 31 Packet(int flow_id, int64_t send_time_us, size_t payload_size); |
32 virtual ~Packet(); | 32 virtual ~Packet(); |
33 | 33 |
34 virtual bool operator<(const Packet& rhs) const; | 34 virtual bool operator<(const Packet& rhs) const; |
35 | 35 |
36 virtual int flow_id() const { return flow_id_; } | 36 virtual int flow_id() const { return flow_id_; } |
37 virtual int64_t creation_time_us() const { return creation_time_us_; } | |
38 virtual void set_send_time_us(int64_t send_time_us); | 37 virtual void set_send_time_us(int64_t send_time_us); |
39 virtual int64_t send_time_us() const { return send_time_us_; } | 38 virtual int64_t send_time_us() const { return send_time_us_; } |
40 virtual size_t payload_size() const { return payload_size_; } | 39 virtual size_t payload_size() const { return payload_size_; } |
41 virtual Packet::Type GetPacketType() const = 0; | 40 virtual Packet::Type GetPacketType() const = 0; |
42 void set_sender_timestamp_us(int64_t sender_timestamp_us) { | 41 virtual void set_sender_timestamp_us(int64_t sender_timestamp_us) { |
43 sender_timestamp_us_ = sender_timestamp_us; | 42 sender_timestamp_us_ = sender_timestamp_us; |
44 } | 43 } |
45 int64_t sender_timestamp_us() const { return sender_timestamp_us_; } | 44 virtual int64_t creation_time_ms() const { |
| 45 return (creation_time_us_ + 500) / 1000; |
| 46 } |
| 47 virtual int64_t sender_timestamp_ms() const { |
| 48 return (sender_timestamp_us_ + 500) / 1000; |
| 49 } |
| 50 virtual int64_t send_time_ms() const { return (send_time_us_ + 500) / 1000; } |
46 | 51 |
47 protected: | 52 protected: |
48 int flow_id_; | 53 int flow_id_; |
49 int64_t creation_time_us_; // Time when the packet was created. | 54 int64_t creation_time_us_; // Time when the packet was created. |
50 int64_t send_time_us_; // Time the packet left last processor touching it. | 55 int64_t send_time_us_; // Time the packet left last processor touching it. |
51 int64_t sender_timestamp_us_; // Time the packet left the Sender. | 56 int64_t sender_timestamp_us_; // Time the packet left the Sender. |
52 size_t payload_size_; // Size of the (non-existent, simulated) payload. | 57 size_t payload_size_; // Size of the (non-existent, simulated) payload. |
53 }; | 58 }; |
54 | 59 |
55 class MediaPacket : public Packet { | 60 class MediaPacket : public Packet { |
56 public: | 61 public: |
57 MediaPacket(); | 62 MediaPacket(); |
58 MediaPacket(int flow_id, | 63 MediaPacket(int flow_id, |
59 int64_t send_time_us, | 64 int64_t send_time_us, |
60 size_t payload_size, | 65 size_t payload_size, |
61 uint16_t sequence_number); | 66 uint16_t sequence_number); |
62 MediaPacket(int flow_id, | 67 MediaPacket(int flow_id, |
63 int64_t send_time_us, | 68 int64_t send_time_us, |
64 size_t payload_size, | 69 size_t payload_size, |
65 const RTPHeader& header); | 70 const RTPHeader& header); |
66 MediaPacket(int64_t send_time_us, uint32_t sequence_number); | 71 MediaPacket(int64_t send_time_us, uint32_t sequence_number); |
| 72 |
67 virtual ~MediaPacket() {} | 73 virtual ~MediaPacket() {} |
68 | 74 |
69 int64_t GetAbsSendTimeInMs() const { | 75 int64_t GetAbsSendTimeInMs() const { |
70 int64_t timestamp = header_.extension.absoluteSendTime | 76 int64_t timestamp = header_.extension.absoluteSendTime |
71 << kAbsSendTimeInterArrivalUpshift; | 77 << kAbsSendTimeInterArrivalUpshift; |
72 return 1000.0 * timestamp / static_cast<double>(1 << kInterArrivalShift); | 78 return 1000.0 * timestamp / static_cast<double>(1 << kInterArrivalShift); |
73 } | 79 } |
74 void SetAbsSendTimeMs(int64_t abs_send_time_ms); | 80 void SetAbsSendTimeMs(int64_t abs_send_time_ms); |
75 const RTPHeader& header() const { return header_; } | 81 const RTPHeader& header() const { return header_; } |
76 virtual Packet::Type GetPacketType() const { return kMedia; } | 82 virtual Packet::Type GetPacketType() const { return kMedia; } |
77 uint16_t sequence_number() const { return header_.sequenceNumber; } | 83 uint16_t sequence_number() const { return header_.sequenceNumber; } |
78 int64_t send_time_ms() const { return send_time_us_ / 1000; } | |
79 | 84 |
80 private: | 85 private: |
81 static const int kAbsSendTimeFraction = 18; | 86 static const int kAbsSendTimeFraction = 18; |
82 static const int kAbsSendTimeInterArrivalUpshift = 8; | 87 static const int kAbsSendTimeInterArrivalUpshift = 8; |
83 static const int kInterArrivalShift = | 88 static const int kInterArrivalShift = |
84 kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift; | 89 kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift; |
85 | 90 |
86 RTPHeader header_; | 91 RTPHeader header_; |
87 }; | 92 }; |
88 | 93 |
89 class FeedbackPacket : public Packet { | 94 class FeedbackPacket : public Packet { |
90 public: | 95 public: |
91 FeedbackPacket(int flow_id, | 96 FeedbackPacket(int flow_id, |
92 int64_t this_send_time_us, | 97 int64_t this_send_time_us, |
93 int64_t latest_send_time_ms) | 98 int64_t latest_send_time_ms) |
94 : Packet(flow_id, this_send_time_us, 0), | 99 : Packet(flow_id, this_send_time_us, 0), |
95 latest_send_time_ms_(latest_send_time_ms) {} | 100 latest_send_time_ms_(latest_send_time_ms) {} |
96 virtual ~FeedbackPacket() {} | 101 virtual ~FeedbackPacket() {} |
97 | 102 |
98 virtual Packet::Type GetPacketType() const { return kFeedback; } | 103 virtual Packet::Type GetPacketType() const { return kFeedback; } |
99 int64_t latest_send_time_ms() const { return latest_send_time_ms_; } | 104 int64_t latest_send_time_ms() const { return latest_send_time_ms_; } |
100 | 105 |
101 private: | 106 private: |
102 int64_t latest_send_time_ms_; // Time stamp for the latest sent packet. | 107 int64_t latest_send_time_ms_; // Time stamp for the latest sent FbPacket. |
103 }; | 108 }; |
104 | 109 |
105 class RembFeedback : public FeedbackPacket { | 110 class RembFeedback : public FeedbackPacket { |
106 public: | 111 public: |
107 RembFeedback(int flow_id, | 112 RembFeedback(int flow_id, |
108 int64_t send_time_us, | 113 int64_t send_time_us, |
109 int64_t latest_send_time_ms, | 114 int64_t latest_send_time_ms, |
110 uint32_t estimated_bps, | 115 uint32_t estimated_bps, |
111 RTCPReportBlock report_block); | 116 RTCPReportBlock report_block); |
112 virtual ~RembFeedback() {} | 117 virtual ~RembFeedback() {} |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 }; | 192 }; |
188 | 193 |
189 typedef std::list<Packet*> Packets; | 194 typedef std::list<Packet*> Packets; |
190 typedef std::list<Packet*>::iterator PacketsIt; | 195 typedef std::list<Packet*>::iterator PacketsIt; |
191 typedef std::list<Packet*>::const_iterator PacketsConstIt; | 196 typedef std::list<Packet*>::const_iterator PacketsConstIt; |
192 | 197 |
193 } // namespace bwe | 198 } // namespace bwe |
194 } // namespace testing | 199 } // namespace testing |
195 } // namespace webrtc | 200 } // namespace webrtc |
196 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_H_ | 201 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_H_ |
OLD | NEW |