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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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/audio/audio_manager_base.cc ('k') | media/filters/video_renderer_base_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "media/filters/ffmpeg_demuxer.h" 5 #include "media/filters/ffmpeg_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // we know we're going to drop it on the floor. 329 // we know we're going to drop it on the floor.
330 330
331 // Always seek to a timestamp less than or equal to the desired timestamp. 331 // Always seek to a timestamp less than or equal to the desired timestamp.
332 int flags = AVSEEK_FLAG_BACKWARD; 332 int flags = AVSEEK_FLAG_BACKWARD;
333 333
334 // Passing -1 as our stream index lets FFmpeg pick a default stream. FFmpeg 334 // Passing -1 as our stream index lets FFmpeg pick a default stream. FFmpeg
335 // will attempt to use the lowest-index video stream, if present, followed by 335 // will attempt to use the lowest-index video stream, if present, followed by
336 // the lowest-index audio stream. 336 // the lowest-index audio stream.
337 pending_seek_ = true; 337 pending_seek_ = true;
338 base::PostTaskAndReplyWithResult( 338 base::PostTaskAndReplyWithResult(
339 blocking_thread_.message_loop_proxy(), FROM_HERE, 339 blocking_thread_.message_loop_proxy().get(),
340 base::Bind(&av_seek_frame, glue_->format_context(), -1, 340 FROM_HERE,
341 time.InMicroseconds(), flags), 341 base::Bind(&av_seek_frame,
342 glue_->format_context(),
343 -1,
344 time.InMicroseconds(),
345 flags),
342 base::Bind(&FFmpegDemuxer::OnSeekFrameDone, weak_this_, cb)); 346 base::Bind(&FFmpegDemuxer::OnSeekFrameDone, weak_this_, cb));
343 } 347 }
344 348
345 void FFmpegDemuxer::SetPlaybackRate(float playback_rate) { 349 void FFmpegDemuxer::SetPlaybackRate(float playback_rate) {
346 DCHECK(message_loop_->BelongsToCurrentThread()); 350 DCHECK(message_loop_->BelongsToCurrentThread());
347 data_source_->SetPlaybackRate(playback_rate); 351 data_source_->SetPlaybackRate(playback_rate);
348 } 352 }
349 353
350 void FFmpegDemuxer::OnAudioRendererDisabled() { 354 void FFmpegDemuxer::OnAudioRendererDisabled() {
351 DCHECK(message_loop_->BelongsToCurrentThread()); 355 DCHECK(message_loop_->BelongsToCurrentThread());
(...skipping 20 matching lines...) Expand all
372 AVFormatContext* format_context = glue_->format_context(); 376 AVFormatContext* format_context = glue_->format_context();
373 377
374 // Disable ID3v1 tag reading to avoid costly seeks to end of file for data we 378 // Disable ID3v1 tag reading to avoid costly seeks to end of file for data we
375 // don't use. FFmpeg will only read ID3v1 tags if no other metadata is 379 // don't use. FFmpeg will only read ID3v1 tags if no other metadata is
376 // available, so add a metadata entry to ensure some is always present. 380 // available, so add a metadata entry to ensure some is always present.
377 av_dict_set(&format_context->metadata, "skip_id3v1_tags", "", 0); 381 av_dict_set(&format_context->metadata, "skip_id3v1_tags", "", 0);
378 382
379 // Open the AVFormatContext using our glue layer. 383 // Open the AVFormatContext using our glue layer.
380 CHECK(blocking_thread_.Start()); 384 CHECK(blocking_thread_.Start());
381 base::PostTaskAndReplyWithResult( 385 base::PostTaskAndReplyWithResult(
382 blocking_thread_.message_loop_proxy(), FROM_HERE, 386 blocking_thread_.message_loop_proxy().get(),
387 FROM_HERE,
383 base::Bind(&FFmpegGlue::OpenContext, base::Unretained(glue_.get())), 388 base::Bind(&FFmpegGlue::OpenContext, base::Unretained(glue_.get())),
384 base::Bind(&FFmpegDemuxer::OnOpenContextDone, weak_this_, status_cb)); 389 base::Bind(&FFmpegDemuxer::OnOpenContextDone, weak_this_, status_cb));
385 } 390 }
386 391
387 DemuxerStream* FFmpegDemuxer::GetStream(DemuxerStream::Type type) { 392 DemuxerStream* FFmpegDemuxer::GetStream(DemuxerStream::Type type) {
388 DCHECK(message_loop_->BelongsToCurrentThread()); 393 DCHECK(message_loop_->BelongsToCurrentThread());
389 return GetFFmpegStream(type); 394 return GetFFmpegStream(type);
390 } 395 }
391 396
392 FFmpegDemuxerStream* FFmpegDemuxer::GetFFmpegStream( 397 FFmpegDemuxerStream* FFmpegDemuxer::GetFFmpegStream(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 return; 454 return;
450 } 455 }
451 456
452 if (!result) { 457 if (!result) {
453 status_cb.Run(DEMUXER_ERROR_COULD_NOT_OPEN); 458 status_cb.Run(DEMUXER_ERROR_COULD_NOT_OPEN);
454 return; 459 return;
455 } 460 }
456 461
457 // Fully initialize AVFormatContext by parsing the stream a little. 462 // Fully initialize AVFormatContext by parsing the stream a little.
458 base::PostTaskAndReplyWithResult( 463 base::PostTaskAndReplyWithResult(
459 blocking_thread_.message_loop_proxy(), FROM_HERE, 464 blocking_thread_.message_loop_proxy().get(),
460 base::Bind(&avformat_find_stream_info, glue_->format_context(), 465 FROM_HERE,
466 base::Bind(&avformat_find_stream_info,
467 glue_->format_context(),
461 static_cast<AVDictionary**>(NULL)), 468 static_cast<AVDictionary**>(NULL)),
462 base::Bind(&FFmpegDemuxer::OnFindStreamInfoDone, weak_this_, status_cb)); 469 base::Bind(&FFmpegDemuxer::OnFindStreamInfoDone, weak_this_, status_cb));
463 } 470 }
464 471
465 void FFmpegDemuxer::OnFindStreamInfoDone(const PipelineStatusCB& status_cb, 472 void FFmpegDemuxer::OnFindStreamInfoDone(const PipelineStatusCB& status_cb,
466 int result) { 473 int result) {
467 DCHECK(message_loop_->BelongsToCurrentThread()); 474 DCHECK(message_loop_->BelongsToCurrentThread());
468 if (!blocking_thread_.IsRunning()) { 475 if (!blocking_thread_.IsRunning()) {
469 status_cb.Run(PIPELINE_ERROR_ABORT); 476 status_cb.Run(PIPELINE_ERROR_ABORT);
470 return; 477 return;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 } 620 }
614 621
615 // Allocate and read an AVPacket from the media. Save |packet_ptr| since 622 // Allocate and read an AVPacket from the media. Save |packet_ptr| since
616 // evaluation order of packet.get() and base::Passed(&packet) is 623 // evaluation order of packet.get() and base::Passed(&packet) is
617 // undefined. 624 // undefined.
618 ScopedAVPacket packet(new AVPacket()); 625 ScopedAVPacket packet(new AVPacket());
619 AVPacket* packet_ptr = packet.get(); 626 AVPacket* packet_ptr = packet.get();
620 627
621 pending_read_ = true; 628 pending_read_ = true;
622 base::PostTaskAndReplyWithResult( 629 base::PostTaskAndReplyWithResult(
623 blocking_thread_.message_loop_proxy(), FROM_HERE, 630 blocking_thread_.message_loop_proxy().get(),
631 FROM_HERE,
624 base::Bind(&av_read_frame, glue_->format_context(), packet_ptr), 632 base::Bind(&av_read_frame, glue_->format_context(), packet_ptr),
625 base::Bind(&FFmpegDemuxer::OnReadFrameDone, weak_this_, 633 base::Bind(
626 base::Passed(&packet))); 634 &FFmpegDemuxer::OnReadFrameDone, weak_this_, base::Passed(&packet)));
627 } 635 }
628 636
629 void FFmpegDemuxer::OnReadFrameDone(ScopedAVPacket packet, int result) { 637 void FFmpegDemuxer::OnReadFrameDone(ScopedAVPacket packet, int result) {
630 DCHECK(message_loop_->BelongsToCurrentThread()); 638 DCHECK(message_loop_->BelongsToCurrentThread());
631 DCHECK(pending_read_); 639 DCHECK(pending_read_);
632 pending_read_ = false; 640 pending_read_ = false;
633 641
634 if (!blocking_thread_.IsRunning() || pending_seek_) { 642 if (!blocking_thread_.IsRunning() || pending_seek_) {
635 return; 643 return;
636 } 644 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 } 774 }
767 for (size_t i = 0; i < buffered.size(); ++i) 775 for (size_t i = 0; i < buffered.size(); ++i)
768 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 776 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
769 } 777 }
770 778
771 void FFmpegDemuxer::OnDataSourceError() { 779 void FFmpegDemuxer::OnDataSourceError() {
772 host_->OnDemuxerError(PIPELINE_ERROR_READ); 780 host_->OnDemuxerError(PIPELINE_ERROR_READ);
773 } 781 }
774 782
775 } // namespace media 783 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/filters/video_renderer_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698