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

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

Issue 11993002: Tighten up media::DecoderBuffer API contract for end of stream buffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months 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 | « media/base/stream_parser_buffer.cc ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | 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) 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_audio_decoder.h" 5 #include "media/filters/ffmpeg_audio_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 output_timestamp_helper_->SetBaseTimestamp(kNoTimestamp()); 344 output_timestamp_helper_->SetBaseTimestamp(kNoTimestamp());
345 last_input_timestamp_ = kNoTimestamp(); 345 last_input_timestamp_ = kNoTimestamp();
346 output_bytes_to_drop_ = 0; 346 output_bytes_to_drop_ = 0;
347 } 347 }
348 348
349 void FFmpegAudioDecoder::RunDecodeLoop( 349 void FFmpegAudioDecoder::RunDecodeLoop(
350 const scoped_refptr<DecoderBuffer>& input, 350 const scoped_refptr<DecoderBuffer>& input,
351 bool skip_eos_append) { 351 bool skip_eos_append) {
352 AVPacket packet; 352 AVPacket packet;
353 av_init_packet(&packet); 353 av_init_packet(&packet);
354 packet.data = const_cast<uint8*>(input->GetData()); 354 if (input->IsEndOfStream()) {
355 packet.size = input->GetDataSize(); 355 packet.data = NULL;
356 packet.size = 0;
357 } else {
358 packet.data = const_cast<uint8*>(input->GetData());
359 packet.size = input->GetDataSize();
360 }
356 361
357 // Each audio packet may contain several frames, so we must call the decoder 362 // Each audio packet may contain several frames, so we must call the decoder
358 // until we've exhausted the packet. Regardless of the packet size we always 363 // until we've exhausted the packet. Regardless of the packet size we always
359 // want to hand it to the decoder at least once, otherwise we would end up 364 // want to hand it to the decoder at least once, otherwise we would end up
360 // skipping end of stream packets since they have a size of zero. 365 // skipping end of stream packets since they have a size of zero.
361 do { 366 do {
362 // Reset frame to default values. 367 // Reset frame to default values.
363 avcodec_get_frame_defaults(av_frame_); 368 avcodec_get_frame_defaults(av_frame_);
364 369
365 int frame_decoded = 0; 370 int frame_decoded = 0;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // Decoding finished successfully, update statistics. 495 // Decoding finished successfully, update statistics.
491 if (result > 0) { 496 if (result > 0) {
492 PipelineStatistics statistics; 497 PipelineStatistics statistics;
493 statistics.audio_bytes_decoded = result; 498 statistics.audio_bytes_decoded = result;
494 statistics_cb_.Run(statistics); 499 statistics_cb_.Run(statistics);
495 } 500 }
496 } while (packet.size > 0); 501 } while (packet.size > 0);
497 } 502 }
498 503
499 } // namespace media 504 } // namespace media
OLDNEW
« no previous file with comments | « media/base/stream_parser_buffer.cc ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698