OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h" |
12 | 12 |
13 #include <assert.h> // assert | 13 #include <assert.h> // assert |
14 #include <string.h> // memcpy | 14 #include <string.h> // memcpy |
15 | 15 |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
19 #include "webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h" | 19 #include "webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h" |
| 20 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 namespace { | 23 namespace { |
23 int ParseVP8PictureID(RTPVideoHeaderVP8* vp8, | 24 int ParseVP8PictureID(RTPVideoHeaderVP8* vp8, |
24 const uint8_t** data, | 25 const uint8_t** data, |
25 size_t* data_length, | 26 size_t* data_length, |
26 size_t* parsed_bytes) { | 27 size_t* parsed_bytes) { |
27 assert(vp8 != NULL); | 28 assert(vp8 != NULL); |
28 if (*data_length == 0) | 29 if (*data_length == 0) |
29 return -1; | 30 return -1; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 part_info_.CopyFrom(*fragmentation); | 191 part_info_.CopyFrom(*fragmentation); |
191 num_partitions_ = fragmentation->fragmentationVectorSize; | 192 num_partitions_ = fragmentation->fragmentationVectorSize; |
192 } else { | 193 } else { |
193 part_info_.VerifyAndAllocateFragmentationHeader(1); | 194 part_info_.VerifyAndAllocateFragmentationHeader(1); |
194 part_info_.fragmentationLength[0] = payload_size; | 195 part_info_.fragmentationLength[0] = payload_size; |
195 part_info_.fragmentationOffset[0] = 0; | 196 part_info_.fragmentationOffset[0] = 0; |
196 num_partitions_ = part_info_.fragmentationVectorSize; | 197 num_partitions_ = part_info_.fragmentationVectorSize; |
197 } | 198 } |
198 } | 199 } |
199 | 200 |
200 bool RtpPacketizerVp8::NextPacket(uint8_t* buffer, | 201 bool RtpPacketizerVp8::NextPacket(RtpPacketToSend* packet, bool* last_packet) { |
201 size_t* bytes_to_send, | 202 RTC_DCHECK(packet); |
202 bool* last_packet) { | 203 RTC_DCHECK(last_packet); |
203 if (!packets_calculated_) { | 204 if (!packets_calculated_) { |
204 int ret = 0; | 205 int ret = 0; |
205 if (aggr_mode_ == kAggrPartitions && balance_) { | 206 if (aggr_mode_ == kAggrPartitions && balance_) { |
206 ret = GeneratePacketsBalancedAggregates(); | 207 ret = GeneratePacketsBalancedAggregates(); |
207 } else { | 208 } else { |
208 ret = GeneratePackets(); | 209 ret = GeneratePackets(); |
209 } | 210 } |
210 if (ret < 0) { | 211 if (ret < 0) { |
211 return false; | 212 return false; |
212 } | 213 } |
213 } | 214 } |
214 if (packets_.empty()) { | 215 if (packets_.empty()) { |
215 return false; | 216 return false; |
216 } | 217 } |
217 InfoStruct packet_info = packets_.front(); | 218 InfoStruct packet_info = packets_.front(); |
218 packets_.pop(); | 219 packets_.pop(); |
219 | 220 |
| 221 uint8_t* buffer = packet->AllocatePayload(max_payload_len_); |
220 int bytes = WriteHeaderAndPayload(packet_info, buffer, max_payload_len_); | 222 int bytes = WriteHeaderAndPayload(packet_info, buffer, max_payload_len_); |
221 if (bytes < 0) { | 223 if (bytes < 0) { |
222 return false; | 224 return false; |
223 } | 225 } |
224 *bytes_to_send = static_cast<size_t>(bytes); | 226 packet->SetPayloadSize(bytes); |
225 | |
226 *last_packet = packets_.empty(); | 227 *last_packet = packets_.empty(); |
| 228 packet->SetMarker(*last_packet); |
227 return true; | 229 return true; |
228 } | 230 } |
229 | 231 |
230 ProtectionType RtpPacketizerVp8::GetProtectionType() { | 232 ProtectionType RtpPacketizerVp8::GetProtectionType() { |
231 bool protect = | 233 bool protect = |
232 hdr_info_.temporalIdx == 0 || hdr_info_.temporalIdx == kNoTemporalIdx; | 234 hdr_info_.temporalIdx == 0 || hdr_info_.temporalIdx == kNoTemporalIdx; |
233 return protect ? kProtectedPacket : kUnprotectedPacket; | 235 return protect ? kProtectedPacket : kUnprotectedPacket; |
234 } | 236 } |
235 | 237 |
236 StorageType RtpPacketizerVp8::GetStorageType(uint32_t retransmission_settings) { | 238 StorageType RtpPacketizerVp8::GetStorageType(uint32_t retransmission_settings) { |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 if (ParseVP8FrameSize(parsed_payload, payload_data, payload_data_length) != | 736 if (ParseVP8FrameSize(parsed_payload, payload_data, payload_data_length) != |
735 0) { | 737 0) { |
736 return false; | 738 return false; |
737 } | 739 } |
738 | 740 |
739 parsed_payload->payload = payload_data; | 741 parsed_payload->payload = payload_data; |
740 parsed_payload->payload_length = payload_data_length; | 742 parsed_payload->payload_length = payload_data_length; |
741 return true; | 743 return true; |
742 } | 744 } |
743 } // namespace webrtc | 745 } // namespace webrtc |
OLD | NEW |