Remove interface directories kept to avoid breaking downstream.

This is a follow-up CL for https://codereview.webrtc.org/1417683006
now that downstream code has been updated to use the 'include' directories
for header files instead.

BUG=webrtc:5095
TESTED=git cl try -c --bot=android_compile_rel --bot=linux_compile_rel --bot=win_compile_rel --bot=mac_compile_rel -m tryserver.webrtc --bot=ios_rel

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

Cr-Commit-Position: refs/heads/master@{#10547}
This commit is contained in:
kjellander 2015-11-06 15:24:47 -08:00 committed by Commit bot
parent d6c0f8cac1
commit 19299fb28b
23 changed files with 0 additions and 3667 deletions

View File

@ -1,79 +0,0 @@
/*
* Copyright (c) 2011 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 WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INCLUDE_AUDIO_CONFERENCE_MIXER_H_
#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INCLUDE_AUDIO_CONFERENCE_MIXER_H_
#pragma message("WARNING: audio_conference_mixer/interface is DEPRECATED; use include")
#include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer_defines.h"
#include "webrtc/modules/include/module.h"
#include "webrtc/modules/include/module_common_types.h"
namespace webrtc {
class AudioMixerOutputReceiver;
class MixerParticipant;
class Trace;
class AudioConferenceMixer : public Module
{
public:
enum {kMaximumAmountOfMixedParticipants = 3};
enum Frequency
{
kNbInHz = 8000,
kWbInHz = 16000,
kSwbInHz = 32000,
kFbInHz = 48000,
kLowestPossible = -1,
kDefaultFrequency = kWbInHz
};
// Factory method. Constructor disabled.
static AudioConferenceMixer* Create(int id);
virtual ~AudioConferenceMixer() {}
// Module functions
int64_t TimeUntilNextProcess() override = 0;
int32_t Process() override = 0;
// Register/unregister a callback class for receiving the mixed audio.
virtual int32_t RegisterMixedStreamCallback(
AudioMixerOutputReceiver* receiver) = 0;
virtual int32_t UnRegisterMixedStreamCallback() = 0;
// Add/remove participants as candidates for mixing.
virtual int32_t SetMixabilityStatus(MixerParticipant* participant,
bool mixable) = 0;
// Returns true if a participant is a candidate for mixing.
virtual bool MixabilityStatus(
const MixerParticipant& participant) const = 0;
// Inform the mixer that the participant should always be mixed and not
// count toward the number of mixed participants. Note that a participant
// must have been added to the mixer (by calling SetMixabilityStatus())
// before this function can be successfully called.
virtual int32_t SetAnonymousMixabilityStatus(
MixerParticipant* participant, bool mixable) = 0;
// Returns true if the participant is mixed anonymously.
virtual bool AnonymousMixabilityStatus(
const MixerParticipant& participant) const = 0;
// Set the minimum sampling frequency at which to mix. The mixing algorithm
// may still choose to mix at a higher samling frequency to avoid
// downsampling of audio contributing to the mixed audio.
virtual int32_t SetMinimumMixingFrequency(Frequency freq) = 0;
protected:
AudioConferenceMixer() {}
};
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INCLUDE_AUDIO_CONFERENCE_MIXER_H_

View File

@ -1,62 +0,0 @@
/*
* Copyright (c) 2011 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 WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INCLUDE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INCLUDE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
#pragma message("WARNING: audio_conference_mixer/interface is DEPRECATED; use include")
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/typedefs.h"
namespace webrtc {
class MixHistory;
// A callback class that all mixer participants must inherit from/implement.
class MixerParticipant
{
public:
// The implementation of this function should update audioFrame with new
// audio every time it's called.
//
// If it returns -1, the frame will not be added to the mix.
virtual int32_t GetAudioFrame(int32_t id,
AudioFrame* audioFrame) = 0;
// Returns true if the participant was mixed this mix iteration.
bool IsMixed() const;
// This function specifies the sampling frequency needed for the AudioFrame
// for future GetAudioFrame(..) calls.
virtual int32_t NeededFrequency(int32_t id) const = 0;
MixHistory* _mixHistory;
protected:
MixerParticipant();
virtual ~MixerParticipant();
};
class AudioMixerOutputReceiver
{
public:
// This callback function provides the mixed audio for this mix iteration.
// Note that uniqueAudioFrames is an array of AudioFrame pointers with the
// size according to the size parameter.
virtual void NewMixedAudio(const int32_t id,
const AudioFrame& generalAudioFrame,
const AudioFrame** uniqueAudioFrames,
const uint32_t size) = 0;
protected:
AudioMixerOutputReceiver() {}
virtual ~AudioMixerOutputReceiver() {}
};
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INCLUDE_AUDIO_CONFERENCE_MIXER_DEFINES_H_

View File

@ -1,83 +0,0 @@
/*
* Copyright (c) 2012 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 WEBRTC_MODULES_INCLUDE_MODULE_H_
#define WEBRTC_MODULES_INCLUDE_MODULE_H_
#pragma message("WARNING: webrtc/modules/include is DEPRECATED; use webrtc/modules/include")
#include "webrtc/typedefs.h"
namespace webrtc {
class ProcessThread;
class Module {
public:
// Returns the number of milliseconds until the module wants a worker
// thread to call Process.
// This method is called on the same worker thread as Process will
// be called on.
// TODO(tommi): Almost all implementations of this function, need to know
// the current tick count. Consider passing it as an argument. It could
// also improve the accuracy of when the next callback occurs since the
// thread that calls Process() will also have it's tick count reference
// which might not match with what the implementations use.
virtual int64_t TimeUntilNextProcess() = 0;
// Process any pending tasks such as timeouts.
// Called on a worker thread.
virtual int32_t Process() = 0;
// This method is called when the module is attached to a *running* process
// thread or detached from one. In the case of detaching, |process_thread|
// will be nullptr.
//
// This method will be called in the following cases:
//
// * Non-null process_thread:
// * ProcessThread::RegisterModule() is called while the thread is running.
// * ProcessThread::Start() is called and RegisterModule has previously
// been called. The thread will be started immediately after notifying
// all modules.
//
// * Null process_thread:
// * ProcessThread::DeRegisterModule() is called while the thread is
// running.
// * ProcessThread::Stop() was called and the thread has been stopped.
//
// NOTE: This method is not called from the worker thread itself, but from
// the thread that registers/deregisters the module or calls Start/Stop.
virtual void ProcessThreadAttached(ProcessThread* process_thread) {}
protected:
virtual ~Module() {}
};
// Reference counted version of the Module interface.
class RefCountedModule : public Module {
public:
// Increase the reference count by one.
// Returns the incremented reference count.
virtual int32_t AddRef() const = 0;
// Decrease the reference count by one.
// Returns the decreased reference count.
// Returns 0 if the last reference was just released.
// When the reference count reaches 0 the object will self-destruct.
virtual int32_t Release() const = 0;
protected:
~RefCountedModule() override = default;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_INCLUDE_MODULE_H_

View File

@ -1,812 +0,0 @@
/*
* Copyright (c) 2012 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 WEBRTC_MODULES_INCLUDE_MODULE_COMMON_TYPES_H_
#define WEBRTC_MODULES_INCLUDE_MODULE_COMMON_TYPES_H_
#pragma message("WARNING: webrtc/modules/include is DEPRECATED; use webrtc/modules/include")
#include <assert.h>
#include <string.h> // memcpy
#include <algorithm>
#include <limits>
#include "webrtc/base/constructormagic.h"
#include "webrtc/common_types.h"
#include "webrtc/common_video/rotation.h"
#include "webrtc/typedefs.h"
namespace webrtc {
struct RTPAudioHeader {
uint8_t numEnergy; // number of valid entries in arrOfEnergy
uint8_t arrOfEnergy[kRtpCsrcSize]; // one energy byte (0-9) per channel
bool isCNG; // is this CNG
uint8_t channel; // number of channels 2 = stereo
};
const int16_t kNoPictureId = -1;
const int16_t kMaxOneBytePictureId = 0x7F; // 7 bits
const int16_t kMaxTwoBytePictureId = 0x7FFF; // 15 bits
const int16_t kNoTl0PicIdx = -1;
const uint8_t kNoTemporalIdx = 0xFF;
const uint8_t kNoSpatialIdx = 0xFF;
const uint8_t kNoGofIdx = 0xFF;
const size_t kMaxVp9RefPics = 3;
const size_t kMaxVp9FramesInGof = 0xFF; // 8 bits
const size_t kMaxVp9NumberOfSpatialLayers = 8;
const int kNoKeyIdx = -1;
struct RTPVideoHeaderVP8 {
void InitRTPVideoHeaderVP8() {
nonReference = false;
pictureId = kNoPictureId;
tl0PicIdx = kNoTl0PicIdx;
temporalIdx = kNoTemporalIdx;
layerSync = false;
keyIdx = kNoKeyIdx;
partitionId = 0;
beginningOfPartition = false;
}
bool nonReference; // Frame is discardable.
int16_t pictureId; // Picture ID index, 15 bits;
// kNoPictureId if PictureID does not exist.
int16_t tl0PicIdx; // TL0PIC_IDX, 8 bits;
// kNoTl0PicIdx means no value provided.
uint8_t temporalIdx; // Temporal layer index, or kNoTemporalIdx.
bool layerSync; // This frame is a layer sync frame.
// Disabled if temporalIdx == kNoTemporalIdx.
int keyIdx; // 5 bits; kNoKeyIdx means not used.
int partitionId; // VP8 partition ID
bool beginningOfPartition; // True if this packet is the first
// in a VP8 partition. Otherwise false
};
enum TemporalStructureMode {
kTemporalStructureMode1, // 1 temporal layer structure - i.e., IPPP...
kTemporalStructureMode2, // 2 temporal layers 0-1-0-1...
kTemporalStructureMode3 // 3 temporal layers 0-2-1-2-0-2-1-2...
};
struct GofInfoVP9 {
void SetGofInfoVP9(TemporalStructureMode tm) {
switch (tm) {
case kTemporalStructureMode1:
num_frames_in_gof = 1;
temporal_idx[0] = 0;
temporal_up_switch[0] = false;
num_ref_pics[0] = 1;
pid_diff[0][0] = 1;
break;
case kTemporalStructureMode2:
num_frames_in_gof = 2;
temporal_idx[0] = 0;
temporal_up_switch[0] = false;
num_ref_pics[0] = 1;
pid_diff[0][0] = 2;
temporal_idx[1] = 1;
temporal_up_switch[1] = true;
num_ref_pics[1] = 1;
pid_diff[1][0] = 1;
break;
case kTemporalStructureMode3:
num_frames_in_gof = 4;
temporal_idx[0] = 0;
temporal_up_switch[0] = false;
num_ref_pics[0] = 1;
pid_diff[0][0] = 4;
temporal_idx[1] = 2;
temporal_up_switch[1] = true;
num_ref_pics[1] = 1;
pid_diff[1][0] = 1;
temporal_idx[2] = 1;
temporal_up_switch[2] = true;
num_ref_pics[2] = 1;
pid_diff[2][0] = 2;
temporal_idx[3] = 2;
temporal_up_switch[3] = false;
num_ref_pics[3] = 2;
pid_diff[3][0] = 1;
pid_diff[3][1] = 2;
break;
default:
assert(false);
}
}
void CopyGofInfoVP9(const GofInfoVP9& src) {
num_frames_in_gof = src.num_frames_in_gof;
for (size_t i = 0; i < num_frames_in_gof; ++i) {
temporal_idx[i] = src.temporal_idx[i];
temporal_up_switch[i] = src.temporal_up_switch[i];
num_ref_pics[i] = src.num_ref_pics[i];
for (uint8_t r = 0; r < num_ref_pics[i]; ++r) {
pid_diff[i][r] = src.pid_diff[i][r];
}
}
}
size_t num_frames_in_gof;
uint8_t temporal_idx[kMaxVp9FramesInGof];
bool temporal_up_switch[kMaxVp9FramesInGof];
uint8_t num_ref_pics[kMaxVp9FramesInGof];
uint8_t pid_diff[kMaxVp9FramesInGof][kMaxVp9RefPics];
};
struct RTPVideoHeaderVP9 {
void InitRTPVideoHeaderVP9() {
inter_pic_predicted = false;
flexible_mode = false;
beginning_of_frame = false;
end_of_frame = false;
ss_data_available = false;
picture_id = kNoPictureId;
max_picture_id = kMaxTwoBytePictureId;
tl0_pic_idx = kNoTl0PicIdx;
temporal_idx = kNoTemporalIdx;
spatial_idx = kNoSpatialIdx;
temporal_up_switch = false;
inter_layer_predicted = false;
gof_idx = kNoGofIdx;
num_ref_pics = 0;
num_spatial_layers = 1;
}
bool inter_pic_predicted; // This layer frame is dependent on previously
// coded frame(s).
bool flexible_mode; // This frame is in flexible mode.
bool beginning_of_frame; // True if this packet is the first in a VP9 layer
// frame.
bool end_of_frame; // True if this packet is the last in a VP9 layer frame.
bool ss_data_available; // True if SS data is available in this payload
// descriptor.
int16_t picture_id; // PictureID index, 15 bits;
// kNoPictureId if PictureID does not exist.
int16_t max_picture_id; // Maximum picture ID index; either 0x7F or 0x7FFF;
int16_t tl0_pic_idx; // TL0PIC_IDX, 8 bits;
// kNoTl0PicIdx means no value provided.
uint8_t temporal_idx; // Temporal layer index, or kNoTemporalIdx.
uint8_t spatial_idx; // Spatial layer index, or kNoSpatialIdx.
bool temporal_up_switch; // True if upswitch to higher frame rate is possible
// starting from this frame.
bool inter_layer_predicted; // Frame is dependent on directly lower spatial
// layer frame.
uint8_t gof_idx; // Index to predefined temporal frame info in SS data.
uint8_t num_ref_pics; // Number of reference pictures used by this layer
// frame.
uint8_t pid_diff[kMaxVp9RefPics]; // P_DIFF signaled to derive the PictureID
// of the reference pictures.
int16_t ref_picture_id[kMaxVp9RefPics]; // PictureID of reference pictures.
// SS data.
size_t num_spatial_layers; // Always populated.
bool spatial_layer_resolution_present;
uint16_t width[kMaxVp9NumberOfSpatialLayers];
uint16_t height[kMaxVp9NumberOfSpatialLayers];
GofInfoVP9 gof;
};
// The packetization types that we support: single, aggregated, and fragmented.
enum H264PacketizationTypes {
kH264SingleNalu, // This packet contains a single NAL unit.
kH264StapA, // This packet contains STAP-A (single time
// aggregation) packets. If this packet has an
// associated NAL unit type, it'll be for the
// first such aggregated packet.
kH264FuA, // This packet contains a FU-A (fragmentation
// unit) packet, meaning it is a part of a frame
// that was too large to fit into a single packet.
};
struct RTPVideoHeaderH264 {
uint8_t nalu_type; // The NAL unit type. If this is a header for a
// fragmented packet, it's the NAL unit type of
// the original data. If this is the header for an
// aggregated packet, it's the NAL unit type of
// the first NAL unit in the packet.
H264PacketizationTypes packetization_type;
};
union RTPVideoTypeHeader {
RTPVideoHeaderVP8 VP8;
RTPVideoHeaderVP9 VP9;
RTPVideoHeaderH264 H264;
};
enum RtpVideoCodecTypes {
kRtpVideoNone,
kRtpVideoGeneric,
kRtpVideoVp8,
kRtpVideoVp9,
kRtpVideoH264
};
// Since RTPVideoHeader is used as a member of a union, it can't have a
// non-trivial default constructor.
struct RTPVideoHeader {
uint16_t width; // size
uint16_t height;
VideoRotation rotation;
bool isFirstPacket; // first packet in frame
uint8_t simulcastIdx; // Index if the simulcast encoder creating
// this frame, 0 if not using simulcast.
RtpVideoCodecTypes codec;
RTPVideoTypeHeader codecHeader;
};
union RTPTypeHeader {
RTPAudioHeader Audio;
RTPVideoHeader Video;
};
struct WebRtcRTPHeader {
RTPHeader header;
FrameType frameType;
RTPTypeHeader type;
// NTP time of the capture time in local timebase in milliseconds.
int64_t ntp_time_ms;
};
class RTPFragmentationHeader {
public:
RTPFragmentationHeader()
: fragmentationVectorSize(0),
fragmentationOffset(NULL),
fragmentationLength(NULL),
fragmentationTimeDiff(NULL),
fragmentationPlType(NULL) {};
~RTPFragmentationHeader() {
delete[] fragmentationOffset;
delete[] fragmentationLength;
delete[] fragmentationTimeDiff;
delete[] fragmentationPlType;
}
void CopyFrom(const RTPFragmentationHeader& src) {
if (this == &src) {
return;
}
if (src.fragmentationVectorSize != fragmentationVectorSize) {
// new size of vectors
// delete old
delete[] fragmentationOffset;
fragmentationOffset = NULL;
delete[] fragmentationLength;
fragmentationLength = NULL;
delete[] fragmentationTimeDiff;
fragmentationTimeDiff = NULL;
delete[] fragmentationPlType;
fragmentationPlType = NULL;
if (src.fragmentationVectorSize > 0) {
// allocate new
if (src.fragmentationOffset) {
fragmentationOffset = new size_t[src.fragmentationVectorSize];
}
if (src.fragmentationLength) {
fragmentationLength = new size_t[src.fragmentationVectorSize];
}
if (src.fragmentationTimeDiff) {
fragmentationTimeDiff = new uint16_t[src.fragmentationVectorSize];
}
if (src.fragmentationPlType) {
fragmentationPlType = new uint8_t[src.fragmentationVectorSize];
}
}
// set new size
fragmentationVectorSize = src.fragmentationVectorSize;
}
if (src.fragmentationVectorSize > 0) {
// copy values
if (src.fragmentationOffset) {
memcpy(fragmentationOffset, src.fragmentationOffset,
src.fragmentationVectorSize * sizeof(size_t));
}
if (src.fragmentationLength) {
memcpy(fragmentationLength, src.fragmentationLength,
src.fragmentationVectorSize * sizeof(size_t));
}
if (src.fragmentationTimeDiff) {
memcpy(fragmentationTimeDiff, src.fragmentationTimeDiff,
src.fragmentationVectorSize * sizeof(uint16_t));
}
if (src.fragmentationPlType) {
memcpy(fragmentationPlType, src.fragmentationPlType,
src.fragmentationVectorSize * sizeof(uint8_t));
}
}
}
void VerifyAndAllocateFragmentationHeader(const size_t size) {
assert(size <= std::numeric_limits<uint16_t>::max());
const uint16_t size16 = static_cast<uint16_t>(size);
if (fragmentationVectorSize < size16) {
uint16_t oldVectorSize = fragmentationVectorSize;
{
// offset
size_t* oldOffsets = fragmentationOffset;
fragmentationOffset = new size_t[size16];
memset(fragmentationOffset + oldVectorSize, 0,
sizeof(size_t) * (size16 - oldVectorSize));
// copy old values
memcpy(fragmentationOffset, oldOffsets,
sizeof(size_t) * oldVectorSize);
delete[] oldOffsets;
}
// length
{
size_t* oldLengths = fragmentationLength;
fragmentationLength = new size_t[size16];
memset(fragmentationLength + oldVectorSize, 0,
sizeof(size_t) * (size16 - oldVectorSize));
memcpy(fragmentationLength, oldLengths,
sizeof(size_t) * oldVectorSize);
delete[] oldLengths;
}
// time diff
{
uint16_t* oldTimeDiffs = fragmentationTimeDiff;
fragmentationTimeDiff = new uint16_t[size16];
memset(fragmentationTimeDiff + oldVectorSize, 0,
sizeof(uint16_t) * (size16 - oldVectorSize));
memcpy(fragmentationTimeDiff, oldTimeDiffs,
sizeof(uint16_t) * oldVectorSize);
delete[] oldTimeDiffs;
}
// payload type
{
uint8_t* oldTimePlTypes = fragmentationPlType;
fragmentationPlType = new uint8_t[size16];
memset(fragmentationPlType + oldVectorSize, 0,
sizeof(uint8_t) * (size16 - oldVectorSize));
memcpy(fragmentationPlType, oldTimePlTypes,
sizeof(uint8_t) * oldVectorSize);
delete[] oldTimePlTypes;
}
fragmentationVectorSize = size16;
}
}
uint16_t fragmentationVectorSize; // Number of fragmentations
size_t* fragmentationOffset; // Offset of pointer to data for each
// fragmentation
size_t* fragmentationLength; // Data size for each fragmentation
uint16_t* fragmentationTimeDiff; // Timestamp difference relative "now" for
// each fragmentation
uint8_t* fragmentationPlType; // Payload type of each fragmentation
private:
RTC_DISALLOW_COPY_AND_ASSIGN(RTPFragmentationHeader);
};
struct RTCPVoIPMetric {
// RFC 3611 4.7
uint8_t lossRate;
uint8_t discardRate;
uint8_t burstDensity;
uint8_t gapDensity;
uint16_t burstDuration;
uint16_t gapDuration;
uint16_t roundTripDelay;
uint16_t endSystemDelay;
uint8_t signalLevel;
uint8_t noiseLevel;
uint8_t RERL;
uint8_t Gmin;
uint8_t Rfactor;
uint8_t extRfactor;
uint8_t MOSLQ;
uint8_t MOSCQ;
uint8_t RXconfig;
uint16_t JBnominal;
uint16_t JBmax;
uint16_t JBabsMax;
};
// Types for the FEC packet masks. The type |kFecMaskRandom| is based on a
// random loss model. The type |kFecMaskBursty| is based on a bursty/consecutive
// loss model. The packet masks are defined in
// modules/rtp_rtcp/fec_private_tables_random(bursty).h
enum FecMaskType {
kFecMaskRandom,
kFecMaskBursty,
};
// Struct containing forward error correction settings.
struct FecProtectionParams {
int fec_rate;
bool use_uep_protection;
int max_fec_frames;
FecMaskType fec_mask_type;
};
// Interface used by the CallStats class to distribute call statistics.
// Callbacks will be triggered as soon as the class has been registered to a
// CallStats object using RegisterStatsObserver.
class CallStatsObserver {
public:
virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) = 0;
virtual ~CallStatsObserver() {}
};
struct VideoContentMetrics {
VideoContentMetrics()
: motion_magnitude(0.0f),
spatial_pred_err(0.0f),
spatial_pred_err_h(0.0f),
spatial_pred_err_v(0.0f) {}
void Reset() {
motion_magnitude = 0.0f;
spatial_pred_err = 0.0f;
spatial_pred_err_h = 0.0f;
spatial_pred_err_v = 0.0f;
}
float motion_magnitude;
float spatial_pred_err;
float spatial_pred_err_h;
float spatial_pred_err_v;
};
/* This class holds up to 60 ms of super-wideband (32 kHz) stereo audio. It
* allows for adding and subtracting frames while keeping track of the resulting
* states.
*
* Notes
* - The total number of samples in |data_| is
* samples_per_channel_ * num_channels_
*
* - Stereo data is interleaved starting with the left channel.
*
* - The +operator assume that you would never add exactly opposite frames when
* deciding the resulting state. To do this use the -operator.
*/
class AudioFrame {
public:
// Stereo, 32 kHz, 60 ms (2 * 32 * 60)
static const size_t kMaxDataSizeSamples = 3840;
enum VADActivity {
kVadActive = 0,
kVadPassive = 1,
kVadUnknown = 2
};
enum SpeechType {
kNormalSpeech = 0,
kPLC = 1,
kCNG = 2,
kPLCCNG = 3,
kUndefined = 4
};
AudioFrame();
virtual ~AudioFrame() {}
// Resets all members to their default state (except does not modify the
// contents of |data_|).
void Reset();
// |interleaved_| is not changed by this method.
void UpdateFrame(int id, uint32_t timestamp, const int16_t* data,
size_t samples_per_channel, int sample_rate_hz,
SpeechType speech_type, VADActivity vad_activity,
int num_channels = 1, uint32_t energy = -1);
AudioFrame& Append(const AudioFrame& rhs);
void CopyFrom(const AudioFrame& src);
void Mute();
AudioFrame& operator>>=(const int rhs);
AudioFrame& operator+=(const AudioFrame& rhs);
AudioFrame& operator-=(const AudioFrame& rhs);
int id_;
// RTP timestamp of the first sample in the AudioFrame.
uint32_t timestamp_;
// Time since the first frame in milliseconds.
// -1 represents an uninitialized value.
int64_t elapsed_time_ms_;
// NTP time of the estimated capture time in local timebase in milliseconds.
// -1 represents an uninitialized value.
int64_t ntp_time_ms_;
int16_t data_[kMaxDataSizeSamples];
size_t samples_per_channel_;
int sample_rate_hz_;
int num_channels_;
SpeechType speech_type_;
VADActivity vad_activity_;
// Note that there is no guarantee that |energy_| is correct. Any user of this
// member must verify that the value is correct.
// TODO(henrike) Remove |energy_|.
// See https://code.google.com/p/webrtc/issues/detail?id=3315.
uint32_t energy_;
bool interleaved_;
private:
RTC_DISALLOW_COPY_AND_ASSIGN(AudioFrame);
};
inline AudioFrame::AudioFrame()
: data_() {
Reset();
}
inline void AudioFrame::Reset() {
id_ = -1;
// TODO(wu): Zero is a valid value for |timestamp_|. We should initialize
// to an invalid value, or add a new member to indicate invalidity.
timestamp_ = 0;
elapsed_time_ms_ = -1;
ntp_time_ms_ = -1;
samples_per_channel_ = 0;
sample_rate_hz_ = 0;
num_channels_ = 0;
speech_type_ = kUndefined;
vad_activity_ = kVadUnknown;
energy_ = 0xffffffff;
interleaved_ = true;
}
inline void AudioFrame::UpdateFrame(int id,
uint32_t timestamp,
const int16_t* data,
size_t samples_per_channel,
int sample_rate_hz,
SpeechType speech_type,
VADActivity vad_activity,
int num_channels,
uint32_t energy) {
id_ = id;
timestamp_ = timestamp;
samples_per_channel_ = samples_per_channel;
sample_rate_hz_ = sample_rate_hz;
speech_type_ = speech_type;
vad_activity_ = vad_activity;
num_channels_ = num_channels;
energy_ = energy;
assert(num_channels >= 0);
const size_t length = samples_per_channel * num_channels;
assert(length <= kMaxDataSizeSamples);
if (data != NULL) {
memcpy(data_, data, sizeof(int16_t) * length);
} else {
memset(data_, 0, sizeof(int16_t) * length);
}
}
inline void AudioFrame::CopyFrom(const AudioFrame& src) {
if (this == &src) return;
id_ = src.id_;
timestamp_ = src.timestamp_;
elapsed_time_ms_ = src.elapsed_time_ms_;
ntp_time_ms_ = src.ntp_time_ms_;
samples_per_channel_ = src.samples_per_channel_;
sample_rate_hz_ = src.sample_rate_hz_;
speech_type_ = src.speech_type_;
vad_activity_ = src.vad_activity_;
num_channels_ = src.num_channels_;
energy_ = src.energy_;
interleaved_ = src.interleaved_;
assert(num_channels_ >= 0);
const size_t length = samples_per_channel_ * num_channels_;
assert(length <= kMaxDataSizeSamples);
memcpy(data_, src.data_, sizeof(int16_t) * length);
}
inline void AudioFrame::Mute() {
memset(data_, 0, samples_per_channel_ * num_channels_ * sizeof(int16_t));
}
inline AudioFrame& AudioFrame::operator>>=(const int rhs) {
assert((num_channels_ > 0) && (num_channels_ < 3));
if ((num_channels_ > 2) || (num_channels_ < 1)) return *this;
for (size_t i = 0; i < samples_per_channel_ * num_channels_; i++) {
data_[i] = static_cast<int16_t>(data_[i] >> rhs);
}
return *this;
}
inline AudioFrame& AudioFrame::Append(const AudioFrame& rhs) {
// Sanity check
assert((num_channels_ > 0) && (num_channels_ < 3));
assert(interleaved_ == rhs.interleaved_);
if ((num_channels_ > 2) || (num_channels_ < 1)) return *this;
if (num_channels_ != rhs.num_channels_) return *this;
if ((vad_activity_ == kVadActive) || rhs.vad_activity_ == kVadActive) {
vad_activity_ = kVadActive;
} else if (vad_activity_ == kVadUnknown || rhs.vad_activity_ == kVadUnknown) {
vad_activity_ = kVadUnknown;
}
if (speech_type_ != rhs.speech_type_) {
speech_type_ = kUndefined;
}
size_t offset = samples_per_channel_ * num_channels_;
for (size_t i = 0; i < rhs.samples_per_channel_ * rhs.num_channels_; i++) {
data_[offset + i] = rhs.data_[i];
}
samples_per_channel_ += rhs.samples_per_channel_;
return *this;
}
namespace {
inline int16_t ClampToInt16(int32_t input) {
if (input < -0x00008000) {
return -0x8000;
} else if (input > 0x00007FFF) {
return 0x7FFF;
} else {
return static_cast<int16_t>(input);
}
}
}
inline AudioFrame& AudioFrame::operator+=(const AudioFrame& rhs) {
// Sanity check
assert((num_channels_ > 0) && (num_channels_ < 3));
assert(interleaved_ == rhs.interleaved_);
if ((num_channels_ > 2) || (num_channels_ < 1)) return *this;
if (num_channels_ != rhs.num_channels_) return *this;
bool noPrevData = false;
if (samples_per_channel_ != rhs.samples_per_channel_) {
if (samples_per_channel_ == 0) {
// special case we have no data to start with
samples_per_channel_ = rhs.samples_per_channel_;
noPrevData = true;
} else {
return *this;
}
}
if ((vad_activity_ == kVadActive) || rhs.vad_activity_ == kVadActive) {
vad_activity_ = kVadActive;
} else if (vad_activity_ == kVadUnknown || rhs.vad_activity_ == kVadUnknown) {
vad_activity_ = kVadUnknown;
}
if (speech_type_ != rhs.speech_type_) speech_type_ = kUndefined;
if (noPrevData) {
memcpy(data_, rhs.data_,
sizeof(int16_t) * rhs.samples_per_channel_ * num_channels_);
} else {
// IMPROVEMENT this can be done very fast in assembly
for (size_t i = 0; i < samples_per_channel_ * num_channels_; i++) {
int32_t wrap_guard =
static_cast<int32_t>(data_[i]) + static_cast<int32_t>(rhs.data_[i]);
data_[i] = ClampToInt16(wrap_guard);
}
}
energy_ = 0xffffffff;
return *this;
}
inline AudioFrame& AudioFrame::operator-=(const AudioFrame& rhs) {
// Sanity check
assert((num_channels_ > 0) && (num_channels_ < 3));
assert(interleaved_ == rhs.interleaved_);
if ((num_channels_ > 2) || (num_channels_ < 1)) return *this;
if ((samples_per_channel_ != rhs.samples_per_channel_) ||
(num_channels_ != rhs.num_channels_)) {
return *this;
}
if ((vad_activity_ != kVadPassive) || rhs.vad_activity_ != kVadPassive) {
vad_activity_ = kVadUnknown;
}
speech_type_ = kUndefined;
for (size_t i = 0; i < samples_per_channel_ * num_channels_; i++) {
int32_t wrap_guard =
static_cast<int32_t>(data_[i]) - static_cast<int32_t>(rhs.data_[i]);
data_[i] = ClampToInt16(wrap_guard);
}
energy_ = 0xffffffff;
return *this;
}
inline bool IsNewerSequenceNumber(uint16_t sequence_number,
uint16_t prev_sequence_number) {
// Distinguish between elements that are exactly 0x8000 apart.
// If s1>s2 and |s1-s2| = 0x8000: IsNewer(s1,s2)=true, IsNewer(s2,s1)=false
// rather than having IsNewer(s1,s2) = IsNewer(s2,s1) = false.
if (static_cast<uint16_t>(sequence_number - prev_sequence_number) == 0x8000) {
return sequence_number > prev_sequence_number;
}
return sequence_number != prev_sequence_number &&
static_cast<uint16_t>(sequence_number - prev_sequence_number) < 0x8000;
}
inline bool IsNewerTimestamp(uint32_t timestamp, uint32_t prev_timestamp) {
// Distinguish between elements that are exactly 0x80000000 apart.
// If t1>t2 and |t1-t2| = 0x80000000: IsNewer(t1,t2)=true,
// IsNewer(t2,t1)=false
// rather than having IsNewer(t1,t2) = IsNewer(t2,t1) = false.
if (static_cast<uint32_t>(timestamp - prev_timestamp) == 0x80000000) {
return timestamp > prev_timestamp;
}
return timestamp != prev_timestamp &&
static_cast<uint32_t>(timestamp - prev_timestamp) < 0x80000000;
}
inline uint16_t LatestSequenceNumber(uint16_t sequence_number1,
uint16_t sequence_number2) {
return IsNewerSequenceNumber(sequence_number1, sequence_number2)
? sequence_number1
: sequence_number2;
}
inline uint32_t LatestTimestamp(uint32_t timestamp1, uint32_t timestamp2) {
return IsNewerTimestamp(timestamp1, timestamp2) ? timestamp1 : timestamp2;
}
// Utility class to unwrap a sequence number to a larger type, for easier
// handling large ranges. Note that sequence numbers will never be unwrapped
// to a negative value.
class SequenceNumberUnwrapper {
public:
SequenceNumberUnwrapper() : last_seq_(-1) {}
// Get the unwrapped sequence, but don't update the internal state.
int64_t UnwrapWithoutUpdate(uint16_t sequence_number) {
if (last_seq_ == -1)
return sequence_number;
uint16_t cropped_last = static_cast<uint16_t>(last_seq_);
int64_t delta = sequence_number - cropped_last;
if (IsNewerSequenceNumber(sequence_number, cropped_last)) {
if (delta < 0)
delta += (1 << 16); // Wrap forwards.
} else if (delta > 0 && (last_seq_ + delta - (1 << 16)) >= 0) {
// If sequence_number is older but delta is positive, this is a backwards
// wrap-around. However, don't wrap backwards past 0 (unwrapped).
delta -= (1 << 16);
}
return last_seq_ + delta;
}
// Only update the internal state to the specified last (unwrapped) sequence.
void UpdateLast(int64_t last_sequence) { last_seq_ = last_sequence; }
// Unwrap the sequence number and update the internal state.
int64_t Unwrap(uint16_t sequence_number) {
int64_t unwrapped = UnwrapWithoutUpdate(sequence_number);
UpdateLast(unwrapped);
return unwrapped;
}
private:
int64_t last_seq_;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_INCLUDE_MODULE_COMMON_TYPES_H_

View File

@ -1,182 +0,0 @@
/*
* Copyright (c) 2012 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 WEBRTC_MODULES_MEDIA_FILE_INCLUDE_MEDIA_FILE_H_
#define WEBRTC_MODULES_MEDIA_FILE_INCLUDE_MEDIA_FILE_H_
#pragma message("WARNING: media_file/interface is DEPRECATED; use media_file/include")
#include "webrtc/common_types.h"
#include "webrtc/modules/include/module.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/media_file/include/media_file_defines.h"
#include "webrtc/typedefs.h"
namespace webrtc {
class MediaFile : public Module
{
public:
// Factory method. Constructor disabled. id is the identifier for the
// MediaFile instance.
static MediaFile* CreateMediaFile(const int32_t id);
static void DestroyMediaFile(MediaFile* module);
// Put 10-60ms of audio data from file into the audioBuffer depending on
// codec frame size. dataLengthInBytes is both an input and output
// parameter. As input parameter it indicates the size of audioBuffer.
// As output parameter it indicates the number of bytes written to
// audioBuffer.
// Note: This API only play mono audio but can be used on file containing
// audio with more channels (in which case the audio will be converted to
// mono).
virtual int32_t PlayoutAudioData(
int8_t* audioBuffer,
size_t& dataLengthInBytes) = 0;
// Put 10-60ms, depending on codec frame size, of audio data from file into
// audioBufferLeft and audioBufferRight. The buffers contain the left and
// right channel of played out stereo audio.
// dataLengthInBytes is both an input and output parameter. As input
// parameter it indicates the size of both audioBufferLeft and
// audioBufferRight. As output parameter it indicates the number of bytes
// written to both audio buffers.
// Note: This API can only be successfully called for WAV files with stereo
// audio.
virtual int32_t PlayoutStereoData(
int8_t* audioBufferLeft,
int8_t* audioBufferRight,
size_t& dataLengthInBytes) = 0;
// Open the file specified by fileName (relative path is allowed) for
// reading. FileCallback::PlayNotification(..) will be called after
// notificationTimeMs of the file has been played if notificationTimeMs is
// greater than zero. If loop is true the file will be played until
// StopPlaying() is called. When end of file is reached the file is read
// from the start. format specifies the type of file fileName refers to.
// codecInst specifies the encoding of the audio data. Note that
// file formats that contain this information (like WAV files) don't need to
// provide a non-NULL codecInst. startPointMs and stopPointMs, unless zero,
// specify what part of the file should be read. From startPointMs ms to
// stopPointMs ms.
// Note: codecInst.channels should be set to 2 for stereo (and 1 for
// mono). Stereo audio is only supported for WAV files.
virtual int32_t StartPlayingAudioFile(
const char* fileName,
const uint32_t notificationTimeMs = 0,
const bool loop = false,
const FileFormats format = kFileFormatPcm16kHzFile,
const CodecInst* codecInst = NULL,
const uint32_t startPointMs = 0,
const uint32_t stopPointMs = 0) = 0;
// Prepare for playing audio from stream.
// FileCallback::PlayNotification(..) will be called after
// notificationTimeMs of the file has been played if notificationTimeMs is
// greater than zero. format specifies the type of file fileName refers to.
// codecInst specifies the encoding of the audio data. Note that
// file formats that contain this information (like WAV files) don't need to
// provide a non-NULL codecInst. startPointMs and stopPointMs, unless zero,
// specify what part of the file should be read. From startPointMs ms to
// stopPointMs ms.
// Note: codecInst.channels should be set to 2 for stereo (and 1 for
// mono). Stereo audio is only supported for WAV files.
virtual int32_t StartPlayingAudioStream(
InStream& stream,
const uint32_t notificationTimeMs = 0,
const FileFormats format = kFileFormatPcm16kHzFile,
const CodecInst* codecInst = NULL,
const uint32_t startPointMs = 0,
const uint32_t stopPointMs = 0) = 0;
// Stop playing from file or stream.
virtual int32_t StopPlaying() = 0;
// Return true if playing.
virtual bool IsPlaying() = 0;
// Set durationMs to the number of ms that has been played from file.
virtual int32_t PlayoutPositionMs(
uint32_t& durationMs) const = 0;
// Write one audio frame, i.e. the bufferLength first bytes of audioBuffer,
// to file. The audio frame size is determined by the codecInst.pacsize
// parameter of the last sucessfull StartRecordingAudioFile(..) call.
// Note: bufferLength must be exactly one frame.
virtual int32_t IncomingAudioData(
const int8_t* audioBuffer,
const size_t bufferLength) = 0;
// Open/creates file specified by fileName for writing (relative path is
// allowed). FileCallback::RecordNotification(..) will be called after
// notificationTimeMs of audio data has been recorded if
// notificationTimeMs is greater than zero.
// format specifies the type of file that should be created/opened.
// codecInst specifies the encoding of the audio data. maxSizeBytes
// specifies the number of bytes allowed to be written to file if it is
// greater than zero.
// Note: codecInst.channels should be set to 2 for stereo (and 1 for
// mono). Stereo is only supported for WAV files.
virtual int32_t StartRecordingAudioFile(
const char* fileName,
const FileFormats format,
const CodecInst& codecInst,
const uint32_t notificationTimeMs = 0,
const uint32_t maxSizeBytes = 0) = 0;
// Prepare for recording audio to stream.
// FileCallback::RecordNotification(..) will be called after
// notificationTimeMs of audio data has been recorded if
// notificationTimeMs is greater than zero.
// format specifies the type of file that stream should correspond to.
// codecInst specifies the encoding of the audio data.
// Note: codecInst.channels should be set to 2 for stereo (and 1 for
// mono). Stereo is only supported for WAV files.
virtual int32_t StartRecordingAudioStream(
OutStream& stream,
const FileFormats format,
const CodecInst& codecInst,
const uint32_t notificationTimeMs = 0) = 0;
// Stop recording to file or stream.
virtual int32_t StopRecording() = 0;
// Return true if recording.
virtual bool IsRecording() = 0;
// Set durationMs to the number of ms that has been recorded to file.
virtual int32_t RecordDurationMs(uint32_t& durationMs) = 0;
// Return true if recording or playing is stereo.
virtual bool IsStereo() = 0;
// Register callback to receive media file related notifications. Disables
// callbacks if callback is NULL.
virtual int32_t SetModuleFileCallback(FileCallback* callback) = 0;
// Set durationMs to the size of the file (in ms) specified by fileName.
// format specifies the type of file fileName refers to. freqInHz specifies
// the sampling frequency of the file.
virtual int32_t FileDurationMs(
const char* fileName,
uint32_t& durationMs,
const FileFormats format,
const uint32_t freqInHz = 16000) = 0;
// Update codecInst according to the current audio codec being used for
// reading or writing.
virtual int32_t codec_info(CodecInst& codecInst) const = 0;
protected:
MediaFile() {}
virtual ~MediaFile() {}
};
} // namespace webrtc
#endif // WEBRTC_MODULES_MEDIA_FILE_INCLUDE_MEDIA_FILE_H_

View File

@ -1,53 +0,0 @@
/*
* Copyright (c) 2011 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 WEBRTC_MODULES_MEDIA_FILE_INCLUDE_MEDIA_FILE_DEFINES_H_
#define WEBRTC_MODULES_MEDIA_FILE_INCLUDE_MEDIA_FILE_DEFINES_H_
#pragma message("WARNING: media_file/interface is DEPRECATED; use media_file/include")
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/typedefs.h"
namespace webrtc {
// Callback class for the MediaFile class.
class FileCallback
{
public:
virtual ~FileCallback(){}
// This function is called by MediaFile when a file has been playing for
// durationMs ms. id is the identifier for the MediaFile instance calling
// the callback.
virtual void PlayNotification(const int32_t id,
const uint32_t durationMs) = 0;
// This function is called by MediaFile when a file has been recording for
// durationMs ms. id is the identifier for the MediaFile instance calling
// the callback.
virtual void RecordNotification(const int32_t id,
const uint32_t durationMs) = 0;
// This function is called by MediaFile when a file has been stopped
// playing. id is the identifier for the MediaFile instance calling the
// callback.
virtual void PlayFileEnded(const int32_t id) = 0;
// This function is called by MediaFile when a file has been stopped
// recording. id is the identifier for the MediaFile instance calling the
// callback.
virtual void RecordFileEnded(const int32_t id) = 0;
protected:
FileCallback() {}
};
} // namespace webrtc
#endif // WEBRTC_MODULES_MEDIA_FILE_INCLUDE_MEDIA_FILE_DEFINES_H_

View File

@ -1,48 +0,0 @@
/*
* Copyright (c) 2013 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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_FEC_RECEIVER_H_
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_FEC_RECEIVER_H_
#pragma message("WARNING: rtp_rtcp/interface is DEPRECATED; use include")
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/typedefs.h"
namespace webrtc {
struct FecPacketCounter {
FecPacketCounter()
: num_packets(0),
num_fec_packets(0),
num_recovered_packets(0) {}
size_t num_packets; // Number of received packets.
size_t num_fec_packets; // Number of received FEC packets.
size_t num_recovered_packets; // Number of recovered media packets using FEC.
};
class FecReceiver {
public:
static FecReceiver* Create(RtpData* callback);
virtual ~FecReceiver() {}
virtual int32_t AddReceivedRedPacket(const RTPHeader& rtp_header,
const uint8_t* incoming_rtp_packet,
size_t packet_length,
uint8_t ulpfec_payload_type) = 0;
virtual int32_t ProcessReceivedFec() = 0;
virtual FecPacketCounter GetPacketCounter() const = 0;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_FEC_RECEIVER_H_

View File

@ -1,104 +0,0 @@
/*
* Copyright (c) 2013 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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_
#pragma message("WARNING: rtp_rtcp/interface is DEPRECATED; use include dir.")
#include <map>
#include "webrtc/modules/include/module.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/typedefs.h"
namespace webrtc {
class Clock;
class StreamStatistician {
public:
virtual ~StreamStatistician();
virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) = 0;
virtual void GetDataCounters(size_t* bytes_received,
uint32_t* packets_received) const = 0;
// Gets received stream data counters (includes reset counter values).
virtual void GetReceiveStreamDataCounters(
StreamDataCounters* data_counters) const = 0;
virtual uint32_t BitrateReceived() const = 0;
// Returns true if the packet with RTP header |header| is likely to be a
// retransmitted packet, false otherwise.
virtual bool IsRetransmitOfOldPacket(const RTPHeader& header,
int64_t min_rtt) const = 0;
// Returns true if |sequence_number| is received in order, false otherwise.
virtual bool IsPacketInOrder(uint16_t sequence_number) const = 0;
};
typedef std::map<uint32_t, StreamStatistician*> StatisticianMap;
class ReceiveStatistics : public Module {
public:
virtual ~ReceiveStatistics() {}
static ReceiveStatistics* Create(Clock* clock);
// Updates the receive statistics with this packet.
virtual void IncomingPacket(const RTPHeader& rtp_header,
size_t packet_length,
bool retransmitted) = 0;
// Increment counter for number of FEC packets received.
virtual void FecPacketReceived(const RTPHeader& header,
size_t packet_length) = 0;
// Returns a map of all statisticians which have seen an incoming packet
// during the last two seconds.
virtual StatisticianMap GetActiveStatisticians() const = 0;
// Returns a pointer to the statistician of an ssrc.
virtual StreamStatistician* GetStatistician(uint32_t ssrc) const = 0;
// Sets the max reordering threshold in number of packets.
virtual void SetMaxReorderingThreshold(int max_reordering_threshold) = 0;
// Called on new RTCP stats creation.
virtual void RegisterRtcpStatisticsCallback(
RtcpStatisticsCallback* callback) = 0;
// Called on new RTP stats creation.
virtual void RegisterRtpStatisticsCallback(
StreamDataCountersCallback* callback) = 0;
};
class NullReceiveStatistics : public ReceiveStatistics {
public:
void IncomingPacket(const RTPHeader& rtp_header,
size_t packet_length,
bool retransmitted) override;
void FecPacketReceived(const RTPHeader& header,
size_t packet_length) override;
StatisticianMap GetActiveStatisticians() const override;
StreamStatistician* GetStatistician(uint32_t ssrc) const override;
int64_t TimeUntilNextProcess() override;
int32_t Process() override;
void SetMaxReorderingThreshold(int max_reordering_threshold) override;
void RegisterRtcpStatisticsCallback(
RtcpStatisticsCallback* callback) override;
void RegisterRtpStatisticsCallback(
StreamDataCountersCallback* callback) override;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_

View File

@ -1,53 +0,0 @@
/*
* Copyright (c) 2014 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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_REMOTE_NTP_TIME_ESTIMATOR_H_
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_REMOTE_NTP_TIME_ESTIMATOR_H_
#pragma message("WARNING: rtp_rtcp/interface is DEPRECATED; use include dir.")
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/system_wrappers/include/rtp_to_ntp.h"
namespace webrtc {
class Clock;
class TimestampExtrapolator;
// RemoteNtpTimeEstimator can be used to estimate a given RTP timestamp's NTP
// time in local timebase.
// Note that it needs to be trained with at least 2 RTCP SR (by calling
// |UpdateRtcpTimestamp|) before it can be used.
class RemoteNtpTimeEstimator {
public:
explicit RemoteNtpTimeEstimator(Clock* clock);
~RemoteNtpTimeEstimator();
// Updates the estimator with round trip time |rtt|, NTP seconds |ntp_secs|,
// NTP fraction |ntp_frac| and RTP timestamp |rtcp_timestamp|.
bool UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac,
uint32_t rtp_timestamp);
// Estimates the NTP timestamp in local timebase from |rtp_timestamp|.
// Returns the NTP timestamp in ms when success. -1 if failed.
int64_t Estimate(uint32_t rtp_timestamp);
private:
Clock* clock_;
rtc::scoped_ptr<TimestampExtrapolator> ts_extrapolator_;
RtcpList rtcp_list_;
int64_t last_timing_log_ms_;
RTC_DISALLOW_COPY_AND_ASSIGN(RemoteNtpTimeEstimator);
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_REMOTE_NTP_TIME_ESTIMATOR_H_

View File

@ -1,56 +0,0 @@
/*
* Copyright (c) 2015 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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
#pragma message("WARNING: rtp_rtcp/interface is DEPRECATED; use include dir.")
#include "webrtc/common_video/rotation.h"
namespace webrtc {
// Please refer to http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/
// 12.07.00_60/ts_126114v120700p.pdf Section 7.4.5. The rotation of a frame is
// the clockwise angle the frames must be rotated in order to display the frames
// correctly if the display is rotated in its natural orientation.
inline uint8_t ConvertVideoRotationToCVOByte(VideoRotation rotation) {
switch (rotation) {
case kVideoRotation_0:
return 0;
case kVideoRotation_90:
return 1;
case kVideoRotation_180:
return 2;
case kVideoRotation_270:
return 3;
}
assert(false);
return 0;
}
inline VideoRotation ConvertCVOByteToVideoRotation(uint8_t rotation) {
switch (rotation) {
case 0:
return kVideoRotation_0;
case 1:
return kVideoRotation_90;
case 2:
return kVideoRotation_180;
break;
case 3:
return kVideoRotation_270;
default:
assert(false);
return kVideoRotation_0;
}
}
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 2013 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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_
#pragma message("WARNING: rtp_rtcp/interface is DEPRECATED; use include dir.")
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "webrtc/typedefs.h"
namespace webrtc {
struct RTPHeader;
class RtpHeaderParser {
public:
static RtpHeaderParser* Create();
virtual ~RtpHeaderParser() {}
// Returns true if the packet is an RTCP packet, false otherwise.
static bool IsRtcp(const uint8_t* packet, size_t length);
// Parses the packet and stores the parsed packet in |header|. Returns true on
// success, false otherwise.
// This method is thread-safe in the sense that it can parse multiple packets
// at once.
virtual bool Parse(const uint8_t* packet,
size_t length,
RTPHeader* header) const = 0;
// Registers an RTP header extension and binds it to |id|.
virtual bool RegisterRtpHeaderExtension(RTPExtensionType type,
uint8_t id) = 0;
// De-registers an RTP header extension.
virtual bool DeregisterRtpHeaderExtension(RTPExtensionType type) = 0;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_

View File

@ -1,195 +0,0 @@
/*
* Copyright (c) 2013 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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_
#pragma message("WARNING: rtp_rtcp/interface is DEPRECATED; use include dir.")
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
namespace webrtc {
// This strategy deals with the audio/video-specific aspects
// of payload handling.
class RTPPayloadStrategy {
public:
virtual ~RTPPayloadStrategy() {}
virtual bool CodecsMustBeUnique() const = 0;
virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate) const = 0;
virtual void UpdatePayloadRate(RtpUtility::Payload* payload,
const uint32_t rate) const = 0;
virtual RtpUtility::Payload* CreatePayloadType(
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const int8_t payloadType,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate) const = 0;
virtual int GetPayloadTypeFrequency(
const RtpUtility::Payload& payload) const = 0;
static RTPPayloadStrategy* CreateStrategy(const bool handling_audio);
protected:
RTPPayloadStrategy() {}
};
class RTPPayloadRegistry {
public:
// The registry takes ownership of the strategy.
RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy);
~RTPPayloadRegistry();
int32_t RegisterReceivePayload(
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int8_t payload_type,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate,
bool* created_new_payload_type);
int32_t DeRegisterReceivePayload(
const int8_t payload_type);
int32_t ReceivePayloadType(
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate,
int8_t* payload_type) const;
bool RtxEnabled() const;
void SetRtxSsrc(uint32_t ssrc);
bool GetRtxSsrc(uint32_t* ssrc) const;
void SetRtxPayloadType(int payload_type, int associated_payload_type);
bool IsRtx(const RTPHeader& header) const;
// DEPRECATED. Use RestoreOriginalPacket below that takes a uint8_t*
// restored_packet, instead of a uint8_t**.
// TODO(noahric): Remove this when all callers have been updated.
bool RestoreOriginalPacket(uint8_t** restored_packet,
const uint8_t* packet,
size_t* packet_length,
uint32_t original_ssrc,
const RTPHeader& header) const;
bool RestoreOriginalPacket(uint8_t* restored_packet,
const uint8_t* packet,
size_t* packet_length,
uint32_t original_ssrc,
const RTPHeader& header) const;
bool IsRed(const RTPHeader& header) const;
// Returns true if the media of this RTP packet is encapsulated within an
// extra header, such as RTX or RED.
bool IsEncapsulated(const RTPHeader& header) const;
bool GetPayloadSpecifics(uint8_t payload_type, PayloadUnion* payload) const;
int GetPayloadTypeFrequency(uint8_t payload_type) const;
bool PayloadTypeToPayload(const uint8_t payload_type,
RtpUtility::Payload*& payload) const;
void ResetLastReceivedPayloadTypes() {
CriticalSectionScoped cs(crit_sect_.get());
last_received_payload_type_ = -1;
last_received_media_payload_type_ = -1;
}
// This sets the payload type of the packets being received from the network
// on the media SSRC. For instance if packets are encapsulated with RED, this
// payload type will be the RED payload type.
void SetIncomingPayloadType(const RTPHeader& header);
// Returns true if the new media payload type has not changed.
bool ReportMediaPayloadType(uint8_t media_payload_type);
int8_t red_payload_type() const {
CriticalSectionScoped cs(crit_sect_.get());
return red_payload_type_;
}
int8_t ulpfec_payload_type() const {
CriticalSectionScoped cs(crit_sect_.get());
return ulpfec_payload_type_;
}
int8_t last_received_payload_type() const {
CriticalSectionScoped cs(crit_sect_.get());
return last_received_payload_type_;
}
void set_last_received_payload_type(int8_t last_received_payload_type) {
CriticalSectionScoped cs(crit_sect_.get());
last_received_payload_type_ = last_received_payload_type;
}
int8_t last_received_media_payload_type() const {
CriticalSectionScoped cs(crit_sect_.get());
return last_received_media_payload_type_;
};
bool use_rtx_payload_mapping_on_restore() const {
CriticalSectionScoped cs(crit_sect_.get());
return use_rtx_payload_mapping_on_restore_;
}
void set_use_rtx_payload_mapping_on_restore(bool val) {
CriticalSectionScoped cs(crit_sect_.get());
use_rtx_payload_mapping_on_restore_ = val;
}
private:
// Prunes the payload type map of the specific payload type, if it exists.
void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const size_t payload_name_length,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate);
bool IsRtxInternal(const RTPHeader& header) const;
rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
RtpUtility::PayloadTypeMap payload_type_map_;
rtc::scoped_ptr<RTPPayloadStrategy> rtp_payload_strategy_;
int8_t red_payload_type_;
int8_t ulpfec_payload_type_;
int8_t incoming_payload_type_;
int8_t last_received_payload_type_;
int8_t last_received_media_payload_type_;
bool rtx_;
// TODO(changbin): Remove rtx_payload_type_ once interop with old clients that
// only understand one RTX PT is no longer needed.
int rtx_payload_type_;
// Mapping rtx_payload_type_map_[rtx] = associated.
std::map<int, int> rtx_payload_type_map_;
// When true, use rtx_payload_type_map_ when restoring RTX packets to get the
// correct payload type.
bool use_rtx_payload_mapping_on_restore_;
uint32_t ssrc_rtx_;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_

View File

@ -1,105 +0,0 @@
/*
* Copyright (c) 2012 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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_
#pragma message("WARNING: rtp_rtcp/interface is DEPRECATED; use include dir.")
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "webrtc/typedefs.h"
namespace webrtc {
class RTPPayloadRegistry;
class TelephoneEventHandler {
public:
virtual ~TelephoneEventHandler() {}
// The following three methods implement the TelephoneEventHandler interface.
// Forward DTMFs to decoder for playout.
virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0;
// Is forwarding of outband telephone events turned on/off?
virtual bool TelephoneEventForwardToDecoder() const = 0;
// Is TelephoneEvent configured with payload type payload_type
virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0;
};
class RtpReceiver {
public:
// Creates a video-enabled RTP receiver.
static RtpReceiver* CreateVideoReceiver(
Clock* clock,
RtpData* incoming_payload_callback,
RtpFeedback* incoming_messages_callback,
RTPPayloadRegistry* rtp_payload_registry);
// Creates an audio-enabled RTP receiver.
static RtpReceiver* CreateAudioReceiver(
Clock* clock,
RtpAudioFeedback* incoming_audio_feedback,
RtpData* incoming_payload_callback,
RtpFeedback* incoming_messages_callback,
RTPPayloadRegistry* rtp_payload_registry);
virtual ~RtpReceiver() {}
// Returns a TelephoneEventHandler if available.
virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
// Registers a receive payload in the payload registry and notifies the media
// receiver strategy.
virtual int32_t RegisterReceivePayload(
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int8_t payload_type,
const uint32_t frequency,
const uint8_t channels,
const uint32_t rate) = 0;
// De-registers |payload_type| from the payload registry.
virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0;
// Parses the media specific parts of an RTP packet and updates the receiver
// state. This for instance means that any changes in SSRC and payload type is
// detected and acted upon.
virtual bool IncomingRtpPacket(const RTPHeader& rtp_header,
const uint8_t* payload,
size_t payload_length,
PayloadUnion payload_specific,
bool in_order) = 0;
// Returns the currently configured NACK method.
virtual NACKMethod NACK() const = 0;
// Turn negative acknowledgement (NACK) requests on/off.
virtual void SetNACKStatus(const NACKMethod method) = 0;
// Gets the last received timestamp. Returns true if a packet has been
// received, false otherwise.
virtual bool Timestamp(uint32_t* timestamp) const = 0;
// Gets the time in milliseconds when the last timestamp was received.
// Returns true if a packet has been received, false otherwise.
virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) const = 0;
// Returns the remote SSRC of the currently received RTP stream.
virtual uint32_t SSRC() const = 0;
// Returns the current remote CSRCs.
virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
// Returns the current energy of the RTP stream received.
virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_

View File

@ -1,643 +0,0 @@
/*
* Copyright (c) 2012 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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
#pragma message("WARNING: rtp_rtcp/interface is DEPRECATED; use include dir.")
#include <set>
#include <vector>
#include "webrtc/modules/include/module.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
namespace webrtc {
// Forward declarations.
class ReceiveStatistics;
class RemoteBitrateEstimator;
class RtpReceiver;
class Transport;
namespace rtcp {
class TransportFeedback;
}
class RtpRtcp : public Module {
public:
struct Configuration {
Configuration();
/* id - Unique identifier of this RTP/RTCP module object
* audio - True for a audio version of the RTP/RTCP module
* object false will create a video version
* clock - The clock to use to read time. If NULL object
* will be using the system clock.
* incoming_data - Callback object that will receive the incoming
* data. May not be NULL; default callback will do
* nothing.
* incoming_messages - Callback object that will receive the incoming
* RTP messages. May not be NULL; default callback
* will do nothing.
* outgoing_transport - Transport object that will be called when packets
* are ready to be sent out on the network
* intra_frame_callback - Called when the receiver request a intra frame.
* bandwidth_callback - Called when we receive a changed estimate from
* the receiver of out stream.
* audio_messages - Telephone events. May not be NULL; default
* callback will do nothing.
* remote_bitrate_estimator - Estimates the bandwidth available for a set of
* streams from the same client.
* paced_sender - Spread any bursts of packets into smaller
* bursts to minimize packet loss.
*/
bool audio;
bool receiver_only;
Clock* clock;
ReceiveStatistics* receive_statistics;
Transport* outgoing_transport;
RtcpIntraFrameObserver* intra_frame_callback;
RtcpBandwidthObserver* bandwidth_callback;
TransportFeedbackObserver* transport_feedback_callback;
RtcpRttStats* rtt_stats;
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer;
RtpAudioFeedback* audio_messages;
RemoteBitrateEstimator* remote_bitrate_estimator;
RtpPacketSender* paced_sender;
TransportSequenceNumberAllocator* transport_sequence_number_allocator;
BitrateStatisticsObserver* send_bitrate_observer;
FrameCountObserver* send_frame_count_observer;
SendSideDelayObserver* send_side_delay_observer;
};
/*
* Create a RTP/RTCP module object using the system clock.
*
* configuration - Configuration of the RTP/RTCP module.
*/
static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
/**************************************************************************
*
* Receiver functions
*
***************************************************************************/
virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
size_t incoming_packet_length) = 0;
virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
/**************************************************************************
*
* Sender
*
***************************************************************************/
/*
* set MTU
*
* size - Max transfer unit in bytes, default is 1500
*
* return -1 on failure else 0
*/
virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
/*
* set transtport overhead
* default is IPv4 and UDP with no encryption
*
* TCP - true for TCP false UDP
* IPv6 - true for IP version 6 false for version 4
* authenticationOverhead - number of bytes to leave for an
* authentication header
*
* return -1 on failure else 0
*/
virtual int32_t SetTransportOverhead(
bool TCP,
bool IPV6,
uint8_t authenticationOverhead = 0) = 0;
/*
* Get max payload length
*
* A combination of the configuration MaxTransferUnit and
* TransportOverhead.
* Does not account FEC/ULP/RED overhead if FEC is enabled.
* Does not account for RTP headers
*/
virtual uint16_t MaxPayloadLength() const = 0;
/*
* Get max data payload length
*
* A combination of the configuration MaxTransferUnit, headers and
* TransportOverhead.
* Takes into account FEC/ULP/RED overhead if FEC is enabled.
* Takes into account RTP headers
*/
virtual uint16_t MaxDataPayloadLength() const = 0;
/*
* set codec name and payload type
*
* return -1 on failure else 0
*/
virtual int32_t RegisterSendPayload(
const CodecInst& voiceCodec) = 0;
/*
* set codec name and payload type
*
* return -1 on failure else 0
*/
virtual int32_t RegisterSendPayload(
const VideoCodec& videoCodec) = 0;
/*
* Unregister a send payload
*
* payloadType - payload type of codec
*
* return -1 on failure else 0
*/
virtual int32_t DeRegisterSendPayload(int8_t payloadType) = 0;
/*
* (De)register RTP header extension type and id.
*
* return -1 on failure else 0
*/
virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
uint8_t id) = 0;
virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
/*
* get start timestamp
*/
virtual uint32_t StartTimestamp() const = 0;
/*
* configure start timestamp, default is a random number
*
* timestamp - start timestamp
*/
virtual void SetStartTimestamp(uint32_t timestamp) = 0;
/*
* Get SequenceNumber
*/
virtual uint16_t SequenceNumber() const = 0;
/*
* Set SequenceNumber, default is a random number
*/
virtual void SetSequenceNumber(uint16_t seq) = 0;
// Returns true if the ssrc matched this module, false otherwise.
virtual bool SetRtpStateForSsrc(uint32_t ssrc,
const RtpState& rtp_state) = 0;
virtual bool GetRtpStateForSsrc(uint32_t ssrc, RtpState* rtp_state) = 0;
/*
* Get SSRC
*/
virtual uint32_t SSRC() const = 0;
/*
* configure SSRC, default is a random number
*/
virtual void SetSSRC(uint32_t ssrc) = 0;
/*
* Set CSRC
*
* csrcs - vector of CSRCs
*/
virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
/*
* Turn on/off sending RTX (RFC 4588). The modes can be set as a combination
* of values of the enumerator RtxMode.
*/
virtual void SetRtxSendStatus(int modes) = 0;
/*
* Get status of sending RTX (RFC 4588). The returned value can be
* a combination of values of the enumerator RtxMode.
*/
virtual int RtxSendStatus() const = 0;
// Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
// only the SSRC is set.
virtual void SetRtxSsrc(uint32_t ssrc) = 0;
// Sets the payload type to use when sending RTX packets. Note that this
// doesn't enable RTX, only the payload type is set.
virtual void SetRtxSendPayloadType(int payload_type,
int associated_payload_type) = 0;
// Gets the payload type pair of (RTX, associated) to use when sending RTX
// packets.
virtual std::pair<int, int> RtxSendPayloadType() const = 0;
/*
* sends kRtcpByeCode when going from true to false
*
* sending - on/off
*
* return -1 on failure else 0
*/
virtual int32_t SetSendingStatus(bool sending) = 0;
/*
* get send status
*/
virtual bool Sending() const = 0;
/*
* Starts/Stops media packets, on by default
*
* sending - on/off
*/
virtual void SetSendingMediaStatus(bool sending) = 0;
/*
* get send status
*/
virtual bool SendingMedia() const = 0;
/*
* get sent bitrate in Kbit/s
*/
virtual void BitrateSent(uint32_t* totalRate,
uint32_t* videoRate,
uint32_t* fecRate,
uint32_t* nackRate) const = 0;
/*
* Used by the codec module to deliver a video or audio frame for
* packetization.
*
* frameType - type of frame to send
* payloadType - payload type of frame to send
* timestamp - timestamp of frame to send
* payloadData - payload buffer of frame to send
* payloadSize - size of payload buffer to send
* fragmentation - fragmentation offset data for fragmented frames such
* as layers or RED
*
* return -1 on failure else 0
*/
virtual int32_t SendOutgoingData(
FrameType frameType,
int8_t payloadType,
uint32_t timeStamp,
int64_t capture_time_ms,
const uint8_t* payloadData,
size_t payloadSize,
const RTPFragmentationHeader* fragmentation = NULL,
const RTPVideoHeader* rtpVideoHdr = NULL) = 0;
virtual bool TimeToSendPacket(uint32_t ssrc,
uint16_t sequence_number,
int64_t capture_time_ms,
bool retransmission) = 0;
virtual size_t TimeToSendPadding(size_t bytes) = 0;
// Called on generation of new statistics after an RTP send.
virtual void RegisterSendChannelRtpStatisticsCallback(
StreamDataCountersCallback* callback) = 0;
virtual StreamDataCountersCallback*
GetSendChannelRtpStatisticsCallback() const = 0;
/**************************************************************************
*
* RTCP
*
***************************************************************************/
/*
* Get RTCP status
*/
virtual RtcpMode RTCP() const = 0;
/*
* configure RTCP status i.e on(compound or non- compound)/off
*
* method - RTCP method to use
*/
virtual void SetRTCPStatus(RtcpMode method) = 0;
/*
* Set RTCP CName (i.e unique identifier)
*
* return -1 on failure else 0
*/
virtual int32_t SetCNAME(const char* c_name) = 0;
/*
* Get remote CName
*
* return -1 on failure else 0
*/
virtual int32_t RemoteCNAME(uint32_t remoteSSRC,
char cName[RTCP_CNAME_SIZE]) const = 0;
/*
* Get remote NTP
*
* return -1 on failure else 0
*/
virtual int32_t RemoteNTP(
uint32_t *ReceivedNTPsecs,
uint32_t *ReceivedNTPfrac,
uint32_t *RTCPArrivalTimeSecs,
uint32_t *RTCPArrivalTimeFrac,
uint32_t *rtcp_timestamp) const = 0;
/*
* AddMixedCNAME
*
* return -1 on failure else 0
*/
virtual int32_t AddMixedCNAME(uint32_t SSRC, const char* c_name) = 0;
/*
* RemoveMixedCNAME
*
* return -1 on failure else 0
*/
virtual int32_t RemoveMixedCNAME(uint32_t SSRC) = 0;
/*
* Get RoundTripTime
*
* return -1 on failure else 0
*/
virtual int32_t RTT(uint32_t remoteSSRC,
int64_t* RTT,
int64_t* avgRTT,
int64_t* minRTT,
int64_t* maxRTT) const = 0;
/*
* Force a send of a RTCP packet
* periodic SR and RR are triggered via the process function
*
* return -1 on failure else 0
*/
virtual int32_t SendRTCP(RTCPPacketType rtcpPacketType) = 0;
/*
* Force a send of a RTCP packet with more than one packet type.
* periodic SR and RR are triggered via the process function
*
* return -1 on failure else 0
*/
virtual int32_t SendCompoundRTCP(
const std::set<RTCPPacketType>& rtcpPacketTypes) = 0;
/*
* Good state of RTP receiver inform sender
*/
virtual int32_t SendRTCPReferencePictureSelection(
const uint64_t pictureID) = 0;
/*
* Send a RTCP Slice Loss Indication (SLI)
* 6 least significant bits of pictureID
*/
virtual int32_t SendRTCPSliceLossIndication(uint8_t pictureID) = 0;
/*
* Statistics of the amount of data sent
*
* return -1 on failure else 0
*/
virtual int32_t DataCountersRTP(
size_t* bytesSent,
uint32_t* packetsSent) const = 0;
/*
* Get send statistics for the RTP and RTX stream.
*/
virtual void GetSendStreamDataCounters(
StreamDataCounters* rtp_counters,
StreamDataCounters* rtx_counters) const = 0;
/*
* Get packet loss statistics for the RTP stream.
*/
virtual void GetRtpPacketLossStats(
bool outgoing,
uint32_t ssrc,
struct RtpPacketLossStats* loss_stats) const = 0;
/*
* Get received RTCP sender info
*
* return -1 on failure else 0
*/
virtual int32_t RemoteRTCPStat(RTCPSenderInfo* senderInfo) = 0;
/*
* Get received RTCP report block
*
* return -1 on failure else 0
*/
virtual int32_t RemoteRTCPStat(
std::vector<RTCPReportBlock>* receiveBlocks) const = 0;
/*
* (APP) Application specific data
*
* return -1 on failure else 0
*/
virtual int32_t SetRTCPApplicationSpecificData(uint8_t subType,
uint32_t name,
const uint8_t* data,
uint16_t length) = 0;
/*
* (XR) VOIP metric
*
* return -1 on failure else 0
*/
virtual int32_t SetRTCPVoIPMetrics(
const RTCPVoIPMetric* VoIPMetric) = 0;
/*
* (XR) Receiver Reference Time Report
*/
virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
virtual bool RtcpXrRrtrStatus() const = 0;
/*
* (REMB) Receiver Estimated Max Bitrate
*/
virtual bool REMB() const = 0;
virtual void SetREMBStatus(bool enable) = 0;
virtual void SetREMBData(uint32_t bitrate,
const std::vector<uint32_t>& ssrcs) = 0;
/*
* (TMMBR) Temporary Max Media Bit Rate
*/
virtual bool TMMBR() const = 0;
virtual void SetTMMBRStatus(bool enable) = 0;
/*
* (NACK)
*/
/*
* TODO(holmer): Propagate this API to VideoEngine.
* Returns the currently configured selective retransmission settings.
*/
virtual int SelectiveRetransmissions() const = 0;
/*
* TODO(holmer): Propagate this API to VideoEngine.
* Sets the selective retransmission settings, which will decide which
* packets will be retransmitted if NACKed. Settings are constructed by
* combining the constants in enum RetransmissionMode with bitwise OR.
* All packets are retransmitted if kRetransmitAllPackets is set, while no
* packets are retransmitted if kRetransmitOff is set.
* By default all packets except FEC packets are retransmitted. For VP8
* with temporal scalability only base layer packets are retransmitted.
*
* Returns -1 on failure, otherwise 0.
*/
virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
/*
* Send a Negative acknowledgement packet
*
* return -1 on failure else 0
*/
virtual int32_t SendNACK(const uint16_t* nackList, uint16_t size) = 0;
/*
* Store the sent packets, needed to answer to a Negative acknowledgement
* requests
*/
virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
// Returns true if the module is configured to store packets.
virtual bool StorePackets() const = 0;
// Called on receipt of RTCP report block from remote side.
virtual void RegisterRtcpStatisticsCallback(
RtcpStatisticsCallback* callback) = 0;
virtual RtcpStatisticsCallback*
GetRtcpStatisticsCallback() = 0;
// BWE feedback packets.
virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
/**************************************************************************
*
* Audio
*
***************************************************************************/
/*
* set audio packet size, used to determine when it's time to send a DTMF
* packet in silence (CNG)
*
* return -1 on failure else 0
*/
virtual int32_t SetAudioPacketSize(uint16_t packetSizeSamples) = 0;
/*
* Send a TelephoneEvent tone using RFC 2833 (4733)
*
* return -1 on failure else 0
*/
virtual int32_t SendTelephoneEventOutband(uint8_t key,
uint16_t time_ms,
uint8_t level) = 0;
/*
* Set payload type for Redundant Audio Data RFC 2198
*
* return -1 on failure else 0
*/
virtual int32_t SetSendREDPayloadType(int8_t payloadType) = 0;
/*
* Get payload type for Redundant Audio Data RFC 2198
*
* return -1 on failure else 0
*/
virtual int32_t SendREDPayloadType(
int8_t& payloadType) const = 0;
/*
* Store the audio level in dBov for header-extension-for-audio-level-
* indication.
* This API shall be called before transmision of an RTP packet to ensure
* that the |level| part of the extended RTP header is updated.
*
* return -1 on failure else 0.
*/
virtual int32_t SetAudioLevel(uint8_t level_dBov) = 0;
/**************************************************************************
*
* Video
*
***************************************************************************/
/*
* Set the target send bitrate
*/
virtual void SetTargetSendBitrate(uint32_t bitrate_bps) = 0;
/*
* Turn on/off generic FEC
*/
virtual void SetGenericFECStatus(bool enable,
uint8_t payload_type_red,
uint8_t payload_type_fec) = 0;
/*
* Get generic FEC setting
*/
virtual void GenericFECStatus(bool& enable,
uint8_t& payloadTypeRED,
uint8_t& payloadTypeFEC) = 0;
virtual int32_t SetFecParameters(
const FecProtectionParams* delta_params,
const FecProtectionParams* key_params) = 0;
/*
* Set method for requestion a new key frame
*
* return -1 on failure else 0
*/
virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
/*
* send a request for a keyframe
*
* return -1 on failure else 0
*/
virtual int32_t RequestKeyFrame() = 0;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_

