OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 class NotifierInterface { | 64 class NotifierInterface { |
65 public: | 65 public: |
66 virtual void RegisterObserver(ObserverInterface* observer) = 0; | 66 virtual void RegisterObserver(ObserverInterface* observer) = 0; |
67 virtual void UnregisterObserver(ObserverInterface* observer) = 0; | 67 virtual void UnregisterObserver(ObserverInterface* observer) = 0; |
68 | 68 |
69 virtual ~NotifierInterface() {} | 69 virtual ~NotifierInterface() {} |
70 }; | 70 }; |
71 | 71 |
72 // Base class for sources. A MediaStreamTrack have an underlying source that | 72 // Base class for sources. A MediaStreamTrack have an underlying source that |
73 // provide media. A source can be shared with multiple tracks. | 73 // provide media. A source can be shared with multiple tracks. |
74 // TODO(perkj): Implement sources for local and remote audio tracks and | |
75 // remote video tracks. | |
76 class MediaSourceInterface : public rtc::RefCountInterface, | 74 class MediaSourceInterface : public rtc::RefCountInterface, |
77 public NotifierInterface { | 75 public NotifierInterface { |
78 public: | 76 public: |
79 enum SourceState { | 77 enum SourceState { |
80 kInitializing, | 78 kInitializing, |
81 kLive, | 79 kLive, |
82 kEnded, | 80 kEnded, |
83 kMuted | 81 kMuted |
84 }; | 82 }; |
85 | 83 |
86 virtual SourceState state() const = 0; | 84 virtual SourceState state() const = 0; |
87 | 85 |
| 86 virtual bool remote() const = 0; |
| 87 |
88 protected: | 88 protected: |
89 virtual ~MediaSourceInterface() {} | 89 virtual ~MediaSourceInterface() {} |
90 }; | 90 }; |
91 | 91 |
92 // Information about a track. | 92 // Information about a track. |
93 class MediaStreamTrackInterface : public rtc::RefCountInterface, | 93 class MediaStreamTrackInterface : public rtc::RefCountInterface, |
94 public NotifierInterface { | 94 public NotifierInterface { |
95 public: | 95 public: |
96 enum TrackState { | 96 enum TrackState { |
97 kInitializing, // Track is beeing negotiated. | 97 kInitializing, // Track is beeing negotiated. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 virtual void AddRenderer(VideoRendererInterface* renderer) = 0; | 145 virtual void AddRenderer(VideoRendererInterface* renderer) = 0; |
146 // Deregister a renderer. | 146 // Deregister a renderer. |
147 virtual void RemoveRenderer(VideoRendererInterface* renderer) = 0; | 147 virtual void RemoveRenderer(VideoRendererInterface* renderer) = 0; |
148 | 148 |
149 virtual VideoSourceInterface* GetSource() const = 0; | 149 virtual VideoSourceInterface* GetSource() const = 0; |
150 | 150 |
151 protected: | 151 protected: |
152 virtual ~VideoTrackInterface() {} | 152 virtual ~VideoTrackInterface() {} |
153 }; | 153 }; |
154 | 154 |
| 155 // Interface for receiving audio data from a AudioTrack. |
| 156 class AudioTrackSinkInterface { |
| 157 public: |
| 158 virtual void OnData(const void* audio_data, |
| 159 int bits_per_sample, |
| 160 int sample_rate, |
| 161 int number_of_channels, |
| 162 size_t number_of_frames) = 0; |
| 163 |
| 164 protected: |
| 165 virtual ~AudioTrackSinkInterface() {} |
| 166 }; |
| 167 |
155 // AudioSourceInterface is a reference counted source used for AudioTracks. | 168 // AudioSourceInterface is a reference counted source used for AudioTracks. |
156 // The same source can be used in multiple AudioTracks. | 169 // The same source can be used in multiple AudioTracks. |
157 class AudioSourceInterface : public MediaSourceInterface { | 170 class AudioSourceInterface : public MediaSourceInterface { |
158 public: | 171 public: |
159 class AudioObserver { | 172 class AudioObserver { |
160 public: | 173 public: |
161 virtual void OnSetVolume(double volume) = 0; | 174 virtual void OnSetVolume(double volume) = 0; |
162 | 175 |
163 protected: | 176 protected: |
164 virtual ~AudioObserver() {} | 177 virtual ~AudioObserver() {} |
165 }; | 178 }; |
166 | 179 |
167 // TODO(xians): Makes all the interface pure virtual after Chrome has their | 180 // TODO(xians): Makes all the interface pure virtual after Chrome has their |
168 // implementations. | 181 // implementations. |
169 // Sets the volume to the source. |volume| is in the range of [0, 10]. | 182 // Sets the volume to the source. |volume| is in the range of [0, 10]. |
170 // TODO(tommi): This method should be on the track and ideally volume should | 183 // TODO(tommi): This method should be on the track and ideally volume should |
171 // be applied in the track in a way that does not affect clones of the track. | 184 // be applied in the track in a way that does not affect clones of the track. |
172 virtual void SetVolume(double volume) {} | 185 virtual void SetVolume(double volume) {} |
173 | 186 |
174 // Registers/unregisters observer to the audio source. | 187 // Registers/unregisters observer to the audio source. |
175 virtual void RegisterAudioObserver(AudioObserver* observer) {} | 188 virtual void RegisterAudioObserver(AudioObserver* observer) {} |
176 virtual void UnregisterAudioObserver(AudioObserver* observer) {} | 189 virtual void UnregisterAudioObserver(AudioObserver* observer) {} |
177 }; | |
178 | 190 |
179 // Interface for receiving audio data from a AudioTrack. | 191 // TODO(tommi): Make pure virtual. |
180 class AudioTrackSinkInterface { | 192 virtual void AddSink(AudioTrackSinkInterface* sink) {} |
181 public: | 193 virtual void RemoveSink(AudioTrackSinkInterface* sink) {} |
182 virtual void OnData(const void* audio_data, | |
183 int bits_per_sample, | |
184 int sample_rate, | |
185 int number_of_channels, | |
186 size_t number_of_frames) = 0; | |
187 protected: | |
188 virtual ~AudioTrackSinkInterface() {} | |
189 }; | 194 }; |
190 | 195 |
191 // Interface of the audio processor used by the audio track to collect | 196 // Interface of the audio processor used by the audio track to collect |
192 // statistics. | 197 // statistics. |
193 class AudioProcessorInterface : public rtc::RefCountInterface { | 198 class AudioProcessorInterface : public rtc::RefCountInterface { |
194 public: | 199 public: |
195 struct AudioProcessorStats { | 200 struct AudioProcessorStats { |
196 AudioProcessorStats() : typing_noise_detected(false), | 201 AudioProcessorStats() : typing_noise_detected(false), |
197 echo_return_loss(0), | 202 echo_return_loss(0), |
198 echo_return_loss_enhancement(0), | 203 echo_return_loss_enhancement(0), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 virtual bool RemoveTrack(AudioTrackInterface* track) = 0; | 274 virtual bool RemoveTrack(AudioTrackInterface* track) = 0; |
270 virtual bool RemoveTrack(VideoTrackInterface* track) = 0; | 275 virtual bool RemoveTrack(VideoTrackInterface* track) = 0; |
271 | 276 |
272 protected: | 277 protected: |
273 virtual ~MediaStreamInterface() {} | 278 virtual ~MediaStreamInterface() {} |
274 }; | 279 }; |
275 | 280 |
276 } // namespace webrtc | 281 } // namespace webrtc |
277 | 282 |
278 #endif // TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_ | 283 #endif // TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_ |
OLD | NEW |