OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_SOUND_SOUNDINPUTSTREAMINTERFACE_H_ | |
12 #define WEBRTC_SOUND_SOUNDINPUTSTREAMINTERFACE_H_ | |
13 | |
14 #include "webrtc/base/constructormagic.h" | |
15 #include "webrtc/base/sigslot.h" | |
16 | |
17 namespace rtc { | |
18 | |
19 // Interface for consuming an input stream from a recording device. | |
20 // Semantics and thread-safety of StartReading()/StopReading() are the same as | |
21 // for rtc::Worker. | |
22 class SoundInputStreamInterface { | |
23 public: | |
24 virtual ~SoundInputStreamInterface(); | |
25 | |
26 // Starts the reading of samples on the current thread. | |
27 virtual bool StartReading() = 0; | |
28 // Stops the reading of samples. | |
29 virtual bool StopReading() = 0; | |
30 | |
31 // Retrieves the current input volume for this stream. Nominal range is | |
32 // defined by SoundSystemInterface::k(Max|Min)Volume, but values exceeding the | |
33 // max may be possible in some implementations. This call retrieves the actual | |
34 // volume currently in use by the OS, not a cached value from a previous | |
35 // (Get|Set)Volume() call. | |
36 virtual bool GetVolume(int *volume) = 0; | |
37 | |
38 // Changes the input volume for this stream. Nominal range is defined by | |
39 // SoundSystemInterface::k(Max|Min)Volume. The effect of exceeding kMaxVolume | |
40 // is implementation-defined. | |
41 virtual bool SetVolume(int volume) = 0; | |
42 | |
43 // Closes this stream object. If currently reading then this may only be | |
44 // called from the reading thread. | |
45 virtual bool Close() = 0; | |
46 | |
47 // Get the latency of the stream. | |
48 virtual int LatencyUsecs() = 0; | |
49 | |
50 // Notifies the consumer of new data read from the device. | |
51 // The first parameter is a pointer to the data read, and is only valid for | |
52 // the duration of the call. | |
53 // The second parameter is the amount of data read in bytes (i.e., the valid | |
54 // length of the memory pointed to). | |
55 // The 3rd parameter is the stream that is issuing the callback. | |
56 sigslot::signal3<const void *, size_t, | |
57 SoundInputStreamInterface *> SignalSamplesRead; | |
58 | |
59 protected: | |
60 SoundInputStreamInterface(); | |
61 | |
62 private: | |
63 RTC_DISALLOW_COPY_AND_ASSIGN(SoundInputStreamInterface); | |
64 }; | |
65 | |
66 } // namespace rtc | |
67 | |
68 #endif // WEBRTC_SOUND_SOUNDINPUTSTREAMINTERFACE_H_ | |
OLD | NEW |