View File

@ -1,442 +0,0 @@
/*
* Copyright (c) 2012 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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_
#pragma message("WARNING: rtp_rtcp/interface is DEPRECATED; use include dir.")
#include <stddef.h>
#include <list>
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/system_wrappers/include/clock.h"
#include "webrtc/typedefs.h"
#define RTCP_CNAME_SIZE 256 // RFC 3550 page 44, including null termination
#define IP_PACKET_SIZE 1500 // we assume ethernet
#define MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS 10
#define TIMEOUT_SEI_MESSAGES_MS 30000 // in milliseconds
namespace webrtc {
namespace rtcp {
class TransportFeedback;
}
const int kVideoPayloadTypeFrequency = 90000;
// Minimum RTP header size in bytes.
const uint8_t kRtpHeaderSize = 12;
struct AudioPayload
{
uint32_t frequency;
uint8_t channels;
uint32_t rate;
};
struct VideoPayload
{
RtpVideoCodecTypes videoCodecType;
uint32_t maxRate;
};
union PayloadUnion
{
AudioPayload Audio;
VideoPayload Video;
};
enum RTPAliveType
{
kRtpDead = 0,
kRtpNoRtp = 1,
kRtpAlive = 2
};
enum ProtectionType {
kUnprotectedPacket,
kProtectedPacket
};
enum StorageType {
kDontRetransmit,
kAllowRetransmission
};
enum RTPExtensionType {
kRtpExtensionNone,
kRtpExtensionTransmissionTimeOffset,
kRtpExtensionAudioLevel,
kRtpExtensionAbsoluteSendTime,
kRtpExtensionVideoRotation,
kRtpExtensionTransportSequenceNumber,
};
enum RTCPAppSubTypes
{
kAppSubtypeBwe = 0x00
};
// TODO(sprang): Make this an enum class once rtcp_receiver has been cleaned up.
enum RTCPPacketType : uint32_t {
kRtcpReport = 0x0001,
kRtcpSr = 0x0002,
kRtcpRr = 0x0004,
kRtcpSdes = 0x0008,
kRtcpBye = 0x0010,
kRtcpPli = 0x0020,
kRtcpNack = 0x0040,
kRtcpFir = 0x0080,
kRtcpTmmbr = 0x0100,
kRtcpTmmbn = 0x0200,
kRtcpSrReq = 0x0400,
kRtcpXrVoipMetric = 0x0800,
kRtcpApp = 0x1000,
kRtcpSli = 0x4000,
kRtcpRpsi = 0x8000,
kRtcpRemb = 0x10000,
kRtcpTransmissionTimeOffset = 0x20000,
kRtcpXrReceiverReferenceTime = 0x40000,
kRtcpXrDlrrReportBlock = 0x80000,
kRtcpTransportFeedback = 0x100000,
};
enum KeyFrameRequestMethod { kKeyFrameReqPliRtcp, kKeyFrameReqFirRtcp };
enum RtpRtcpPacketType
{
kPacketRtp = 0,
kPacketKeepAlive = 1
};
enum NACKMethod
{
kNackOff = 0,
kNackRtcp = 2
};
enum RetransmissionMode : uint8_t {
kRetransmitOff = 0x0,
kRetransmitFECPackets = 0x1,
kRetransmitBaseLayer = 0x2,
kRetransmitHigherLayers = 0x4,
kRetransmitAllPackets = 0xFF
};
enum RtxMode {
kRtxOff = 0x0,
kRtxRetransmitted = 0x1, // Only send retransmissions over RTX.
kRtxRedundantPayloads = 0x2 // Preventively send redundant payloads
// instead of padding.
};
const size_t kRtxHeaderSize = 2;
struct RTCPSenderInfo
{
uint32_t NTPseconds;
uint32_t NTPfraction;
uint32_t RTPtimeStamp;
uint32_t sendPacketCount;
uint32_t sendOctetCount;
};
struct RTCPReportBlock {
RTCPReportBlock()
: remoteSSRC(0), sourceSSRC(0), fractionLost(0), cumulativeLost(0),
extendedHighSeqNum(0), jitter(0), lastSR(0),
delaySinceLastSR(0) {}
RTCPReportBlock(uint32_t remote_ssrc,
uint32_t source_ssrc,
uint8_t fraction_lost,
uint32_t cumulative_lost,
uint32_t extended_high_sequence_number,
uint32_t jitter,
uint32_t last_sender_report,
uint32_t delay_since_last_sender_report)
: remoteSSRC(remote_ssrc),
sourceSSRC(source_ssrc),
fractionLost(fraction_lost),
cumulativeLost(cumulative_lost),
extendedHighSeqNum(extended_high_sequence_number),
jitter(jitter),
lastSR(last_sender_report),
delaySinceLastSR(delay_since_last_sender_report) {}
// Fields as described by RFC 3550 6.4.2.
uint32_t remoteSSRC; // SSRC of sender of this report.
uint32_t sourceSSRC; // SSRC of the RTP packet sender.
uint8_t fractionLost;
uint32_t cumulativeLost; // 24 bits valid.
uint32_t extendedHighSeqNum;
uint32_t jitter;
uint32_t lastSR;
uint32_t delaySinceLastSR;
};
struct RtcpReceiveTimeInfo {
// Fields as described by RFC 3611 4.5.
uint32_t sourceSSRC;
uint32_t lastRR;
uint32_t delaySinceLastRR;
};
typedef std::list<RTCPReportBlock> ReportBlockList;
struct RtpState {
RtpState()
: sequence_number(0),
start_timestamp(0),
timestamp(0),
capture_time_ms(-1),
last_timestamp_time_ms(-1),
media_has_been_sent(false) {}
uint16_t sequence_number;
uint32_t start_timestamp;
uint32_t timestamp;
int64_t capture_time_ms;
int64_t last_timestamp_time_ms;
bool media_has_been_sent;
};
class RtpData
{
public:
virtual ~RtpData() {}
virtual int32_t OnReceivedPayloadData(
const uint8_t* payloadData,
const size_t payloadSize,
const WebRtcRTPHeader* rtpHeader) = 0;
virtual bool OnRecoveredPacket(const uint8_t* packet,
size_t packet_length) = 0;
};
class RtpFeedback
{
public:
virtual ~RtpFeedback() {}
// Receiving payload change or SSRC change. (return success!)
/*
* channels - number of channels in codec (1 = mono, 2 = stereo)
*/
virtual int32_t OnInitializeDecoder(
const int8_t payloadType,
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const int frequency,
const uint8_t channels,
const uint32_t rate) = 0;
virtual void OnIncomingSSRCChanged(const uint32_t ssrc) = 0;
virtual void OnIncomingCSRCChanged(const uint32_t CSRC,
const bool added) = 0;
};
class RtpAudioFeedback {
public:
virtual void OnPlayTelephoneEvent(const uint8_t event,
const uint16_t lengthMs,
const uint8_t volume) = 0;
protected:
virtual ~RtpAudioFeedback() {}
};
class RtcpIntraFrameObserver {
public:
virtual void OnReceivedIntraFrameRequest(uint32_t ssrc) = 0;
virtual void OnReceivedSLI(uint32_t ssrc,
uint8_t picture_id) = 0;
virtual void OnReceivedRPSI(uint32_t ssrc,
uint64_t picture_id) = 0;
virtual void OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) = 0;
virtual ~RtcpIntraFrameObserver() {}
};
class RtcpBandwidthObserver {
public:
// REMB or TMMBR
virtual void OnReceivedEstimatedBitrate(uint32_t bitrate) = 0;
virtual void OnReceivedRtcpReceiverReport(
const ReportBlockList& report_blocks,
int64_t rtt,
int64_t now_ms) = 0;
virtual ~RtcpBandwidthObserver() {}
};
struct PacketInfo {
PacketInfo(int64_t arrival_time_ms, uint16_t sequence_number)
: PacketInfo(-1, arrival_time_ms, -1, sequence_number, 0, false) {}
PacketInfo(int64_t arrival_time_ms,
int64_t send_time_ms,
uint16_t sequence_number,
size_t payload_size,
bool was_paced)
: PacketInfo(-1,
arrival_time_ms,
send_time_ms,
sequence_number,
payload_size,
was_paced) {}
PacketInfo(int64_t creation_time_ms,
int64_t arrival_time_ms,
int64_t send_time_ms,
uint16_t sequence_number,
size_t payload_size,
bool was_paced)
: creation_time_ms(creation_time_ms),
arrival_time_ms(arrival_time_ms),
send_time_ms(send_time_ms),
sequence_number(sequence_number),
payload_size(payload_size),
was_paced(was_paced) {}
// Time corresponding to when this object was created.
int64_t creation_time_ms;
// Time corresponding to when the packet was received. Timestamped with the
// receiver's clock.
int64_t arrival_time_ms;
// Time corresponding to when the packet was sent, timestamped with the
// sender's clock.
int64_t send_time_ms;
// Packet identifier, incremented with 1 for every packet generated by the
// sender.
uint16_t sequence_number;
// Size of the packet excluding RTP headers.
size_t payload_size;
// True if the packet was paced out by the pacer.
bool was_paced;
};
class TransportFeedbackObserver {
public:
TransportFeedbackObserver() {}
virtual ~TransportFeedbackObserver() {}
// Note: Transport-wide sequence number as sequence number. Arrival time
// must be set to 0.
virtual void AddPacket(uint16_t sequence_number,
size_t length,
bool was_paced) = 0;
virtual void OnTransportFeedback(const rtcp::TransportFeedback& feedback) = 0;
};
class RtcpRttStats {
public:
virtual void OnRttUpdate(int64_t rtt) = 0;
virtual int64_t LastProcessedRtt() const = 0;
virtual ~RtcpRttStats() {};
};
// Null object version of RtpFeedback.
class NullRtpFeedback : public RtpFeedback {
public:
virtual ~NullRtpFeedback() {}
int32_t OnInitializeDecoder(const int8_t payloadType,
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const int frequency,
const uint8_t channels,
const uint32_t rate) override {
return 0;
}
void OnIncomingSSRCChanged(const uint32_t ssrc) override {}
void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {}
};
// Null object version of RtpData.
class NullRtpData : public RtpData {
public:
virtual ~NullRtpData() {}
int32_t OnReceivedPayloadData(const uint8_t* payloadData,
const size_t payloadSize,
const WebRtcRTPHeader* rtpHeader) override {
return 0;
}
bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override {
return true;
}
};
// Null object version of RtpAudioFeedback.
class NullRtpAudioFeedback : public RtpAudioFeedback {
public:
virtual ~NullRtpAudioFeedback() {}
void OnPlayTelephoneEvent(const uint8_t event,
const uint16_t lengthMs,
const uint8_t volume) override {}
};
// Statistics about packet loss for a single directional connection. All values
// are totals since the connection initiated.
struct RtpPacketLossStats {
// The number of packets lost in events where no adjacent packets were also
// lost.
uint64_t single_packet_loss_count;
// The number of events in which more than one adjacent packet was lost.
uint64_t multiple_packet_loss_event_count;
// The number of packets lost in events where more than one adjacent packet
// was lost.
uint64_t multiple_packet_loss_packet_count;
};
class RtpPacketSender {
public:
RtpPacketSender() {}
virtual ~RtpPacketSender() {}
enum Priority {
kHighPriority = 0, // Pass through; will be sent immediately.
kNormalPriority = 2, // Put in back of the line.
kLowPriority = 3, // Put in back of the low priority line.
};
// Low priority packets are mixed with the normal priority packets
// while we are paused.
// Returns true if we send the packet now, else it will add the packet
// information to the queue and call TimeToSendPacket when it's time to send.
virtual void InsertPacket(Priority priority,
uint32_t ssrc,
uint16_t sequence_number,
int64_t capture_time_ms,
size_t bytes,
bool retransmission) = 0;
};
class TransportSequenceNumberAllocator {
public:
TransportSequenceNumberAllocator() {}
virtual ~TransportSequenceNumberAllocator() {}
virtual uint16_t AllocateSequenceNumber() = 0;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2012 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 WEBRTC_MODULES_UTILITY_INCLUDE_AUDIO_FRAME_OPERATIONS_H_
#define WEBRTC_MODULES_UTILITY_INCLUDE_AUDIO_FRAME_OPERATIONS_H_
#pragma message("WARNING: utility/interface is DEPRECATED; use utility/include")
#include "webrtc/typedefs.h"
namespace webrtc {
class AudioFrame;
// TODO(andrew): consolidate this with utility.h and audio_frame_manipulator.h.
// Change reference parameters to pointers. Consider using a namespace rather
// than a class.
class AudioFrameOperations {
public:
// Upmixes mono |src_audio| to stereo |dst_audio|. This is an out-of-place
// operation, meaning src_audio and dst_audio must point to different
// buffers. It is the caller's responsibility to ensure that |dst_audio| is
// sufficiently large.
static void MonoToStereo(const int16_t* src_audio, size_t samples_per_channel,
int16_t* dst_audio);
// |frame.num_channels_| will be updated. This version checks for sufficient
// buffer size and that |num_channels_| is mono.
static int MonoToStereo(AudioFrame* frame);
// Downmixes stereo |src_audio| to mono |dst_audio|. This is an in-place
// operation, meaning |src_audio| and |dst_audio| may point to the same
// buffer.
static void StereoToMono(const int16_t* src_audio, size_t samples_per_channel,
int16_t* dst_audio);
// |frame.num_channels_| will be updated. This version checks that
// |num_channels_| is stereo.
static int StereoToMono(AudioFrame* frame);
// Swap the left and right channels of |frame|. Fails silently if |frame| is
// not stereo.
static void SwapStereoChannels(AudioFrame* frame);
// Zeros out the audio and sets |frame.energy| to zero.
static void Mute(AudioFrame& frame);
static int Scale(float left, float right, AudioFrame& frame);
static int ScaleWithSat(float scale, AudioFrame& frame);
};
} // namespace webrtc
#endif // #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_AUDIO_FRAME_OPERATIONS_H_

View File

@ -1,113 +0,0 @@
/*
* Copyright (c) 2012 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 WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_
#define WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_
#pragma message("WARNING: utility/interface is DEPRECATED; use utility/include")
#include "webrtc/common_types.h"
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/typedefs.h"
#include "webrtc/video_frame.h"
namespace webrtc {
class FileCallback;
class FilePlayer
{
public:
// The largest decoded frame size in samples (60ms with 32kHz sample rate).
enum {MAX_AUDIO_BUFFER_IN_SAMPLES = 60*32};
enum {MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES*2};
// Note: will return NULL for unsupported formats.
static FilePlayer* CreateFilePlayer(const uint32_t instanceID,
const FileFormats fileFormat);
static void DestroyFilePlayer(FilePlayer* player);
// Read 10 ms of audio at |frequencyInHz| to |outBuffer|. |lengthInSamples|
// will be set to the number of samples read (not the number of samples per
// channel).
virtual int Get10msAudioFromFile(
int16_t* outBuffer,
size_t& lengthInSamples,
int frequencyInHz) = 0;
// Register callback for receiving file playing notifications.
virtual int32_t RegisterModuleFileCallback(
FileCallback* callback) = 0;
// API for playing audio from fileName to channel.
// Note: codecInst is used for pre-encoded files.
virtual int32_t StartPlayingFile(
const char* fileName,
bool loop,
uint32_t startPosition,
float volumeScaling,
uint32_t notification,
uint32_t stopPosition = 0,
const CodecInst* codecInst = NULL) = 0;
// Note: codecInst is used for pre-encoded files.
virtual int32_t StartPlayingFile(
InStream& sourceStream,
uint32_t startPosition,
float volumeScaling,
uint32_t notification,
uint32_t stopPosition = 0,
const CodecInst* codecInst = NULL) = 0;
virtual int32_t StopPlayingFile() = 0;
virtual bool IsPlayingFile() const = 0;
virtual int32_t GetPlayoutPosition(uint32_t& durationMs) = 0;
// Set audioCodec to the currently used audio codec.
virtual int32_t AudioCodec(CodecInst& audioCodec) const = 0;
virtual int32_t Frequency() const = 0;
// Note: scaleFactor is in the range [0.0 - 2.0]
virtual int32_t SetAudioScaling(float scaleFactor) = 0;
// Return the time in ms until next video frame should be pulled (by
// calling GetVideoFromFile(..)).
// Note: this API reads one video frame from file. This means that it should
// be called exactly once per GetVideoFromFile(..) API call.
virtual int32_t TimeUntilNextVideoFrame() { return -1;}
virtual int32_t StartPlayingVideoFile(
const char* /*fileName*/,
bool /*loop*/,
bool /*videoOnly*/) { return -1;}
virtual int32_t video_codec_info(VideoCodec& /*videoCodec*/) const
{return -1;}
virtual int32_t GetVideoFromFile(VideoFrame& /*videoFrame*/) { return -1; }
// Same as GetVideoFromFile(). videoFrame will have the resolution specified
// by the width outWidth and height outHeight in pixels.
virtual int32_t GetVideoFromFile(VideoFrame& /*videoFrame*/,
const uint32_t /*outWidth*/,
const uint32_t /*outHeight*/) {
return -1;
}
protected:
virtual ~FilePlayer() {}
};
} // namespace webrtc
#endif // WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_

