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/gpu_video_decoder.h" | 5 #include "media/filters/gpu_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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 GpuVideoDecoder::BufferPair::~BufferPair() {} | 37 GpuVideoDecoder::BufferPair::~BufferPair() {} |
38 | 38 |
39 GpuVideoDecoder::BufferData::BufferData( | 39 GpuVideoDecoder::BufferData::BufferData( |
40 int32 bbid, base::TimeDelta ts, const gfx::Size& ns) | 40 int32 bbid, base::TimeDelta ts, const gfx::Size& ns) |
41 : bitstream_buffer_id(bbid), timestamp(ts), natural_size(ns) { | 41 : bitstream_buffer_id(bbid), timestamp(ts), natural_size(ns) { |
42 } | 42 } |
43 | 43 |
44 GpuVideoDecoder::BufferData::~BufferData() {} | 44 GpuVideoDecoder::BufferData::~BufferData() {} |
45 | 45 |
46 GpuVideoDecoder::GpuVideoDecoder( | 46 GpuVideoDecoder::GpuVideoDecoder( |
47 MessageLoop* message_loop, | 47 const MessageLoopFactoryCB& message_loop_factory_cb, |
48 MessageLoop* vda_loop, | 48 const scoped_refptr<base::MessageLoopProxy>& vda_loop_proxy, |
49 const scoped_refptr<Factories>& factories) | 49 const scoped_refptr<Factories>& factories) |
50 : gvd_loop_proxy_(message_loop->message_loop_proxy()), | 50 : message_loop_factory_cb_(message_loop_factory_cb), |
51 vda_loop_proxy_(vda_loop->message_loop_proxy()), | 51 gvd_loop_proxy_(NULL), |
| 52 vda_loop_proxy_(vda_loop_proxy), |
52 factories_(factories), | 53 factories_(factories), |
53 state_(kNormal), | 54 state_(kNormal), |
54 demuxer_read_in_progress_(false), | 55 demuxer_read_in_progress_(false), |
55 decoder_texture_target_(0), | 56 decoder_texture_target_(0), |
56 next_picture_buffer_id_(0), | 57 next_picture_buffer_id_(0), |
57 next_bitstream_buffer_id_(0), | 58 next_bitstream_buffer_id_(0), |
58 shutting_down_(false), | 59 shutting_down_(false), |
59 error_occured_(false) { | 60 error_occured_(false) { |
60 DCHECK(gvd_loop_proxy_ && factories_); | 61 DCHECK(!message_loop_factory_cb_.is_null()); |
| 62 DCHECK(factories_); |
61 } | 63 } |
62 | 64 |
63 void GpuVideoDecoder::Reset(const base::Closure& closure) { | 65 void GpuVideoDecoder::Reset(const base::Closure& closure) { |
64 if (!gvd_loop_proxy_->BelongsToCurrentThread() || | 66 if (!gvd_loop_proxy_->BelongsToCurrentThread() || |
65 state_ == kDrainingDecoder) { | 67 state_ == kDrainingDecoder) { |
66 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 68 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
67 &GpuVideoDecoder::Reset, this, closure)); | 69 &GpuVideoDecoder::Reset, this, closure)); |
68 return; | 70 return; |
69 } | 71 } |
70 | 72 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 closure.Run(); | 108 closure.Run(); |
107 return; | 109 return; |
108 } | 110 } |
109 DestroyVDA(); | 111 DestroyVDA(); |
110 closure.Run(); | 112 closure.Run(); |
111 } | 113 } |
112 | 114 |
113 void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, | 115 void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, |
114 const PipelineStatusCB& orig_status_cb, | 116 const PipelineStatusCB& orig_status_cb, |
115 const StatisticsCB& statistics_cb) { | 117 const StatisticsCB& statistics_cb) { |
116 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { | 118 if (!gvd_loop_proxy_) { |
| 119 gvd_loop_proxy_ = base::ResetAndReturn(&message_loop_factory_cb_).Run(); |
117 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 120 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
118 &GpuVideoDecoder::Initialize, | 121 &GpuVideoDecoder::Initialize, |
119 this, stream, orig_status_cb, statistics_cb)); | 122 this, stream, orig_status_cb, statistics_cb)); |
120 return; | 123 return; |
121 } | 124 } |
122 | 125 |
| 126 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); |
123 PipelineStatusCB status_cb = CreateUMAReportingPipelineCB( | 127 PipelineStatusCB status_cb = CreateUMAReportingPipelineCB( |
124 "Media.GpuVideoDecoderInitializeStatus", orig_status_cb); | 128 "Media.GpuVideoDecoderInitializeStatus", orig_status_cb); |
125 | 129 |
126 DCHECK(!demuxer_stream_); | 130 DCHECK(!demuxer_stream_); |
127 if (!stream) { | 131 if (!stream) { |
128 status_cb.Run(PIPELINE_ERROR_DECODE); | 132 status_cb.Run(PIPELINE_ERROR_DECODE); |
129 return; | 133 return; |
130 } | 134 } |
131 | 135 |
132 const VideoDecoderConfig& config = stream->video_decoder_config(); | 136 const VideoDecoderConfig& config = stream->video_decoder_config(); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 | 562 |
559 error_occured_ = true; | 563 error_occured_ = true; |
560 | 564 |
561 if (!pending_read_cb_.is_null()) { | 565 if (!pending_read_cb_.is_null()) { |
562 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); | 566 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); |
563 return; | 567 return; |
564 } | 568 } |
565 } | 569 } |
566 | 570 |
567 } // namespace media | 571 } // namespace media |
OLD | NEW |