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

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

Issue 1986303002: Motown: Use new TimelineTransform and related definitions (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixes per feedback. 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_ 5 #ifndef SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_
6 #define SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_ 6 #define SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 10
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
13 #include "mojo/public/cpp/bindings/callback.h" 13 #include "mojo/public/cpp/bindings/callback.h"
14 #include "mojo/services/media/audio/interfaces/audio_track.mojom.h" 14 #include "mojo/services/media/audio/interfaces/audio_track.mojom.h"
15 #include "mojo/services/media/common/cpp/linear_transform.h" 15 #include "mojo/services/media/common/cpp/linear_transform.h"
16 #include "services/media/audio/audio_pipe.h" 16 #include "services/media/audio/audio_pipe.h"
17 #include "services/media/audio/fwd_decls.h" 17 #include "services/media/audio/fwd_decls.h"
18 #include "services/media/common/rate_control_base.h" 18 #include "services/media/common/timeline_control_site.h"
19 19
20 namespace mojo { 20 namespace mojo {
21 namespace media { 21 namespace media {
22 namespace audio { 22 namespace audio {
23 23
24 class AudioTrackImpl : public AudioTrack { 24 class AudioTrackImpl : public AudioTrack {
25 public: 25 public:
26 // TODO(johngro): Find a better place for this constant. It affects the 26 // TODO(johngro): Find a better place for this constant. It affects the
27 // behavior of more than just the Audio Track implementation. 27 // behavior of more than just the Audio Track implementation.
28 static constexpr size_t PTS_FRACTIONAL_BITS = 12; 28 static constexpr size_t PTS_FRACTIONAL_BITS = 12;
29 29
30 ~AudioTrackImpl() override; 30 ~AudioTrackImpl() override;
31 static AudioTrackImplPtr Create(InterfaceRequest<AudioTrack> iface, 31 static AudioTrackImplPtr Create(InterfaceRequest<AudioTrack> iface,
32 AudioServerImpl* owner); 32 AudioServerImpl* owner);
33 33
34 // Shutdown the audio track, unlinking it from all outputs, closing 34 // Shutdown the audio track, unlinking it from all outputs, closing
35 // connections to all clients and removing it from its owner server's list. 35 // connections to all clients and removing it from its owner server's list.
36 void Shutdown(); 36 void Shutdown();
37 37
38 // Methods used by the output manager to link this track to different outputs. 38 // Methods used by the output manager to link this track to different outputs.
39 void AddOutput(AudioTrackToOutputLinkPtr link); 39 void AddOutput(AudioTrackToOutputLinkPtr link);
40 void RemoveOutput(AudioTrackToOutputLinkPtr link); 40 void RemoveOutput(AudioTrackToOutputLinkPtr link);
41 41
42 // Accessors used by AudioOutputs during mixing to access parameters which are 42 // Accessors used by AudioOutputs during mixing to access parameters which are
43 // important for the mixing process. 43 // important for the mixing process.
44 void SnapshotRateTrans(LinearTransform* out, uint32_t* generation = nullptr) { 44 void SnapshotRateTrans(LinearTransform* out, uint32_t* generation = nullptr);
45 rate_control_.SnapshotCurrentTransform(out, generation);
46 }
47 45
48 const LinearTransform::Ratio& FractionalFrameToMediaTimeRatio() const { 46 const LinearTransform::Ratio& FractionalFrameToMediaTimeRatio() const {
49 return frame_to_media_ratio_; 47 return frame_to_media_ratio_;
50 } 48 }
51 49
52 uint32_t BytesPerFrame() const { return bytes_per_frame_; } 50 uint32_t BytesPerFrame() const { return bytes_per_frame_; }
53 const AudioMediaTypeDetailsPtr& Format() const { return format_; } 51 const AudioMediaTypeDetailsPtr& Format() const { return format_; }
54 float DbGain() const { return db_gain_; } 52 float DbGain() const { return db_gain_; }
55 53
56 private: 54 private:
57 friend class AudioPipe; 55 friend class AudioPipe;
58 56
59 AudioTrackImpl(InterfaceRequest<AudioTrack> track, 57 AudioTrackImpl(InterfaceRequest<AudioTrack> track,
60 AudioServerImpl* owner); 58 AudioServerImpl* owner);
61 59
62 // Implementation of AudioTrack interface. 60 // Implementation of AudioTrack interface.
63 void Describe(const DescribeCallback& cbk) override; 61 void Describe(const DescribeCallback& cbk) override;
64 void Configure(AudioTrackConfigurationPtr configuration, 62 void Configure(AudioTrackConfigurationPtr configuration,
65 InterfaceRequest<MediaConsumer> req) override; 63 InterfaceRequest<MediaConsumer> req) override;
66 void GetRateControl(InterfaceRequest<RateControl> req) override; 64 void GetTimelineControlSite(InterfaceRequest<MediaTimelineControlSite> req)
65 override;
67 void SetGain(float db_gain) override; 66 void SetGain(float db_gain) override;
68 67
69 // Methods called by our AudioPipe. 68 // Methods called by our AudioPipe.
70 // 69 //
71 // TODO(johngro): MI is banned by style, but multiple interface inheritance 70 // TODO(johngro): MI is banned by style, but multiple interface inheritance
72 // (inheriting for one or more base classes consisting only of pure virtual 71 // (inheriting for one or more base classes consisting only of pure virtual
73 // methods) is allowed. Consider defining an interface for AudioPipe 72 // methods) is allowed. Consider defining an interface for AudioPipe
74 // encapsulation so that AudioPipe does not have to know that we are an 73 // encapsulation so that AudioPipe does not have to know that we are an
75 // AudioTrackImpl (just that we implement its interface). 74 // AudioTrackImpl (just that we implement its interface).
76 void OnPacketReceived(AudioPipe::AudioPacketRefPtr packet); 75 void OnPacketReceived(AudioPipe::AudioPacketRefPtr packet);
77 bool OnFlushRequested(const MediaConsumer::FlushCallback& cbk); 76 bool OnFlushRequested(const MediaConsumer::FlushCallback& cbk);
78 77
79 AudioTrackImplWeakPtr weak_this_; 78 AudioTrackImplWeakPtr weak_this_;
80 AudioServerImpl* owner_; 79 AudioServerImpl* owner_;
81 Binding<AudioTrack> binding_; 80 Binding<AudioTrack> binding_;
82 AudioPipe pipe_; 81 AudioPipe pipe_;
83 RateControlBase rate_control_; 82 TimelineControlSite timeline_control_site_;
83 TimelineRate frames_per_ns_;
84 LinearTransform::Ratio frame_to_media_ratio_; 84 LinearTransform::Ratio frame_to_media_ratio_;
85 uint32_t bytes_per_frame_ = 1; 85 uint32_t bytes_per_frame_ = 1;
86 AudioMediaTypeDetailsPtr format_; 86 AudioMediaTypeDetailsPtr format_;
87 AudioTrackToOutputLinkSet outputs_; 87 AudioTrackToOutputLinkSet outputs_;
88 float db_gain_ = 0.0; 88 float db_gain_ = 0.0;
89 }; 89 };
90 90
91 } // namespace audio 91 } // namespace audio
92 } // namespace media 92 } // namespace media
93 } // namespace mojo 93 } // namespace mojo
94 94
95 #endif // SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_ 95 #endif // SERVICES_MEDIA_AUDIO_AUDIO_TRACK_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/services/media/core/interfaces/timeline_controller.mojom ('k') | services/media/audio/audio_track_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698