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

Side by Side Diff: media/mojo/clients/mojo_data_source_impl.h

Issue 2643743002: Mojify demuxers and allow running {Chunk/FFmpeg}Demuxer in a Utility Process (Closed)
Patch Set: Rebase and make sure to unbind mojom::DemuxerPtr on the bound thread during termination Created 3 years, 10 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
« no previous file with comments | « media/mojo/clients/BUILD.gn ('k') | media/mojo/clients/mojo_data_source_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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_CLIENTS_MOJO_DATA_SOURCE_IMPL_H_
6 #define MEDIA_MOJO_CLIENTS_MOJO_DATA_SOURCE_IMPL_H_
7
8 #include <memory>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "media/base/data_source.h"
14 #include "media/mojo/interfaces/data_source.mojom.h"
15 #include "mojo/public/cpp/bindings/binding.h"
16
17 namespace media {
18
19 class DataSource;
20 class MojoDataBufferWriter;
21
22 // This class wraps a media::DataSource and exposes it as a
23 // mojom::DataSource for use as a proxy from remote applications.
24 class MojoDataSourceImpl : public mojom::DataSource {
25 public:
26 // |data_source| is the underlying DataSource we are proxying for.
27 // Note: |this| does not take ownership of |data_source|.
28 MojoDataSourceImpl(media::DataSource* data_source,
29 mojo::InterfaceRequest<mojom::DataSource> request);
30 ~MojoDataSourceImpl() override;
31
32 // mojom::DataSource implementation.
33 void Initialize(const InitializeCallback& callback) final;
34 void Read(int64_t position, int size, const ReadCallback& callback) final;
35 void Stop() final;
36 void Abort() final;
37 void GetSize(const GetSizeCallback& callback) final;
38 void IsStreaming(const IsStreamingCallback& callback) final;
39 void SetBitrate(int bitrate) final;
40
41 // Sets an error handler that will be called if a connection error occurs on
42 // the bound message pipe.
43 void set_connection_error_handler(const base::Closure& error_handler) {
44 binding_.set_connection_error_handler(error_handler);
45 }
46
47 private:
48 void OnRead(const ReadCallback& callback,
49 std::unique_ptr<uint8_t[]> data,
50 int size);
51
52 mojo::Binding<mojom::DataSource> binding_;
53
54 // See constructor. We do not own |stream_|.
55 media::DataSource* data_source_;
56
57 std::unique_ptr<MojoDataBufferWriter> mojo_data_buffer_writer_;
58
59 base::WeakPtrFactory<MojoDataSourceImpl> weak_factory_;
60 DISALLOW_COPY_AND_ASSIGN(MojoDataSourceImpl);
61 };
62
63 } // namespace media
64
65 #endif // MEDIA_MOJO_CLIENTS_MOJO_DATA_SOURCE_IMPL_H_
OLDNEW
« no previous file with comments | « media/mojo/clients/BUILD.gn ('k') | media/mojo/clients/mojo_data_source_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698