blob: 23c0339504f27ad758a12db18afac01836b01e9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_FILTERS_PIPELINE_INTEGRATION_TEST_BASE_H_
#define MEDIA_FILTERS_PIPELINE_INTEGRATION_TEST_BASE_H_
#include "base/message_loop.h"
#include "base/md5.h"
#include "media/audio/null_audio_sink.h"
#include "media/base/filter_collection.h"
#include "media/base/pipeline.h"
#include "media/filters/chunk_demuxer.h"
#include "media/filters/video_renderer_base.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace base {
class FilePath;
}
namespace media {
class Decryptor;
// Empty MD5 hash string. Used to verify empty audio or video tracks.
extern const char kNullHash[];
// Integration tests for Pipeline. Real demuxers, real decoders, and
// base renderer implementations are used to verify pipeline functionality. The
// renderers used in these tests rely heavily on the AudioRendererBase &
// VideoRendererBase implementations which contain a majority of the code used
// in the real AudioRendererImpl & SkCanvasVideoRenderer implementations used in
// the browser. The renderers in this test don't actually write data to a
// display or audio device. Both of these devices are simulated since they have
// little effect on verifying pipeline behavior and allow tests to run faster
// than real-time.
class PipelineIntegrationTestBase {
public:
PipelineIntegrationTestBase();
virtual ~PipelineIntegrationTestBase();
bool WaitUntilOnEnded();
PipelineStatus WaitUntilEndedOrError();
bool Start(const base::FilePath& file_path, PipelineStatus expected_status);
// Enable playback with audio and video hashing enabled. Frame dropping and
// audio underflow will be disabled to ensure consistent hashes.
bool Start(const base::FilePath& file_path, PipelineStatus expected_status,
bool hashing_enabled);
// Initialize the pipeline and ignore any status updates. Useful for testing
// invalid audio/video clips which don't have deterministic results.
bool Start(const base::FilePath& file_path);
void Play();
void Pause();
bool Seek(base::TimeDelta seek_time);
void Stop();
bool WaitUntilCurrentTimeIsAfter(const base::TimeDelta& wait_time);
scoped_ptr<FilterCollection> CreateFilterCollection(
const base::FilePath& file_path);
// Returns the MD5 hash of all video frames seen. Should only be called once
// after playback completes. First time hashes should be generated with
// --video-threads=1 to ensure correctness. Pipeline must have been started
// with hashing enabled.
std::string GetVideoHash();
// Returns the MD5 hash of all audio frames seen. Should only be called once
// after playback completes. Pipeline must have been started with hashing
// enabled.
std::string GetAudioHash();
protected:
MessageLoop message_loop_;
base::MD5Context md5_context_;
bool hashing_enabled_;
scoped_refptr<Pipeline> pipeline_;
scoped_refptr<NullAudioSink> audio_sink_;
bool ended_;
PipelineStatus pipeline_status_;
void OnStatusCallbackChecked(PipelineStatus expected_status,
PipelineStatus status);
void OnStatusCallback(PipelineStatus status);
PipelineStatusCB QuitOnStatusCB(PipelineStatus expected_status);
void OnEnded();
void OnError(PipelineStatus status);
void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time);
scoped_ptr<FilterCollection> CreateFilterCollection(
const scoped_refptr<Demuxer>& demuxer, Decryptor* decryptor);
void SetDecryptor(Decryptor* decryptor,
const DecryptorReadyCB& decryptor_ready_cb);
void OnVideoRendererPaint(const scoped_refptr<VideoFrame>& frame);
MOCK_METHOD1(OnSetOpaque, void(bool));
MOCK_METHOD1(OnBufferingState, void(Pipeline::BufferingState));
};
} // namespace media
#endif // MEDIA_FILTERS_PIPELINE_INTEGRATION_TEST_BASE_H_
|