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

Side by Side Diff: media/mojo/services/mojo_demuxer_stream_adapter.h

Issue 551963004: media: scaffolding and plumbing for MojoRenderer{Impl, Service} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2014 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_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_
6 #define MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_
7
8 #include <queue>
9
10 #include "base/memory/weak_ptr.h"
11 #include "media/base/audio_decoder_config.h"
12 #include "media/base/demuxer_stream.h"
13 #include "media/base/video_decoder_config.h"
14 #include "media/mojo/interfaces/demuxer_stream.mojom.h"
15
16 namespace media {
17
18 // This class acts as a MojoRendererService-side stub for a real
19 // media::DemuxerStream that is part of a media::Pipeline in a remote
20 // application. Roughly speaking, it takes a mojo::DemuxerStreamPtr and exposes
21 // it as a media::DemuxerStream for use by media components.
22 class MojoDemuxerStreamAdapter : public media::DemuxerStream,
23 public mojo::DemuxerStreamClient {
24 public:
25 // |stream| is connected to the mojo::DemuxerStream that |this| will become
26 // the client of.
27 // |stream_ready| will be invoked when |stream| has fully initialized
28 // and |this| is ready for use.
29 // NOTE: It is illegal to call any methods until |stream_ready| is invoked.
30 MojoDemuxerStreamAdapter(mojo::DemuxerStreamPtr stream,
xhwang 2014/09/10 00:00:52 nit: s/stream/demuxer_stream
tim (not reviewing) 2014/09/10 23:08:29 Done.
31 const base::Closure& stream_ready);
xhwang 2014/09/10 00:00:52 nit: s/stream_ready/stream_ready_cb/
tim (not reviewing) 2014/09/10 23:08:29 Done.
32 virtual ~MojoDemuxerStreamAdapter();
33
34 // media::DemuxerStream implementation
scherkus (not reviewing) 2014/09/09 20:35:32 comments end w/ periods
tim (not reviewing) 2014/09/10 23:08:29 Done.
35 virtual void Read(const ReadCB& read_cb) OVERRIDE;
36 virtual AudioDecoderConfig audio_decoder_config() OVERRIDE;
37 virtual VideoDecoderConfig video_decoder_config() OVERRIDE;
38 virtual Type type() OVERRIDE;
39 virtual void EnableBitstreamConverter() OVERRIDE;
40 virtual bool SupportsConfigChanges() OVERRIDE;
41 virtual VideoRotation video_rotation() OVERRIDE;
42
43 // mojo::DemuxerStreamClient implementation.
44 virtual void OnStreamReady(
45 mojo::ScopedDataPipeConsumerHandle pipe) OVERRIDE;
46 virtual void OnAudioDecoderConfigChanged(
47 mojo::AudioDecoderConfigPtr config) OVERRIDE;
48
49 private:
50 // The callback from |demuxer_stream_| that a read operation has completed.
51 // |read_cb| is a callback from the client who invoked Read() on |this|.
52 void OnBufferReady(const ReadCB& read_cb,
53 mojo::DemuxerStream::Status status,
54 mojo::MediaDecoderBufferPtr buffer);
55
56 // See constructor for descriptions.
57 mojo::DemuxerStreamPtr demuxer_stream_;
58 base::Closure stream_ready_callback_;
xhwang 2014/09/10 00:00:52 nit: s/stream_ready_callback_/stream_ready_cb_/
tim (not reviewing) 2014/09/10 23:08:29 Done.
59
60 // Used to store the results of OnBufferReady() in the event it is called
61 // with DemuxerStream::Status::kConfigChanged and we don't have an up to
62 // date AudioDecoderConfig yet. In that case we can't forward the results
63 // on to the caller of Read() until OnAudioDecoderConfigChanged is observed.
64 base::Closure on_config_change_cb_;
65
66 // The front of the queue is the current config. We pop when we observe
67 // DemuxerStatus::CONFIG_CHANGED.
68 std::queue<media::AudioDecoderConfig> config_queue_;
69
70 base::WeakPtrFactory<MojoDemuxerStreamAdapter> weak_factory_;
71 DISALLOW_COPY_AND_ASSIGN(MojoDemuxerStreamAdapter);
72 };
73
74 } // namespace media
75
76 #endif // MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698