Change NetEq::GetPlayoutTimestamp to return an rtc::Optional<uint32_t>

This is in preparation for changes to when the playout timestamp is
valid.

BUG=webrtc:5669

Review URL: https://codereview.webrtc.org/1853183002

Cr-Commit-Position: refs/heads/master@{#12256}
This commit is contained in:
henrik.lundin
2016-04-06 01:39:22 -07:00
committed by Commit bot
parent 05255b0e8a
commit 9a410dd082
13 changed files with 77 additions and 58 deletions

View File

@ -196,9 +196,10 @@ int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
// |GetPlayoutTimestamp|, which is the timestamp of the last sample of
// |audio_frame|.
// TODO(henrik.lundin) Move setting of audio_frame->timestamp_ inside NetEq.
uint32_t playout_timestamp = 0;
if (GetPlayoutTimestamp(&playout_timestamp)) {
audio_frame->timestamp_ = playout_timestamp -
rtc::Optional<uint32_t> playout_timestamp = GetPlayoutTimestamp();
if (playout_timestamp) {
audio_frame->timestamp_ =
*playout_timestamp -
static_cast<uint32_t>(audio_frame->samples_per_channel_);
} else {
// Remain 0 until we have a valid |playout_timestamp|.
@ -318,8 +319,8 @@ int AcmReceiver::RemoveCodec(uint8_t payload_type) {
return 0;
}
bool AcmReceiver::GetPlayoutTimestamp(uint32_t* timestamp) {
return neteq_->GetPlayoutTimestamp(timestamp);
rtc::Optional<uint32_t> AcmReceiver::GetPlayoutTimestamp() {
return neteq_->GetPlayoutTimestamp();
}
int AcmReceiver::LastAudioCodec(CodecInst* codec) const {

View File

@ -195,11 +195,9 @@ class AcmReceiver {
//
int RemoveAllCodecs();
//
// Gets the RTP timestamp of the last sample delivered by GetAudio().
// Returns true if the RTP timestamp is valid, otherwise false.
//
bool GetPlayoutTimestamp(uint32_t* timestamp);
// Returns the RTP timestamp for the last sample delivered by GetAudio().
// The return value will be empty if no valid timestamp is available.
rtc::Optional<uint32_t> GetPlayoutTimestamp();
//
// Get the audio codec associated with the last non-CNG/non-DTMF received

View File

@ -902,8 +902,16 @@ int AudioCodingModuleImpl::DisableOpusDtx() {
return encoder_stack_->SetDtx(false) ? 0 : -1;
}
int AudioCodingModuleImpl::PlayoutTimestamp(uint32_t* timestamp) {
return receiver_.GetPlayoutTimestamp(timestamp) ? 0 : -1;
int32_t AudioCodingModuleImpl::PlayoutTimestamp(uint32_t* timestamp) {
rtc::Optional<uint32_t> ts = PlayoutTimestamp();
if (!ts)
return -1;
*timestamp = *ts;
return 0;
}
rtc::Optional<uint32_t> AudioCodingModuleImpl::PlayoutTimestamp() {
return receiver_.GetPlayoutTimestamp();
}
bool AudioCodingModuleImpl::HaveValidEncoder(const char* caller_name) const {

View File

@ -157,8 +157,9 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
// Smallest latency NetEq will maintain.
int LeastRequiredDelayMs() const override;
// Get playout timestamp.
int PlayoutTimestamp(uint32_t* timestamp) override;
RTC_DEPRECATED int32_t PlayoutTimestamp(uint32_t* timestamp) override;
rtc::Optional<uint32_t> PlayoutTimestamp() override;
// Get 10 milliseconds of raw audio data to play out, and
// automatic resample to the requested frequency if > 0.