| 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 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return payload; | 72 return payload; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer, | 75 void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer, |
| 76 size_t payload_length, | 76 size_t payload_length, |
| 77 size_t rtp_header_length, | 77 size_t rtp_header_length, |
| 78 uint16_t seq_num, | 78 uint16_t seq_num, |
| 79 uint32_t capture_timestamp, | 79 uint32_t capture_timestamp, |
| 80 int64_t capture_time_ms, | 80 int64_t capture_time_ms, |
| 81 StorageType storage) { | 81 StorageType storage) { |
| 82 if (!rtp_sender_->SendToNetwork(data_buffer, payload_length, | 82 if (rtp_sender_->SendToNetwork(data_buffer, payload_length, rtp_header_length, |
| 83 rtp_header_length, capture_time_ms, storage, | 83 capture_time_ms, storage, |
| 84 RtpPacketSender::kLowPriority)) { | 84 RtpPacketSender::kLowPriority) == 0) { |
| 85 rtc::CritScope cs(&stats_crit_); |
| 86 video_bitrate_.Update(payload_length + rtp_header_length, |
| 87 clock_->TimeInMilliseconds()); |
| 88 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
| 89 "Video::PacketNormal", "timestamp", capture_timestamp, |
| 90 "seqnum", seq_num); |
| 91 } else { |
| 85 LOG(LS_WARNING) << "Failed to send video packet " << seq_num; | 92 LOG(LS_WARNING) << "Failed to send video packet " << seq_num; |
| 86 return; | |
| 87 } | 93 } |
| 88 rtc::CritScope cs(&stats_crit_); | |
| 89 video_bitrate_.Update(payload_length + rtp_header_length, | |
| 90 clock_->TimeInMilliseconds()); | |
| 91 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | |
| 92 "Video::PacketNormal", "timestamp", capture_timestamp, | |
| 93 "seqnum", seq_num); | |
| 94 } | 94 } |
| 95 | 95 |
| 96 void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer, | 96 void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer, |
| 97 size_t payload_length, | 97 size_t payload_length, |
| 98 size_t rtp_header_length, | 98 size_t rtp_header_length, |
| 99 uint16_t media_seq_num, | 99 uint16_t media_seq_num, |
| 100 uint32_t capture_timestamp, | 100 uint32_t capture_timestamp, |
| 101 int64_t capture_time_ms, | 101 int64_t capture_time_ms, |
| 102 StorageType media_packet_storage, | 102 StorageType media_packet_storage, |
| 103 bool protect) { | 103 bool protect) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 const FecProtectionParams* key_params) { | 199 const FecProtectionParams* key_params) { |
| 200 rtc::CritScope cs(&crit_); | 200 rtc::CritScope cs(&crit_); |
| 201 RTC_DCHECK(delta_params); | 201 RTC_DCHECK(delta_params); |
| 202 RTC_DCHECK(key_params); | 202 RTC_DCHECK(key_params); |
| 203 if (fec_enabled_) { | 203 if (fec_enabled_) { |
| 204 delta_fec_params_ = *delta_params; | 204 delta_fec_params_ = *delta_params; |
| 205 key_fec_params_ = *key_params; | 205 key_fec_params_ = *key_params; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 bool RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type, | 209 int32_t RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type, |
| 210 FrameType frame_type, | 210 FrameType frame_type, |
| 211 int8_t payload_type, | 211 int8_t payload_type, |
| 212 uint32_t capture_timestamp, | 212 uint32_t capture_timestamp, |
| 213 int64_t capture_time_ms, | 213 int64_t capture_time_ms, |
| 214 const uint8_t* payload_data, | 214 const uint8_t* payload_data, |
| 215 size_t payload_size, | 215 size_t payload_size, |
| 216 const RTPFragmentationHeader* fragmentation, | 216 const RTPFragmentationHeader* fragmentation, |
| 217 const RTPVideoHeader* video_header) { | 217 const RTPVideoHeader* video_header) { |
| 218 if (payload_size == 0) | 218 if (payload_size == 0) { |
| 219 return false; | 219 return -1; |
| 220 } |
| 220 | 221 |
| 221 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( | 222 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( |
| 222 video_type, rtp_sender_->MaxDataPayloadLength(), | 223 video_type, rtp_sender_->MaxDataPayloadLength(), |
| 223 video_header ? &(video_header->codecHeader) : nullptr, frame_type)); | 224 video_header ? &(video_header->codecHeader) : nullptr, frame_type)); |
| 224 | 225 |
| 225 StorageType storage; | 226 StorageType storage; |
| 226 int red_payload_type; | 227 int red_payload_type; |
| 227 bool first_frame = first_frame_sent_(); | 228 bool first_frame = first_frame_sent_(); |
| 228 { | 229 { |
| 229 rtc::CritScope cs(&crit_); | 230 rtc::CritScope cs(&crit_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 254 packetizer->SetPayloadData(data, payload_bytes_to_send, frag); | 255 packetizer->SetPayloadData(data, payload_bytes_to_send, frag); |
| 255 | 256 |
| 256 bool first = true; | 257 bool first = true; |
| 257 bool last = false; | 258 bool last = false; |
| 258 while (!last) { | 259 while (!last) { |
| 259 uint8_t dataBuffer[IP_PACKET_SIZE] = {0}; | 260 uint8_t dataBuffer[IP_PACKET_SIZE] = {0}; |
| 260 size_t payload_bytes_in_packet = 0; | 261 size_t payload_bytes_in_packet = 0; |
| 261 | 262 |
| 262 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], | 263 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], |
| 263 &payload_bytes_in_packet, &last)) { | 264 &payload_bytes_in_packet, &last)) { |
| 264 return false; | 265 return -1; |
| 265 } | 266 } |
| 266 | 267 |
| 267 // Write RTP header. | 268 // Write RTP header. |
| 268 int32_t header_length = rtp_sender_->BuildRtpHeader( | 269 int32_t header_length = rtp_sender_->BuildRtpHeader( |
| 269 dataBuffer, payload_type, last, capture_timestamp, capture_time_ms); | 270 dataBuffer, payload_type, last, capture_timestamp, capture_time_ms); |
| 270 if (header_length <= 0) | 271 if (header_length <= 0) |
| 271 return false; | 272 return -1; |
| 272 | 273 |
| 273 // According to | 274 // According to |
| 274 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 275 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
| 275 // ts_126114v120700p.pdf Section 7.4.5: | 276 // ts_126114v120700p.pdf Section 7.4.5: |
| 276 // The MTSI client shall add the payload bytes as defined in this clause | 277 // The MTSI client shall add the payload bytes as defined in this clause |
| 277 // onto the last RTP packet in each group of packets which make up a key | 278 // onto the last RTP packet in each group of packets which make up a key |
| 278 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 | 279 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 |
| 279 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP | 280 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP |
| 280 // packet in each group of packets which make up another type of frame | 281 // packet in each group of packets which make up another type of frame |
| 281 // (e.g. a P-Frame) only if the current value is different from the previous | 282 // (e.g. a P-Frame) only if the current value is different from the previous |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 if (last) { | 317 if (last) { |
| 317 LOG(LS_INFO) | 318 LOG(LS_INFO) |
| 318 << "Sent last RTP packet of the first video frame (pre-pacer)"; | 319 << "Sent last RTP packet of the first video frame (pre-pacer)"; |
| 319 } | 320 } |
| 320 } | 321 } |
| 321 first = false; | 322 first = false; |
| 322 } | 323 } |
| 323 | 324 |
| 324 TRACE_EVENT_ASYNC_END1("webrtc", "Video", capture_time_ms, "timestamp", | 325 TRACE_EVENT_ASYNC_END1("webrtc", "Video", capture_time_ms, "timestamp", |
| 325 rtp_sender_->Timestamp()); | 326 rtp_sender_->Timestamp()); |
| 326 return true; | 327 return 0; |
| 327 } | 328 } |
| 328 | 329 |
| 329 uint32_t RTPSenderVideo::VideoBitrateSent() const { | 330 uint32_t RTPSenderVideo::VideoBitrateSent() const { |
| 330 rtc::CritScope cs(&stats_crit_); | 331 rtc::CritScope cs(&stats_crit_); |
| 331 return video_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0); | 332 return video_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0); |
| 332 } | 333 } |
| 333 | 334 |
| 334 uint32_t RTPSenderVideo::FecOverheadRate() const { | 335 uint32_t RTPSenderVideo::FecOverheadRate() const { |
| 335 rtc::CritScope cs(&stats_crit_); | 336 rtc::CritScope cs(&stats_crit_); |
| 336 return fec_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0); | 337 return fec_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0); |
| 337 } | 338 } |
| 338 | 339 |
| 339 int RTPSenderVideo::SelectiveRetransmissions() const { | 340 int RTPSenderVideo::SelectiveRetransmissions() const { |
| 340 rtc::CritScope cs(&crit_); | 341 rtc::CritScope cs(&crit_); |
| 341 return retransmission_settings_; | 342 return retransmission_settings_; |
| 342 } | 343 } |
| 343 | 344 |
| 344 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 345 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
| 345 rtc::CritScope cs(&crit_); | 346 rtc::CritScope cs(&crit_); |
| 346 retransmission_settings_ = settings; | 347 retransmission_settings_ = settings; |
| 347 } | 348 } |
| 348 | 349 |
| 349 } // namespace webrtc | 350 } // namespace webrtc |
| OLD | NEW |