OLD | NEW |
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
376 void FFmpegDemuxerStream::SetEndOfStream() { | 376 void FFmpegDemuxerStream::SetEndOfStream() { |
377 DCHECK(task_runner_->BelongsToCurrentThread()); | 377 DCHECK(task_runner_->BelongsToCurrentThread()); |
378 end_of_stream_ = true; | 378 end_of_stream_ = true; |
379 SatisfyPendingRead(); | 379 SatisfyPendingRead(); |
380 } | 380 } |
381 | 381 |
382 void FFmpegDemuxerStream::FlushBuffers() { | 382 void FFmpegDemuxerStream::FlushBuffers() { |
383 DCHECK(task_runner_->BelongsToCurrentThread()); | 383 DCHECK(task_runner_->BelongsToCurrentThread()); |
384 DCHECK(read_cb_.is_null()) << "There should be no pending read"; | 384 DCHECK(read_cb_.is_null()) << "There should be no pending read"; |
| 385 |
| 386 // H264 requires that we resend the header after flush. |
| 387 // Reset its bitstream for converter to do so. |
| 388 // This is related to chromium issue 140371 (http://crbug.com/140371). |
| 389 ResetBitstreamConverter(); |
| 390 |
385 buffer_queue_.Clear(); | 391 buffer_queue_.Clear(); |
386 end_of_stream_ = false; | 392 end_of_stream_ = false; |
387 last_packet_timestamp_ = kNoTimestamp(); | 393 last_packet_timestamp_ = kNoTimestamp(); |
388 last_packet_duration_ = kNoTimestamp(); | 394 last_packet_duration_ = kNoTimestamp(); |
389 } | 395 } |
390 | 396 |
391 void FFmpegDemuxerStream::Stop() { | 397 void FFmpegDemuxerStream::Stop() { |
392 DCHECK(task_runner_->BelongsToCurrentThread()); | 398 DCHECK(task_runner_->BelongsToCurrentThread()); |
393 buffer_queue_.Clear(); | 399 buffer_queue_.Clear(); |
394 if (!read_cb_.is_null()) { | 400 if (!read_cb_.is_null()) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 DCHECK(task_runner_->BelongsToCurrentThread()); | 433 DCHECK(task_runner_->BelongsToCurrentThread()); |
428 | 434 |
429 #if defined(USE_PROPRIETARY_CODECS) | 435 #if defined(USE_PROPRIETARY_CODECS) |
430 CHECK(bitstream_converter_.get()); | 436 CHECK(bitstream_converter_.get()); |
431 bitstream_converter_enabled_ = true; | 437 bitstream_converter_enabled_ = true; |
432 #else | 438 #else |
433 NOTREACHED() << "Proprietary codecs not enabled."; | 439 NOTREACHED() << "Proprietary codecs not enabled."; |
434 #endif | 440 #endif |
435 } | 441 } |
436 | 442 |
| 443 void FFmpegDemuxerStream::ResetBitstreamConverter() { |
| 444 #if defined(USE_PROPRIETARY_CODECS) |
| 445 if (!bitstream_converter_enabled_ || !bitstream_converter_) |
| 446 return; |
| 447 |
| 448 bitstream_converter_.reset( |
| 449 new FFmpegH264ToAnnexBBitstreamConverter(stream_->codec)); |
| 450 #endif // defined(USE_PROPRIETARY_CODECS) |
| 451 } |
| 452 |
437 bool FFmpegDemuxerStream::SupportsConfigChanges() { return false; } | 453 bool FFmpegDemuxerStream::SupportsConfigChanges() { return false; } |
438 | 454 |
439 AudioDecoderConfig FFmpegDemuxerStream::audio_decoder_config() { | 455 AudioDecoderConfig FFmpegDemuxerStream::audio_decoder_config() { |
440 DCHECK(task_runner_->BelongsToCurrentThread()); | 456 DCHECK(task_runner_->BelongsToCurrentThread()); |
441 CHECK_EQ(type_, AUDIO); | 457 CHECK_EQ(type_, AUDIO); |
442 return audio_config_; | 458 return audio_config_; |
443 } | 459 } |
444 | 460 |
445 VideoDecoderConfig FFmpegDemuxerStream::video_decoder_config() { | 461 VideoDecoderConfig FFmpegDemuxerStream::video_decoder_config() { |
446 DCHECK(task_runner_->BelongsToCurrentThread()); | 462 DCHECK(task_runner_->BelongsToCurrentThread()); |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 } | 1264 } |
1249 for (size_t i = 0; i < buffered.size(); ++i) | 1265 for (size_t i = 0; i < buffered.size(); ++i) |
1250 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); | 1266 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); |
1251 } | 1267 } |
1252 | 1268 |
1253 void FFmpegDemuxer::OnDataSourceError() { | 1269 void FFmpegDemuxer::OnDataSourceError() { |
1254 host_->OnDemuxerError(PIPELINE_ERROR_READ); | 1270 host_->OnDemuxerError(PIPELINE_ERROR_READ); |
1255 } | 1271 } |
1256 | 1272 |
1257 } // namespace media | 1273 } // namespace media |
OLD | NEW |