1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/files/memory_mapped_file.h"
6 #include "base/logging.h"
7 #include "media/base/test_data_util.h"
8 #include "media/filters/h265_parser.h"
9 #include "testing/gtest/include/gtest/gtest.h"
13 TEST(H265ParserTest
, RawHevcStreamFileParsing
) {
14 base::FilePath file_path
= GetTestDataFilePath("bear.hevc");
15 // Number of NALUs in the test stream to be parsed.
16 const int num_nalus
= 35;
18 base::MemoryMappedFile stream
;
19 ASSERT_TRUE(stream
.Initialize(file_path
))
20 << "Couldn't open stream file: " << file_path
.MaybeAsASCII();
23 parser
.SetStream(stream
.data(), stream
.length());
25 // Parse until the end of stream/unsupported stream/error in stream is found.
26 int num_parsed_nalus
= 0;
29 H265Parser::Result res
= parser
.AdvanceToNextNALU(&nalu
);
30 if (res
== H265Parser::kEOStream
) {
31 DVLOG(1) << "Number of successfully parsed NALUs before EOS: "
33 ASSERT_EQ(num_nalus
, num_parsed_nalus
);
36 ASSERT_EQ(res
, H265Parser::kOk
);
39 DVLOG(4) << "Found NALU " << nalu
.nal_unit_type
;