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

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

Issue 8786013: Replace media::Limits struct with media::limits namespace and update documentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 513 }
514 if (format_context_->duration != static_cast<int64_t>(AV_NOPTS_VALUE)) { 514 if (format_context_->duration != static_cast<int64_t>(AV_NOPTS_VALUE)) {
515 // If there is a duration value in the container use that to find the 515 // If there is a duration value in the container use that to find the
516 // maximum between it and the duration from A/V streams. 516 // maximum between it and the duration from A/V streams.
517 const AVRational av_time_base = {1, AV_TIME_BASE}; 517 const AVRational av_time_base = {1, AV_TIME_BASE};
518 max_duration = 518 max_duration =
519 std::max(max_duration, 519 std::max(max_duration,
520 ConvertFromTimeBase(av_time_base, format_context_->duration)); 520 ConvertFromTimeBase(av_time_base, format_context_->duration));
521 } else { 521 } else {
522 // The duration is not a valid value. Assume that this is a live stream 522 // The duration is not a valid value. Assume that this is a live stream
523 // and set duration to the maximum int64 number to represent infinity. 523 // and set duration to the maximum int64 number to represent infinity.
Ami GONE FROM CHROMIUM 2011/12/03 02:11:38 This is crazy. If we want \infty we should define
scherkus (not reviewing) 2011/12/06 02:05:57 That makes sense for durations, but if we're going
524 max_duration = base::TimeDelta::FromMicroseconds( 524 max_duration = base::TimeDelta::FromMicroseconds(
525 Limits::kMaxTimeInMicroseconds); 525 limits::kMaxTimeInMicroseconds);
526 } 526 }
527 527
528 // Some demuxers, like WAV, do not put timestamps on their frames. We 528 // Some demuxers, like WAV, do not put timestamps on their frames. We
529 // assume the the start time is 0. 529 // assume the the start time is 0.
530 if (start_time_ == kNoTimestamp) 530 if (start_time_ == kNoTimestamp)
531 start_time_ = base::TimeDelta(); 531 start_time_ = base::TimeDelta();
532 532
533 // Good to go: set the duration and bitrate and notify we're done 533 // Good to go: set the duration and bitrate and notify we're done
534 // initializing. 534 // initializing.
535 if (host()) 535 if (host())
(...skipping 19 matching lines...) Expand all
555 for (size_t i = 0; i < format_context_->nb_streams; ++i) { 555 for (size_t i = 0; i < format_context_->nb_streams; ++i) {
556 AVCodecContext* codec_context = format_context_->streams[i]->codec; 556 AVCodecContext* codec_context = format_context_->streams[i]->codec;
557 bitrate += codec_context->bit_rate; 557 bitrate += codec_context->bit_rate;
558 } 558 }
559 if (bitrate > 0) 559 if (bitrate > 0)
560 return bitrate; 560 return bitrate;
561 561
562 // If there isn't a bitrate set in the container or streams, but there is a 562 // If there isn't a bitrate set in the container or streams, but there is a
563 // valid duration, approximate the bitrate using the duration. 563 // valid duration, approximate the bitrate using the duration.
564 if (max_duration_.InMilliseconds() > 0 && 564 if (max_duration_.InMilliseconds() > 0 &&
565 max_duration_.InMicroseconds() < Limits::kMaxTimeInMicroseconds) { 565 max_duration_.InMicroseconds() < limits::kMaxTimeInMicroseconds) {
Ami GONE FROM CHROMIUM 2011/12/03 02:11:38 This would be a lot clearer as != kInfinity IMO.
scherkus (not reviewing) 2011/12/06 02:05:57 Done.
566 int64 filesize_in_bytes; 566 int64 filesize_in_bytes;
567 if (GetSize(&filesize_in_bytes)) 567 if (GetSize(&filesize_in_bytes))
568 return 8000 * filesize_in_bytes / max_duration_.InMilliseconds(); 568 return 8000 * filesize_in_bytes / max_duration_.InMilliseconds();
Ami GONE FROM CHROMIUM 2011/12/03 02:11:38 This can SIGFPE b/c the >0 check is done in micros
scherkus (not reviewing) 2011/12/06 02:05:57 Done.
569 } 569 }
570 570
571 // Bitrate could not be determined. 571 // Bitrate could not be determined.
572 return 0; 572 return 0;
573 } 573 }
574 574
575 bool FFmpegDemuxer::IsLocalSource() { 575 bool FFmpegDemuxer::IsLocalSource() {
576 return local_source_; 576 return local_source_;
577 } 577 }
578 578
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 read_event_.Wait(); 732 read_event_.Wait();
733 return last_read_bytes_; 733 return last_read_bytes_;
734 } 734 }
735 735
736 void FFmpegDemuxer::SignalReadCompleted(size_t size) { 736 void FFmpegDemuxer::SignalReadCompleted(size_t size) {
737 last_read_bytes_ = size; 737 last_read_bytes_ = size;
738 read_event_.Signal(); 738 read_event_.Signal();
739 } 739 }
740 740
741 } // namespace media 741 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698