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

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

Issue 4619001: Make sure that ffmpeg returning us an invalid stream cannot damage us too... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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 | « no previous file | no next file » | 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) 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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 StreamHasEnded(); 522 StreamHasEnded();
523 return; 523 return;
524 } 524 }
525 525
526 // Queue the packet with the appropriate stream. 526 // Queue the packet with the appropriate stream.
527 // TODO(scherkus): should we post this back to the pipeline thread? I'm 527 // TODO(scherkus): should we post this back to the pipeline thread? I'm
528 // worried about downstream filters (i.e., decoders) executing on this 528 // worried about downstream filters (i.e., decoders) executing on this
529 // thread. 529 // thread.
530 DCHECK_GE(packet->stream_index, 0); 530 DCHECK_GE(packet->stream_index, 0);
531 DCHECK_LT(packet->stream_index, static_cast<int>(packet_streams_.size())); 531 DCHECK_LT(packet->stream_index, static_cast<int>(packet_streams_.size()));
532 FFmpegDemuxerStream* demuxer_stream = packet_streams_[packet->stream_index]; 532 FFmpegDemuxerStream* demuxer_stream = NULL;
533 size_t i = packet->stream_index;
fbarchard 2010/11/08 15:55:47 Why create a new variable (i)? FFmpegDemuxerStream
534 // Defend against ffmpeg giving us a bad stream index.
535 if (i < packet_streams_.size()) {
536 demuxer_stream = packet_streams_[i];
537 }
533 if (demuxer_stream) { 538 if (demuxer_stream) {
534 // Queue the packet with the appropriate stream. The stream takes 539 // Queue the packet with the appropriate stream. The stream takes
535 // ownership of the AVPacket. 540 // ownership of the AVPacket.
536 if (packet.get()) { 541 if (packet.get()) {
537 // If a packet is returned by FFmpeg's av_parser_parse2() 542 // If a packet is returned by FFmpeg's av_parser_parse2()
538 // the packet will reference an inner memory of FFmpeg. 543 // the packet will reference an inner memory of FFmpeg.
539 // In this case, the packet's "destruct" member is NULL, 544 // In this case, the packet's "destruct" member is NULL,
540 // and it MUST be duplicated. This fixes issue with MP3 and possibly 545 // and it MUST be duplicated. This fixes issue with MP3 and possibly
541 // other codecs. It is safe to call this function even if the packet does 546 // other codecs. It is safe to call this function even if the packet does
542 // not refer to inner memory from FFmpeg. 547 // not refer to inner memory from FFmpeg.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 read_event_.Wait(); 616 read_event_.Wait();
612 return last_read_bytes_; 617 return last_read_bytes_;
613 } 618 }
614 619
615 void FFmpegDemuxer::SignalReadCompleted(size_t size) { 620 void FFmpegDemuxer::SignalReadCompleted(size_t size) {
616 last_read_bytes_ = size; 621 last_read_bytes_ = size;
617 read_event_.Signal(); 622 read_event_.Signal();
618 } 623 }
619 624
620 } // namespace media 625 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698