OLD | NEW |
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 "webrtc/modules/video_coding/utility/ivf_file_writer.h" | 11 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
18 #include "webrtc/system_wrappers/include/tick_util.h" | |
19 #include "webrtc/test/testsupport/fileutils.h" | 18 #include "webrtc/test/testsupport/fileutils.h" |
20 | 19 |
21 namespace webrtc { | 20 namespace webrtc { |
22 | 21 |
23 namespace { | 22 namespace { |
24 static const int kHeaderSize = 32; | 23 static const int kHeaderSize = 32; |
25 static const int kFrameHeaderSize = 12; | 24 static const int kFrameHeaderSize = 12; |
26 static uint8_t dummy_payload[4] = {0, 1, 2, 3}; | 25 static uint8_t dummy_payload[4] = {0, 1, 2, 3}; |
27 } // namespace | 26 } // namespace |
28 | 27 |
29 class IvfFileWriterTest : public ::testing::Test { | 28 class IvfFileWriterTest : public ::testing::Test { |
30 protected: | 29 protected: |
31 void SetUp() override { | 30 void SetUp() override { |
32 const int64_t start_id = | 31 const int64_t start_id = |
33 reinterpret_cast<int64_t>(this) ^ TickTime::MicrosecondTimestamp(); | 32 reinterpret_cast<int64_t>(this) ^ rtc::TimeMicros(); |
34 int64_t id = start_id; | 33 int64_t id = start_id; |
35 do { | 34 do { |
36 std::ostringstream oss; | 35 std::ostringstream oss; |
37 oss << test::OutputPath() << "ivf_test_file_" << id++ << ".ivf"; | 36 oss << test::OutputPath() << "ivf_test_file_" << id++ << ".ivf"; |
38 file_name_ = oss.str(); | 37 file_name_ = oss.str(); |
39 } while (id < start_id + 100 && FileExists()); | 38 } while (id < start_id + 100 && FileExists()); |
40 ASSERT_LT(id, start_id + 100); | 39 ASSERT_LT(id, start_id + 100); |
41 } | 40 } |
42 | 41 |
43 bool WriteDummyTestFrames(int width, | 42 bool WriteDummyTestFrames(int width, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 const uint8_t fourcc[4] = {'H', '2', '6', '4'}; | 166 const uint8_t fourcc[4] = {'H', '2', '6', '4'}; |
168 RunBasicFileStructureTest(kRtpVideoH264, fourcc, false); | 167 RunBasicFileStructureTest(kRtpVideoH264, fourcc, false); |
169 } | 168 } |
170 | 169 |
171 TEST_F(IvfFileWriterTest, WritesBasicH264FileMsTimestamp) { | 170 TEST_F(IvfFileWriterTest, WritesBasicH264FileMsTimestamp) { |
172 const uint8_t fourcc[4] = {'H', '2', '6', '4'}; | 171 const uint8_t fourcc[4] = {'H', '2', '6', '4'}; |
173 RunBasicFileStructureTest(kRtpVideoH264, fourcc, true); | 172 RunBasicFileStructureTest(kRtpVideoH264, fourcc, true); |
174 } | 173 } |
175 | 174 |
176 } // namespace webrtc | 175 } // namespace webrtc |
OLD | NEW |