Chromium Code Reviews

Side by Side Diff: services/media/audio/audio_track_impl.h

Issue 1424933002: Add an initial revision of an audio server. (Closed) Base URL: https://github.com/domokit/mojo.git@change4
Patch Set: fix issues discovered with initial preflight Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « services/media/audio/audio_server_impl.cc ('k') | services/media/audio/audio_track_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 2015 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 SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_
6 #define SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_
7
8 #include <deque>
9 #include <set>
10
11 #include "base/synchronization/lock.h"
12 #include "mojo/public/cpp/bindings/binding.h"
13 #include "mojo/public/cpp/bindings/callback.h"
14 #include "mojo/services/media/audio/interfaces/audio_track.mojom.h"
15 #include "mojo/services/media/common/cpp/linear_transform.h"
16 #include "services/media/audio/audio_pipe.h"
17 #include "services/media/audio/fwd_decls.h"
18 #include "services/media/common/rate_control_base.h"
19
20 namespace mojo {
21 namespace media {
22 namespace audio {
23
24 class AudioTrackImpl : public AudioTrack {
25 public:
26 // TODO(johngro): Find a better place for this constant. It affects the
27 // behavior of more than just the Audio Track implementation.
28 static constexpr size_t PTS_FRACTIONAL_BITS = 12;
29
30 ~AudioTrackImpl() override;
31 static AudioTrackImplPtr Create(InterfaceRequest<AudioTrack> iface,
32 AudioServerImpl* owner);
33
34 // Methods used by the output manager to link this track to different outputs.
35 void AddOutput(AudioTrackToOutputLinkPtr link);
36 void RemoveOutput(AudioTrackToOutputLinkPtr link);
37
38 // Accessors used by AudioOutputs during mixing to access parameters which are
39 // important for the mixing process.
40 void SnapshotRateTrans(LinearTransform* out, uint32_t* generation = nullptr) {
41 rate_control_.SnapshotCurrentTransform(out, generation);
42 }
43
44 const LinearTransform::Ratio& FractionalFrameToMediaTimeRatio() const {
45 return frame_to_media_ratio_;
46 }
47
48 uint32_t BytesPerFrame() const { return bytes_per_frame_; }
49 const LpcmMediaTypeDetailsPtr& Format() const { return format_; }
50
51 private:
52 friend class AudioPipe;
53
54 AudioTrackImpl(InterfaceRequest<AudioTrack> track,
55 AudioServerImpl* owner);
56
57 // Implementation of AudioTrack interface.
58 void Describe(const DescribeCallback& cbk) override;
59 void Configure(AudioTrackConfigurationPtr configuration,
60 InterfaceRequest<MediaPipe> req,
61 const ConfigureCallback& cbk) override;
62 void GetRateControl(InterfaceRequest<RateControl> req,
63 const GetRateControlCallback& cbk) override;
64
65 // Methods called by our AudioPipe.
66 //
67 // TODO(johngro): MI is banned by style, but multiple interface inheritance
68 // (inheriting for one or more base classes consisting only of pure virtual
69 // methods) is allowed. Consider defining an interface for AudioPipe
70 // encapsulation so that AudioPipe does not have to know that we are an
71 // AudioTrackImpl (just that we implement its interface).
72 void OnPacketReceived(AudioPipe::AudioPacketRefPtr packet);
73 void OnFlushRequested(const MediaPipe::FlushCallback& cbk);
74
75 AudioTrackImplWeakPtr weak_this_;
76 AudioServerImpl* owner_;
77 Binding<AudioTrack> binding_;
78 AudioPipe pipe_;
79 RateControlBase rate_control_;
80 LinearTransform::Ratio frame_to_media_ratio_;
81 uint32_t bytes_per_frame_ = 1;
82 LpcmMediaTypeDetailsPtr format_;
83 AudioTrackToOutputLinkSet outputs_;
84 };
85
86 } // namespace audio
87 } // namespace media
88 } // namespace mojo
89
90 #endif // SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_
OLDNEW
« no previous file with comments | « services/media/audio/audio_server_impl.cc ('k') | services/media/audio/audio_track_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine