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

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

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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_
6 #define MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "media/base/demuxer_stream.h"
13 #include "media/mojo/interfaces/media_types.mojom.h"
14 #include "mojo/public/cpp/system/data_pipe.h"
15
16 namespace media {
17
18 class DecoderBuffer;
19
20 // A helper class that converts mojom::DecoderBuffer to media::DecoderBuffer.
21 // The data part of the DecoderBuffer is read from a DataPipe.
22 class MojoDecoderBufferReader {
23 public:
24 // Creates a MojoDecoderBufferWriter of |type| and set the |producer_handle|.
alokp 2016/06/24 19:35:10 is this a typo?
xhwang 2016/06/24 23:44:12 Done.
25 static std::unique_ptr<MojoDecoderBufferReader> Create(
26 DemuxerStream::Type type,
27 mojo::ScopedDataPipeProducerHandle* producer_handle);
28
29 // Hold the consumer handle to read DecoderBuffer data.
30 explicit MojoDecoderBufferReader(
31 mojo::ScopedDataPipeConsumerHandle consumer_handle);
32
33 ~MojoDecoderBufferReader();
34
35 // Converts |buffer| into a DecoderBuffer (read data from DataPipe if needed).
36 // Returns the result DecoderBuffer. Returns null in case of an error.
37 scoped_refptr<DecoderBuffer> ConvertDecoderBuffer(
alokp 2016/06/24 19:35:10 A Convert function on a Reader seems a bit weird.
xhwang 2016/06/24 23:44:12 Done.
38 const mojom::DecoderBufferPtr& buffer);
39
40 private:
41 // For reading the data section of a DecoderBuffer.
42 mojo::ScopedDataPipeConsumerHandle consumer_handle_;
43
44 DISALLOW_COPY_AND_ASSIGN(MojoDecoderBufferReader);
45 };
46
47 // A helper class that converts media::DecoderBuffer to mojom::DecoderBuffer.
48 // The data part of the DecoderBuffer is written into a DataPipe.
49 class MojoDecoderBufferWriter {
50 public:
51 // Creates a MojoDecoderBufferWriter of |type| and set the |consumer_handle|.
52 static std::unique_ptr<MojoDecoderBufferWriter> Create(
alokp 2016/06/24 19:35:10 I would replace this with a CreateDataPipe functio
xhwang 2016/06/24 23:44:12 See above.
53 DemuxerStream::Type type,
54 mojo::ScopedDataPipeConsumerHandle* consumer_handle);
55
56 // Hold the producer handle to write DecoderBuffer data.
57 explicit MojoDecoderBufferWriter(
58 mojo::ScopedDataPipeProducerHandle producer_handle);
59
60 ~MojoDecoderBufferWriter();
61
62 // Converts a DecoderBuffer into mojo DecoderBuffer, writing data into
63 // DataPipe if needed. Returns null if conversion failed.
64 mojom::DecoderBufferPtr ConvertDecoderBuffer(
alokp 2016/06/24 19:35:10 ditto. A Convert function on writer seems weird.
xhwang 2016/06/24 23:44:11 Done.
65 const scoped_refptr<DecoderBuffer>& media_buffer);
66
67 private:
68 // For writing the data section of DecoderBuffer into DataPipe.
69 mojo::ScopedDataPipeProducerHandle producer_handle_;
70
71 DISALLOW_COPY_AND_ASSIGN(MojoDecoderBufferWriter);
72 };
73
74 } // namespace media
75
76 #endif // MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698