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

Side by Side Diff: media/cast/net/rtp/packet_storage.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/net/rtp/packet_storage.h" 5 #include "media/cast/net/rtp/packet_storage.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/cast/constants.h" 8 #include "media/cast/constants.h"
9 9
10 namespace media { 10 namespace media {
11 namespace cast { 11 namespace cast {
12 12
13 PacketStorage::PacketStorage() 13 PacketStorage::PacketStorage()
14 : first_frame_id_in_list_(0), 14 : first_frame_id_in_list_(0),
15 zombie_count_(0) { 15 zombie_count_(0) {
16 } 16 }
17 17
18 PacketStorage::~PacketStorage() { 18 PacketStorage::~PacketStorage() {
19 } 19 }
20 20
21 size_t PacketStorage::GetNumberOfStoredFrames() const { 21 size_t PacketStorage::GetNumberOfStoredFrames() const {
22 return frames_.size() - zombie_count_; 22 return frames_.size() - zombie_count_;
23 } 23 }
24 24
25 void PacketStorage::StoreFrame(uint32 frame_id, 25 void PacketStorage::StoreFrame(uint32_t frame_id,
26 const SendPacketVector& packets) { 26 const SendPacketVector& packets) {
27 if (packets.empty()) { 27 if (packets.empty()) {
28 NOTREACHED(); 28 NOTREACHED();
29 return; 29 return;
30 } 30 }
31 31
32 if (frames_.empty()) { 32 if (frames_.empty()) {
33 first_frame_id_in_list_ = frame_id; 33 first_frame_id_in_list_ = frame_id;
34 } else { 34 } else {
35 // Make sure frame IDs are consecutive. 35 // Make sure frame IDs are consecutive.
36 DCHECK_EQ(first_frame_id_in_list_ + static_cast<uint32>(frames_.size()), 36 DCHECK_EQ(first_frame_id_in_list_ + static_cast<uint32_t>(frames_.size()),
37 frame_id); 37 frame_id);
38 // Make sure we aren't being asked to store more frames than the system's 38 // Make sure we aren't being asked to store more frames than the system's
39 // design limit. 39 // design limit.
40 DCHECK_LT(frames_.size(), static_cast<size_t>(kMaxUnackedFrames)); 40 DCHECK_LT(frames_.size(), static_cast<size_t>(kMaxUnackedFrames));
41 } 41 }
42 42
43 // Save new frame to the end of the list. 43 // Save new frame to the end of the list.
44 frames_.push_back(packets); 44 frames_.push_back(packets);
45 } 45 }
46 46
47 void PacketStorage::ReleaseFrame(uint32 frame_id) { 47 void PacketStorage::ReleaseFrame(uint32_t frame_id) {
48 const uint32 offset = frame_id - first_frame_id_in_list_; 48 const uint32_t offset = frame_id - first_frame_id_in_list_;
49 if (static_cast<int32>(offset) < 0 || offset >= frames_.size() || 49 if (static_cast<int32_t>(offset) < 0 || offset >= frames_.size() ||
50 frames_[offset].empty()) { 50 frames_[offset].empty()) {
51 return; 51 return;
52 } 52 }
53 53
54 frames_[offset].clear(); 54 frames_[offset].clear();
55 ++zombie_count_; 55 ++zombie_count_;
56 56
57 while (!frames_.empty() && frames_.front().empty()) { 57 while (!frames_.empty() && frames_.front().empty()) {
58 DCHECK_GT(zombie_count_, 0u); 58 DCHECK_GT(zombie_count_, 0u);
59 --zombie_count_; 59 --zombie_count_;
60 frames_.pop_front(); 60 frames_.pop_front();
61 ++first_frame_id_in_list_; 61 ++first_frame_id_in_list_;
62 } 62 }
63 } 63 }
64 64
65 const SendPacketVector* PacketStorage::GetFrame8(uint8 frame_id_8bits) const { 65 const SendPacketVector* PacketStorage::GetFrame8(uint8_t frame_id_8bits) const {
66 // The requested frame ID has only 8-bits so convert the first frame ID 66 // The requested frame ID has only 8-bits so convert the first frame ID
67 // in list to match. 67 // in list to match.
68 uint8 index_8bits = first_frame_id_in_list_ & 0xFF; 68 uint8_t index_8bits = first_frame_id_in_list_ & 0xFF;
69 index_8bits = frame_id_8bits - index_8bits; 69 index_8bits = frame_id_8bits - index_8bits;
70 if (index_8bits >= frames_.size()) 70 if (index_8bits >= frames_.size())
71 return NULL; 71 return NULL;
72 const SendPacketVector& packets = frames_[index_8bits]; 72 const SendPacketVector& packets = frames_[index_8bits];
73 return packets.empty() ? NULL : &packets; 73 return packets.empty() ? NULL : &packets;
74 } 74 }
75 75
76 } // namespace cast 76 } // namespace cast
77 } // namespace media 77 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698