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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const base::Callback<MessageLoop*()>& message_loop_cb) | 52 const base::Callback<MessageLoop*()>& message_loop_cb) |
53 : message_loop_factory_cb_(message_loop_cb), | 53 : message_loop_factory_cb_(message_loop_cb), |
54 message_loop_(NULL), | 54 message_loop_(NULL), |
55 state_(kUninitialized), | 55 state_(kUninitialized), |
56 codec_context_(NULL), | 56 codec_context_(NULL), |
57 av_frame_(NULL), | 57 av_frame_(NULL), |
58 frame_rate_numerator_(0), | 58 frame_rate_numerator_(0), |
59 frame_rate_denominator_(0) { | 59 frame_rate_denominator_(0) { |
60 } | 60 } |
61 | 61 |
62 FFmpegVideoDecoder::~FFmpegVideoDecoder() { | |
63 ReleaseFFmpegResources(); | |
64 } | |
65 | |
66 void FFmpegVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, | 62 void FFmpegVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, |
67 const PipelineStatusCB& status_cb, | 63 const PipelineStatusCB& status_cb, |
68 const StatisticsCB& statistics_cb) { | 64 const StatisticsCB& statistics_cb) { |
69 if (!message_loop_) { | 65 if (!message_loop_) { |
70 message_loop_ = message_loop_factory_cb_.Run(); | 66 message_loop_ = message_loop_factory_cb_.Run(); |
71 message_loop_factory_cb_.Reset(); | 67 message_loop_factory_cb_.Reset(); |
72 | 68 |
73 message_loop_->PostTask(FROM_HERE, base::Bind( | 69 message_loop_->PostTask(FROM_HERE, base::Bind( |
74 &FFmpegVideoDecoder::Initialize, this, | 70 &FFmpegVideoDecoder::Initialize, this, |
75 stream, status_cb, statistics_cb)); | 71 stream, status_cb, statistics_cb)); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 168 } |
173 | 169 |
174 const gfx::Size& FFmpegVideoDecoder::natural_size() { | 170 const gfx::Size& FFmpegVideoDecoder::natural_size() { |
175 return natural_size_; | 171 return natural_size_; |
176 } | 172 } |
177 | 173 |
178 AesDecryptor* FFmpegVideoDecoder::decryptor() { | 174 AesDecryptor* FFmpegVideoDecoder::decryptor() { |
179 return &decryptor_; | 175 return &decryptor_; |
180 } | 176 } |
181 | 177 |
| 178 FFmpegVideoDecoder::~FFmpegVideoDecoder() { |
| 179 ReleaseFFmpegResources(); |
| 180 } |
| 181 |
182 void FFmpegVideoDecoder::DoRead(const ReadCB& read_cb) { | 182 void FFmpegVideoDecoder::DoRead(const ReadCB& read_cb) { |
183 DCHECK_EQ(MessageLoop::current(), message_loop_); | 183 DCHECK_EQ(MessageLoop::current(), message_loop_); |
184 DCHECK(!read_cb.is_null()); | 184 DCHECK(!read_cb.is_null()); |
185 CHECK(read_cb_.is_null()) << "Overlapping decodes are not supported."; | 185 CHECK(read_cb_.is_null()) << "Overlapping decodes are not supported."; |
186 | 186 |
187 // This can happen during shutdown after Stop() has been called. | 187 // This can happen during shutdown after Stop() has been called. |
188 if (state_ == kUninitialized) { | 188 if (state_ == kUninitialized) { |
189 return; | 189 return; |
190 } | 190 } |
191 | 191 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() { | 419 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() { |
420 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt); | 420 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt); |
421 size_t width = codec_context_->width; | 421 size_t width = codec_context_->width; |
422 size_t height = codec_context_->height; | 422 size_t height = codec_context_->height; |
423 | 423 |
424 return VideoFrame::CreateFrame(format, width, height, | 424 return VideoFrame::CreateFrame(format, width, height, |
425 kNoTimestamp(), kNoTimestamp()); | 425 kNoTimestamp(), kNoTimestamp()); |
426 } | 426 } |
427 | 427 |
428 } // namespace media | 428 } // namespace media |
OLD | NEW |