| 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/services/mojo_video_decoder_service.h" | 5 #include "media/mojo/services/mojo_video_decoder_service.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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/optional.h" | 10 #include "base/optional.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "media/base/decoder_buffer.h" | 12 #include "media/base/decoder_buffer.h" |
| 13 #include "media/base/video_decoder.h" | 13 #include "media/base/video_decoder.h" |
| 14 #include "media/base/video_decoder_config.h" | 14 #include "media/base/video_decoder_config.h" |
| 15 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
| 16 #include "media/mojo/clients/mojo_media_log.h" |
| 16 #include "media/mojo/common/media_type_converters.h" | 17 #include "media/mojo/common/media_type_converters.h" |
| 17 #include "media/mojo/common/mojo_decoder_buffer_converter.h" | 18 #include "media/mojo/common/mojo_decoder_buffer_converter.h" |
| 18 #include "media/mojo/services/mojo_media_client.h" | 19 #include "media/mojo/services/mojo_media_client.h" |
| 19 #include "mojo/public/c/system/types.h" | 20 #include "mojo/public/c/system/types.h" |
| 20 #include "mojo/public/cpp/system/buffer.h" | 21 #include "mojo/public/cpp/system/buffer.h" |
| 21 #include "mojo/public/cpp/system/handle.h" | 22 #include "mojo/public/cpp/system/handle.h" |
| 22 | 23 |
| 23 namespace media { | 24 namespace media { |
| 24 | 25 |
| 25 MojoVideoDecoderService::MojoVideoDecoderService( | 26 MojoVideoDecoderService::MojoVideoDecoderService( |
| 26 MojoMediaClient* mojo_media_client) | 27 MojoMediaClient* mojo_media_client) |
| 27 : mojo_media_client_(mojo_media_client), weak_factory_(this) { | 28 : mojo_media_client_(mojo_media_client), weak_factory_(this) { |
| 28 weak_this_ = weak_factory_.GetWeakPtr(); | 29 weak_this_ = weak_factory_.GetWeakPtr(); |
| 29 } | 30 } |
| 30 | 31 |
| 31 MojoVideoDecoderService::~MojoVideoDecoderService() {} | 32 MojoVideoDecoderService::~MojoVideoDecoderService() {} |
| 32 | 33 |
| 33 void MojoVideoDecoderService::Construct( | 34 void MojoVideoDecoderService::Construct( |
| 34 mojom::VideoDecoderClientAssociatedPtrInfo client, | 35 mojom::VideoDecoderClientAssociatedPtrInfo client, |
| 36 mojom::MediaLogAssociatedPtrInfo media_log, |
| 35 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe, | 37 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe, |
| 36 mojom::CommandBufferIdPtr command_buffer_id) { | 38 mojom::CommandBufferIdPtr command_buffer_id) { |
| 37 DVLOG(1) << __func__; | 39 DVLOG(1) << __func__; |
| 38 | 40 |
| 39 if (decoder_) { | 41 if (decoder_) { |
| 40 // TODO(sandersd): Close the channel. | 42 // TODO(sandersd): Close the channel. |
| 41 return; | 43 return; |
| 42 } | 44 } |
| 43 | 45 |
| 44 decoder_ = mojo_media_client_->CreateVideoDecoder( | 46 client_.Bind(std::move(client)); |
| 45 base::ThreadTaskRunnerHandle::Get(), std::move(command_buffer_id), | |
| 46 base::Bind(&MojoVideoDecoderService::OnDecoderOutput, weak_this_)); | |
| 47 | 47 |
| 48 client_.Bind(std::move(client)); | 48 mojom::MediaLogAssociatedPtr media_log_ptr; |
| 49 media_log_ptr.Bind(std::move(media_log)); |
| 50 media_log_ = base::MakeUnique<MojoMediaLog>(std::move(media_log_ptr)); |
| 49 | 51 |
| 50 mojo_decoder_buffer_reader_.reset( | 52 mojo_decoder_buffer_reader_.reset( |
| 51 new MojoDecoderBufferReader(std::move(decoder_buffer_pipe))); | 53 new MojoDecoderBufferReader(std::move(decoder_buffer_pipe))); |
| 54 |
| 55 decoder_ = mojo_media_client_->CreateVideoDecoder( |
| 56 base::ThreadTaskRunnerHandle::Get(), media_log_.get(), |
| 57 std::move(command_buffer_id), |
| 58 base::Bind(&MojoVideoDecoderService::OnDecoderOutput, weak_this_)); |
| 52 } | 59 } |
| 53 | 60 |
| 54 void MojoVideoDecoderService::Initialize(mojom::VideoDecoderConfigPtr config, | 61 void MojoVideoDecoderService::Initialize(mojom::VideoDecoderConfigPtr config, |
| 55 bool low_delay, | 62 bool low_delay, |
| 56 const InitializeCallback& callback) { | 63 const InitializeCallback& callback) { |
| 57 DVLOG(1) << __func__; | 64 DVLOG(1) << __func__; |
| 58 | 65 |
| 59 if (!decoder_) { | 66 if (!decoder_) { |
| 60 callback.Run(false, false, 1); | 67 callback.Run(false, false, 1); |
| 61 return; | 68 return; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 auto it = release_mailbox_cbs_.find(release_token); | 163 auto it = release_mailbox_cbs_.find(release_token); |
| 157 if (it == release_mailbox_cbs_.end()) | 164 if (it == release_mailbox_cbs_.end()) |
| 158 return; | 165 return; |
| 159 | 166 |
| 160 MojoMediaClient::ReleaseMailboxCB cb = std::move(it->second); | 167 MojoMediaClient::ReleaseMailboxCB cb = std::move(it->second); |
| 161 release_mailbox_cbs_.erase(it); | 168 release_mailbox_cbs_.erase(it); |
| 162 std::move(cb).Run(release_sync_token); | 169 std::move(cb).Run(release_sync_token); |
| 163 } | 170 } |
| 164 | 171 |
| 165 } // namespace media | 172 } // namespace media |
| OLD | NEW |