| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // Fully initialize AVFormatContext by parsing the stream a little. | 397 // Fully initialize AVFormatContext by parsing the stream a little. |
| 398 result = av_find_stream_info(format_context_); | 398 result = av_find_stream_info(format_context_); |
| 399 if (result < 0) { | 399 if (result < 0) { |
| 400 host()->SetError(DEMUXER_ERROR_COULD_NOT_PARSE); | 400 host()->SetError(DEMUXER_ERROR_COULD_NOT_PARSE); |
| 401 callback->Run(); | 401 callback->Run(); |
| 402 return; | 402 return; |
| 403 } | 403 } |
| 404 | 404 |
| 405 // Create demuxer streams for all supported streams. | 405 // Create demuxer streams for all supported streams. |
| 406 base::TimeDelta max_duration; | 406 base::TimeDelta max_duration; |
| 407 const bool kDemuxerIsWebm = !strcmp("webm", format_context_->iformat->name); |
| 407 for (size_t i = 0; i < format_context_->nb_streams; ++i) { | 408 for (size_t i = 0; i < format_context_->nb_streams; ++i) { |
| 408 AVCodecContext* codec_context = format_context_->streams[i]->codec; | 409 AVCodecContext* codec_context = format_context_->streams[i]->codec; |
| 409 CodecType codec_type = codec_context->codec_type; | 410 CodecType codec_type = codec_context->codec_type; |
| 410 if (codec_type == CODEC_TYPE_AUDIO || codec_type == CODEC_TYPE_VIDEO) { | 411 if (codec_type == CODEC_TYPE_AUDIO || codec_type == CODEC_TYPE_VIDEO) { |
| 411 AVStream* stream = format_context_->streams[i]; | 412 AVStream* stream = format_context_->streams[i]; |
| 413 // WebM is currently strictly VP8 and Vorbis. |
| 414 if (kDemuxerIsWebm && (stream->codec->codec_id != CODEC_ID_VP8 && |
| 415 stream->codec->codec_id != CODEC_ID_VORBIS)) { |
| 416 packet_streams_.push_back(NULL); |
| 417 continue; |
| 418 } |
| 419 |
| 412 FFmpegDemuxerStream* demuxer_stream | 420 FFmpegDemuxerStream* demuxer_stream |
| 413 = new FFmpegDemuxerStream(this, stream); | 421 = new FFmpegDemuxerStream(this, stream); |
| 414 | 422 |
| 415 // Initialize the bitstream if OpenMAX is enabled. | 423 // Initialize the bitstream if OpenMAX is enabled. |
| 416 // TODO(hclam): Should be enabled by the decoder. | 424 // TODO(hclam): Should be enabled by the decoder. |
| 417 if (CommandLine::ForCurrentProcess()->HasSwitch( | 425 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 418 switches::kEnableOpenMax)) { | 426 switches::kEnableOpenMax)) { |
| 419 // TODO(ajwong): Unittest this branch of the if statement. | 427 // TODO(ajwong): Unittest this branch of the if statement. |
| 420 // TODO(hclam): In addition to codec we should also check the container. | 428 // TODO(hclam): In addition to codec we should also check the container. |
| 421 const char* filter_name = NULL; | 429 const char* filter_name = NULL; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 read_event_.Wait(); | 613 read_event_.Wait(); |
| 606 return last_read_bytes_; | 614 return last_read_bytes_; |
| 607 } | 615 } |
| 608 | 616 |
| 609 void FFmpegDemuxer::SignalReadCompleted(size_t size) { | 617 void FFmpegDemuxer::SignalReadCompleted(size_t size) { |
| 610 last_read_bytes_ = size; | 618 last_read_bytes_ = size; |
| 611 read_event_.Signal(); | 619 read_event_.Signal(); |
| 612 } | 620 } |
| 613 | 621 |
| 614 } // namespace media | 622 } // namespace media |
| OLD | NEW |