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

Side by Side Diff: webrtc/modules/audio_coding/neteq/payload_splitter.h

Issue 2326003002: Moved codec-specific audio packet splitting into decoders. (Closed)
Patch Set: Fixed types in packet splitting (size_t vs. uint32_t) Created 4 years, 3 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_PAYLOAD_SPLITTER_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_PAYLOAD_SPLITTER_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PAYLOAD_SPLITTER_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PAYLOAD_SPLITTER_H_
13 13
14 #include "webrtc/base/constructormagic.h" 14 #include "webrtc/base/constructormagic.h"
15 #include "webrtc/modules/audio_coding/neteq/packet.h" 15 #include "webrtc/modules/audio_coding/neteq/packet.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 18
19 // Forward declarations. 19 // Forward declarations.
20 class DecoderDatabase; 20 class DecoderDatabase;
21 21
22 // This class handles splitting of payloads into smaller parts. 22 // This class handles splitting of payloads into smaller parts.
23 // The class does not have any member variables, and the methods could have 23
24 // been made static. The reason for not making them static is testability. 24 // For RED and FEC the splitting is done internally. Other codecs' packets are
25 // With this design, the splitting functionality can be mocked during testing 25 // split by calling AudioDecoder::SplitPacket.
26 // of the NetEqImpl class.
27 class PayloadSplitter { 26 class PayloadSplitter {
28 public: 27 public:
29 enum SplitterReturnCodes { 28 enum SplitterReturnCodes {
30 kOK = 0, 29 kOK = 0,
31 kNoSplit = 1, 30 kNoSplit = 1,
32 kTooLargePayload = -1,
33 kFrameSplitError = -2, 31 kFrameSplitError = -2,
34 kUnknownPayloadType = -3, 32 kUnknownPayloadType = -3,
35 kRedLengthMismatch = -4, 33 kRedLengthMismatch = -4,
36 kFecSplitError = -5, 34 kFecSplitError = -5,
37 }; 35 };
38 36
39 PayloadSplitter() {} 37 PayloadSplitter() {}
40 38
41 virtual ~PayloadSplitter() {} 39 virtual ~PayloadSplitter() {}
42 40
(...skipping 10 matching lines...) Expand all
53 // get information about which payload type each packet contains. 51 // get information about which payload type each packet contains.
54 virtual int SplitFec(PacketList* packet_list, 52 virtual int SplitFec(PacketList* packet_list,
55 DecoderDatabase* decoder_database); 53 DecoderDatabase* decoder_database);
56 54
57 // Checks all packets in |packet_list|. Packets that are DTMF events or 55 // Checks all packets in |packet_list|. Packets that are DTMF events or
58 // comfort noise payloads are kept. Except that, only one single payload type 56 // comfort noise payloads are kept. Except that, only one single payload type
59 // is accepted. Any packet with another payload type is discarded. 57 // is accepted. Any packet with another payload type is discarded.
60 virtual int CheckRedPayloads(PacketList* packet_list, 58 virtual int CheckRedPayloads(PacketList* packet_list,
61 const DecoderDatabase& decoder_database); 59 const DecoderDatabase& decoder_database);
62 60
63 // Iterates through |packet_list| and, if possible, splits each audio payload
64 // into suitable size chunks. The result is written back to |packet_list| as
65 // new packets. The decoder database is needed to get information about which
66 // payload type each packet contains.
67 virtual int SplitAudio(PacketList* packet_list,
68 const DecoderDatabase& decoder_database);
69
70 private: 61 private:
71 // Splits the payload in |packet|. The payload is assumed to be from a
72 // sample-based codec.
73 virtual void SplitBySamples(const Packet* packet,
74 size_t bytes_per_ms,
75 uint32_t timestamps_per_ms,
76 PacketList* new_packets);
77
78 // Splits the payload in |packet|. The payload will be split into chunks of
79 // size |bytes_per_frame|, corresponding to a |timestamps_per_frame|
80 // RTP timestamps.
81 virtual int SplitByFrames(const Packet* packet,
82 size_t bytes_per_frame,
83 uint32_t timestamps_per_frame,
84 PacketList* new_packets);
85
86 RTC_DISALLOW_COPY_AND_ASSIGN(PayloadSplitter); 62 RTC_DISALLOW_COPY_AND_ASSIGN(PayloadSplitter);
87 }; 63 };
88 64
89 } // namespace webrtc 65 } // namespace webrtc
90 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PAYLOAD_SPLITTER_H_ 66 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PAYLOAD_SPLITTER_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc ('k') | webrtc/modules/audio_coding/neteq/payload_splitter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698