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