Chromium Code Reviews| OLD | NEW |
|---|---|
| (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" | |
|
kwiberg-webrtc
2017/06/27 11:09:23
Are you using this one?
| |
| 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 | |
| OLD | NEW |