OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 11 matching lines...) Expand all Loading... |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #ifndef TALK_APP_WEBRTC_REMOTEAUDIOSOURCE_H_ | 28 #ifndef TALK_APP_WEBRTC_REMOTEAUDIOSOURCE_H_ |
29 #define TALK_APP_WEBRTC_REMOTEAUDIOSOURCE_H_ | 29 #define TALK_APP_WEBRTC_REMOTEAUDIOSOURCE_H_ |
30 | 30 |
31 #include <list> | 31 #include <list> |
| 32 #include <string> |
32 | 33 |
33 #include "talk/app/webrtc/mediastreaminterface.h" | 34 #include "talk/app/webrtc/mediastreaminterface.h" |
34 #include "talk/app/webrtc/notifier.h" | 35 #include "talk/app/webrtc/notifier.h" |
| 36 #include "talk/media/base/audiorenderer.h" |
| 37 #include "webrtc/base/criticalsection.h" |
| 38 |
| 39 namespace rtc { |
| 40 struct Message; |
| 41 class Thread; |
| 42 } // namespace rtc |
35 | 43 |
36 namespace webrtc { | 44 namespace webrtc { |
37 | 45 |
38 using webrtc::AudioSourceInterface; | 46 class AudioProviderInterface; |
39 | 47 |
40 // This class implements the audio source used by the remote audio track. | 48 // This class implements the audio source used by the remote audio track. |
41 class RemoteAudioSource : public Notifier<AudioSourceInterface> { | 49 class RemoteAudioSource : public Notifier<AudioSourceInterface>, |
| 50 public cricket::AudioRenderer::Sink { |
42 public: | 51 public: |
43 // Creates an instance of RemoteAudioSource. | 52 // Creates an instance of RemoteAudioSource. |
44 static rtc::scoped_refptr<RemoteAudioSource> Create(); | 53 static rtc::scoped_refptr<RemoteAudioSource> Create( |
| 54 uint32_t ssrc, |
| 55 AudioProviderInterface* provider); |
| 56 |
| 57 void AddSink(AudioTrackSinkInterface* sink); |
| 58 void RemoveSink(AudioTrackSinkInterface* sink); |
45 | 59 |
46 protected: | 60 protected: |
47 RemoteAudioSource(); | 61 RemoteAudioSource(uint32_t ssrc, AudioProviderInterface* provider); |
48 virtual ~RemoteAudioSource(); | 62 ~RemoteAudioSource() override; |
49 | 63 |
50 private: | 64 private: |
51 typedef std::list<AudioObserver*> AudioObserverList; | 65 typedef std::list<AudioObserver*> AudioObserverList; |
52 | 66 |
53 // MediaSourceInterface implementation. | 67 // MediaSourceInterface implementation. |
54 MediaSourceInterface::SourceState state() const override; | 68 MediaSourceInterface::SourceState state() const override; |
55 | 69 |
56 // AudioSourceInterface implementation. | 70 // AudioSourceInterface implementation. |
57 void SetVolume(double volume) override; | 71 void SetVolume(double volume) override; |
58 void RegisterAudioObserver(AudioObserver* observer) override; | 72 void RegisterAudioObserver(AudioObserver* observer) override; |
59 void UnregisterAudioObserver(AudioObserver* observer) override; | 73 void UnregisterAudioObserver(AudioObserver* observer) override; |
60 | 74 |
| 75 // cricket::AudioRenderer::Sink implementation. |
| 76 void OnData(const void* audio_data, |
| 77 int bits_per_sample, |
| 78 int sample_rate, |
| 79 int number_of_channels, |
| 80 size_t number_of_frames) override; |
| 81 void OnClose() override; |
| 82 |
| 83 class MessageHandler; |
| 84 void OnMessage(rtc::Message* msg); |
| 85 |
61 AudioObserverList audio_observers_; | 86 AudioObserverList audio_observers_; |
| 87 const uint32_t ssrc_; |
| 88 AudioProviderInterface* provider_; |
| 89 rtc::CriticalSection sink_lock_; |
| 90 std::list<AudioTrackSinkInterface*> sinks_; |
| 91 rtc::Thread* const main_thread_; |
| 92 SourceState state_; |
62 }; | 93 }; |
63 | 94 |
64 } // namespace webrtc | 95 } // namespace webrtc |
65 | 96 |
66 #endif // TALK_APP_WEBRTC_REMOTEAUDIOSOURCE_H_ | 97 #endif // TALK_APP_WEBRTC_REMOTEAUDIOSOURCE_H_ |
OLD | NEW |