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/remoting/demuxer_stream_adapter.h" | 5 #include "media/remoting/demuxer_stream_adapter.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "media/base/bind_to_current_loop.h" | 10 #include "media/base/bind_to_current_loop.h" |
11 #include "media/base/decoder_buffer.h" | 11 #include "media/base/decoder_buffer.h" |
12 #include "media/base/timestamp_constants.h" | 12 #include "media/base/timestamp_constants.h" |
13 #include "media/remoting/proto_enum_utils.h" | 13 #include "media/remoting/proto_enum_utils.h" |
14 #include "media/remoting/proto_utils.h" | 14 #include "media/remoting/proto_utils.h" |
15 | 15 |
16 // Convenience logging macro used throughout this file. | 16 // Convenience logging macro used throughout this file. |
17 #define DEMUXER_VLOG(level) VLOG(level) << __func__ << "[" << name_ << "]: " | 17 #define DEMUXER_VLOG(level) VLOG(level) << __func__ << "[" << name_ << "]: " |
18 | 18 |
19 namespace media { | 19 namespace media { |
20 namespace remoting { | 20 namespace remoting { |
21 | 21 |
22 // static | 22 // static |
23 mojo::DataPipe* DemuxerStreamAdapter::CreateDataPipe() { | 23 mojo::DataPipe* DemuxerStreamAdapter::CreateDataPipe() { |
24 // Capacity in bytes for Mojo data pipe. | 24 // Capacity in bytes for Mojo data pipe. |
25 constexpr int kMojoDataPipeCapacityInBytes = 512 * 1024; | 25 constexpr int kMojoDataPipeCapacityInBytes = 512 * 1024; |
26 | 26 return new mojo::DataPipe(kMojoDataPipeCapacityInBytes); |
27 MojoCreateDataPipeOptions options; | |
28 options.struct_size = sizeof(MojoCreateDataPipeOptions); | |
29 options.flags = MOJO_WRITE_DATA_FLAG_NONE; | |
30 options.element_num_bytes = 1; | |
31 options.capacity_num_bytes = kMojoDataPipeCapacityInBytes; | |
32 return new mojo::DataPipe(options); | |
33 } | 27 } |
34 | 28 |
35 DemuxerStreamAdapter::DemuxerStreamAdapter( | 29 DemuxerStreamAdapter::DemuxerStreamAdapter( |
36 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 30 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
37 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner, | 31 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner, |
38 const std::string& name, | 32 const std::string& name, |
39 DemuxerStream* demuxer_stream, | 33 DemuxerStream* demuxer_stream, |
40 const base::WeakPtr<RpcBroker>& rpc_broker, | 34 const base::WeakPtr<RpcBroker>& rpc_broker, |
41 int rpc_handle, | 35 int rpc_handle, |
42 mojom::RemotingDataStreamSenderPtrInfo stream_sender_info, | 36 mojom::RemotingDataStreamSenderPtrInfo stream_sender_info, |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 if (write_watcher_.IsWatching()) { | 431 if (write_watcher_.IsWatching()) { |
438 DEMUXER_VLOG(2) << "Cancel mojo data pipe watcher"; | 432 DEMUXER_VLOG(2) << "Cancel mojo data pipe watcher"; |
439 write_watcher_.Cancel(); | 433 write_watcher_.Cancel(); |
440 } | 434 } |
441 | 435 |
442 base::ResetAndReturn(&error_callback_).Run(stop_trigger); | 436 base::ResetAndReturn(&error_callback_).Run(stop_trigger); |
443 } | 437 } |
444 | 438 |
445 } // namespace remoting | 439 } // namespace remoting |
446 } // namespace media | 440 } // namespace media |
OLD | NEW |