| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 13 #include "base/unguessable_token.h" | 14 #include "base/unguessable_token.h" |
| 14 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
| 15 #include "media/base/decoder_buffer.h" | 16 #include "media/base/decoder_buffer.h" |
| 16 #include "media/base/demuxer_stream.h" | 17 #include "media/base/demuxer_stream.h" |
| 17 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
| 18 #include "media/mojo/common/media_type_converters.h" | 19 #include "media/mojo/common/media_type_converters.h" |
| 19 #include "media/mojo/common/mojo_decoder_buffer_converter.h" | 20 #include "media/mojo/common/mojo_decoder_buffer_converter.h" |
| 20 #include "media/mojo/interfaces/media_types.mojom.h" | 21 #include "media/mojo/interfaces/media_types.mojom.h" |
| 21 #include "media/renderers/gpu_video_accelerator_factories.h" | 22 #include "media/renderers/gpu_video_accelerator_factories.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 102 } |
| 102 | 103 |
| 103 uint64_t decode_id = decode_counter_++; | 104 uint64_t decode_id = decode_counter_++; |
| 104 pending_decodes_[decode_id] = decode_cb; | 105 pending_decodes_[decode_id] = decode_cb; |
| 105 remote_decoder_->Decode(std::move(mojo_buffer), | 106 remote_decoder_->Decode(std::move(mojo_buffer), |
| 106 base::Bind(&MojoVideoDecoder::OnDecodeDone, | 107 base::Bind(&MojoVideoDecoder::OnDecodeDone, |
| 107 base::Unretained(this), decode_id)); | 108 base::Unretained(this), decode_id)); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void MojoVideoDecoder::OnVideoFrameDecoded( | 111 void MojoVideoDecoder::OnVideoFrameDecoded( |
| 111 mojom::VideoFramePtr frame, | 112 const scoped_refptr<VideoFrame>& frame, |
| 112 const base::Optional<base::UnguessableToken>& release_token) { | 113 const base::Optional<base::UnguessableToken>& release_token) { |
| 113 DVLOG(2) << __func__; | 114 DVLOG(2) << __func__; |
| 114 DCHECK(task_runner_->BelongsToCurrentThread()); | 115 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 115 | 116 |
| 116 scoped_refptr<VideoFrame> video_frame = frame.To<scoped_refptr<VideoFrame>>(); | |
| 117 if (release_token) { | 117 if (release_token) { |
| 118 video_frame->SetReleaseMailboxCB( | 118 frame->SetReleaseMailboxCB( |
| 119 BindToCurrentLoop(base::Bind(&MojoVideoDecoder::OnReleaseMailbox, | 119 BindToCurrentLoop(base::Bind(&MojoVideoDecoder::OnReleaseMailbox, |
| 120 weak_this_, release_token.value()))); | 120 weak_this_, release_token.value()))); |
| 121 } | 121 } |
| 122 output_cb_.Run(std::move(video_frame)); | 122 output_cb_.Run(frame); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void MojoVideoDecoder::OnReleaseMailbox( | 125 void MojoVideoDecoder::OnReleaseMailbox( |
| 126 const base::UnguessableToken& release_token, | 126 const base::UnguessableToken& release_token, |
| 127 const gpu::SyncToken& release_sync_token) { | 127 const gpu::SyncToken& release_sync_token) { |
| 128 DCHECK(task_runner_->BelongsToCurrentThread()); | 128 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 129 remote_decoder_->OnReleaseMailbox(release_token, release_sync_token); | 129 remote_decoder_->OnReleaseMailbox(release_token, release_sync_token); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void MojoVideoDecoder::OnDecodeDone(uint64_t decode_id, DecodeStatus status) { | 132 void MojoVideoDecoder::OnDecodeDone(uint64_t decode_id, DecodeStatus status) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 for (const auto& pending_decode : pending_decodes_) | 228 for (const auto& pending_decode : pending_decodes_) |
| 229 pending_decode.second.Run(DecodeStatus::DECODE_ERROR); | 229 pending_decode.second.Run(DecodeStatus::DECODE_ERROR); |
| 230 pending_decodes_.clear(); | 230 pending_decodes_.clear(); |
| 231 | 231 |
| 232 if (!reset_cb_.is_null()) | 232 if (!reset_cb_.is_null()) |
| 233 base::ResetAndReturn(&reset_cb_).Run(); | 233 base::ResetAndReturn(&reset_cb_).Run(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace media | 236 } // namespace media |
| OLD | NEW |