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

Side by Side Diff: webrtc/modules/audio_coding/acm2/initial_delay_manager.h

Issue 2363993002: ACM: Removed the code for InitialDelayManager (Closed)
Patch Set: 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
(Empty)
1 /*
2 * Copyright (c) 2013 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 WEBRTC_MODULES_AUDIO_CODING_ACM2_INITIAL_DELAY_MANAGER_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_ACM2_INITIAL_DELAY_MANAGER_H_
13
14 #include "webrtc/modules/include/module_common_types.h"
15
16 namespace webrtc {
17
18 namespace acm2 {
19
20 class InitialDelayManager {
21 public:
22 enum PacketType {
23 kUndefinedPacket, kCngPacket, kAvtPacket, kAudioPacket, kSyncPacket };
24
25 // Specifies a stream of sync-packets.
26 struct SyncStream {
27 SyncStream()
28 : num_sync_packets(0),
29 receive_timestamp(0),
30 timestamp_step(0) {
31 memset(&rtp_info, 0, sizeof(rtp_info));
32 }
33
34 int num_sync_packets;
35
36 // RTP header of the first sync-packet in the sequence.
37 WebRtcRTPHeader rtp_info;
38
39 // Received timestamp of the first sync-packet in the sequence.
40 uint32_t receive_timestamp;
41
42 // Samples per packet.
43 uint32_t timestamp_step;
44 };
45
46 InitialDelayManager(int initial_delay_ms, int late_packet_threshold);
47
48 // Update with the last received RTP header, |header|, and received timestamp,
49 // |received_timestamp|. |type| indicates the packet type. If codec is changed
50 // since the last time |new_codec| should be true. |sample_rate_hz| is the
51 // decoder's sampling rate in Hz. |header| has a field to store sampling rate
52 // but we are not sure if that is properly set at the send side, and |header|
53 // is declared constant in the caller of this function
54 // (AcmReceiver::InsertPacket()). |sync_stream| contains information required
55 // to generate a stream of sync packets.
56 void UpdateLastReceivedPacket(const WebRtcRTPHeader& header,
57 uint32_t receive_timestamp,
58 PacketType type,
59 bool new_codec,
60 int sample_rate_hz,
61 SyncStream* sync_stream);
62
63 // Based on the last received timestamp and given the current timestamp,
64 // sequence of late (or perhaps missing) packets is computed.
65 void LatePackets(uint32_t timestamp_now, SyncStream* sync_stream);
66
67 // Get playout timestamp.
68 // Returns true if the timestamp is valid (when buffering), otherwise false.
69 bool GetPlayoutTimestamp(uint32_t* playout_timestamp);
70
71 // True if buffered audio is less than the given initial delay (specified at
72 // the constructor). Buffering might be disabled by the client of this class.
73 bool buffering() { return buffering_; }
74
75 // Disable buffering in the class.
76 void DisableBuffering();
77
78 // True if any packet received for buffering.
79 bool PacketBuffered() { return last_packet_type_ != kUndefinedPacket; }
80
81 private:
82 static const uint8_t kInvalidPayloadType = 0xFF;
83
84 // Update playout timestamps. While buffering, this is about
85 // |initial_delay_ms| millisecond behind the latest received timestamp.
86 void UpdatePlayoutTimestamp(const RTPHeader& current_header,
87 int sample_rate_hz);
88
89 // Record an RTP headr and related parameter
90 void RecordLastPacket(const WebRtcRTPHeader& rtp_info,
91 uint32_t receive_timestamp,
92 PacketType type);
93
94 PacketType last_packet_type_;
95 WebRtcRTPHeader last_packet_rtp_info_;
96 uint32_t last_receive_timestamp_;
97 uint32_t timestamp_step_;
98 uint8_t audio_payload_type_;
99 const int initial_delay_ms_;
100 int buffered_audio_ms_;
101 bool buffering_;
102
103 // During the initial phase where packets are being accumulated and silence
104 // is played out, |playout_ts| is a timestamp which is equal to
105 // |initial_delay_ms_| milliseconds earlier than the most recently received
106 // RTP timestamp.
107 uint32_t playout_timestamp_;
108
109 // If the number of late packets exceed this value (computed based on current
110 // timestamp and last received timestamp), sequence of sync-packets is
111 // specified.
112 const int late_packet_threshold_;
113 };
114
115 } // namespace acm2
116
117 } // namespace webrtc
118
119 #endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_INITIAL_DELAY_MANAGER_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/acm2/acm_receiver.h ('k') | webrtc/modules/audio_coding/acm2/initial_delay_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698