Lists of codecs have a lot of cross references (RTX/APT and the like). We should introduce functionality to verify that those linkages are correct before modifying the handling of these. This CL introduces the CodecList class, which can be extended to do that verification. It is used by pc/media_session.cc, but inter-module APIs are not changed in this version (they will be later). Bug: webrtc:360058654 Change-Id: Ifd6313d0289cfa090e51ac28bc775265d18fe6f2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/371600 Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43582}
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2024 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef MEDIA_BASE_CODEC_LIST_H_
|
|
#define MEDIA_BASE_CODEC_LIST_H_
|
|
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
#include "media/base/codec.h"
|
|
|
|
namespace cricket {
|
|
|
|
class CodecList {
|
|
public:
|
|
using iterator = std::vector<Codec>::iterator;
|
|
using const_iterator = std::vector<Codec>::const_iterator;
|
|
|
|
CodecList() {}
|
|
explicit CodecList(const std::vector<Codec>& codecs) {
|
|
codecs_ = codecs;
|
|
CheckConsistency();
|
|
}
|
|
// Vector-compatible API to access the codecs.
|
|
iterator begin() { return codecs_.begin(); }
|
|
iterator end() { return codecs_.end(); }
|
|
const_iterator begin() const { return codecs_.begin(); }
|
|
const_iterator end() const { return codecs_.end(); }
|
|
const Codec& operator[](size_t i) const { return codecs_[i]; }
|
|
Codec& operator[](size_t i) { return codecs_[i]; }
|
|
void push_back(const Codec& codec) { codecs_.push_back(codec); }
|
|
bool empty() const { return codecs_.empty(); }
|
|
// Access to the whole codec list
|
|
const std::vector<Codec>& codecs() const { return codecs_; }
|
|
std::vector<Codec>& writable_codecs() { return codecs_; }
|
|
// Verify consistency of the codec list.
|
|
// Examples: checking that all RTX codecs have APT pointing
|
|
// to a codec in the list.
|
|
// The function will CHECK or DCHECK on inconsistencies.
|
|
void CheckConsistency();
|
|
|
|
private:
|
|
std::vector<Codec> codecs_;
|
|
};
|
|
|
|
} // namespace cricket
|
|
|
|
#endif // MEDIA_BASE_CODEC_LIST_H_
|