legacy_encoded_audio_frame.h (1506B)
1 /* 2 * Copyright (c) 2016 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 #ifndef MODULES_AUDIO_CODING_CODECS_LEGACY_ENCODED_AUDIO_FRAME_H_ 12 #define MODULES_AUDIO_CODING_CODECS_LEGACY_ENCODED_AUDIO_FRAME_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include <optional> 18 #include <vector> 19 20 #include "api/array_view.h" 21 #include "api/audio_codecs/audio_decoder.h" 22 #include "rtc_base/buffer.h" 23 24 namespace webrtc { 25 26 class LegacyEncodedAudioFrame final : public AudioDecoder::EncodedAudioFrame { 27 public: 28 LegacyEncodedAudioFrame(AudioDecoder* decoder, Buffer&& payload); 29 ~LegacyEncodedAudioFrame() override; 30 31 static std::vector<AudioDecoder::ParseResult> SplitBySamples( 32 AudioDecoder* decoder, 33 Buffer&& payload, 34 uint32_t timestamp, 35 size_t bytes_per_ms, 36 uint32_t timestamps_per_ms); 37 38 size_t Duration() const override; 39 40 std::optional<DecodeResult> Decode(ArrayView<int16_t> decoded) const override; 41 42 // For testing: 43 const Buffer& payload() const { return payload_; } 44 45 private: 46 AudioDecoder* const decoder_; 47 const Buffer payload_; 48 }; 49 50 } // namespace webrtc 51 52 #endif // MODULES_AUDIO_CODING_CODECS_LEGACY_ENCODED_AUDIO_FRAME_H_