| 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/common/mojo_decoder_buffer_converter.h" | 5 #include "media/mojo/common/mojo_decoder_buffer_converter.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "media/base/audio_buffer.h" | 13 #include "media/base/audio_buffer.h" |
| 14 #include "media/base/cdm_context.h" | 14 #include "media/base/cdm_context.h" |
| 15 #include "media/base/decoder_buffer.h" | 15 #include "media/base/decoder_buffer.h" |
| 16 #include "media/mojo/common/media_type_converters.h" | 16 #include "media/mojo/common/media_type_converters.h" |
| 17 | 17 |
| 18 namespace media { | 18 namespace media { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 std::unique_ptr<mojo::DataPipe> CreateDataPipe(DemuxerStream::Type type) { | 22 std::unique_ptr<mojo::DataPipe> CreateDataPipe(DemuxerStream::Type type) { |
| 23 MojoCreateDataPipeOptions options; | 23 uint32_t capacity = 0; |
| 24 options.struct_size = sizeof(MojoCreateDataPipeOptions); | |
| 25 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE; | |
| 26 options.element_num_bytes = 1; | |
| 27 | 24 |
| 28 if (type == DemuxerStream::AUDIO) { | 25 if (type == DemuxerStream::AUDIO) { |
| 29 // TODO(timav): Consider capacity calculation based on AudioDecoderConfig. | 26 // TODO(timav): Consider capacity calculation based on AudioDecoderConfig. |
| 30 options.capacity_num_bytes = 512 * 1024; | 27 capacity = 512 * 1024; |
| 31 } else if (type == DemuxerStream::VIDEO) { | 28 } else if (type == DemuxerStream::VIDEO) { |
| 32 // Video can get quite large; at 4K, VP9 delivers packets which are ~1MB in | 29 // Video can get quite large; at 4K, VP9 delivers packets which are ~1MB in |
| 33 // size; so allow for some head room. | 30 // size; so allow for some head room. |
| 34 // TODO(xhwang, sandersd): Provide a better way to customize this value. | 31 // TODO(xhwang, sandersd): Provide a better way to customize this value. |
| 35 options.capacity_num_bytes = 2 * (1024 * 1024); | 32 capacity = 2 * (1024 * 1024); |
| 36 } else { | 33 } else { |
| 37 NOTREACHED() << "Unsupported type: " << type; | 34 NOTREACHED() << "Unsupported type: " << type; |
| 38 // Choose an arbitrary size. | 35 // Choose an arbitrary size. |
| 39 options.capacity_num_bytes = 512 * 1024; | 36 capacity = 512 * 1024; |
| 40 } | 37 } |
| 41 | 38 |
| 42 return base::MakeUnique<mojo::DataPipe>(options); | 39 return base::MakeUnique<mojo::DataPipe>(capacity); |
| 43 } | 40 } |
| 44 | 41 |
| 45 bool IsPipeReadWriteError(MojoResult result) { | 42 bool IsPipeReadWriteError(MojoResult result) { |
| 46 return result != MOJO_RESULT_OK && result != MOJO_RESULT_SHOULD_WAIT; | 43 return result != MOJO_RESULT_OK && result != MOJO_RESULT_SHOULD_WAIT; |
| 47 } | 44 } |
| 48 | 45 |
| 49 } // namespace | 46 } // namespace |
| 50 | 47 |
| 51 // MojoDecoderBufferReader | 48 // MojoDecoderBufferReader |
| 52 | 49 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 media_buffer_ = nullptr; | 286 media_buffer_ = nullptr; |
| 290 bytes_written_ = 0; | 287 bytes_written_ = 0; |
| 291 } | 288 } |
| 292 } | 289 } |
| 293 } | 290 } |
| 294 | 291 |
| 295 return result; | 292 return result; |
| 296 } | 293 } |
| 297 | 294 |
| 298 } // namespace media | 295 } // namespace media |
| OLD | NEW |