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

Side by Side Diff: webrtc/modules/audio_coding/codecs/audio_decoder.cc

Issue 2342443005: Moved Opus-specific payload splitting into AudioDecoderOpus. (Closed)
Patch Set: Some small fixes. Created 4 years, 2 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
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" 11 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <memory> 14 #include <memory>
15 #include <utility> 15 #include <utility>
16 16
17 #include <utility>
18
19 #include "webrtc/base/array_view.h" 17 #include "webrtc/base/array_view.h"
20 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
21 #include "webrtc/base/sanitizer.h" 19 #include "webrtc/base/sanitizer.h"
22 #include "webrtc/base/trace_event.h" 20 #include "webrtc/base/trace_event.h"
23 #include "webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame.h" 21 #include "webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame.h"
24 22
25 namespace webrtc { 23 namespace webrtc {
26 24
27 AudioDecoder::ParseResult::ParseResult() = default; 25 AudioDecoder::ParseResult::ParseResult() = default;
28 AudioDecoder::ParseResult::ParseResult(ParseResult&& b) = default; 26 AudioDecoder::ParseResult::ParseResult(ParseResult&& b) = default;
29 AudioDecoder::ParseResult::ParseResult(uint32_t timestamp, 27 AudioDecoder::ParseResult::ParseResult(uint32_t timestamp,
30 bool primary, 28 int priority,
31 std::unique_ptr<EncodedAudioFrame> frame) 29 std::unique_ptr<EncodedAudioFrame> frame)
32 : timestamp(timestamp), primary(primary), frame(std::move(frame)) {} 30 : timestamp(timestamp), priority(priority), frame(std::move(frame)) {
31 RTC_DCHECK_GE(priority, 0);
32 }
33 33
34 AudioDecoder::ParseResult::~ParseResult() = default; 34 AudioDecoder::ParseResult::~ParseResult() = default;
35 35
36 AudioDecoder::ParseResult& AudioDecoder::ParseResult::operator=( 36 AudioDecoder::ParseResult& AudioDecoder::ParseResult::operator=(
37 ParseResult&& b) = default; 37 ParseResult&& b) = default;
38 38
39 std::vector<AudioDecoder::ParseResult> AudioDecoder::ParsePayload( 39 std::vector<AudioDecoder::ParseResult> AudioDecoder::ParsePayload(
40 rtc::Buffer&& payload, 40 rtc::Buffer&& payload,
41 uint32_t timestamp, 41 uint32_t timestamp) {
42 bool is_primary) {
43 std::vector<ParseResult> results; 42 std::vector<ParseResult> results;
44 std::unique_ptr<EncodedAudioFrame> frame( 43 std::unique_ptr<EncodedAudioFrame> frame(
45 new LegacyEncodedAudioFrame(this, std::move(payload), is_primary)); 44 new LegacyEncodedAudioFrame(this, std::move(payload)));
46 results.emplace_back(timestamp, is_primary, std::move(frame)); 45 results.emplace_back(timestamp, 0, std::move(frame));
47 return results; 46 return results;
48 } 47 }
49 48
50 int AudioDecoder::Decode(const uint8_t* encoded, size_t encoded_len, 49 int AudioDecoder::Decode(const uint8_t* encoded, size_t encoded_len,
51 int sample_rate_hz, size_t max_decoded_bytes, 50 int sample_rate_hz, size_t max_decoded_bytes,
52 int16_t* decoded, SpeechType* speech_type) { 51 int16_t* decoded, SpeechType* speech_type) {
53 TRACE_EVENT0("webrtc", "AudioDecoder::Decode"); 52 TRACE_EVENT0("webrtc", "AudioDecoder::Decode");
54 rtc::MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len)); 53 rtc::MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
55 int duration = PacketDuration(encoded, encoded_len); 54 int duration = PacketDuration(encoded, encoded_len);
56 if (duration >= 0 && 55 if (duration >= 0 &&
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return kSpeech; 120 return kSpeech;
122 case 2: 121 case 2:
123 return kComfortNoise; 122 return kComfortNoise;
124 default: 123 default:
125 assert(false); 124 assert(false);
126 return kSpeech; 125 return kSpeech;
127 } 126 }
128 } 127 }
129 128
130 } // namespace webrtc 129 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698