blob: 782595307d0808c07854c65220769f499d867202 [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
Karl Wiberg98900742018-03-01 12:03:49 +010017#include "api/audio_codecs/audio_codec_pair_id.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "api/audio_codecs/audio_encoder.h"
19#include "api/audio_codecs/audio_format.h"
Karl Wiberg98900742018-03-01 12:03:49 +010020#include "api/optional.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "rtc_base/refcount.h"
ossua1a040a2017-04-06 10:03:21 -070022
23namespace webrtc {
24
25// A factory that creates AudioEncoders.
26// NOTE: This class is still under development and may change without notice.
27class AudioEncoderFactory : public rtc::RefCountInterface {
28 public:
29 // Returns a prioritized list of audio codecs, to use for signaling etc.
30 virtual std::vector<AudioCodecSpec> GetSupportedEncoders() = 0;
31
32 // Returns information about how this format would be encoded, provided it's
33 // supported. More format and format variations may be supported than those
34 // returned by GetSupportedEncoders().
35 virtual rtc::Optional<AudioCodecInfo> QueryAudioEncoder(
36 const SdpAudioFormat& format) = 0;
37
Karl Wiberg98900742018-03-01 12:03:49 +010038 // Creates an AudioEncoder for the specified format. The encoder will tags
39 // its payloads with the specified payload type. The `codec_pair_id` argument
40 // is used to link encoders and decoders that talk to the same remote entity;
41 // if a MakeAudioEncoder() and a MakeAudioDecoder() call receive non-null IDs
42 // that compare equal, the factory implementations may assume that the
43 // encoder and decoder form a pair.
44 //
45 // Note: Implementations need to be robust against combinations other than
46 // one encoder, one decoder getting the same ID; such encoders must still
47 // work.
48 //
ossua1a040a2017-04-06 10:03:21 -070049 // TODO(ossu): Try to avoid audio encoders having to know their payload type.
50 virtual std::unique_ptr<AudioEncoder> MakeAudioEncoder(
51 int payload_type,
Karl Wiberg98900742018-03-01 12:03:49 +010052 const SdpAudioFormat& format,
Karl Wibergf1c470e2018-06-01 11:24:55 +020053 rtc::Optional<AudioCodecPairId> codec_pair_id) = 0;
ossua1a040a2017-04-06 10:03:21 -070054};
55
56} // namespace webrtc
57
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020058#endif // API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_