View File

@ -1,86 +0,0 @@
/*
* Copyright (c) 2012 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 WEBRTC_MODULES_UTILITY_INCLUDE_FILE_RECORDER_H_
#define WEBRTC_MODULES_UTILITY_INCLUDE_FILE_RECORDER_H_
#pragma message("WARNING: utility/interface is DEPRECATED; use utility/include")
#include "webrtc/common_types.h"
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/media_file/include/media_file_defines.h"
#include "webrtc/system_wrappers/include/tick_util.h"
#include "webrtc/typedefs.h"
#include "webrtc/video_frame.h"
namespace webrtc {
class FileRecorder
{
public:
// Note: will return NULL for unsupported formats.
static FileRecorder* CreateFileRecorder(const uint32_t instanceID,
const FileFormats fileFormat);
static void DestroyFileRecorder(FileRecorder* recorder);
virtual int32_t RegisterModuleFileCallback(
FileCallback* callback) = 0;
virtual FileFormats RecordingFileFormat() const = 0;
virtual int32_t StartRecordingAudioFile(
const char* fileName,
const CodecInst& codecInst,
uint32_t notification) = 0;
virtual int32_t StartRecordingAudioFile(
OutStream& destStream,
const CodecInst& codecInst,
uint32_t notification) = 0;
// Stop recording.
// Note: this API is for both audio and video.
virtual int32_t StopRecording() = 0;
// Return true if recording.
// Note: this API is for both audio and video.
virtual bool IsRecording() const = 0;
virtual int32_t codec_info(CodecInst& codecInst) const = 0;
// Write frame to file. Frame should contain 10ms of un-ecoded audio data.
virtual int32_t RecordAudioToFile(
const AudioFrame& frame,
const TickTime* playoutTS = NULL) = 0;
// Open/create the file specified by fileName for writing audio/video data
// (relative path is allowed). audioCodecInst specifies the encoding of the
// audio data. videoCodecInst specifies the encoding of the video data.
// Only video data will be recorded if videoOnly is true. amrFormat
// specifies the amr/amrwb storage format.
// Note: the file format is AVI.
virtual int32_t StartRecordingVideoFile(
const char* fileName,
const CodecInst& audioCodecInst,
const VideoCodec& videoCodecInst,
bool videoOnly = false) = 0;
// Record the video frame in videoFrame to AVI file.
virtual int32_t RecordVideoToFile(const VideoFrame& videoFrame) = 0;
protected:
virtual ~FileRecorder() {}
};
} // namespace webrtc
#endif // WEBRTC_MODULES_UTILITY_INCLUDE_FILE_RECORDER_H_

View File

@ -1,89 +0,0 @@
/*
* Copyright (c) 2013 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 WEBRTC_MODULES_UTILITY_INCLUDE_HELPERS_ANDROID_H_
#define WEBRTC_MODULES_UTILITY_INCLUDE_HELPERS_ANDROID_H_
#pragma message("WARNING: utility/interface is DEPRECATED; use utility/include")
#include <jni.h>
#include <string>
// Abort the process if |jni| has a Java exception pending.
// TODO(henrika): merge with CHECK_JNI_EXCEPTION() in jni_helpers.h.
#define CHECK_EXCEPTION(jni) \
RTC_CHECK(!jni->ExceptionCheck()) \
<< (jni->ExceptionDescribe(), jni->ExceptionClear(), "")
namespace webrtc {
// Return a |JNIEnv*| usable on this thread or NULL if this thread is detached.
JNIEnv* GetEnv(JavaVM* jvm);
// Return a |jlong| that will correctly convert back to |ptr|. This is needed
// because the alternative (of silently passing a 32-bit pointer to a vararg
// function expecting a 64-bit param) picks up garbage in the high 32 bits.
jlong PointerTojlong(void* ptr);
// JNIEnv-helper methods that wraps the API which uses the JNI interface
// pointer (JNIEnv*). It allows us to RTC_CHECK success and that no Java
// exception is thrown while calling the method.
jmethodID GetMethodID(
JNIEnv* jni, jclass c, const char* name, const char* signature);
jmethodID GetStaticMethodID(
JNIEnv* jni, jclass c, const char* name, const char* signature);
jclass FindClass(JNIEnv* jni, const char* name);
jobject NewGlobalRef(JNIEnv* jni, jobject o);
void DeleteGlobalRef(JNIEnv* jni, jobject o);
// Return thread ID as a string.
std::string GetThreadId();
// Return thread ID as string suitable for debug logging.
std::string GetThreadInfo();
// Attach thread to JVM if necessary and detach at scope end if originally
// attached.
class AttachThreadScoped {
public:
explicit AttachThreadScoped(JavaVM* jvm);
~AttachThreadScoped();
JNIEnv* env();
private:
bool attached_;
JavaVM* jvm_;
JNIEnv* env_;
};
// Scoped holder for global Java refs.
template<class T> // T is jclass, jobject, jintArray, etc.
class ScopedGlobalRef {
public:
ScopedGlobalRef(JNIEnv* jni, T obj)
: jni_(jni), obj_(static_cast<T>(NewGlobalRef(jni, obj))) {}
~ScopedGlobalRef() {
DeleteGlobalRef(jni_, obj_);
}
T operator*() const {
return obj_;
}
private:
JNIEnv* jni_;
T obj_;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_UTILITY_INCLUDE_HELPERS_ANDROID_H_

View File

@ -1,61 +0,0 @@
/*
* Copyright (c) 2015 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 WEBRTC_MODULES_UTILITY_INCLUDE_HELPERS_IOS_H_
#define WEBRTC_MODULES_UTILITY_INCLUDE_HELPERS_IOS_H_
#pragma message("WARNING: utility/interface is DEPRECATED; use utility/include")
#if defined(WEBRTC_IOS)
#include <string>
namespace webrtc {
namespace ios {
bool CheckAndLogError(BOOL success, NSError* error);
std::string StdStringFromNSString(NSString* nsString);
// Return thread ID as a string.
std::string GetThreadId();
// Return thread ID as string suitable for debug logging.
std::string GetThreadInfo();
// Returns [NSThread currentThread] description as string.
// Example: <NSThread: 0x170066d80>{number = 1, name = main}
std::string GetCurrentThreadDescription();
std::string GetAudioSessionCategory();
// Returns the current name of the operating system.
std::string GetSystemName();
// Returns the current version of the operating system.
std::string GetSystemVersion();
// Returns the version of the operating system as a floating point value.
float GetSystemVersionAsFloat();
// Returns the device type.
// Examples: ”iPhone” and ”iPod touch”.
std::string GetDeviceType();
// Returns a more detailed device name.
// Examples: "iPhone 5s (GSM)" and "iPhone 6 Plus".
std::string GetDeviceName();
} // namespace ios
} // namespace webrtc
#endif // defined(WEBRTC_IOS)
#endif // WEBRTC_MODULES_UTILITY_INCLUDE_HELPERS_IOS_H_

View File

@ -1,187 +0,0 @@
/*
* Copyright (c) 2015 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 WEBRTC_MODULES_UTILITY_INCLUDE_JVM_ANDROID_H_
#define WEBRTC_MODULES_UTILITY_INCLUDE_JVM_ANDROID_H_
#pragma message("WARNING: utility/interface is DEPRECATED; use utility/include")
#include <jni.h>
#include <string>
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/modules/utility/include/helpers_android.h"
namespace webrtc {
// The JNI interface pointer (JNIEnv) is valid only in the current thread.
// Should another thread need to access the Java VM, it must first call
// AttachCurrentThread() to attach itself to the VM and obtain a JNI interface
// pointer. The native thread remains attached to the VM until it calls
// DetachCurrentThread() to detach.
class AttachCurrentThreadIfNeeded {
public:
AttachCurrentThreadIfNeeded();
~AttachCurrentThreadIfNeeded();
private:
rtc::ThreadChecker thread_checker_;
bool attached_;
};
// This class is created by the NativeRegistration class and is used to wrap
// the actual Java object handle (jobject) on which we can call methods from
// C++ in to Java. See example in JVM for more details.
// TODO(henrika): extend support for type of function calls.
class GlobalRef {
public:
GlobalRef(JNIEnv* jni, jobject object);
~GlobalRef();
jboolean CallBooleanMethod(jmethodID methodID, ...);
jint CallIntMethod(jmethodID methodID, ...);
void CallVoidMethod(jmethodID methodID, ...);
private:
JNIEnv* const jni_;
const jobject j_object_;
};
// Wraps the jclass object on which we can call GetMethodId() functions to
// query method IDs.
class JavaClass {
public:
JavaClass(JNIEnv* jni, jclass clazz) : jni_(jni), j_class_(clazz) {}
~JavaClass() {}
jmethodID GetMethodId(const char* name, const char* signature);
jmethodID GetStaticMethodId(const char* name, const char* signature);
jobject CallStaticObjectMethod(jmethodID methodID, ...);
protected:
JNIEnv* const jni_;
jclass const j_class_;
};
// Adds support of the NewObject factory method to the JavaClass class.
// See example in JVM for more details on how to use it.
class NativeRegistration : public JavaClass {
public:
NativeRegistration(JNIEnv* jni, jclass clazz);
~NativeRegistration();
rtc::scoped_ptr<GlobalRef> NewObject(
const char* name, const char* signature, ...);
private:
JNIEnv* const jni_;
};
// This class is created by the JVM class and is used to expose methods that
// needs the JNI interface pointer but its main purpose is to create a
// NativeRegistration object given name of a Java class and a list of native
// methods. See example in JVM for more details.
class JNIEnvironment {
public:
explicit JNIEnvironment(JNIEnv* jni);
~JNIEnvironment();
// Registers native methods with the Java class specified by |name|.
// Note that the class name must be one of the names in the static
// |loaded_classes| array defined in jvm_android.cc.
// This method must be called on the construction thread.
rtc::scoped_ptr<NativeRegistration> RegisterNatives(
const char* name, const JNINativeMethod *methods, int num_methods);
// Converts from Java string to std::string.
// This method must be called on the construction thread.
std::string JavaToStdString(const jstring& j_string);
private:
rtc::ThreadChecker thread_checker_;
JNIEnv* const jni_;
};
// Main class for working with Java from C++ using JNI in WebRTC.
//
// Example usage:
//
// // At initialization (e.g. in JNI_OnLoad), call JVM::Initialize.
// JNIEnv* jni = ::base::android::AttachCurrentThread();
// JavaVM* jvm = NULL;
// jni->GetJavaVM(&jvm);
// jobject context = ::base::android::GetApplicationContext();
// webrtc::JVM::Initialize(jvm, context);
//
// // Header (.h) file of example class called User.
// rtc::scoped_ptr<JNIEnvironment> env;
// rtc::scoped_ptr<NativeRegistration> reg;
// rtc::scoped_ptr<GlobalRef> obj;
//
// // Construction (in .cc file) of User class.
// User::User() {
// // Calling thread must be attached to the JVM.
// env = JVM::GetInstance()->environment();
// reg = env->RegisterNatives("org/webrtc/WebRtcTest", ,);
// obj = reg->NewObject("<init>", ,);
// }
//
// // Each User method can now use |reg| and |obj| and call Java functions
// // in WebRtcTest.java, e.g. boolean init() {}.
// bool User::Foo() {
// jmethodID id = reg->GetMethodId("init", "()Z");
// return obj->CallBooleanMethod(id);
// }
//
// // And finally, e.g. in JNI_OnUnLoad, call JVM::Uninitialize.
// JVM::Uninitialize();
class JVM {
public:
// Stores global handles to the Java VM interface and the application context.
// Should be called once on a thread that is attached to the JVM.
static void Initialize(JavaVM* jvm, jobject context);
// Clears handles stored in Initialize(). Must be called on same thread as
// Initialize().
static void Uninitialize();
// Gives access to the global Java VM interface pointer, which then can be
// used to create a valid JNIEnvironment object or to get a JavaClass object.
static JVM* GetInstance();
// Creates a JNIEnvironment object.
// This method returns a NULL pointer if AttachCurrentThread() has not been
// called successfully. Use the AttachCurrentThreadIfNeeded class if needed.
rtc::scoped_ptr<JNIEnvironment> environment();
// Returns a JavaClass object given class |name|.
// Note that the class name must be one of the names in the static
// |loaded_classes| array defined in jvm_android.cc.
// This method must be called on the construction thread.
JavaClass GetClass(const char* name);
// TODO(henrika): can we make these private?
JavaVM* jvm() const { return jvm_; }
jobject context() const { return context_; }
protected:
JVM(JavaVM* jvm, jobject context);
~JVM();
private:
JNIEnv* jni() const { return GetEnv(jvm_); }
rtc::ThreadChecker thread_checker_;
JavaVM* const jvm_;
jobject context_;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_UTILITY_INCLUDE_JVM_ANDROID_H_

View File

@ -1,40 +0,0 @@
/*
* Copyright (c) 2014 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 WEBRTC_MODULES_UTILITY_INCLUDE_MOCK_MOCK_PROCESS_THREAD_H_
#define WEBRTC_MODULES_UTILITY_INCLUDE_MOCK_MOCK_PROCESS_THREAD_H_
#pragma message("WARNING: utility/interface is DEPRECATED; use utility/include")
#include "webrtc/modules/utility/include/process_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace webrtc {
class MockProcessThread : public ProcessThread {
public:
MOCK_METHOD0(Start, void());
MOCK_METHOD0(Stop, void());
MOCK_METHOD1(WakeUp, void(Module* module));
MOCK_METHOD1(PostTask, void(ProcessTask* task));
MOCK_METHOD1(RegisterModule, void(Module* module));
MOCK_METHOD1(DeRegisterModule, void(Module* module));
// MOCK_METHOD1 gets confused with mocking this method, so we work around it
// by overriding the method from the interface and forwarding the call to a
// mocked, simpler method.
void PostTask(rtc::scoped_ptr<ProcessTask> task) override {
PostTask(task.get());
}
};
} // namespace webrtc
#endif // WEBRTC_MODULES_UTILITY_INCLUDE_MOCK_MOCK_PROCESS_THREAD_H_

View File

@ -1,68 +0,0 @@
/*
* Copyright (c) 2011 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 WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_
#define WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_
#pragma message("WARNING: utility/interface is DEPRECATED; use utility/include")
#include "webrtc/typedefs.h"
#include "webrtc/base/scoped_ptr.h"
namespace webrtc {
class Module;
class ProcessTask {
public:
ProcessTask() {}
virtual ~ProcessTask() {}
virtual void Run() = 0;
};
class ProcessThread {
public:
virtual ~ProcessThread();
static rtc::scoped_ptr<ProcessThread> Create(const char* thread_name);
// Starts the worker thread. Must be called from the construction thread.
virtual void Start() = 0;
// Stops the worker thread. Must be called from the construction thread.
virtual void Stop() = 0;
// Wakes the thread up to give a module a chance to do processing right
// away. This causes the worker thread to wake up and requery the specified
// module for when it should be called back. (Typically the module should
// return 0 from TimeUntilNextProcess on the worker thread at that point).
// Can be called on any thread.
virtual void WakeUp(Module* module) = 0;
// Queues a task object to run on the worker thread. Ownership of the
// task object is transferred to the ProcessThread and the object will
// either be deleted after running on the worker thread, or on the
// construction thread of the ProcessThread instance, if the task did not
// get a chance to run (e.g. posting the task while shutting down or when
// the thread never runs).
virtual void PostTask(rtc::scoped_ptr<ProcessTask> task) = 0;
// Adds a module that will start to receive callbacks on the worker thread.
// Can be called from any thread.
virtual void RegisterModule(Module* module) = 0;
// Removes a previously registered module.
// Can be called from any thread.
virtual void DeRegisterModule(Module* module) = 0;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_