blob: d353c4185b7d89fe845d6790e7473df22a3455f4 (
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
// Copyright (c) 2009 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_BASE_MOCK_PIPELINE_H_
#define MEDIA_BASE_MOCK_PIPELINE_H_
#include <string>
#include "media/base/media_format.h"
#include "media/base/pipeline.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {
class MockPipeline : public media::Pipeline {
public:
MockPipeline() {
Reset(false);
}
virtual ~MockPipeline() {}
// Implementation of PipelineStatus interface.
virtual bool IsInitialized() const {
return initialized_;
}
virtual base::TimeDelta GetDuration() const {
return duration_;
}
virtual base::TimeDelta GetBufferedTime() const {
return buffered_time_;
}
virtual int64 GetTotalBytes() const {
return total_bytes_;
}
virtual int64 GetBufferedBytes() const {
return buffered_bytes_;
}
virtual void GetVideoSize(size_t* width_out, size_t* height_out) const {
*width_out = width_;
*height_out = height_;
}
virtual float GetVolume() const {
return volume_;
}
virtual float GetPlaybackRate() const {
return playback_rate_;
}
virtual base::TimeDelta GetTime() const {
return time_;
}
virtual base::TimeDelta GetInterpolatedTime() const {
return time_;
}
virtual PipelineError GetError() const {
return error_;
}
// Implementation of Pipeline interface.
virtual bool Start(FilterFactory* filter_factory,
const std::string& url,
Callback1<bool>::Type* init_complete_callback) {
EXPECT_FALSE(initialized_);
initialized_ = true;
if (init_complete_callback) {
init_complete_callback->Run(true);
delete init_complete_callback;
}
return true;
}
virtual void Stop() {
EXPECT_TRUE(initialized_ || error_ != media::PIPELINE_OK);
Reset(false);
}
virtual void SetPlaybackRate(float playback_rate) {
playback_rate_ = playback_rate;
}
virtual void Seek(base::TimeDelta time) {
time_ = time;
}
virtual void SetVolume(float volume) {
volume_ = volume;
}
// Public methods used by tests and by MockFilterHost to manipulate the
// state of the mock pipeline.
// Set the state to the same as a newly created MockPipeline. If
// |reset_to_initialized| is true then the pipeline's |initialized_| state
// will be true when this method returns.
void Reset(bool reset_to_initialized) {
error_ = media::PIPELINE_OK;
volume_ = 1.0f;
playback_rate_ = 0.0f;
initialized_ = reset_to_initialized;
time_ = base::TimeDelta();
duration_ = base::TimeDelta();
buffered_time_ = base::TimeDelta();
width_ = 0;
height_ = 0;
buffered_bytes_ = 0;
total_bytes_ = 0;
}
void SetInitialized(bool init_value) {
initialized_ = init_value;
}
void Error(media::PipelineError error) {
initialized_ = false;
error_ = error;
}
void SetTime(base::TimeDelta time) {
time_ = time;
}
virtual void SetDuration(base::TimeDelta duration) {
duration_ = duration;
}
virtual void SetBufferedTime(base::TimeDelta buffered_time) {
buffered_time = buffered_time;
}
virtual void SetTotalBytes(int64 total_bytes) {
total_bytes_ = total_bytes;
}
virtual void SetBufferedBytes(int64 buffered_bytes) {
buffered_bytes_ = buffered_bytes;
}
// Sets the size of the video output in pixel units.
virtual void SetVideoSize(size_t width, size_t height) {
width_ = width;
height_ = height;
}
private:
PipelineError error_;
float volume_;
float playback_rate_;
bool initialized_;
base::TimeDelta time_;
base::TimeDelta duration_;
base::TimeDelta buffered_time_;
size_t width_;
size_t height_;
int64 buffered_bytes_;
int64 total_bytes_;
DISALLOW_COPY_AND_ASSIGN(MockPipeline);
};
} // namespace media
#endif // MEDIA_BASE_MOCK_PIPELINE_H_
|