| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mojo/clients/mojo_video_decoder.h" | 5 #include "media/mojo/clients/mojo_video_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 uint64_t decode_id = decode_counter_++; | 104 uint64_t decode_id = decode_counter_++; |
| 105 pending_decodes_[decode_id] = decode_cb; | 105 pending_decodes_[decode_id] = decode_cb; |
| 106 remote_decoder_->Decode(std::move(mojo_buffer), | 106 remote_decoder_->Decode(std::move(mojo_buffer), |
| 107 base::Bind(&MojoVideoDecoder::OnDecodeDone, | 107 base::Bind(&MojoVideoDecoder::OnDecodeDone, |
| 108 base::Unretained(this), decode_id)); | 108 base::Unretained(this), decode_id)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void MojoVideoDecoder::OnVideoFrameDecoded( | 111 void MojoVideoDecoder::OnVideoFrameDecoded( |
| 112 const scoped_refptr<VideoFrame>& frame, | 112 const scoped_refptr<VideoFrame>& frame, |
| 113 bool can_read_without_stalling, |
| 113 const base::Optional<base::UnguessableToken>& release_token) { | 114 const base::Optional<base::UnguessableToken>& release_token) { |
| 114 DVLOG(2) << __func__; | 115 DVLOG(2) << __func__; |
| 115 DCHECK(task_runner_->BelongsToCurrentThread()); | 116 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 116 | 117 |
| 118 // TODO(sandersd): Prove that all paths read this value again after running |
| 119 // |output_cb_|. In practice this isn't very important, since all decoders |
| 120 // running via MojoVideoDecoder currently use a static value. |
| 121 can_read_without_stalling_ = can_read_without_stalling; |
| 122 |
| 117 if (release_token) { | 123 if (release_token) { |
| 118 frame->SetReleaseMailboxCB( | 124 frame->SetReleaseMailboxCB( |
| 119 BindToCurrentLoop(base::Bind(&MojoVideoDecoder::OnReleaseMailbox, | 125 BindToCurrentLoop(base::Bind(&MojoVideoDecoder::OnReleaseMailbox, |
| 120 weak_this_, release_token.value()))); | 126 weak_this_, release_token.value()))); |
| 121 } | 127 } |
| 122 output_cb_.Run(frame); | 128 output_cb_.Run(frame); |
| 123 } | 129 } |
| 124 | 130 |
| 125 void MojoVideoDecoder::OnReleaseMailbox( | 131 void MojoVideoDecoder::OnReleaseMailbox( |
| 126 const base::UnguessableToken& release_token, | 132 const base::UnguessableToken& release_token, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 171 } |
| 166 | 172 |
| 167 bool MojoVideoDecoder::NeedsBitstreamConversion() const { | 173 bool MojoVideoDecoder::NeedsBitstreamConversion() const { |
| 168 DVLOG(3) << __func__; | 174 DVLOG(3) << __func__; |
| 169 DCHECK(initialized_); | 175 DCHECK(initialized_); |
| 170 return needs_bitstream_conversion_; | 176 return needs_bitstream_conversion_; |
| 171 } | 177 } |
| 172 | 178 |
| 173 bool MojoVideoDecoder::CanReadWithoutStalling() const { | 179 bool MojoVideoDecoder::CanReadWithoutStalling() const { |
| 174 DVLOG(3) << __func__; | 180 DVLOG(3) << __func__; |
| 175 return true; | 181 return can_read_without_stalling_; |
| 176 } | 182 } |
| 177 | 183 |
| 178 int MojoVideoDecoder::GetMaxDecodeRequests() const { | 184 int MojoVideoDecoder::GetMaxDecodeRequests() const { |
| 179 DVLOG(3) << __func__; | 185 DVLOG(3) << __func__; |
| 180 DCHECK(initialized_); | 186 DCHECK(initialized_); |
| 181 return max_decode_requests_; | 187 return max_decode_requests_; |
| 182 } | 188 } |
| 183 | 189 |
| 184 void MojoVideoDecoder::BindRemoteDecoder() { | 190 void MojoVideoDecoder::BindRemoteDecoder() { |
| 185 DVLOG(3) << __func__; | 191 DVLOG(3) << __func__; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 233 |
| 228 for (const auto& pending_decode : pending_decodes_) | 234 for (const auto& pending_decode : pending_decodes_) |
| 229 pending_decode.second.Run(DecodeStatus::DECODE_ERROR); | 235 pending_decode.second.Run(DecodeStatus::DECODE_ERROR); |
| 230 pending_decodes_.clear(); | 236 pending_decodes_.clear(); |
| 231 | 237 |
| 232 if (!reset_cb_.is_null()) | 238 if (!reset_cb_.is_null()) |
| 233 base::ResetAndReturn(&reset_cb_).Run(); | 239 base::ResetAndReturn(&reset_cb_).Run(); |
| 234 } | 240 } |
| 235 | 241 |
| 236 } // namespace media | 242 } // namespace media |
| OLD | NEW |