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

Side by Side Diff: webrtc/modules/video_coding/video_packet_buffer_unittest.cc

Issue 2124943002: Added various timestamps to FrameObject. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renamed |received_timestamp| to |received_time|. Created 4 years, 5 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
« no previous file with comments | « webrtc/modules/video_coding/packet_buffer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 <cstring> 11 #include <cstring>
12 #include <limits> 12 #include <limits>
13 #include <map> 13 #include <map>
14 #include <set> 14 #include <set>
15 #include <utility> 15 #include <utility>
16 16
17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webrtc/base/random.h"
17 #include "webrtc/modules/video_coding/frame_object.h" 19 #include "webrtc/modules/video_coding/frame_object.h"
18 #include "webrtc/modules/video_coding/packet_buffer.h" 20 #include "webrtc/modules/video_coding/packet_buffer.h"
19 21 #include "webrtc/system_wrappers/include/clock.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "webrtc/base/random.h"
22 22
23 namespace webrtc { 23 namespace webrtc {
24 namespace video_coding { 24 namespace video_coding {
25 25
26 class TestPacketBuffer : public ::testing::Test, 26 class TestPacketBuffer : public ::testing::Test,
27 public OnCompleteFrameCallback { 27 public OnCompleteFrameCallback {
28 protected: 28 protected:
29 TestPacketBuffer() 29 TestPacketBuffer()
30 : rand_(0x8739211), 30 : rand_(0x8739211),
31 packet_buffer_(new PacketBuffer(kStartSize, kMaxSize, this)), 31 clock_(new SimulatedClock(0)),
32 packet_buffer_(new PacketBuffer(clock_.get(),
33 kStartSize,
34 kMaxSize,
35 this)),
32 frames_from_callback_(FrameComp()), 36 frames_from_callback_(FrameComp()),
33 dummy_data_(new uint8_t[kDummyDataSize]()) {} 37 dummy_data_(new uint8_t[kDummyDataSize]()) {}
34 38
35 uint16_t Rand() { return rand_.Rand(std::numeric_limits<uint16_t>::max()); } 39 uint16_t Rand() { return rand_.Rand(std::numeric_limits<uint16_t>::max()); }
36 40
37 void OnCompleteFrame(std::unique_ptr<FrameObject> frame) override { 41 void OnCompleteFrame(std::unique_ptr<FrameObject> frame) override {
38 uint16_t pid = frame->picture_id; 42 uint16_t pid = frame->picture_id;
39 uint16_t sidx = frame->spatial_layer; 43 uint16_t sidx = frame->spatial_layer;
40 auto frame_it = frames_from_callback_.find(std::make_pair(pid, sidx)); 44 auto frame_it = frames_from_callback_.find(std::make_pair(pid, sidx));
41 if (frame_it != frames_from_callback_.end()) { 45 if (frame_it != frames_from_callback_.end()) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 RefsToSet(m, refs...); 245 RefsToSet(m, refs...);
242 } 246 }
243 247
244 void RefsToSet(std::set<uint16_t>* m) const {} 248 void RefsToSet(std::set<uint16_t>* m) const {}
245 249
246 const int kStartSize = 16; 250 const int kStartSize = 16;
247 const int kMaxSize = 64; 251 const int kMaxSize = 64;
248 const int kDummyDataSize = 4; 252 const int kDummyDataSize = 4;
249 253
250 Random rand_; 254 Random rand_;
255 std::unique_ptr<Clock> clock_;
251 std::unique_ptr<PacketBuffer> packet_buffer_; 256 std::unique_ptr<PacketBuffer> packet_buffer_;
252 struct FrameComp { 257 struct FrameComp {
253 bool operator()(const std::pair<uint16_t, uint8_t> f1, 258 bool operator()(const std::pair<uint16_t, uint8_t> f1,
254 const std::pair<uint16_t, uint8_t> f2) const { 259 const std::pair<uint16_t, uint8_t> f2) const {
255 if (f1.first == f2.first) 260 if (f1.first == f2.first)
256 return f1.second < f2.second; 261 return f1.second < f2.second;
257 return f1.first < f2.first; 262 return f1.first < f2.first;
258 } 263 }
259 }; 264 };
260 std::map<std::pair<uint16_t, uint8_t>, 265 std::map<std::pair<uint16_t, uint8_t>,
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 CheckReferencesVp8(pid); 927 CheckReferencesVp8(pid);
923 CheckReferencesVp8(pid + 1, pid); 928 CheckReferencesVp8(pid + 1, pid);
924 CheckReferencesVp8(pid + 2, pid); 929 CheckReferencesVp8(pid + 2, pid);
925 CheckReferencesVp8(pid + 4, pid + 2); 930 CheckReferencesVp8(pid + 4, pid + 2);
926 CheckReferencesVp8(pid + 5, pid + 4); 931 CheckReferencesVp8(pid + 5, pid + 4);
927 CheckReferencesVp8(pid + 6, pid + 4); 932 CheckReferencesVp8(pid + 6, pid + 4);
928 CheckReferencesVp8(pid + 7, pid + 6, pid + 5); 933 CheckReferencesVp8(pid + 7, pid + 6, pid + 5);
929 } 934 }
930 935
931 TEST_F(TestPacketBuffer, Vp8InsertLargeFrames) { 936 TEST_F(TestPacketBuffer, Vp8InsertLargeFrames) {
932 packet_buffer_.reset(new PacketBuffer(1 << 3, 1 << 12, this)); 937 packet_buffer_.reset(new PacketBuffer(clock_.get(), 1 << 3, 1 << 12, this));
933 uint16_t pid = Rand(); 938 uint16_t pid = Rand();
934 uint16_t seq_num = Rand(); 939 uint16_t seq_num = Rand();
935 940
936 const uint16_t packets_per_frame = 1000; 941 const uint16_t packets_per_frame = 1000;
937 uint16_t current = seq_num; 942 uint16_t current = seq_num;
938 uint16_t end = current + packets_per_frame; 943 uint16_t end = current + packets_per_frame;
939 944
940 // seq_num , keyf, frst, lst, sync, pid, tid, tl0 945 // seq_num , keyf, frst, lst, sync, pid, tid, tl0
941 InsertVp8(current++, kT , kT , kF , kF , pid, 0 , 0); 946 InsertVp8(current++, kT , kT , kF , kF , pid, 0 , 0);
942 while (current != end) 947 while (current != end)
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 CheckReferencesVp9(pid + 5, 1, pid + 4); 1524 CheckReferencesVp9(pid + 5, 1, pid + 4);
1520 CheckReferencesVp9(pid + 6, 0, pid + 4); 1525 CheckReferencesVp9(pid + 6, 0, pid + 4);
1521 CheckReferencesVp9(pid + 6, 1, pid + 5); 1526 CheckReferencesVp9(pid + 6, 1, pid + 5);
1522 CheckReferencesVp9(pid + 7, 1, pid + 6); 1527 CheckReferencesVp9(pid + 7, 1, pid + 6);
1523 CheckReferencesVp9(pid + 8, 0, pid + 6); 1528 CheckReferencesVp9(pid + 8, 0, pid + 6);
1524 CheckReferencesVp9(pid + 8, 1, pid + 7); 1529 CheckReferencesVp9(pid + 8, 1, pid + 7);
1525 } 1530 }
1526 1531
1527 } // namespace video_coding 1532 } // namespace video_coding
1528 } // namespace webrtc 1533 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/packet_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698