Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.cc

Issue 2951873002: Expose ILBC codec in webrtc/api/audio_codecs/ (Closed)
Patch Set: fuzzer test updated Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
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
11 #include "webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h"
12
13 #include <memory>
14 #include <vector>
15
16 #include "webrtc/base/ptr_util.h"
17 #include "webrtc/base/safe_conversions.h"
18 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h"
19
20 namespace webrtc {
21 namespace {
22 int GetIlbcBitrate(int ptime) {
23 switch (ptime) {
24 case 20:
25 case 40:
26 // 38 bytes per frame of 20 ms => 15200 bits/s.
27 return 15200;
28 case 30:
29 case 60:
30 // 50 bytes per frame of 30 ms => (approx) 13333 bits/s.
31 return 13333;
32 default:
33 FATAL();
34 }
35 }
36 } // namespace
37
38 rtc::Optional<AudioEncoderIlbcConfig> AudioEncoderIlbc::SdpToConfig(
39 const SdpAudioFormat& format) {
40 return AudioEncoderIlbcImpl::SdpToConfig(format);
41 }
42
43 void AudioEncoderIlbc::AppendSupportedEncoders(
44 std::vector<AudioCodecSpec>* specs) {
45 const SdpAudioFormat fmt = {"ILBC", 8000, 1};
46 const AudioCodecInfo info = QueryAudioEncoder(*SdpToConfig(fmt));
47 specs->push_back({fmt, info});
48 }
49
50 AudioCodecInfo AudioEncoderIlbc::QueryAudioEncoder(
51 const AudioEncoderIlbcConfig& config) {
52 RTC_DCHECK(config.IsOk());
53 return {8000, 1, GetIlbcBitrate(config.frame_size_ms)};
54 }
55
56 std::unique_ptr<AudioEncoder> AudioEncoderIlbc::MakeAudioEncoder(
57 const AudioEncoderIlbcConfig& config,
58 int payload_type) {
59 RTC_DCHECK(config.IsOk());
60 return rtc::MakeUnique<AudioEncoderIlbcImpl>(config, payload_type);
61 }
62
63 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h ('k') | webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698