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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/playout_delay_oracle.h

Issue 2007743003: Add sender controlled playout delay limits (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@cleanup_rtp_hdr_extensions
Patch Set: Removed audio changes and added locking on playout delay oracle Created 4 years, 7 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) 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 WEBRTC_MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_
13
14 #include "webrtc/base/basictypes.h"
15 #include "webrtc/base/criticalsection.h"
16 #include "webrtc/base/thread_annotations.h"
17 #include "webrtc/modules/include/module_common_types.h"
18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
19
20 namespace webrtc {
21
22 // This class tracks the application requests to limit minimum and maximum
23 // playout delay and makes a decision on whether the current RTP frame
24 // should include the playout out delay extension header.
25 //
26 // Playout delay can be defined in terms of capture and render time as follows:
27 //
28 // Render time = Capture time in receiver time + playout delay
29 //
30 // The application specifies a minimum and maximum limit for the playout delay
31 // which are both communicated to the receiver and the receiver can adapt
32 // the playout delay within this range based on observed network jitter.
33 class PlayoutDelayOracle {
34 public:
35 PlayoutDelayOracle();
36 ~PlayoutDelayOracle();
37
38 // Returns true if the current frame should include the playout delay
39 // extension
40 bool send_playout_delay() const {
41 rtc::CritScope lock(&crit_sect_);
42 return send_playout_delay_;
43 }
44
45 // Returns current minimum playout delay in milliseconds.
46 int min_playout_delay_ms() const { return min_playout_delay_ms_; }
47
48 // Returns current maximum playout delay in milliseconds.
49 int max_playout_delay_ms() const { return max_playout_delay_ms_; }
50
51 // Updates the application requested playout delay, current ssrc
52 // and the current sequence number.
53 void UpdateRequest(uint32_t ssrc,
54 PlayoutDelay playout_delay,
55 uint16_t seq_num);
56
57 void OnReceivedRtcpReceiverReport(const ReportBlockList& report_blocks);
58
59 private:
60 // The playout delay information is updated from the encoder thread or
61 // a thread controlled by application in case of external encoder.
62 // The sequence number feedback is updated from the worker thread.
63 // Guards access to data across the two threads.
64 rtc::CriticalSection crit_sect_;
65 // The current highest sequence number on which playout delay has been sent.
66 int64_t high_sequence_number_ GUARDED_BY(crit_sect_);
67 // Indicates whether the playout delay should go on the next frame.
68 bool send_playout_delay_ GUARDED_BY(crit_sect_);
69 // Sender ssrc.
70 uint32_t ssrc_ GUARDED_BY(crit_sect_);
71
72 // Data in this section is accessed on the sending/encoder thread alone.
danilchap 2016/05/26 09:41:58 this is possible to check (see ThreadChecker) and
stefan-webrtc 2016/05/28 05:01:44 I think using a thread checker would be a good ide
Irfan 2016/06/01 08:38:33 Done.
73 // Sequence number unwrapper.
74 SequenceNumberUnwrapper unwrapper_;
75 // Min playout delay value on the next frame if |send_playout_delay_| is set.
76 int min_playout_delay_ms_;
77 // Max playout delay value on the next frame if |send_playout_delay_| is set.
78 int max_playout_delay_ms_;
79
80 RTC_DISALLOW_COPY_AND_ASSIGN(PlayoutDelayOracle);
81 };
82
83 } // namespace webrtc
84
85 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698