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 // A fake media source that generates video and audio frames to a cast | 5 // A fake media source that generates video and audio frames to a cast |
6 // sender. | 6 // sender. |
7 // This class can transcode a WebM file using FFmpeg. It can also | 7 // This class can transcode a WebM file using FFmpeg. It can also |
8 // generate an animation and audio of fixed frequency. | 8 // generate an animation and audio of fixed frequency. |
9 | 9 |
10 #ifndef MEDIA_CAST_TEST_FAKE_MEDIA_SOURCE_H_ | 10 #ifndef MEDIA_CAST_TEST_FAKE_MEDIA_SOURCE_H_ |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 base::TickClock* const clock_; // Not owned by this class. | 105 base::TickClock* const clock_; // Not owned by this class. |
106 | 106 |
107 // Time when the stream starts. | 107 // Time when the stream starts. |
108 base::TimeTicks start_time_; | 108 base::TimeTicks start_time_; |
109 | 109 |
110 // The following three members are used only for fake frames. | 110 // The following three members are used only for fake frames. |
111 int audio_frame_count_; // Each audio frame is exactly 10ms. | 111 int audio_frame_count_; // Each audio frame is exactly 10ms. |
112 int video_frame_count_; | 112 int video_frame_count_; |
113 scoped_ptr<TestAudioBusFactory> audio_bus_factory_; | 113 scoped_ptr<TestAudioBusFactory> audio_bus_factory_; |
114 | 114 |
115 // NOTE: Weak pointers must be invalidated before all other member variables. | |
116 base::WeakPtrFactory<FakeMediaSource> weak_factory_; | |
117 | |
118 base::MemoryMappedFile file_data_; | 115 base::MemoryMappedFile file_data_; |
119 scoped_ptr<InMemoryUrlProtocol> protocol_; | 116 scoped_ptr<InMemoryUrlProtocol> protocol_; |
120 scoped_ptr<FFmpegGlue> glue_; | 117 scoped_ptr<FFmpegGlue> glue_; |
121 AVFormatContext* av_format_context_; | 118 AVFormatContext* av_format_context_; |
122 | 119 |
123 int audio_stream_index_; | 120 int audio_stream_index_; |
124 AudioParameters audio_params_; | 121 AudioParameters audio_params_; |
125 double playback_rate_; | 122 double playback_rate_; |
126 | 123 |
127 int video_stream_index_; | 124 int video_stream_index_; |
128 int video_frame_rate_numerator_; | 125 int video_frame_rate_numerator_; |
129 int video_frame_rate_denominator_; | 126 int video_frame_rate_denominator_; |
130 | 127 |
131 // These are used for audio resampling. | 128 // These are used for audio resampling. |
132 scoped_ptr<media::MultiChannelResampler> audio_resampler_; | 129 scoped_ptr<media::MultiChannelResampler> audio_resampler_; |
133 scoped_ptr<media::AudioFifo> audio_fifo_; | 130 scoped_ptr<media::AudioFifo> audio_fifo_; |
134 scoped_ptr<media::AudioBus> audio_fifo_input_bus_; | 131 scoped_ptr<media::AudioBus> audio_fifo_input_bus_; |
135 media::AudioRendererAlgorithm audio_algo_; | 132 media::AudioRendererAlgorithm audio_algo_; |
136 | 133 |
137 // Track the timestamp of audio sent to the receiver. | 134 // Track the timestamp of audio sent to the receiver. |
138 scoped_ptr<media::AudioTimestampHelper> audio_sent_ts_; | 135 scoped_ptr<media::AudioTimestampHelper> audio_sent_ts_; |
139 | 136 |
140 std::queue<scoped_refptr<VideoFrame> > video_frame_queue_; | 137 std::queue<scoped_refptr<VideoFrame> > video_frame_queue_; |
141 int64 video_first_pts_; | 138 int64 video_first_pts_; |
142 bool video_first_pts_set_; | 139 bool video_first_pts_set_; |
143 | 140 |
144 std::queue<AudioBus*> audio_bus_queue_; | 141 std::queue<AudioBus*> audio_bus_queue_; |
145 | 142 |
| 143 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 144 base::WeakPtrFactory<FakeMediaSource> weak_factory_; |
| 145 |
146 DISALLOW_COPY_AND_ASSIGN(FakeMediaSource); | 146 DISALLOW_COPY_AND_ASSIGN(FakeMediaSource); |
147 }; | 147 }; |
148 | 148 |
149 } // namespace cast | 149 } // namespace cast |
150 } // namespace media | 150 } // namespace media |
151 | 151 |
152 #endif // MEDIA_CAST_TEST_FAKE_MEDIA_SOURCE_H_ | 152 #endif // MEDIA_CAST_TEST_FAKE_MEDIA_SOURCE_H_ |
OLD | NEW |