webrtc_m130/modules/rtp_rtcp/source/playout_delay_oracle.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
3.0 KiB
C
Raw Normal View History

/*
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_
#define MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_
Reland of place basictypes.h with stdint.h for int_t types. (patchset #1 id:1 of https://codereview.webrtc.org/2603203003/ ) Reason for revert: Doing a reland where systeminfo.cc includes basictypes.h so that CPU_X86 etc. are defined when they are checked/used. Original issue's description: > Revert of Replace basictypes.h with stdint.h for int_t types. (patchset #1 id:1 of https://codereview.webrtc.org/2604043002/ ) > > Reason for revert: > Very likely cause of Chromium import bot breakage (unused function '__cpuid'), TBD why. > > Original issue's description: > > Replace basictypes.h with stdint.h for int_t types. > > > > Removes basictypes.h for types that only makes use of it for fixed-size-int > > typedefs and replaces it with stdint.h. > > > > BUG=webrtc:6853 > > R=tommi@webrtc.org > > > > Review-Url: https://codereview.webrtc.org/2604043002 > > Cr-Commit-Position: refs/heads/master@{#15867} > > Committed: https://chromium.googlesource.com/external/webrtc/+/7fd1a753005ca93e8bd934a55808a2137b0ad84f > > TBR=tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6853 > > Review-Url: https://codereview.webrtc.org/2603203003 > Cr-Commit-Position: refs/heads/master@{#15869} > Committed: https://chromium.googlesource.com/external/webrtc/+/7eb0e23bcf675635ef339a519a10563ebc9d93dc BUG=webrtc:6853 TBR=tommi@webrtc.org Review-Url: https://codereview.webrtc.org/2609783002 Cr-Commit-Position: refs/heads/master@{#15873}
2017-01-02 08:42:32 -08:00
#include <stdint.h>
#include "absl/types/optional.h"
#include "common_types.h" // NOLINT(build/include)
#include "modules/include/module_common_types_public.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
// This class tracks the application requests to limit minimum and maximum
// playout delay and makes a decision on whether the current RTP frame
// should include the playout out delay extension header.
//
// Playout delay can be defined in terms of capture and render time as follows:
//
// Render time = Capture time in receiver time + playout delay
//
// The application specifies a minimum and maximum limit for the playout delay
// which are both communicated to the receiver and the receiver can adapt
// the playout delay within this range based on observed network jitter.
class PlayoutDelayOracle {
public:
PlayoutDelayOracle();
~PlayoutDelayOracle();
// The playout delay to be added to a packet. The input delays are provided by
// the application, with -1 meaning unchanged/unspecified. The output delay
// are the values to be attached to packets on the wire. Presence and value
// depends on the current input, previous inputs, and received acks from the
// remote end.
absl::optional<PlayoutDelay> PlayoutDelayToSend(
PlayoutDelay requested_delay) const;
void OnSentPacket(uint16_t sequence_number,
absl::optional<PlayoutDelay> playout_delay);
void OnReceivedAck(int64_t extended_highest_sequence_number);
private:
// The playout delay information is updated from the encoder thread(s).
// The sequence number feedback is updated from the worker thread.
// Guards access to data across multiple threads.
rtc::CriticalSection crit_sect_;
// The oldest sequence number on which the current playout delay values have
// been sent. When set, it means we need to attach extension to sent packets.
absl::optional<int64_t> unacked_sequence_number_ RTC_GUARDED_BY(crit_sect_);
// Sequence number unwrapper for sent packets.
// TODO(nisse): Could potentially get out of sync with the unwrapper used by
// the caller of OnReceivedAck.
SequenceNumberUnwrapper unwrapper_ RTC_GUARDED_BY(crit_sect_);
// Playout delay values on the next frame if |send_playout_delay_| is set.
PlayoutDelay latest_delay_ RTC_GUARDED_BY(crit_sect_) = {-1, -1};
RTC_DISALLOW_COPY_AND_ASSIGN(PlayoutDelayOracle);
};
} // namespace webrtc
#endif // MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_