OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // demuxer_bench is a standalone benchmarking tool for FFmpegDemuxer. It | 5 // demuxer_bench is a standalone benchmarking tool for FFmpegDemuxer. It |
6 // simulates the reading requirements for playback by reading from the stream | 6 // simulates the reading requirements for playback by reading from the stream |
7 // that has the earliest timestamp. | 7 // that has the earliest timestamp. |
8 | 8 |
9 #include <iostream> | 9 #include <iostream> |
10 | 10 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return true; | 136 return true; |
137 } | 137 } |
138 | 138 |
139 void StreamReader::OnReadDone( | 139 void StreamReader::OnReadDone( |
140 base::MessageLoop* message_loop, | 140 base::MessageLoop* message_loop, |
141 bool* end_of_stream, | 141 bool* end_of_stream, |
142 base::TimeDelta* timestamp, | 142 base::TimeDelta* timestamp, |
143 media::DemuxerStream::Status status, | 143 media::DemuxerStream::Status status, |
144 const scoped_refptr<media::DecoderBuffer>& buffer) { | 144 const scoped_refptr<media::DecoderBuffer>& buffer) { |
145 CHECK_EQ(status, media::DemuxerStream::kOk); | 145 CHECK_EQ(status, media::DemuxerStream::kOk); |
146 CHECK(buffer); | 146 CHECK(buffer.get()); |
147 *end_of_stream = buffer->IsEndOfStream(); | 147 *end_of_stream = buffer->IsEndOfStream(); |
148 *timestamp = *end_of_stream ? media::kNoTimestamp() : buffer->GetTimestamp(); | 148 *timestamp = *end_of_stream ? media::kNoTimestamp() : buffer->GetTimestamp(); |
149 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 149 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
150 } | 150 } |
151 | 151 |
152 int StreamReader::GetNextStreamIndexToRead() { | 152 int StreamReader::GetNextStreamIndexToRead() { |
153 int index = -1; | 153 int index = -1; |
154 for (int i = 0; i < number_of_streams(); ++i) { | 154 for (int i = 0; i < number_of_streams(); ++i) { |
155 // Ignore streams at EOS. | 155 // Ignore streams at EOS. |
156 if (end_of_stream_[i]) | 156 if (end_of_stream_[i]) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 std::cout << ", " << stream_reader.counts()[i] << " packets" << std::endl; | 228 std::cout << ", " << stream_reader.counts()[i] << " packets" << std::endl; |
229 } | 229 } |
230 | 230 |
231 // Teardown. | 231 // Teardown. |
232 demuxer.Stop(base::Bind( | 232 demuxer.Stop(base::Bind( |
233 &QuitLoopWithStatus, &message_loop, media::PIPELINE_OK)); | 233 &QuitLoopWithStatus, &message_loop, media::PIPELINE_OK)); |
234 message_loop.Run(); | 234 message_loop.Run(); |
235 | 235 |
236 return 0; | 236 return 0; |
237 } | 237 } |
OLD | NEW |