diff --git a/media/cdm/fuchsia/fuchsia_stream_decryptor.cc b/media/cdm/fuchsia/fuchsia_stream_decryptor.cc index d974462dbabb..d8db9b13b731 100644 --- a/media/cdm/fuchsia/fuchsia_stream_decryptor.cc +++ b/media/cdm/fuchsia/fuchsia_stream_decryptor.cc @@ -156,16 +156,15 @@ void FuchsiaStreamDecryptor::OnStreamProcessorAllocateOutputBuffers( base::BindOnce(&Sink::OnSysmemBufferStreamBufferCollectionToken, base::Unretained(sink_))); - fuchsia::sysmem::BufferCollectionConstraints buffer_constraints; - buffer_constraints.usage.none = fuchsia::sysmem::noneUsage; - buffer_constraints.min_buffer_count = min_buffer_count_; - buffer_constraints.has_buffer_memory_constraints = true; - buffer_constraints.buffer_memory_constraints.min_size_bytes = - min_buffer_size_; - buffer_constraints.buffer_memory_constraints.ram_domain_supported = true; - buffer_constraints.buffer_memory_constraints.cpu_domain_supported = true; - buffer_constraints.buffer_memory_constraints.inaccessible_domain_supported = - true; + fuchsia::sysmem2::BufferCollectionConstraints buffer_constraints; + buffer_constraints.mutable_usage()->set_none(fuchsia::sysmem2::noneUsage); + buffer_constraints.set_min_buffer_count(min_buffer_count_); + auto& buffer_memory_constraints = + buffer_constraints.mutable_buffer_memory_constraints(); + buffer_memory_constraints.set_min_size_bytes(min_buffer_size_); + buffer_memory_constraints.set_ram_domain_supported(true); + buffer_memory_constraints.set_cpu_domain_supported(true); + buffer_memory_constraints.set_inaccessible_domain_supported(true); output_buffer_collection_->Initialize(std::move(buffer_constraints), "CrFuchsiaStreamDecryptorOutput"); @@ -225,7 +224,7 @@ void FuchsiaStreamDecryptor::OnError() { void FuchsiaStreamDecryptor::OnInputBuffersAcquired( std::vector buffers, - const fuchsia::sysmem::SingleBufferSettings&) { + const fuchsia::sysmem2::SingleBufferSettings&) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (buffers.empty()) { diff --git a/media/cdm/fuchsia/fuchsia_stream_decryptor.h b/media/cdm/fuchsia/fuchsia_stream_decryptor.h index 165b78d2170c..a08337744b98 100644 --- a/media/cdm/fuchsia/fuchsia_stream_decryptor.h +++ b/media/cdm/fuchsia/fuchsia_stream_decryptor.h @@ -69,7 +69,7 @@ class MEDIA_EXPORT FuchsiaStreamDecryptor void OnInputBuffersAcquired( std::vector buffers, - const fuchsia::sysmem::SingleBufferSettings& buffer_settings); + const fuchsia::sysmem2::SingleBufferSettings& buffer_settings); void SendInputPacket(const DecoderBuffer* buffer, StreamProcessorHelper::IoPacket packet); void ProcessEndOfStream(); diff --git a/media/fuchsia/common/sysmem_client.cc b/media/fuchsia/common/sysmem_client.cc index c897a0560f8d..16bd942b8a7f 100644 --- a/media/fuchsia/common/sysmem_client.cc +++ b/media/fuchsia/common/sysmem_client.cc @@ -18,8 +18,8 @@ namespace media { SysmemCollectionClient::SysmemCollectionClient( - fuchsia::sysmem::Allocator* allocator, - fuchsia::sysmem::BufferCollectionTokenPtr collection_token) + fuchsia::sysmem2::Allocator* allocator, + fuchsia::sysmem2::BufferCollectionTokenPtr collection_token) : allocator_(allocator), collection_token_(std::move(collection_token)) { DCHECK(allocator_); DCHECK(collection_token_); @@ -32,13 +32,13 @@ SysmemCollectionClient::~SysmemCollectionClient() { } void SysmemCollectionClient::Initialize( - fuchsia::sysmem::BufferCollectionConstraints constraints, + fuchsia::sysmem2::BufferCollectionConstraints constraints, base::StringPiece name, uint32_t name_priority) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - writable_ = (constraints.usage.cpu & fuchsia::sysmem::cpuUsageWrite) == - fuchsia::sysmem::cpuUsageWrite; + writable_ = (constraints.usage.cpu & fuchsia::sysmem2::cpuUsageWrite) == + fuchsia::sysmem2::cpuUsageWrite; allocator_->BindSharedCollection(std::move(collection_token_), collection_.NewRequest()); @@ -55,7 +55,7 @@ void SysmemCollectionClient::Initialize( } sync_completion_closures_.push_back( - base::BindOnce(&fuchsia::sysmem::BufferCollection::SetConstraints, + base::BindOnce(&fuchsia::sysmem2::BufferCollection::SetConstraints, base::Unretained(collection_.get()), /*have_constraints=*/true, std::move(constraints))); collection_->Sync( @@ -69,7 +69,7 @@ void SysmemCollectionClient::CreateSharedToken( DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(collection_token_); - fuchsia::sysmem::BufferCollectionTokenPtr token; + fuchsia::sysmem2::BufferCollectionTokenPtr token; collection_token_->Duplicate(ZX_RIGHT_SAME_RIGHTS, token.NewRequest()); if (!debug_client_name.empty()) { @@ -106,7 +106,7 @@ void SysmemCollectionClient::OnSyncComplete() { void SysmemCollectionClient::OnBuffersAllocated( zx_status_t status, - fuchsia::sysmem::BufferCollectionInfo_2 buffer_collection_info) { + fuchsia::sysmem2::BufferCollectionInfo_2 buffer_collection_info) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); if (status != ZX_OK) { @@ -134,7 +134,7 @@ void SysmemCollectionClient::OnError(zx_status_t status) { SysmemAllocatorClient::SysmemAllocatorClient(base::StringPiece client_name) { allocator_ = base::ComponentContextForProcess() ->svc() - ->Connect(); + ->Connect(); allocator_->SetDebugClientInfo(std::string(client_name), base::GetCurrentProcId()); @@ -143,15 +143,15 @@ SysmemAllocatorClient::SysmemAllocatorClient(base::StringPiece client_name) { // Just log a warning. We will handle BufferCollection the failure when // trying to create a new BufferCollection. ZX_DLOG(WARNING, status) - << "The fuchsia.sysmem.Allocator channel was disconnected."; + << "The fuchsia.sysmem2.Allocator channel was disconnected."; }); } SysmemAllocatorClient::~SysmemAllocatorClient() = default; -fuchsia::sysmem::BufferCollectionTokenPtr +fuchsia::sysmem2::BufferCollectionTokenPtr SysmemAllocatorClient::CreateNewToken() { - fuchsia::sysmem::BufferCollectionTokenPtr collection_token; + fuchsia::sysmem2::BufferCollectionTokenPtr collection_token; allocator_->AllocateSharedCollection(collection_token.NewRequest()); return collection_token; } @@ -164,7 +164,7 @@ SysmemAllocatorClient::AllocateNewCollection() { std::unique_ptr SysmemAllocatorClient::BindSharedCollection( - fuchsia::sysmem::BufferCollectionTokenPtr token) { + fuchsia::sysmem2::BufferCollectionTokenPtr token) { return std::make_unique(allocator_.get(), std::move(token)); } diff --git a/media/fuchsia/common/sysmem_client.h b/media/fuchsia/common/sysmem_client.h index 497bea80ada5..4df6c5809366 100644 --- a/media/fuchsia/common/sysmem_client.h +++ b/media/fuchsia/common/sysmem_client.h @@ -6,7 +6,7 @@ #define MEDIA_FUCHSIA_COMMON_SYSMEM_CLIENT_H_ #include -#include +#include #include @@ -18,7 +18,7 @@ namespace media { class VmoBuffer; -// Wrapper for fuchsia.sysmem.BufferCollection . It provides the following two +// Wrapper for fuchsia.sysmem2.BufferCollection . It provides the following two // features: // 1. Calls Sync() and ensures that it completes before buffer constrains are // set and shared tokens are passed to other participants. @@ -30,17 +30,17 @@ class MEDIA_EXPORT SysmemCollectionClient { // Callback for GetSharedToken(). using GetSharedTokenCB = - base::OnceCallback; + base::OnceCallback; // Callback for AcquireBuffers(). Called with an empty |buffers| if buffers // allocation failed. using AcquireBuffersCB = base::OnceCallback buffers, - const fuchsia::sysmem::SingleBufferSettings& settings)>; + const fuchsia::sysmem2::SingleBufferSettings& settings)>; SysmemCollectionClient( - fuchsia::sysmem::Allocator* allocator, - fuchsia::sysmem::BufferCollectionTokenPtr collection_token); + fuchsia::sysmem2::Allocator* allocator, + fuchsia::sysmem2::BufferCollectionTokenPtr collection_token); ~SysmemCollectionClient(); SysmemCollectionClient(const SysmemCollectionClient&) = delete; @@ -55,7 +55,7 @@ class MEDIA_EXPORT SysmemCollectionClient { uint64_t debug_client_id = 0); // Initializes the collection with the given name and constraints. - void Initialize(fuchsia::sysmem::BufferCollectionConstraints constraints, + void Initialize(fuchsia::sysmem2::BufferCollectionConstraints constraints, base::StringPiece name, uint32_t name_priority = kDefaultNamePriority); @@ -67,12 +67,12 @@ class MEDIA_EXPORT SysmemCollectionClient { void OnSyncComplete(); void OnBuffersAllocated( zx_status_t status, - fuchsia::sysmem::BufferCollectionInfo_2 buffer_collection_info); + fuchsia::sysmem2::BufferCollectionInfo buffer_collection_info); void OnError(zx_status_t status); - fuchsia::sysmem::Allocator* const allocator_; - fuchsia::sysmem::BufferCollectionTokenPtr collection_token_; - fuchsia::sysmem::BufferCollectionPtr collection_; + fuchsia::sysmem2::Allocator* const allocator_; + fuchsia::sysmem2::BufferCollectionTokenPtr collection_token_; + fuchsia::sysmem2::BufferCollectionPtr collection_; bool writable_ = false; std::vector sync_completion_closures_; @@ -90,19 +90,19 @@ class MEDIA_EXPORT SysmemAllocatorClient { SysmemAllocatorClient(const SysmemAllocatorClient&) = delete; SysmemAllocatorClient& operator=(const SysmemAllocatorClient&) = delete; - fuchsia::sysmem::BufferCollectionTokenPtr CreateNewToken(); + fuchsia::sysmem2::BufferCollectionTokenPtr CreateNewToken(); // Creates new buffer collection. std::unique_ptr AllocateNewCollection(); // Binds the specified token to a SysmemCollectionClient. std::unique_ptr BindSharedCollection( - fuchsia::sysmem::BufferCollectionTokenPtr token); + fuchsia::sysmem2::BufferCollectionTokenPtr token); private: friend SysmemCollectionClient; - fuchsia::sysmem::AllocatorPtr allocator_; + fuchsia::sysmem2::AllocatorPtr allocator_; }; } // namespace media diff --git a/media/fuchsia/video/fuchsia_video_decoder.cc b/media/fuchsia/video/fuchsia_video_decoder.cc index 92859666b0c2..97af2036eded 100644 --- a/media/fuchsia/video/fuchsia_video_decoder.cc +++ b/media/fuchsia/video/fuchsia_video_decoder.cc @@ -4,7 +4,9 @@ #include "media/fuchsia/video/fuchsia_video_decoder.h" +#include #include +#include #include #include @@ -66,17 +68,17 @@ constexpr size_t kNumInputBuffers = 2; // codecs, not just H264). constexpr size_t kInputBufferSize = 1920 * 1080 * 3 / 2 / 2 + 128 * 1024; -const fuchsia::sysmem::PixelFormatType kSupportedPixelFormats[] = { - fuchsia::sysmem::PixelFormatType::NV12, - fuchsia::sysmem::PixelFormatType::I420, - fuchsia::sysmem::PixelFormatType::YV12, +const fuchsia::images2::PixelFormat kSupportedPixelFormats[] = { + fuchsia::images2::PixelFormat::NV12, + fuchsia::images2::PixelFormat::I420, + fuchsia::images2::PixelFormat::YV12, }; -const fuchsia::sysmem::ColorSpaceType kSupportedColorSpaces[] = { - fuchsia::sysmem::ColorSpaceType::REC601_NTSC, - fuchsia::sysmem::ColorSpaceType::REC601_NTSC_FULL_RANGE, - fuchsia::sysmem::ColorSpaceType::REC601_PAL, - fuchsia::sysmem::ColorSpaceType::REC601_PAL_FULL_RANGE, - fuchsia::sysmem::ColorSpaceType::REC709, +const fuchsia::images2::ColorSpace kSupportedColorSpaces[] = { + fuchsia::images2::ColorSpace::REC601_NTSC, + fuchsia::images2::ColorSpace::REC601_NTSC_FULL_RANGE, + fuchsia::images2::ColorSpace::REC601_PAL, + fuchsia::images2::ColorSpace::REC601_PAL_FULL_RANGE, + fuchsia::images2::ColorSpace::REC709, }; absl::optional ParseMinBufferSize() { @@ -438,7 +440,7 @@ DecoderStatus FuchsiaVideoDecoder::InitializeSysmemBufferStream( } void FuchsiaVideoDecoder::OnSysmemBufferStreamBufferCollectionToken( - fuchsia::sysmem::BufferCollectionTokenPtr token) { + fuchsia::sysmem2::BufferCollectionTokenPtr token) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(decoder_); decoder_->SetInputBufferCollectionToken(std::move(token)); @@ -485,29 +487,25 @@ void FuchsiaVideoDecoder::OnStreamProcessorAllocateOutputBuffers( base::Unretained(this)), "gpu"); - fuchsia::sysmem::BufferCollectionConstraints buffer_constraints; - buffer_constraints.usage.none = fuchsia::sysmem::noneUsage; - buffer_constraints.min_buffer_count_for_camping = kOutputBuffersForCamping; - buffer_constraints.min_buffer_count_for_shared_slack = - kMaxUsedOutputBuffers - kOutputBuffersForCamping; + fuchsia::sysmem2::BufferCollectionConstraints buffer_constraints; + buffer_constraints.mutable_usage()->set_none(fuchsia::sysmem2::noneUsage); + buffer_constraints.set_min_buffer_count_for_camping(kOutputBuffersForCamping); + buffer_constraints.set_min_buffer_count_for_shared_slack( + kMaxUsedOutputBuffers - kOutputBuffersForCamping); - buffer_constraints.image_format_constraints_count = - std::size(kSupportedPixelFormats); + auto& image_format_constraints_vector = + buffer_constraints.mutable_image_format_constraints(); for (size_t pixel_format_index = 0; pixel_format_index < std::size(kSupportedPixelFormats); ++pixel_format_index) { auto& image_format_constraints = - buffer_constraints.image_format_constraints[pixel_format_index]; - image_format_constraints.pixel_format.type = - kSupportedPixelFormats[pixel_format_index]; - image_format_constraints.pixel_format.has_format_modifier = true; - image_format_constraints.pixel_format.format_modifier.value = - fuchsia::sysmem::FORMAT_MODIFIER_LINEAR; - - image_format_constraints.color_spaces_count = - std::size(kSupportedColorSpaces); + image_format_constraints_vector.emplace_back(); + image_format_constraints.set_pixel_format( + kSupportedPixelFormats[pixel_format_index]); + + auto& color_spaces = image_format_constraints.mutable_color_spaces(); for (size_t i = 0; i < std::size(kSupportedColorSpaces); ++i) { - image_format_constraints.color_space[i].type = kSupportedColorSpaces[i]; + color_spaces.emplace_back(kSupportedColorSpaces[i]); } } @@ -517,11 +515,10 @@ void FuchsiaVideoDecoder::OnStreamProcessorAllocateOutputBuffers( pixel_format_index < std::size(kSupportedPixelFormats); ++pixel_format_index) { auto& image_format_constraints = - buffer_constraints.image_format_constraints[pixel_format_index]; - image_format_constraints.required_max_coded_width = - min_buffer_size->width(); - image_format_constraints.required_max_coded_height = - min_buffer_size->height(); + buffer_constraints.image_format_constraints()[pixel_format_index]; + image_format_constraints.set_required_max_size(fuchsia::math::SizeU{ + .width = min_buffer_size->width(), + .height = min_buffer_size->height()}); } } @@ -739,7 +736,7 @@ void FuchsiaVideoDecoder::OnError() { } void FuchsiaVideoDecoder::SetBufferCollectionTokenForGpu( - fuchsia::sysmem::BufferCollectionTokenPtr token) { + fuchsia::sysmem2::BufferCollectionTokenPtr token) { // Register the new collection with the GPU process. DCHECK(!output_buffer_collection_handle_);