Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: media/filters/chunk_demuxer.cc

Issue 8351045: Change DemuxerStream::ReadCallback to use ref-counted buffers. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: forgot some &s Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Implements a Demuxer that can switch among different data sources mid-stream. 5 // Implements a Demuxer that can switch among different data sources mid-stream.
6 // Uses FFmpegDemuxer under the covers, so see the caveats at the top of 6 // Uses FFmpegDemuxer under the covers, so see the caveats at the top of
7 // ffmpeg_demuxer.h. 7 // ffmpeg_demuxer.h.
8 8
9 #include "media/filters/chunk_demuxer.h" 9 #include "media/filters/chunk_demuxer.h"
10 10
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 if (buffers_.empty()) 217 if (buffers_.empty())
218 return false; 218 return false;
219 219
220 *timestamp = buffers_.back()->GetTimestamp(); 220 *timestamp = buffers_.back()->GetTimestamp();
221 return true; 221 return true;
222 } 222 }
223 223
224 // Helper function that makes sure |read_callback| runs on |message_loop|. 224 // Helper function that makes sure |read_callback| runs on |message_loop|.
225 static void RunOnMessageLoop(const DemuxerStream::ReadCallback& read_callback, 225 static void RunOnMessageLoop(const DemuxerStream::ReadCallback& read_callback,
226 MessageLoop* message_loop, 226 MessageLoop* message_loop,
227 Buffer* buffer) { 227 const scoped_refptr<Buffer>& buffer) {
228 if (MessageLoop::current() != message_loop) { 228 if (MessageLoop::current() != message_loop) {
229 message_loop->PostTask(FROM_HERE, base::Bind( 229 message_loop->PostTask(FROM_HERE, base::Bind(
230 &RunOnMessageLoop, read_callback, message_loop, 230 &RunOnMessageLoop, read_callback, message_loop, buffer));
231 scoped_refptr<Buffer>(buffer)));
232 return; 231 return;
233 } 232 }
234 233
235 read_callback.Run(buffer); 234 read_callback.Run(buffer);
236 } 235 }
237 236
238 // DemuxerStream methods. 237 // DemuxerStream methods.
239 void ChunkDemuxerStream::Read(const ReadCallback& read_callback) { 238 void ChunkDemuxerStream::Read(const ReadCallback& read_callback) {
240 scoped_refptr<Buffer> buffer; 239 scoped_refptr<Buffer> buffer;
241 240
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 base::AutoUnlock auto_unlock(lock_); 738 base::AutoUnlock auto_unlock(lock_);
740 if (cb.is_null()) { 739 if (cb.is_null()) {
741 host()->SetError(error); 740 host()->SetError(error);
742 return; 741 return;
743 } 742 }
744 cb.Run(error); 743 cb.Run(error);
745 } 744 }
746 } 745 }
747 746
748 } // namespace media 747 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698