| 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 API_VOIP_VOIP_BASE_H_ |
| 12 | #define API_VOIP_VOIP_BASE_H_ |
| 13 |
| 14 | #include "absl/types/optional.h" |
| 15 |
| 16 | namespace webrtc { |
| 17 |
| 18 | class Transport; |
| 19 |
| 20 | // VoipBase interface |
| 21 | // |
| 22 | // VoipBase provides a management interface on a media session using a |
| 23 | // concept called 'channel'. A channel represents an interface handle |
| 24 | // for application to request various media session operations. This |
| 25 | // notion of channel is used throughout other interfaces as well. |
| 26 | // |
| 27 | // Underneath the interface, a channel id is mapped into an audio session |
| 28 | // object that is capable of sending and receiving a single RTP stream with |
| 29 | // another media endpoint. It's possible to create and use multiple active |
| 30 | // channels simultaneously which would mean that particular application |
| 31 | // session has RTP streams with multiple remote endpoints. |
| 32 | // |
| 33 | // A typical example for the usage context is outlined in VoipEngine |
| 34 | // header file. |
| 35 |
| 36 | enum class ChannelId : int {}; |
| 37 |
| 38 | class VoipBase { |
| 39 | public: |
| 40 | // Creates a channel. |
| 41 | // Each channel handle maps into one audio media session where each has |
| 42 | // its own separate module for send/receive rtp packet with one peer. |
| 43 | // Caller must set |transport|, webrtc::Transport callback pointer to |
| 44 | // receive rtp/rtcp packets from corresponding media session in VoIP engine. |
| 45 | // VoipEngine framework expects applications to handle network I/O directly |
| 46 | // and injection for incoming RTP from remote endpoint is handled via |
| 47 | // VoipNetwork interface. |local_ssrc| is optional and when local_ssrc is not |
| 48 | // set, some random value will be used by voip engine. |
| 49 | // Returns value is optional as to indicate the failure to create channel. |
| 50 | virtual absl::optional<ChannelId> CreateChannel( |
| 51 | Transport* transport, |
| 52 | absl::optional<uint32_t> local_ssrc) = 0; |
| 53 |
| 54 | // Releases |channel_id| that no longer has any use. |
| 55 | virtual void ReleaseChannel(ChannelId channel_id) = 0; |
| 56 |
| 57 | // Starts sending on |channel_id|. This will start microphone if not started |
| 58 | // yet. Returns false if initialization has failed on selected microphone |
| 59 | // device. API is subject to expand to reflect error condition to application |
| 60 | // later. |
| 61 | virtual bool StartSend(ChannelId channel_id) = 0; |
| 62 |
| 63 | // Stops sending on |channel_id|. If this is the last active channel, it will |
| 64 | // stop microphone input from underlying audio platform layer. |
| 65 | // Returns false if termination logic has failed on selected microphone |
| 66 | // device. API is subject to expand to reflect error condition to application |
| 67 | // later. |
| 68 | virtual bool StopSend(ChannelId channel_id) = 0; |
| 69 |
| 70 | // Starts playing on speaker device for |channel_id|. |
| 71 | // This will start underlying platform speaker device if not started. |
| 72 | // Returns false if initialization has failed |
| 73 | // on selected speaker device. API is subject to expand to reflect error |
| 74 | // condition to application later. |
| 75 | virtual bool StartPlayout(ChannelId channel_id) = 0; |
| 76 |
| 77 | // Stops playing on speaker device for |channel_id|. |
| 78 | // If this is the last active channel playing, then it will stop speaker |
| 79 | // from the platform layer. |
| 80 | // Returns false if termination logic has failed on selected speaker device. |
| 81 | // API is subject to expand to reflect error condition to application later. |
| 82 | virtual bool StopPlayout(ChannelId channel_id) = 0; |
| 83 |
| 84 | protected: |
| 85 | virtual ~VoipBase() = default; |
| 86 | }; |
| 87 |
| 88 | } // namespace webrtc |
| 89 |
| 90 | #endif // API_VOIP_VOIP_BASE_H_ |
| 91 |