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

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

Issue 8936014: Removing DataSource from Filter hierarchy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build busters Created 9 years 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "media/base/data_buffer.h" 13 #include "media/base/data_buffer.h"
14 #include "media/base/filter_host.h"
15 #include "media/base/limits.h" 14 #include "media/base/limits.h"
16 #include "media/base/media_switches.h" 15 #include "media/base/media_switches.h"
17 #include "media/ffmpeg/ffmpeg_common.h" 16 #include "media/ffmpeg/ffmpeg_common.h"
18 #include "media/filters/bitstream_converter.h" 17 #include "media/filters/bitstream_converter.h"
19 #include "media/filters/ffmpeg_demuxer.h" 18 #include "media/filters/ffmpeg_demuxer.h"
20 #include "media/filters/ffmpeg_glue.h" 19 #include "media/filters/ffmpeg_glue.h"
21 #include "media/filters/ffmpeg_h264_bitstream_converter.h" 20 #include "media/filters/ffmpeg_h264_bitstream_converter.h"
22 21
23 namespace media { 22 namespace media {
24 23
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 void FFmpegDemuxer::SetPreload(Preload preload) { 331 void FFmpegDemuxer::SetPreload(Preload preload) {
333 DCHECK(data_source_.get()); 332 DCHECK(data_source_.get());
334 data_source_->SetPreload(preload); 333 data_source_->SetPreload(preload);
335 } 334 }
336 335
337 void FFmpegDemuxer::OnAudioRendererDisabled() { 336 void FFmpegDemuxer::OnAudioRendererDisabled() {
338 message_loop_->PostTask(FROM_HERE, base::Bind( 337 message_loop_->PostTask(FROM_HERE, base::Bind(
339 &FFmpegDemuxer::DisableAudioStreamTask, this)); 338 &FFmpegDemuxer::DisableAudioStreamTask, this));
340 } 339 }
341 340
342 void FFmpegDemuxer::set_host(FilterHost* filter_host) { 341 void FFmpegDemuxer::set_host(DemuxerHost* demuxer_host) {
343 Demuxer::set_host(filter_host); 342 Demuxer::set_host(demuxer_host);
344 if (data_source_) 343 if (data_source_)
345 data_source_->set_host(filter_host); 344 data_source_->set_host(demuxer_host);
346 if (max_duration_.InMicroseconds() >= 0) 345 if (max_duration_.InMicroseconds() >= 0)
347 host()->SetDuration(max_duration_); 346 host()->SetDuration(max_duration_);
348 if (read_position_ > 0) 347 if (read_position_ > 0)
349 host()->SetCurrentReadPosition(read_position_); 348 host()->SetCurrentReadPosition(read_position_);
350 if (deferred_status_ != PIPELINE_OK) 349 if (deferred_status_ != PIPELINE_OK)
351 host()->SetError(deferred_status_); 350 host()->OnDemuxerError(deferred_status_);
352 } 351 }
353 352
354 void FFmpegDemuxer::Initialize(DataSource* data_source, 353 void FFmpegDemuxer::Initialize(DataSource* data_source,
355 const PipelineStatusCB& callback) { 354 const PipelineStatusCB& callback) {
356 message_loop_->PostTask( 355 message_loop_->PostTask(
357 FROM_HERE, 356 FROM_HERE,
358 base::Bind(&FFmpegDemuxer::InitializeTask, this, 357 base::Bind(&FFmpegDemuxer::InitializeTask, this,
359 make_scoped_refptr(data_source), 358 make_scoped_refptr(data_source),
360 callback)); 359 callback));
361 } 360 }
(...skipping 26 matching lines...) Expand all
388 // Asynchronous read from data source. 387 // Asynchronous read from data source.
389 data_source_->Read(read_position_, size, data, 388 data_source_->Read(read_position_, size, data,
390 base::Bind(&FFmpegDemuxer::OnReadCompleted, this)); 389 base::Bind(&FFmpegDemuxer::OnReadCompleted, this));
391 390
392 // TODO(hclam): The method is called on the demuxer thread and this method 391 // TODO(hclam): The method is called on the demuxer thread and this method
393 // call will block the thread. We need to implemented an additional thread to 392 // call will block the thread. We need to implemented an additional thread to
394 // let FFmpeg demuxer methods to run on. 393 // let FFmpeg demuxer methods to run on.
395 size_t last_read_bytes = WaitForRead(); 394 size_t last_read_bytes = WaitForRead();
396 if (last_read_bytes == DataSource::kReadError) { 395 if (last_read_bytes == DataSource::kReadError) {
397 if (host()) 396 if (host())
398 host()->SetError(PIPELINE_ERROR_READ); 397 host()->OnDemuxerError(PIPELINE_ERROR_READ);
399 else 398 else
400 deferred_status_ = PIPELINE_ERROR_READ; 399 deferred_status_ = PIPELINE_ERROR_READ;
401 400
402 // Returns with a negative number to signal an error to FFmpeg. 401 // Returns with a negative number to signal an error to FFmpeg.
403 read_has_failed_ = true; 402 read_has_failed_ = true;
404 return AVERROR(EIO); 403 return AVERROR(EIO);
405 } 404 }
406 read_position_ += last_read_bytes; 405 read_position_ += last_read_bytes;
407 406
408 if (host()) 407 if (host())
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 read_event_.Wait(); 732 read_event_.Wait();
734 return last_read_bytes_; 733 return last_read_bytes_;
735 } 734 }
736 735
737 void FFmpegDemuxer::SignalReadCompleted(size_t size) { 736 void FFmpegDemuxer::SignalReadCompleted(size_t size) {
738 last_read_bytes_ = size; 737 last_read_bytes_ = size;
739 read_event_.Signal(); 738 read_event_.Signal();
740 } 739 }
741 740
742 } // namespace media 741 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698