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 <vector>
18 
19 #include "absl/types/optional.h"
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, rtc::Buffer&& payload);
29   ~LegacyEncodedAudioFrame() override;
30 
31   static std::vector<AudioDecoder::ParseResult> SplitBySamples(
32       AudioDecoder* decoder,
33       rtc::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   absl::optional<DecodeResult> Decode(
41       rtc::ArrayView<int16_t> decoded) const override;
42 
43   // For testing:
payload()44   const rtc::Buffer& payload() const { return payload_; }
45 
46  private:
47   AudioDecoder* const decoder_;
48   const rtc::Buffer payload_;
49 };
50 
51 }  // namespace webrtc
52 
53 #endif  // MODULES_AUDIO_CODING_CODECS_LEGACY_ENCODED_AUDIO_FRAME_H_
54