| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_FORMATS_COMMON_STREAM_PARSER_TEST_BASE_H_ | 5 #ifndef MEDIA_FORMATS_COMMON_STREAM_PARSER_TEST_BASE_H_ |
| 6 #define MEDIA_FORMATS_COMMON_STREAM_PARSER_TEST_BASE_H_ | 6 #define MEDIA_FORMATS_COMMON_STREAM_PARSER_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> |
| 12 |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "media/base/audio_decoder_config.h" | 14 #include "media/base/audio_decoder_config.h" |
| 14 #include "media/base/stream_parser.h" | 15 #include "media/base/stream_parser.h" |
| 15 #include "media/base/stream_parser_buffer.h" | 16 #include "media/base/stream_parser_buffer.h" |
| 16 #include "media/base/text_track_config.h" | 17 #include "media/base/text_track_config.h" |
| 17 #include "media/base/video_decoder_config.h" | 18 #include "media/base/video_decoder_config.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 | 21 |
| 21 // Test helper for verifying StreamParser behavior. | 22 // Test helper for verifying StreamParser behavior. |
| 22 class StreamParserTestBase { | 23 class StreamParserTestBase { |
| 23 public: | 24 public: |
| 24 explicit StreamParserTestBase(scoped_ptr<StreamParser> stream_parser); | 25 explicit StreamParserTestBase(std::unique_ptr<StreamParser> stream_parser); |
| 25 virtual ~StreamParserTestBase(); | 26 virtual ~StreamParserTestBase(); |
| 26 | 27 |
| 27 protected: | 28 protected: |
| 28 // Chunks a given parser appropriate file. Appends |append_bytes| at a time | 29 // Chunks a given parser appropriate file. Appends |append_bytes| at a time |
| 29 // until the file is exhausted. Returns a coded string representing the | 30 // until the file is exhausted. Returns a coded string representing the |
| 30 // segments and timestamps of the extracted frames. | 31 // segments and timestamps of the extracted frames. |
| 31 // | 32 // |
| 32 // The start of each media segment is designated by "NewSegment", similarly | 33 // The start of each media segment is designated by "NewSegment", similarly |
| 33 // the end of each segment by "EndOfSegment". Segments end when one or more | 34 // the end of each segment by "EndOfSegment". Segments end when one or more |
| 34 // frames are parsed from an append. If the append contains a partial frame | 35 // frames are parsed from an append. If the append contains a partial frame |
| (...skipping 15 matching lines...) Expand all Loading... |
| 50 // The last AudioDecoderConfig handed to OnNewConfig(). | 51 // The last AudioDecoderConfig handed to OnNewConfig(). |
| 51 const AudioDecoderConfig& last_audio_config() const { | 52 const AudioDecoderConfig& last_audio_config() const { |
| 52 return last_audio_config_; | 53 return last_audio_config_; |
| 53 } | 54 } |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 bool AppendDataInPieces(const uint8_t* data, | 57 bool AppendDataInPieces(const uint8_t* data, |
| 57 size_t length, | 58 size_t length, |
| 58 size_t piece_size); | 59 size_t piece_size); |
| 59 void OnInitDone(const StreamParser::InitParameters& params); | 60 void OnInitDone(const StreamParser::InitParameters& params); |
| 60 bool OnNewConfig(scoped_ptr<MediaTracks> tracks, | 61 bool OnNewConfig(std::unique_ptr<MediaTracks> tracks, |
| 61 const StreamParser::TextTrackConfigMap& text_config); | 62 const StreamParser::TextTrackConfigMap& text_config); |
| 62 bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers, | 63 bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers, |
| 63 const StreamParser::BufferQueue& video_buffers, | 64 const StreamParser::BufferQueue& video_buffers, |
| 64 const StreamParser::TextBufferQueueMap& text_map); | 65 const StreamParser::TextBufferQueueMap& text_map); |
| 65 void OnKeyNeeded(EmeInitDataType type, const std::vector<uint8_t>& init_data); | 66 void OnKeyNeeded(EmeInitDataType type, const std::vector<uint8_t>& init_data); |
| 66 void OnNewSegment(); | 67 void OnNewSegment(); |
| 67 void OnEndOfSegment(); | 68 void OnEndOfSegment(); |
| 68 | 69 |
| 69 scoped_ptr<StreamParser> parser_; | 70 std::unique_ptr<StreamParser> parser_; |
| 70 std::stringstream results_stream_; | 71 std::stringstream results_stream_; |
| 71 AudioDecoderConfig last_audio_config_; | 72 AudioDecoderConfig last_audio_config_; |
| 72 | 73 |
| 73 DISALLOW_COPY_AND_ASSIGN(StreamParserTestBase); | 74 DISALLOW_COPY_AND_ASSIGN(StreamParserTestBase); |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 } // namespace media | 77 } // namespace media |
| 77 | 78 |
| 78 #endif // MEDIA_FORMATS_COMMON_STREAM_PARSER_TEST_BASE_H_ | 79 #endif // MEDIA_FORMATS_COMMON_STREAM_PARSER_TEST_BASE_H_ |
| OLD | NEW |