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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 std::unique_ptr<mojo::DataPipe> CreateDataPipe(DemuxerStream::Type type) { | 22 std::unique_ptr<mojo::DataPipe> CreateDataPipe(DemuxerStream::Type type) { |
23 MojoCreateDataPipeOptions options; | 23 MojoCreateDataPipeOptions options; |
24 options.struct_size = sizeof(MojoCreateDataPipeOptions); | 24 options.struct_size = sizeof(MojoCreateDataPipeOptions); |
25 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE; | 25 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE; |
26 options.element_num_bytes = 1; | 26 options.element_num_bytes = 1; |
27 | 27 |
28 if (type == DemuxerStream::AUDIO) { | 28 if (type == DemuxerStream::AUDIO) { |
29 // TODO(timav): Consider capacity calculation based on AudioDecoderConfig. | 29 // TODO(timav): Consider capacity calculation based on AudioDecoderConfig. |
30 options.capacity_num_bytes = 512 * 1024; | 30 options.capacity_num_bytes = 512 * 1024; |
31 } else if (type == DemuxerStream::VIDEO) { | 31 } else if (type == DemuxerStream::VIDEO) { |
32 // Video can get quite large; at 4K, VP9 delivers packets which are ~1MB in | 32 // Video can get quite large; at 4K, VP9 delivers packets which could be |
33 // size; so allow for some head room. | 33 // larger than 2MB in size; so allow for some head room. |
34 // TODO(xhwang, sandersd): Provide a better way to customize this value. | 34 // TODO(xhwang, sandersd): Provide a better way to customize this value. |
35 options.capacity_num_bytes = 2 * (1024 * 1024); | 35 options.capacity_num_bytes = 3 * (1024 * 1024); |
36 } else { | 36 } else { |
37 NOTREACHED() << "Unsupported type: " << type; | 37 NOTREACHED() << "Unsupported type: " << type; |
38 // Choose an arbitrary size. | 38 // Choose an arbitrary size. |
39 options.capacity_num_bytes = 512 * 1024; | 39 options.capacity_num_bytes = 512 * 1024; |
40 } | 40 } |
41 | 41 |
42 return base::MakeUnique<mojo::DataPipe>(options); | 42 return base::MakeUnique<mojo::DataPipe>(options); |
43 } | 43 } |
44 | 44 |
45 } // namespace | 45 } // namespace |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE); | 144 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE); |
145 if (result != MOJO_RESULT_OK || num_bytes != media_buffer->data_size()) { | 145 if (result != MOJO_RESULT_OK || num_bytes != media_buffer->data_size()) { |
146 DVLOG(1) << __FUNCTION__ << ": writing to data pipe failed"; | 146 DVLOG(1) << __FUNCTION__ << ": writing to data pipe failed"; |
147 return nullptr; | 147 return nullptr; |
148 } | 148 } |
149 | 149 |
150 return buffer; | 150 return buffer; |
151 } | 151 } |
152 | 152 |
153 } // namespace media | 153 } // namespace media |
OLD | NEW |