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

Side by Side Diff: webrtc/modules/audio_coding/neteq/packet_buffer.cc

Issue 2290153002: NetEq: Change member variables for current RTP types to rtc::Optionals (Closed)
Patch Set: Updates after review Created 4 years, 3 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
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 packet->header.timestamp == (*it)->header.timestamp) { 101 packet->header.timestamp == (*it)->header.timestamp) {
102 delete [] (*it)->payload; 102 delete [] (*it)->payload;
103 delete *it; 103 delete *it;
104 it = buffer_.erase(it); 104 it = buffer_.erase(it);
105 } 105 }
106 buffer_.insert(it, packet); // Insert the packet at that position. 106 buffer_.insert(it, packet); // Insert the packet at that position.
107 107
108 return return_val; 108 return return_val;
109 } 109 }
110 110
111 int PacketBuffer::InsertPacketList(PacketList* packet_list, 111 int PacketBuffer::InsertPacketList(
112 const DecoderDatabase& decoder_database, 112 PacketList* packet_list,
113 uint8_t* current_rtp_payload_type, 113 const DecoderDatabase& decoder_database,
114 uint8_t* current_cng_rtp_payload_type) { 114 rtc::Optional<uint8_t>* current_rtp_payload_type,
115 rtc::Optional<uint8_t>* current_cng_rtp_payload_type) {
115 bool flushed = false; 116 bool flushed = false;
116 while (!packet_list->empty()) { 117 while (!packet_list->empty()) {
117 Packet* packet = packet_list->front(); 118 Packet* packet = packet_list->front();
118 if (decoder_database.IsComfortNoise(packet->header.payloadType)) { 119 if (decoder_database.IsComfortNoise(packet->header.payloadType)) {
119 if (*current_cng_rtp_payload_type != 0xFF && 120 if (*current_cng_rtp_payload_type &&
120 *current_cng_rtp_payload_type != packet->header.payloadType) { 121 **current_cng_rtp_payload_type != packet->header.payloadType) {
121 // New CNG payload type implies new codec type. 122 // New CNG payload type implies new codec type.
122 *current_rtp_payload_type = 0xFF; 123 *current_rtp_payload_type = rtc::Optional<uint8_t>();
123 Flush(); 124 Flush();
124 flushed = true; 125 flushed = true;
125 } 126 }
126 *current_cng_rtp_payload_type = packet->header.payloadType; 127 *current_cng_rtp_payload_type =
128 rtc::Optional<uint8_t>(packet->header.payloadType);
127 } else if (!decoder_database.IsDtmf(packet->header.payloadType)) { 129 } else if (!decoder_database.IsDtmf(packet->header.payloadType)) {
128 // This must be speech. 130 // This must be speech.
129 if (*current_rtp_payload_type != 0xFF && 131 if (*current_rtp_payload_type &&
130 *current_rtp_payload_type != packet->header.payloadType) { 132 **current_rtp_payload_type != packet->header.payloadType) {
131 *current_cng_rtp_payload_type = 0xFF; 133 *current_cng_rtp_payload_type = rtc::Optional<uint8_t>();
132 Flush(); 134 Flush();
133 flushed = true; 135 flushed = true;
134 } 136 }
135 *current_rtp_payload_type = packet->header.payloadType; 137 *current_rtp_payload_type =
138 rtc::Optional<uint8_t>(packet->header.payloadType);
136 } 139 }
137 int return_val = InsertPacket(packet); 140 int return_val = InsertPacket(packet);
138 packet_list->pop_front(); 141 packet_list->pop_front();
139 if (return_val == kFlushed) { 142 if (return_val == kFlushed) {
140 // The buffer flushed, but this is not an error. We can still continue. 143 // The buffer flushed, but this is not an error. We can still continue.
141 flushed = true; 144 flushed = true;
142 } else if (return_val != kOK) { 145 } else if (return_val != kOK) {
143 // An error occurred. Delete remaining packets in list and return. 146 // An error occurred. Delete remaining packets in list and return.
144 DeleteAllPackets(packet_list); 147 DeleteAllPackets(packet_list);
145 return return_val; 148 return return_val;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // Continue while the list is not empty. 291 // Continue while the list is not empty.
289 } 292 }
290 } 293 }
291 294
292 void PacketBuffer::BufferStat(int* num_packets, int* max_num_packets) const { 295 void PacketBuffer::BufferStat(int* num_packets, int* max_num_packets) const {
293 *num_packets = static_cast<int>(buffer_.size()); 296 *num_packets = static_cast<int>(buffer_.size());
294 *max_num_packets = static_cast<int>(max_number_of_packets_); 297 *max_num_packets = static_cast<int>(max_number_of_packets_);
295 } 298 }
296 299
297 } // namespace webrtc 300 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/packet_buffer.h ('k') | webrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698