| 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_video_decoder.h" | 5 #include "media/filters/ffmpeg_video_decoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 // The FFmpeg API expects us to zero the data pointers in | 127 // The FFmpeg API expects us to zero the data pointers in |
| 128 // this callback | 128 // this callback |
| 129 memset(frame->data, 0, sizeof(frame->data)); | 129 memset(frame->data, 0, sizeof(frame->data)); |
| 130 frame->opaque = NULL; | 130 frame->opaque = NULL; |
| 131 } | 131 } |
| 132 | 132 |
| 133 void FFmpegVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, | 133 void FFmpegVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, |
| 134 const PipelineStatusCB& status_cb, | 134 const PipelineStatusCB& status_cb, |
| 135 const StatisticsCB& statistics_cb) { | 135 const StatisticsCB& statistics_cb) { |
| 136 // Ensure FFmpeg has been initialized | 136 FFmpegGlue::InitializeFFmpeg(); |
| 137 FFmpegGlue::GetInstance(); | |
| 138 | 137 |
| 139 if (!message_loop_) { | 138 if (!message_loop_) { |
| 140 message_loop_ = base::ResetAndReturn(&message_loop_factory_cb_).Run(); | 139 message_loop_ = base::ResetAndReturn(&message_loop_factory_cb_).Run(); |
| 141 message_loop_->PostTask(FROM_HERE, base::Bind( | 140 message_loop_->PostTask(FROM_HERE, base::Bind( |
| 142 &FFmpegVideoDecoder::Initialize, this, | 141 &FFmpegVideoDecoder::Initialize, this, |
| 143 stream, status_cb, statistics_cb)); | 142 stream, status_cb, statistics_cb)); |
| 144 return; | 143 return; |
| 145 } | 144 } |
| 146 | 145 |
| 147 DCHECK(message_loop_->BelongsToCurrentThread()); | 146 DCHECK(message_loop_->BelongsToCurrentThread()); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { | 537 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { |
| 539 ReleaseFFmpegResources(); | 538 ReleaseFFmpegResources(); |
| 540 return false; | 539 return false; |
| 541 } | 540 } |
| 542 | 541 |
| 543 av_frame_ = avcodec_alloc_frame(); | 542 av_frame_ = avcodec_alloc_frame(); |
| 544 return true; | 543 return true; |
| 545 } | 544 } |
| 546 | 545 |
| 547 } // namespace media | 546 } // namespace media |
| OLD | NEW |