blob: b290967c7803fd747d8b47b3465f449e74beae09 [file] [log] [blame]
ossua1a040a2017-04-06 10:03:21 -07001/*
2 * Copyright (c) 2017 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_
12#define API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_
ossua1a040a2017-04-06 10:03:21 -070013
14#include <memory>
15#include <vector>
16
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020017#include "absl/types/optional.h"
Karl Wiberg98900742018-03-01 12:03:49 +010018#include "api/audio_codecs/audio_codec_pair_id.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "api/audio_codecs/audio_encoder.h"
20#include "api/audio_codecs/audio_format.h"
21#include "rtc_base/refcount.h"
ossua1a040a2017-04-06 10:03:21 -070022
23namespace webrtc {
24
25// A factory that creates AudioEncoders.
ossua1a040a2017-04-06 10:03:21 -070026class AudioEncoderFactory : public rtc::RefCountInterface {
27 public:
28 // Returns a prioritized list of audio codecs, to use for signaling etc.
29 virtual std::vector<AudioCodecSpec> GetSupportedEncoders() = 0;
30
31 // Returns information about how this format would be encoded, provided it's
32 // supported. More format and format variations may be supported than those
33 // returned by GetSupportedEncoders().
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020034 virtual absl::optional<AudioCodecInfo> QueryAudioEncoder(
ossua1a040a2017-04-06 10:03:21 -070035 const SdpAudioFormat& format) = 0;
36
Karl Wiberg98900742018-03-01 12:03:49 +010037 // Creates an AudioEncoder for the specified format. The encoder will tags
38 // its payloads with the specified payload type. The `codec_pair_id` argument
39 // is used to link encoders and decoders that talk to the same remote entity;
40 // if a MakeAudioEncoder() and a MakeAudioDecoder() call receive non-null IDs
41 // that compare equal, the factory implementations may assume that the
42 // encoder and decoder form a pair.
43 //
44 // Note: Implementations need to be robust against combinations other than
45 // one encoder, one decoder getting the same ID; such encoders must still
46 // work.
47 //
ossua1a040a2017-04-06 10:03:21 -070048 // TODO(ossu): Try to avoid audio encoders having to know their payload type.
49 virtual std::unique_ptr<AudioEncoder> MakeAudioEncoder(
50 int payload_type,
Karl Wiberg98900742018-03-01 12:03:49 +010051 const SdpAudioFormat& format,
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020052 absl::optional<AudioCodecPairId> codec_pair_id) = 0;
ossua1a040a2017-04-06 10:03:21 -070053};
54
55} // namespace webrtc
56
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020057#endif // API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_