OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 int AudioEncoderIlbc::Num10MsFramesInNextPacket() const { | 61 int AudioEncoderIlbc::Num10MsFramesInNextPacket() const { |
62 return num_10ms_frames_per_packet_; | 62 return num_10ms_frames_per_packet_; |
63 } | 63 } |
64 | 64 |
65 int AudioEncoderIlbc::Max10MsFramesInAPacket() const { | 65 int AudioEncoderIlbc::Max10MsFramesInAPacket() const { |
66 return num_10ms_frames_per_packet_; | 66 return num_10ms_frames_per_packet_; |
67 } | 67 } |
68 | 68 |
| 69 int AudioEncoderIlbc::GetTargetBitrate() const { |
| 70 switch (num_10ms_frames_per_packet_) { |
| 71 case 2: case 4: |
| 72 // 38 bytes per frame of 20 ms => 15200 bits/s. |
| 73 return 15200; |
| 74 case 3: case 6: |
| 75 // 50 bytes per frame of 30 ms => (approx) 13333 bits/s. |
| 76 return 13333; |
| 77 default: |
| 78 FATAL(); |
| 79 } |
| 80 } |
| 81 |
69 AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeInternal( | 82 AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeInternal( |
70 uint32_t rtp_timestamp, | 83 uint32_t rtp_timestamp, |
71 const int16_t* audio, | 84 const int16_t* audio, |
72 size_t max_encoded_bytes, | 85 size_t max_encoded_bytes, |
73 uint8_t* encoded) { | 86 uint8_t* encoded) { |
74 DCHECK_GE(max_encoded_bytes, RequiredOutputSizeBytes()); | 87 DCHECK_GE(max_encoded_bytes, RequiredOutputSizeBytes()); |
75 | 88 |
76 // Save timestamp if starting a new packet. | 89 // Save timestamp if starting a new packet. |
77 if (num_10ms_frames_buffered_ == 0) | 90 if (num_10ms_frames_buffered_ == 0) |
78 first_timestamp_in_buffer_ = rtp_timestamp; | 91 first_timestamp_in_buffer_ = rtp_timestamp; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 config.payload_type = codec_inst.pltype; | 135 config.payload_type = codec_inst.pltype; |
123 return config; | 136 return config; |
124 } | 137 } |
125 } // namespace | 138 } // namespace |
126 | 139 |
127 AudioEncoderMutableIlbc::AudioEncoderMutableIlbc(const CodecInst& codec_inst) | 140 AudioEncoderMutableIlbc::AudioEncoderMutableIlbc(const CodecInst& codec_inst) |
128 : AudioEncoderMutableImpl<AudioEncoderIlbc>(CreateConfig(codec_inst)) { | 141 : AudioEncoderMutableImpl<AudioEncoderIlbc>(CreateConfig(codec_inst)) { |
129 } | 142 } |
130 | 143 |
131 } // namespace webrtc | 144 } // namespace webrtc |
OLD | NEW |