Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1161)

Unified Diff: media/mojo/clients/mojo_demuxer_stream_impl.cc

Issue 2096063003: media: Add MojoDecoderBuffer{Reader|Writer} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/mojo/clients/mojo_demuxer_stream_impl.cc
diff --git a/media/mojo/clients/mojo_demuxer_stream_impl.cc b/media/mojo/clients/mojo_demuxer_stream_impl.cc
index 7a91b766b8f6e7510b1f9be43df6fdb0af358124..68b4af52770ca23bdba9ff9d9760c0ee4bb10be1 100644
--- a/media/mojo/clients/mojo_demuxer_stream_impl.cc
+++ b/media/mojo/clients/mojo_demuxer_stream_impl.cc
@@ -13,7 +13,7 @@
#include "media/base/decoder_buffer.h"
#include "media/base/video_decoder_config.h"
#include "media/mojo/common/media_type_converters.h"
-#include "mojo/public/cpp/system/data_pipe.h"
+#include "media/mojo/common/mojo_decoder_buffer_converter.h"
namespace media {
@@ -31,24 +31,6 @@ MojoDemuxerStreamImpl::~MojoDemuxerStreamImpl() {}
// we are now ready for business.
void MojoDemuxerStreamImpl::Initialize(const InitializeCallback& callback) {
DVLOG(2) << __FUNCTION__;
- MojoCreateDataPipeOptions options;
- options.struct_size = sizeof(MojoCreateDataPipeOptions);
- options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
- options.element_num_bytes = 1;
-
- // Allocate DataPipe sizes based on content type to reduce overhead. If this
- // is still too burdensome we can adjust for sample rate or resolution.
- if (stream_->type() == media::DemuxerStream::VIDEO) {
- // Video can get quite large; at 4K, VP9 delivers packets which are ~1MB in
- // size; so allow for 50% headroom.
- options.capacity_num_bytes = 1.5 * (1024 * 1024);
- } else {
- // Other types don't require a lot of room, so use a smaller pipe.
- options.capacity_num_bytes = 512 * 1024;
- }
-
- mojo::DataPipe data_pipe(options);
- stream_pipe_ = std::move(data_pipe.producer_handle);
// Prepare the initial config.
mojom::AudioDecoderConfigPtr audio_config;
@@ -64,8 +46,12 @@ void MojoDemuxerStreamImpl::Initialize(const InitializeCallback& callback) {
return;
}
+ mojo::ScopedDataPipeConsumerHandle remote_consumer_handle;
+ mojo_decoder_buffer_writer_ =
+ MojoDecoderBufferWriter::Create(stream_->type(), &remote_consumer_handle);
+
callback.Run(static_cast<mojom::DemuxerStream::Type>(stream_->type()),
- std::move(data_pipe.consumer_handle), std::move(audio_config),
+ std::move(remote_consumer_handle), std::move(audio_config),
std::move(video_config));
}
@@ -114,22 +100,21 @@ void MojoDemuxerStreamImpl::OnBufferReady(
}
DCHECK_EQ(status, media::DemuxerStream::kOk);
- if (!buffer->end_of_stream()) {
- DCHECK_GT(buffer->data_size(), 0u);
- // Serialize the data section of the DecoderBuffer into our pipe.
- uint32_t bytes_to_write = base::checked_cast<uint32_t>(buffer->data_size());
- uint32_t bytes_written = bytes_to_write;
- CHECK_EQ(WriteDataRaw(stream_pipe_.get(), buffer->data(), &bytes_written,
- MOJO_READ_DATA_FLAG_ALL_OR_NONE),
- MOJO_RESULT_OK);
- CHECK_EQ(bytes_to_write, bytes_written);
+
+ mojom::DecoderBufferPtr mojo_buffer =
+ mojo_decoder_buffer_writer_->ConvertDecoderBuffer(buffer);
+ if (!mojo_buffer) {
+ callback.Run(mojom::DemuxerStream::Status::ABORTED,
+ mojom::DecoderBufferPtr(), std::move(audio_config),
+ std::move(video_config));
+ return;
}
// TODO(dalecurtis): Once we can write framed data to the DataPipe, fill via
// the producer handle and then read more to keep the pipe full. Waiting for
// space can be accomplished using an AsyncWaiter.
callback.Run(static_cast<mojom::DemuxerStream::Status>(status),
- mojom::DecoderBuffer::From(buffer), std::move(audio_config),
+ std::move(mojo_buffer), std::move(audio_config),
std::move(video_config));
}

Powered by Google App Engine
This is Rietveld 408576698