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

Side by Side Diff: webrtc/api/audio/audio_mixer.h

Issue 2420913002: Move audio frame memory handling inside AudioMixer. (Closed)
Patch Set: Updated interface usages (I landed another CL in the wrong order...). Created 4 years, 2 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 | « no previous file | webrtc/audio/audio_receive_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 17 matching lines...) Expand all
28 public: 28 public:
29 enum class AudioFrameInfo { 29 enum class AudioFrameInfo {
30 kNormal, // The samples in audio_frame are valid and should be used. 30 kNormal, // The samples in audio_frame are valid and should be used.
31 kMuted, // The samples in audio_frame should not be used, but 31 kMuted, // The samples in audio_frame should not be used, but
32 // should be implicitly interpreted as zero. Other 32 // should be implicitly interpreted as zero. Other
33 // fields in audio_frame may be read and should 33 // fields in audio_frame may be read and should
34 // contain meaningful values. 34 // contain meaningful values.
35 kError, // The audio_frame will not be used. 35 kError, // The audio_frame will not be used.
36 }; 36 };
37 37
38 struct AudioFrameWithInfo { 38 // Overwrites |audio_frame|. The data_ field is overwritten with
39 AudioFrame* audio_frame; 39 // 10 ms of new audio (either 1 or 2 interleaved channels) at
40 AudioFrameInfo audio_frame_info; 40 // |sample_rate_hz|. All fields in |audio_frame| must be updated.
41 }; 41 virtual AudioFrameInfo GetAudioFrameWithInfo(int sample_rate_hz,
42 42 AudioFrame* audio_frame) = 0;
43 // The implementation of GetAudioFrameWithInfo should update
44 // audio_frame with new audio every time it's called. Implementing
45 // classes are allowed to return the same AudioFrame pointer on
46 // different calls. The pointer must stay valid until the next
47 // mixing call or until this audio source is disconnected from the
48 // mixer. The mixer may modify the contents of the passed
49 // AudioFrame pointer at any time until the next call to
50 // GetAudioFrameWithInfo, or until the source is removed from the
51 // mixer.
52 virtual AudioFrameWithInfo GetAudioFrameWithInfo(int sample_rate_hz) = 0;
53 43
54 // A way for a mixer implementation to distinguish participants. 44 // A way for a mixer implementation to distinguish participants.
55 virtual int Ssrc() = 0; 45 virtual int Ssrc() = 0;
56 46
57 protected:
58 virtual ~Source() {} 47 virtual ~Source() {}
59 }; 48 };
60 49
61 // Since the mixer is reference counted, the destructor may be
62 // called from any thread.
63 ~AudioMixer() override {}
64
65 // Returns true if adding/removing was successful. A source is never 50 // Returns true if adding/removing was successful. A source is never
66 // added twice and removal is never attempted if a source has not 51 // added twice and removal is never attempted if a source has not
67 // been successfully added to the mixer. Addition and removal can 52 // been successfully added to the mixer. Addition and removal can
68 // happen on different threads. 53 // happen on different threads.
69 virtual bool AddSource(Source* audio_source) = 0; 54 virtual bool AddSource(Source* audio_source) = 0;
70 virtual bool RemoveSource(Source* audio_source) = 0; 55 virtual bool RemoveSource(Source* audio_source) = 0;
71 56
72 // Performs mixing by asking registered audio sources for audio. The 57 // Performs mixing by asking registered audio sources for audio. The
73 // mixed result is placed in the provided AudioFrame. Will only be 58 // mixed result is placed in the provided AudioFrame. This method
74 // called from a single thread. The rate and channels arguments 59 // will only be called from a single thread. The rate and channels
75 // specify the rate and number of channels of the mix result. 60 // arguments specify the rate and number of channels of the mix
61 // result. All fields in |audio_frame_for_mixing| must be updated.
76 virtual void Mix(int sample_rate_hz, 62 virtual void Mix(int sample_rate_hz,
77 size_t number_of_channels, 63 size_t number_of_channels,
78 AudioFrame* audio_frame_for_mixing) = 0; 64 AudioFrame* audio_frame_for_mixing) = 0;
65
66 protected:
67 // Since the mixer is reference counted, the destructor may be
68 // called from any thread.
69 ~AudioMixer() override {}
79 }; 70 };
80 } // namespace webrtc 71 } // namespace webrtc
81 72
82 #endif // WEBRTC_API_AUDIO_AUDIO_MIXER_H_ 73 #endif // WEBRTC_API_AUDIO_AUDIO_MIXER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/audio/audio_receive_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698