1 /* 2 * Copyright (c) 2020 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 API_VOIP_VOIP_CODEC_H_ 12 #define API_VOIP_VOIP_CODEC_H_ 13 14 #include <map> 15 16 #include "api/audio_codecs/audio_format.h" 17 #include "api/voip/voip_base.h" 18 19 namespace webrtc { 20 21 // VoipCodec interface currently provides any codec related interface 22 // such as setting encoder and decoder types that are negotiated with 23 // remote endpoint. Typically after SDP offer and answer exchange, 24 // the local endpoint understands what are the codec payload types that 25 // are used with negotiated codecs. This interface is subject to expand 26 // as needed in future. 27 // 28 // This interface requires a channel id created via VoipBase interface. 29 class VoipCodec { 30 public: 31 // Set encoder type here along with its payload type to use. 32 // Returns following VoipResult; 33 // kOk - sending codec is set as provided. 34 // kInvalidArgument - `channel_id` is invalid. 35 virtual VoipResult SetSendCodec(ChannelId channel_id, 36 int payload_type, 37 const SdpAudioFormat& encoder_spec) = 0; 38 39 // Set decoder payload type here. In typical offer and answer model, 40 // this should be called after payload type has been agreed in media 41 // session. Note that payload type can differ with same codec in each 42 // direction. 43 // Returns following VoipResult; 44 // kOk - receiving codecs are set as provided. 45 // kInvalidArgument - `channel_id` is invalid. 46 virtual VoipResult SetReceiveCodecs( 47 ChannelId channel_id, 48 const std::map<int, SdpAudioFormat>& decoder_specs) = 0; 49 50 protected: 51 virtual ~VoipCodec() = default; 52 }; 53 54 } // namespace webrtc 55 56 #endif // API_VOIP_VOIP_CODEC_H_ 57