| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "base/stl_util-inl.h" | 6 #include "base/stl_util-inl.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "media/base/filter_host.h" | 9 #include "media/base/filter_host.h" |
| 10 #include "media/filters/ffmpeg_common.h" | 10 #include "media/filters/ffmpeg_common.h" |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 488 } |
| 489 | 489 |
| 490 // Queue the packet with the appropriate stream. | 490 // Queue the packet with the appropriate stream. |
| 491 // TODO(scherkus): should we post this back to the pipeline thread? I'm | 491 // TODO(scherkus): should we post this back to the pipeline thread? I'm |
| 492 // worried about downstream filters (i.e., decoders) executing on this | 492 // worried about downstream filters (i.e., decoders) executing on this |
| 493 // thread. | 493 // thread. |
| 494 DCHECK(packet->stream_index >= 0); | 494 DCHECK(packet->stream_index >= 0); |
| 495 DCHECK(packet->stream_index < static_cast<int>(packet_streams_.size())); | 495 DCHECK(packet->stream_index < static_cast<int>(packet_streams_.size())); |
| 496 FFmpegDemuxerStream* demuxer_stream = packet_streams_[packet->stream_index]; | 496 FFmpegDemuxerStream* demuxer_stream = packet_streams_[packet->stream_index]; |
| 497 if (demuxer_stream) { | 497 if (demuxer_stream) { |
| 498 // Duplicate the entire packet if we're dealing with MP3 due to an issue | 498 // Duplicate the entire packet to avoid aliasing. |
| 499 // where previously demuxed packets can become corrupted by simply demuxing | 499 // Directly affects MP3, but do all formats to be safe. |
| 500 // additional packets. | 500 scoped_ptr<AVPacket> clone(ClonePacket(packet.get())); |
| 501 // | 501 if (!clone.get()) { |
| 502 // TODO(scherkus): fix the MP3 packet copying hack. | 502 NOTREACHED(); |
| 503 if (demuxer_stream->GetAVStream()->codec->codec_id == CODEC_ID_MP3) { | 503 return; |
| 504 scoped_ptr<AVPacket> clone(ClonePacket(packet.get())); | |
| 505 if (!clone.get()) { | |
| 506 NOTREACHED(); | |
| 507 return; | |
| 508 } | |
| 509 // Free FFmpeg-allocated memory and swap original packet into |clone| so | |
| 510 // that it gets deleted as |clone| goes out of scope. | |
| 511 av_free_packet(packet.get()); | |
| 512 packet.swap(clone); | |
| 513 } | 504 } |
| 505 // Free FFmpeg-allocated memory and swap original packet into |clone| so |
| 506 // that it gets deleted as |clone| goes out of scope. |
| 507 av_free_packet(packet.get()); |
| 508 packet.swap(clone); |
| 514 | 509 |
| 515 // Queue the packet with the appropriate stream. The stream takes | 510 // Queue the packet with the appropriate stream. The stream takes |
| 516 // ownership of the AVPacket. | 511 // ownership of the AVPacket. |
| 517 current_timestamp_ = demuxer_stream->EnqueuePacket(packet.release()); | 512 current_timestamp_ = demuxer_stream->EnqueuePacket(packet.release()); |
| 518 } else { | 513 } else { |
| 519 av_free_packet(packet.get()); | 514 av_free_packet(packet.get()); |
| 520 } | 515 } |
| 521 | 516 |
| 522 // Create a loop by posting another task. This allows seek and message loop | 517 // Create a loop by posting another task. This allows seek and message loop |
| 523 // quit tasks to get processed. | 518 // quit tasks to get processed. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 read_event_.Wait(); | 576 read_event_.Wait(); |
| 582 return last_read_bytes_; | 577 return last_read_bytes_; |
| 583 } | 578 } |
| 584 | 579 |
| 585 void FFmpegDemuxer::SignalReadCompleted(size_t size) { | 580 void FFmpegDemuxer::SignalReadCompleted(size_t size) { |
| 586 last_read_bytes_ = size; | 581 last_read_bytes_ = size; |
| 587 read_event_.Signal(); | 582 read_event_.Signal(); |
| 588 } | 583 } |
| 589 | 584 |
| 590 } // namespace media | 585 } // namespace media |
| OLD | NEW |