Update V8 to version 4.7.56.
[chromium-blink-merge.git] / media / formats / common / stream_parser_test_base.h
blobea61dd3a9a2e486a59e4633a84226250cdc1d7d5
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.
5 #ifndef MEDIA_FORMATS_COMMON_STREAM_PARSER_TEST_BASE_H_
6 #define MEDIA_FORMATS_COMMON_STREAM_PARSER_TEST_BASE_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "media/base/audio_decoder_config.h"
10 #include "media/base/stream_parser.h"
11 #include "media/base/stream_parser_buffer.h"
12 #include "media/base/text_track_config.h"
13 #include "media/base/video_decoder_config.h"
15 namespace media {
17 // Test helper for verifying StreamParser behavior.
18 class StreamParserTestBase {
19 public:
20 explicit StreamParserTestBase(scoped_ptr<StreamParser> stream_parser);
21 virtual ~StreamParserTestBase();
23 protected:
24 // Chunks a given parser appropriate file. Appends |append_bytes| at a time
25 // until the file is exhausted. Returns a coded string representing the
26 // segments and timestamps of the extracted frames.
28 // The start of each media segment is designated by "NewSegment", similarly
29 // the end of each segment by "EndOfSegment". Segments end when one or more
30 // frames are parsed from an append. If the append contains a partial frame
31 // the segment will continue into the next append.
33 // Parsed frame(s) are represented as "{ xxK yyK zzK }" Where xx, yy, and zz
34 // are the timestamps in milliseconds of each parsed frame. For example:
36 // "NewSegment{ 0K 23K 46K }EndOfSegment"
37 // "NewSegment{ 0K }{ 23K }{ 46K }EndOfSegment"
38 // "NewSegment{ 0K }{ 23K }EndOfSegmentNewSegment{ 46K }EndOfSegment"
40 std::string ParseFile(const std::string& filename, int append_bytes);
42 // Similar to ParseFile() except parses the given |data| in a single append of
43 // size |length|.
44 std::string ParseData(const uint8* data, size_t length);
46 // The last AudioDecoderConfig handed to OnNewConfig().
47 const AudioDecoderConfig& last_audio_config() const {
48 return last_audio_config_;
51 private:
52 bool AppendDataInPieces(const uint8* data, size_t length, size_t piece_size);
53 void OnInitDone(const StreamParser::InitParameters& params);
54 bool OnNewConfig(const AudioDecoderConfig& audio_config,
55 const VideoDecoderConfig& video_config,
56 const StreamParser::TextTrackConfigMap& text_config);
57 bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers,
58 const StreamParser::BufferQueue& video_buffers,
59 const StreamParser::TextBufferQueueMap& text_map);
60 void OnKeyNeeded(EmeInitDataType type, const std::vector<uint8>& init_data);
61 void OnNewSegment();
62 void OnEndOfSegment();
64 scoped_ptr<StreamParser> parser_;
65 std::stringstream results_stream_;
66 AudioDecoderConfig last_audio_config_;
68 DISALLOW_COPY_AND_ASSIGN(StreamParserTestBase);
71 } // namespace media
73 #endif // MEDIA_FORMATS_COMMON_STREAM_PARSER_TEST_BASE_H_