Formatted dtmf_queue.
BUG= R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1398004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3982 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
73a4d5ab12
commit
315d39866e
@ -8,72 +8,57 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dtmf_queue.h"
|
#include "webrtc/modules/rtp_rtcp/source/dtmf_queue.h"
|
||||||
|
|
||||||
#include <string.h> //memset
|
#include <string.h> //memset
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
DTMFqueue::DTMFqueue():
|
DTMFqueue::DTMFqueue()
|
||||||
_DTMFCritsect(CriticalSectionWrapper::CreateCriticalSection()),
|
: dtmf_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_nextEmptyIndex(0)
|
next_empty_index_(0) {
|
||||||
{
|
memset(dtmf_key_, 0, sizeof(dtmf_key_));
|
||||||
memset(_DTMFKey,0, sizeof(_DTMFKey));
|
memset(dtmf_length, 0, sizeof(dtmf_length));
|
||||||
memset(_DTMFLen,0, sizeof(_DTMFLen));
|
memset(dtmf_level_, 0, sizeof(dtmf_level_));
|
||||||
memset(_DTMFLevel,0, sizeof(_DTMFLevel));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DTMFqueue::~DTMFqueue()
|
DTMFqueue::~DTMFqueue() { delete dtmf_critsect_; }
|
||||||
{
|
|
||||||
delete _DTMFCritsect;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t
|
int32_t DTMFqueue::AddDTMF(uint8_t key, uint16_t len, uint8_t level) {
|
||||||
DTMFqueue::AddDTMF(uint8_t key, uint16_t len, uint8_t level)
|
CriticalSectionScoped lock(dtmf_critsect_);
|
||||||
{
|
|
||||||
CriticalSectionScoped lock(_DTMFCritsect);
|
|
||||||
|
|
||||||
if(_nextEmptyIndex >= DTMF_OUTBAND_MAX)
|
if (next_empty_index_ >= DTMF_OUTBAND_MAX) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int32_t index = _nextEmptyIndex;
|
int32_t index = next_empty_index_;
|
||||||
_DTMFKey[index] = key;
|
dtmf_key_[index] = key;
|
||||||
_DTMFLen[index] = len;
|
dtmf_length[index] = len;
|
||||||
_DTMFLevel[index] = level;
|
dtmf_level_[index] = level;
|
||||||
_nextEmptyIndex++;
|
next_empty_index_++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t
|
int8_t DTMFqueue::NextDTMF(uint8_t* dtmf_key, uint16_t* len, uint8_t* level) {
|
||||||
DTMFqueue::NextDTMF(uint8_t* DTMFKey, uint16_t* len, uint8_t* level)
|
CriticalSectionScoped lock(dtmf_critsect_);
|
||||||
{
|
|
||||||
CriticalSectionScoped lock(_DTMFCritsect);
|
|
||||||
|
|
||||||
if(!PendingDTMF())
|
if (!PendingDTMF()) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*DTMFKey=_DTMFKey[0];
|
*dtmf_key = dtmf_key_[0];
|
||||||
*len=_DTMFLen[0];
|
*len = dtmf_length[0];
|
||||||
*level=_DTMFLevel[0];
|
*level = dtmf_level_[0];
|
||||||
|
|
||||||
memmove(&(_DTMFKey[0]), &(_DTMFKey[1]), _nextEmptyIndex*sizeof(uint8_t));
|
memmove(&(dtmf_key_[0]), &(dtmf_key_[1]),
|
||||||
memmove(&(_DTMFLen[0]), &(_DTMFLen[1]), _nextEmptyIndex*sizeof(uint16_t));
|
next_empty_index_ * sizeof(uint8_t));
|
||||||
memmove(&(_DTMFLevel[0]), &(_DTMFLevel[1]), _nextEmptyIndex*sizeof(uint8_t));
|
memmove(&(dtmf_length[0]), &(dtmf_length[1]),
|
||||||
|
next_empty_index_ * sizeof(uint16_t));
|
||||||
|
memmove(&(dtmf_level_[0]), &(dtmf_level_[1]),
|
||||||
|
next_empty_index_ * sizeof(uint8_t));
|
||||||
|
|
||||||
_nextEmptyIndex--;
|
next_empty_index_--;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool DTMFqueue::PendingDTMF() { return (next_empty_index_ > 0); }
|
||||||
DTMFqueue::PendingDTMF()
|
|
||||||
{
|
|
||||||
return(_nextEmptyIndex>0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void DTMFqueue::ResetDTMF() { next_empty_index_ = 0; }
|
||||||
DTMFqueue::ResetDTMF()
|
|
||||||
{
|
|
||||||
_nextEmptyIndex = 0;
|
|
||||||
}
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -11,29 +11,27 @@
|
|||||||
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_DTMF_QUEUE_H_
|
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_DTMF_QUEUE_H_
|
||||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_DTMF_QUEUE_H_
|
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_DTMF_QUEUE_H_
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
||||||
#include "rtp_rtcp_config.h"
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||||
|
#include "webrtc/typedefs.h"
|
||||||
#include "critical_section_wrapper.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class DTMFqueue
|
class DTMFqueue {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
DTMFqueue();
|
DTMFqueue();
|
||||||
virtual ~DTMFqueue();
|
virtual ~DTMFqueue();
|
||||||
|
|
||||||
int32_t AddDTMF(uint8_t DTMFKey, uint16_t len, uint8_t level);
|
int32_t AddDTMF(uint8_t dtmf_key, uint16_t len, uint8_t level);
|
||||||
int8_t NextDTMF(uint8_t* DTMFKey, uint16_t * len, uint8_t * level);
|
int8_t NextDTMF(uint8_t* dtmf_key, uint16_t* len, uint8_t* level);
|
||||||
bool PendingDTMF();
|
bool PendingDTMF();
|
||||||
void ResetDTMF();
|
void ResetDTMF();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CriticalSectionWrapper* _DTMFCritsect;
|
CriticalSectionWrapper* dtmf_critsect_;
|
||||||
uint8_t _nextEmptyIndex;
|
uint8_t next_empty_index_;
|
||||||
uint8_t _DTMFKey[DTMF_OUTBAND_MAX];
|
uint8_t dtmf_key_[DTMF_OUTBAND_MAX];
|
||||||
uint16_t _DTMFLen[DTMF_OUTBAND_MAX];
|
uint16_t dtmf_length[DTMF_OUTBAND_MAX];
|
||||||
uint8_t _DTMFLevel[DTMF_OUTBAND_MAX];
|
uint8_t dtmf_level_[DTMF_OUTBAND_MAX];
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user