Remove CodecInst pt.2
The following APIs on AudioCodingModule are deprecated with this CL:
static int NumberOfCodecs();
static int Codec(int, CodecInst*);
static int Codec(const char*, CodecInst*, int, size_t);
static int Codec(const char*, int, size_t);
absl::optional<CodecInst> SendCodec() const;
bool RegisterReceiveCodec(int, const SdpAudioFormat&);
int RegisterExternalReceiveCodec(int, AudioDecoder*, int, int, const std::string&);
int UnregisterReceiveCodec(uint8_t);
int32_t ReceiveCodec(CodecInst*);
absl::optional<SdpAudioFormat> ReceiveFormat();
As well as this method on RtpRtcp module:
int32_t RegisterSendPayload(const CodecInst&);
Bug: webrtc:7626
Change-Id: I1230732136f1fe9048cf74afdeab767ca57ac9ce
Reviewed-on: https://webrtc-review.googlesource.com/c/113816
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26025}
diff --git a/modules/audio_coding/acm2/acm_receiver.h b/modules/audio_coding/acm2/acm_receiver.h
index 8e7d839..0cbaa9a 100644
--- a/modules/audio_coding/acm2/acm_receiver.h
+++ b/modules/audio_coding/acm2/acm_receiver.h
@@ -15,6 +15,7 @@
#include <map>
#include <memory>
#include <string>
+#include <utility>
#include <vector>
#include "absl/types/optional.h"
@@ -30,7 +31,6 @@
namespace webrtc {
class Clock;
-struct CodecInst;
class NetEq;
struct RTPHeader;
struct WebRtcRTPHeader;
@@ -85,43 +85,6 @@
void SetCodecs(const std::map<int, SdpAudioFormat>& codecs);
//
- // Adds a new codec to the NetEq codec database.
- //
- // Input:
- // - acm_codec_id : ACM codec ID; -1 means external decoder.
- // - payload_type : payload type.
- // - sample_rate_hz : sample rate.
- // - audio_decoder : pointer to a decoder object. If it's null, then
- // NetEq will internally create a decoder object
- // based on the value of |acm_codec_id| (which
- // mustn't be -1). Otherwise, NetEq will use the
- // given decoder for the given payload type. NetEq
- // won't take ownership of the decoder; it's up to
- // the caller to delete it when it's no longer
- // needed.
- //
- // Providing an existing decoder object here is
- // necessary for external decoders, but may also be
- // used for built-in decoders if NetEq doesn't have
- // all the info it needs to construct them properly
- // (e.g. iSAC, where the decoder needs to be paired
- // with an encoder).
- //
- // Return value : 0 if OK.
- // <0 if NetEq returned an error.
- //
- int AddCodec(int acm_codec_id,
- uint8_t payload_type,
- size_t channels,
- int sample_rate_hz,
- AudioDecoder* audio_decoder,
- const std::string& name);
-
- // Adds a new decoder to the NetEq codec database. Returns true iff
- // successful.
- bool AddCodec(int rtp_payload_type, const SdpAudioFormat& audio_format);
-
- //
// Sets a minimum delay for packet buffer. The given delay is maintained,
// unless channel condition dictates a higher delay.
//
@@ -173,17 +136,6 @@
void FlushBuffers();
//
- // Removes a payload-type from the NetEq codec database.
- //
- // Input:
- // - payload_type : the payload-type to be removed.
- //
- // Return value : 0 if OK.
- // -1 if an error occurred.
- //
- int RemoveCodec(uint8_t payload_type);
-
- //
// Remove all registered codecs.
//
void RemoveAllCodecs();
@@ -204,30 +156,10 @@
int TargetDelayMs() const;
//
- // Get the audio codec associated with the last non-CNG/non-DTMF received
- // payload. If no non-CNG/non-DTMF packet is received -1 is returned,
- // otherwise return 0.
+ // Get payload type and format of the last non-CNG/non-DTMF received payload.
+ // If no non-CNG/non-DTMF packet is received absl::nullopt is returned.
//
- int LastAudioCodec(CodecInst* codec) const;
-
- absl::optional<SdpAudioFormat> LastAudioFormat() const;
-
- //
- // Get a decoder given its registered payload-type.
- //
- // Input:
- // -payload_type : the payload-type of the codec to be retrieved.
- //
- // Output:
- // -codec : codec associated with the given payload-type.
- //
- // Return value : 0 if succeeded.
- // -1 if failed, e.g. given payload-type is not
- // registered.
- //
- int DecoderByPayloadType(uint8_t payload_type,
- CodecInst* codec) const;
- absl::optional<SdpAudioFormat> DecoderByPayloadType(int payload_type) const;
+ absl::optional<std::pair<int, SdpAudioFormat>> LastDecoder() const;
//
// Enable NACK and set the maximum size of the NACK list. If NACK is already
@@ -260,32 +192,17 @@
void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const;
private:
- struct Decoder {
- int acm_codec_id;
- uint8_t payload_type;
- // This field is meaningful for codecs where both mono and
- // stereo versions are registered under the same ID.
- size_t channels;
- int sample_rate_hz;
- };
-
- const absl::optional<CodecInst> RtpHeaderToDecoder(
- const RTPHeader& rtp_header,
- uint8_t first_payload_byte) const
- RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
-
uint32_t NowInTimestamp(int decoder_sampling_rate) const;
rtc::CriticalSection crit_sect_;
- absl::optional<CodecInst> last_audio_decoder_ RTC_GUARDED_BY(crit_sect_);
- absl::optional<SdpAudioFormat> last_audio_format_ RTC_GUARDED_BY(crit_sect_);
+ absl::optional<std::pair<int, SdpAudioFormat>> last_decoder_
+ RTC_GUARDED_BY(crit_sect_);
ACMResampler resampler_ RTC_GUARDED_BY(crit_sect_);
std::unique_ptr<int16_t[]> last_audio_buffer_ RTC_GUARDED_BY(crit_sect_);
CallStatistics call_stats_ RTC_GUARDED_BY(crit_sect_);
const std::unique_ptr<NetEq> neteq_; // NetEq is thread-safe; no lock needed.
const Clock* const clock_;
bool resampled_last_output_frame_ RTC_GUARDED_BY(crit_sect_);
- absl::optional<int> last_packet_sample_rate_hz_ RTC_GUARDED_BY(crit_sect_);
};
} // namespace acm2