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 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ByteReader<uint64_t>::ReadLittleEndian(&frame_header[4]); | 96 ByteReader<uint64_t>::ReadLittleEndian(&frame_header[4]); |
97 EXPECT_EQ(i, timestamp); | 97 EXPECT_EQ(i, timestamp); |
98 | 98 |
99 uint8_t data[kMaxFrameSize] = {}; | 99 uint8_t data[kMaxFrameSize] = {}; |
100 ASSERT_EQ(frame_length, | 100 ASSERT_EQ(frame_length, |
101 static_cast<uint32_t>(file->Read(data, frame_length))); | 101 static_cast<uint32_t>(file->Read(data, frame_length))); |
102 EXPECT_EQ(0, memcmp(data, dummy_payload, frame_length)); | 102 EXPECT_EQ(0, memcmp(data, dummy_payload, frame_length)); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 void RunBasicFileStructureTest(VideoCodecType codec_type, | 106 void RunBasicFileStructureTest(RtpVideoCodecTypes codec_type, |
107 const uint8_t fourcc[4], | 107 const uint8_t fourcc[4], |
108 bool use_capture_tims_ms) { | 108 bool use_capture_tims_ms) { |
109 file_writer_ = IvfFileWriter::Open(file_name_, codec_type); | 109 file_writer_ = IvfFileWriter::Open(file_name_, codec_type); |
110 ASSERT_TRUE(file_writer_.get()); | 110 ASSERT_TRUE(file_writer_.get()); |
111 const int kWidth = 320; | 111 const int kWidth = 320; |
112 const int kHeight = 240; | 112 const int kHeight = 240; |
113 const int kNumFrames = 257; | 113 const int kNumFrames = 257; |
114 EXPECT_TRUE( | 114 EXPECT_TRUE( |
115 WriteDummyTestFrames(kWidth, kHeight, kNumFrames, use_capture_tims_ms)); | 115 WriteDummyTestFrames(kWidth, kHeight, kNumFrames, use_capture_tims_ms)); |
116 EXPECT_TRUE(file_writer_->Close()); | 116 EXPECT_TRUE(file_writer_->Close()); |
(...skipping 11 matching lines...) Expand all Loading... |
128 bool FileExists() { | 128 bool FileExists() { |
129 std::unique_ptr<FileWrapper> file_wrapper(FileWrapper::Create()); | 129 std::unique_ptr<FileWrapper> file_wrapper(FileWrapper::Create()); |
130 return file_wrapper->OpenFile(file_name_.c_str(), true) == 0; | 130 return file_wrapper->OpenFile(file_name_.c_str(), true) == 0; |
131 } | 131 } |
132 | 132 |
133 std::string file_name_; | 133 std::string file_name_; |
134 std::unique_ptr<IvfFileWriter> file_writer_; | 134 std::unique_ptr<IvfFileWriter> file_writer_; |
135 }; | 135 }; |
136 | 136 |
137 TEST_F(IvfFileWriterTest, RemovesUnusedFile) { | 137 TEST_F(IvfFileWriterTest, RemovesUnusedFile) { |
138 file_writer_ = IvfFileWriter::Open(file_name_, kVideoCodecVP8); | 138 file_writer_ = IvfFileWriter::Open(file_name_, kRtpVideoVp8); |
139 ASSERT_TRUE(file_writer_.get() != nullptr); | 139 ASSERT_TRUE(file_writer_.get() != nullptr); |
140 EXPECT_TRUE(FileExists()); | 140 EXPECT_TRUE(FileExists()); |
141 EXPECT_TRUE(file_writer_->Close()); | 141 EXPECT_TRUE(file_writer_->Close()); |
142 EXPECT_FALSE(FileExists()); | 142 EXPECT_FALSE(FileExists()); |
143 EXPECT_FALSE(file_writer_->Close()); // Can't close twice. | 143 EXPECT_FALSE(file_writer_->Close()); // Can't close twice. |
144 } | 144 } |
145 | 145 |
146 TEST_F(IvfFileWriterTest, WritesBasicVP8FileNtpTimestamp) { | 146 TEST_F(IvfFileWriterTest, WritesBasicVP8FileNtpTimestamp) { |
147 const uint8_t fourcc[4] = {'V', 'P', '8', '0'}; | 147 const uint8_t fourcc[4] = {'V', 'P', '8', '0'}; |
148 RunBasicFileStructureTest(kVideoCodecVP8, fourcc, false); | 148 RunBasicFileStructureTest(kRtpVideoVp8, fourcc, false); |
149 } | 149 } |
150 | 150 |
151 TEST_F(IvfFileWriterTest, WritesBasicVP8FileMsTimestamp) { | 151 TEST_F(IvfFileWriterTest, WritesBasicVP8FileMsTimestamp) { |
152 const uint8_t fourcc[4] = {'V', 'P', '8', '0'}; | 152 const uint8_t fourcc[4] = {'V', 'P', '8', '0'}; |
153 RunBasicFileStructureTest(kVideoCodecVP8, fourcc, true); | 153 RunBasicFileStructureTest(kRtpVideoVp8, fourcc, true); |
154 } | 154 } |
155 | 155 |
156 TEST_F(IvfFileWriterTest, WritesBasicVP9FileNtpTimestamp) { | 156 TEST_F(IvfFileWriterTest, WritesBasicVP9FileNtpTimestamp) { |
157 const uint8_t fourcc[4] = {'V', 'P', '9', '0'}; | 157 const uint8_t fourcc[4] = {'V', 'P', '9', '0'}; |
158 RunBasicFileStructureTest(kVideoCodecVP9, fourcc, false); | 158 RunBasicFileStructureTest(kRtpVideoVp9, fourcc, false); |
159 } | 159 } |
160 | 160 |
161 TEST_F(IvfFileWriterTest, WritesBasicVP9FileMsTimestamp) { | 161 TEST_F(IvfFileWriterTest, WritesBasicVP9FileMsTimestamp) { |
162 const uint8_t fourcc[4] = {'V', 'P', '9', '0'}; | 162 const uint8_t fourcc[4] = {'V', 'P', '9', '0'}; |
163 RunBasicFileStructureTest(kVideoCodecVP9, fourcc, true); | 163 RunBasicFileStructureTest(kRtpVideoVp9, fourcc, true); |
164 } | 164 } |
165 | 165 |
166 TEST_F(IvfFileWriterTest, WritesBasicH264FileNtpTimestamp) { | 166 TEST_F(IvfFileWriterTest, WritesBasicH264FileNtpTimestamp) { |
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(kRtpVideoH264, 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(kRtpVideoH264, fourcc, true); |
174 } | 174 } |
175 | 175 |
176 } // namespace webrtc | 176 } // namespace webrtc |
OLD | NEW |