diff options
author | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 16:37:46 +0000 |
---|---|---|
committer | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 16:37:46 +0000 |
commit | 020fba32dc0e07d855d644bd575d88365b7e2deb (patch) | |
tree | 73cce4387cebbc4497b746f3641a60b66e0ff3be /media/ffmpeg | |
parent | 8914a69a5973071c57b47d4a0c6c43b7330ff9b1 (diff) | |
download | chromium_src-020fba32dc0e07d855d644bd575d88365b7e2deb.zip chromium_src-020fba32dc0e07d855d644bd575d88365b7e2deb.tar.gz chromium_src-020fba32dc0e07d855d644bd575d88365b7e2deb.tar.bz2 |
Adding ChunkDemuxer implementation.
BUG=86536
TEST=ChunkDemuxerTest.*
Review URL: http://codereview.chromium.org/7203002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90966 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/ffmpeg')
-rw-r--r-- | media/ffmpeg/ffmpeg_common.cc | 24 | ||||
-rw-r--r-- | media/ffmpeg/ffmpeg_common.h | 4 |
2 files changed, 28 insertions, 0 deletions
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc index 7af9635..c86acb5 100644 --- a/media/ffmpeg/ffmpeg_common.cc +++ b/media/ffmpeg/ffmpeg_common.cc @@ -206,4 +206,28 @@ int GetSurfaceWidth(AVStream* stream) { return width & ~1; } +void DestroyAVFormatContext(AVFormatContext* format_context) { + DCHECK(format_context); + + // Iterate each stream and destroy each one of them. + int streams = format_context->nb_streams; + for (int i = 0; i < streams; ++i) { + AVStream* stream = format_context->streams[i]; + + // The conditions for calling avcodec_close(): + // 1. AVStream is alive. + // 2. AVCodecContext in AVStream is alive. + // 3. AVCodec in AVCodecContext is alive. + // Notice that closing a codec context without prior avcodec_open() will + // result in a crash in FFmpeg. + if (stream && stream->codec && stream->codec->codec) { + stream->discard = AVDISCARD_ALL; + avcodec_close(stream->codec); + } + } + + // Then finally cleanup the format context. + av_close_input_file(format_context); +} + } // namespace media diff --git a/media/ffmpeg/ffmpeg_common.h b/media/ffmpeg/ffmpeg_common.h index 07daae1..5ac0607 100644 --- a/media/ffmpeg/ffmpeg_common.h +++ b/media/ffmpeg/ffmpeg_common.h @@ -109,6 +109,10 @@ bool GetStreamByteCountOverRange(AVStream* stream, int GetSurfaceHeight(AVStream* stream); int GetSurfaceWidth(AVStream* stream); +// Closes & destroys all AVStreams in the context and then closes & +// destroys the AVFormatContext. +void DestroyAVFormatContext(AVFormatContext* format_context); + } // namespace media #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ |