adts_stream_parser_unittest.cc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2014 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.
  4. #include "media/formats/mpeg/adts_stream_parser.h"
  5. #include <memory>
  6. #include "media/formats/common/stream_parser_test_base.h"
  7. #include "testing/gtest/include/gtest/gtest.h"
  8. namespace media {
  9. class ADTSStreamParserTest : public StreamParserTestBase, public testing::Test {
  10. public:
  11. ADTSStreamParserTest()
  12. : StreamParserTestBase(std::make_unique<ADTSStreamParser>()) {}
  13. };
  14. // Test parsing with small prime sized chunks to smoke out "power of
  15. // 2" field size assumptions.
  16. TEST_F(ADTSStreamParserTest, UnalignedAppend) {
  17. const std::string expected =
  18. "NewSegment"
  19. "{ 0K }"
  20. "{ 0K }"
  21. "{ 0K }"
  22. "{ 0K }"
  23. "{ 0K }"
  24. "{ 0K }"
  25. "{ 0K }"
  26. "{ 0K }"
  27. "{ 0K }"
  28. "EndOfSegment"
  29. "NewSegment"
  30. "{ 0K }"
  31. "{ 0K }"
  32. "{ 0K }"
  33. "{ 0K }"
  34. "{ 0K }"
  35. "EndOfSegment";
  36. EXPECT_EQ(expected, ParseFile("sfx.adts", 17));
  37. }
  38. // Test parsing with a larger piece size to verify that multiple buffers
  39. // are passed to |new_buffer_cb_|.
  40. TEST_F(ADTSStreamParserTest, UnalignedAppend512) {
  41. const std::string expected =
  42. "NewSegment"
  43. "{ 0K 23K 46K }"
  44. "{ 0K 23K 46K 69K 92K }"
  45. "{ 0K 23K 46K 69K 92K }"
  46. "EndOfSegment"
  47. "NewSegment"
  48. "{ 0K }"
  49. "EndOfSegment";
  50. EXPECT_EQ(expected, ParseFile("sfx.adts", 512));
  51. }
  52. } // namespace media