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

Side by Side Diff: media/mojo/common/mojo_decoder_buffer_converter.h

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: rebase Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 #ifndef MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_ 5 #ifndef MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_
6 #define MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_ 6 #define MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "media/base/demuxer_stream.h" 12 #include "media/base/demuxer_stream.h"
13 #include "media/mojo/interfaces/media_types.mojom.h" 13 #include "media/mojo/interfaces/media_types.mojom.h"
14 #include "mojo/public/cpp/system/data_pipe.h" 14 #include "mojo/public/cpp/system/data_pipe.h"
15 #include "mojo/public/cpp/system/watcher.h" 15 #include "mojo/public/cpp/system/simple_watcher.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 class DecoderBuffer; 19 class DecoderBuffer;
20 20
21 // A helper class that converts mojom::DecoderBuffer to media::DecoderBuffer. 21 // A helper class that converts mojom::DecoderBuffer to media::DecoderBuffer.
22 // The data part of the DecoderBuffer is read from a DataPipe. 22 // The data part of the DecoderBuffer is read from a DataPipe.
23 class MojoDecoderBufferReader { 23 class MojoDecoderBufferReader {
24 public: 24 public:
25 using ReadCB = base::OnceCallback<void(scoped_refptr<DecoderBuffer>)>; 25 using ReadCB = base::OnceCallback<void(scoped_refptr<DecoderBuffer>)>;
(...skipping 14 matching lines...) Expand all
40 // Reports a null DecoderBuffer in case of an error. 40 // Reports a null DecoderBuffer in case of an error.
41 void ReadDecoderBuffer(mojom::DecoderBufferPtr buffer, ReadCB read_cb); 41 void ReadDecoderBuffer(mojom::DecoderBufferPtr buffer, ReadCB read_cb);
42 42
43 private: 43 private:
44 void OnPipeError(MojoResult result); 44 void OnPipeError(MojoResult result);
45 void OnPipeReadable(MojoResult result); 45 void OnPipeReadable(MojoResult result);
46 void ReadDecoderBufferData(); 46 void ReadDecoderBufferData();
47 47
48 // For reading the data section of a DecoderBuffer. 48 // For reading the data section of a DecoderBuffer.
49 mojo::ScopedDataPipeConsumerHandle consumer_handle_; 49 mojo::ScopedDataPipeConsumerHandle consumer_handle_;
50 mojo::Watcher pipe_watcher_; 50 mojo::SimpleWatcher pipe_watcher_;
51 51
52 // Only valid during pending read. 52 // Only valid during pending read.
53 ReadCB read_cb_; 53 ReadCB read_cb_;
54 scoped_refptr<DecoderBuffer> media_buffer_; 54 scoped_refptr<DecoderBuffer> media_buffer_;
55 uint32_t bytes_read_; 55 uint32_t bytes_read_;
56 56
57 DISALLOW_COPY_AND_ASSIGN(MojoDecoderBufferReader); 57 DISALLOW_COPY_AND_ASSIGN(MojoDecoderBufferReader);
58 }; 58 };
59 59
60 // A helper class that converts media::DecoderBuffer to mojom::DecoderBuffer. 60 // A helper class that converts media::DecoderBuffer to mojom::DecoderBuffer.
(...skipping 17 matching lines...) Expand all
78 mojom::DecoderBufferPtr WriteDecoderBuffer( 78 mojom::DecoderBufferPtr WriteDecoderBuffer(
79 const scoped_refptr<DecoderBuffer>& media_buffer); 79 const scoped_refptr<DecoderBuffer>& media_buffer);
80 80
81 private: 81 private:
82 void OnPipeError(MojoResult result); 82 void OnPipeError(MojoResult result);
83 void OnPipeWritable(MojoResult result); 83 void OnPipeWritable(MojoResult result);
84 MojoResult WriteDecoderBufferData(); 84 MojoResult WriteDecoderBufferData();
85 85
86 // For writing the data section of DecoderBuffer into DataPipe. 86 // For writing the data section of DecoderBuffer into DataPipe.
87 mojo::ScopedDataPipeProducerHandle producer_handle_; 87 mojo::ScopedDataPipeProducerHandle producer_handle_;
88 mojo::Watcher pipe_watcher_; 88 mojo::SimpleWatcher pipe_watcher_;
89 89
90 // Only valid when data is being written to the pipe. 90 // Only valid when data is being written to the pipe.
91 scoped_refptr<DecoderBuffer> media_buffer_; 91 scoped_refptr<DecoderBuffer> media_buffer_;
92 uint32_t bytes_written_; 92 uint32_t bytes_written_;
93 93
94 DISALLOW_COPY_AND_ASSIGN(MojoDecoderBufferWriter); 94 DISALLOW_COPY_AND_ASSIGN(MojoDecoderBufferWriter);
95 }; 95 };
96 96
97 } // namespace media 97 } // namespace media
98 98
99 #endif // MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_ 99 #endif // MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698