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

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

Issue 159476: Merge 21611 - Implemented proper pausethenseek behaviour for the media pipeli... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 months 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
« no previous file with comments | « media/filters/decoder_base.h ('k') | media/filters/ffmpeg_video_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/media/filters/ffmpeg_demuxer.cc:r21611
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "base/scoped_ptr.h" 5 #include "base/scoped_ptr.h"
6 #include "base/stl_util-inl.h" 6 #include "base/stl_util-inl.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "media/base/filter_host.h" 9 #include "media/base/filter_host.h"
10 #include "media/filters/ffmpeg_common.h" 10 #include "media/filters/ffmpeg_common.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 NOTREACHED() << "Unable to allocate AVPacketBuffer"; 132 NOTREACHED() << "Unable to allocate AVPacketBuffer";
133 return timestamp; 133 return timestamp;
134 } 134 }
135 buffer_queue_.push_back(buffer); 135 buffer_queue_.push_back(buffer);
136 FulfillPendingRead(); 136 FulfillPendingRead();
137 return timestamp; 137 return timestamp;
138 } 138 }
139 139
140 void FFmpegDemuxerStream::FlushBuffers() { 140 void FFmpegDemuxerStream::FlushBuffers() {
141 DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop()); 141 DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop());
142 DCHECK(read_queue_.empty()) << "Read requests should be empty";
142 buffer_queue_.clear(); 143 buffer_queue_.clear();
143 discontinuous_ = true; 144 discontinuous_ = true;
144 } 145 }
145 146
146 void FFmpegDemuxerStream::Stop() { 147 void FFmpegDemuxerStream::Stop() {
147 DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop()); 148 DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop());
148 buffer_queue_.clear(); 149 buffer_queue_.clear();
149 STLDeleteElements(&read_queue_); 150 STLDeleteElements(&read_queue_);
150 stopped_ = true; 151 stopped_ = true;
151 } 152 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { 424 for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
424 (*iter)->FlushBuffers(); 425 (*iter)->FlushBuffers();
425 } 426 }
426 427
427 // Seek backwards if requested timestamp is behind FFmpeg's current time. 428 // Seek backwards if requested timestamp is behind FFmpeg's current time.
428 int flags = 0; 429 int flags = 0;
429 if (time <= current_timestamp_) { 430 if (time <= current_timestamp_) {
430 flags |= AVSEEK_FLAG_BACKWARD; 431 flags |= AVSEEK_FLAG_BACKWARD;
431 } 432 }
432 433
433 if (av_seek_frame(format_context_, -1, time.InMicroseconds(), 434 // Passing -1 as our stream index lets FFmpeg pick a default stream. FFmpeg
434 flags) < 0) { 435 // will attempt to use the lowest-index video stream, if present, followed by
436 // the lowest-index audio stream.
437 if (av_seek_frame(format_context_, -1, time.InMicroseconds(), flags) < 0) {
435 // TODO(scherkus): signal error. 438 // TODO(scherkus): signal error.
436 NOTIMPLEMENTED(); 439 NOTIMPLEMENTED();
437 } 440 }
438 441
439 // Notify we're finished seeking. 442 // Notify we're finished seeking.
440 callback->Run(); 443 callback->Run();
441 } 444 }
442 445
443 void FFmpegDemuxer::DemuxTask() { 446 void FFmpegDemuxer::DemuxTask() {
444 DCHECK_EQ(MessageLoop::current(), message_loop()); 447 DCHECK_EQ(MessageLoop::current(), message_loop());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 read_event_.Wait(); 537 read_event_.Wait();
535 return last_read_bytes_; 538 return last_read_bytes_;
536 } 539 }
537 540
538 void FFmpegDemuxer::SignalReadCompleted(size_t size) { 541 void FFmpegDemuxer::SignalReadCompleted(size_t size) {
539 last_read_bytes_ = size; 542 last_read_bytes_ = size;
540 read_event_.Signal(); 543 read_event_.Signal();
541 } 544 }
542 545
543 } // namespace media 546 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_base.h ('k') | media/filters/ffmpeg_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698