Skip to content

Commit

Permalink
fix all warnings, modify timestamp to float
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjiegit committed Dec 25, 2014
1 parent 5666271 commit a895b40
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 35 deletions.
2 changes: 1 addition & 1 deletion trunk/3rdparty/libRtAudio/RtAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5002,7 +5002,7 @@ static std::string convertTChar( LPCTSTR name )

static BOOL CALLBACK deviceQueryCallback( LPGUID lpguid,
LPCTSTR description,
LPCTSTR module,
LPCTSTR /*module*/,
LPVOID lpContext )
{
struct DsProbeData& probeInfo = *(struct DsProbeData*) lpContext;
Expand Down
3 changes: 0 additions & 3 deletions trunk/3rdparty/librtmp/rtmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
//typedef size_t off_t;
#endif

#pragma warning(disable:4996) //depricated warnings
#pragma warning(disable:4244) //64bit defensive mechanism, fixed the ones that mattered

#ifdef __cplusplus
extern "C"
{
Expand Down
5 changes: 5 additions & 0 deletions trunk/src/BleAudioEncoderAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
BleAudioEncoderAbstract::BleAudioEncoderAbstract()
{
}

BleAudioEncoderAbstract::~BleAudioEncoderAbstract()
{

}
3 changes: 2 additions & 1 deletion trunk/src/BleAudioEncoderAbstract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ class BleAudioEncoderAbstract

public:
BleAudioEncoderAbstract();
virtual ~BleAudioEncoderAbstract();

virtual bool init(int samplerate, int channel, int bitrate) = 0;
virtual void fini() = 0;
virtual bool encode(const QByteArray &data, QByteArray &output) = 0;
virtual int getFrameSize() = 0;
virtual int getFrameDuration() = 0;
virtual float getFrameDuration() = 0;
inline AudioEncoderType encoderType() { return m_encoderType; }

protected:
Expand Down
7 changes: 5 additions & 2 deletions trunk/src/BleAudioEncoder_AAC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ bool BleAudioEncoder_AAC::encode(const QByteArray &data, QByteArray &outputArray
if (encodedBytes < 0) {
log_error("faacEncEncode failed, aac ori data %d , encode data %d", data.size(), encodedBytes);
return false;
} else if (encodedBytes == 0) {
log_trace("audio frame delayed in encoder.");
return true;
}

static unsigned char af[2] = {0xaf, 0x01};
Expand All @@ -139,9 +142,9 @@ int BleAudioEncoder_AAC::getFrameSize()
return m_samplesInputSize * 16 / 8;
}

int BleAudioEncoder_AAC::getFrameDuration()
float BleAudioEncoder_AAC::getFrameDuration()
{
return getFrameSize() * 1000 / (m_samplerate * 16 / 8 * 2);
return (float)getFrameSize() * 1000.00 / ((float)m_samplerate * 16.0 / 8.0 * 2.0);
}

QByteArray BleAudioEncoder_AAC::getHeader()
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/BleAudioEncoder_AAC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BleAudioEncoder_AAC : public BleAudioEncoderAbstract
virtual void fini();
virtual bool encode(const QByteArray &data, QByteArray &output);\
virtual int getFrameSize();
virtual int getFrameDuration();
virtual float getFrameDuration();

QByteArray getHeader();

Expand Down
10 changes: 7 additions & 3 deletions trunk/src/BleImageProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ BleImageProcess::BleImageProcess(QWidget *parent)
ui->setupUi(this);

connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(onRefreshTimeout()));
m_refreshTimer.start(100);
m_refreshTimer.start(60);

setMouseTracking(true);
setFocusPolicy(Qt::ClickFocus);
Expand Down Expand Up @@ -84,6 +84,8 @@ void BleImageProcess::addCaptureSource(BleSourceAbstract *source, int x, int y,

void BleImageProcess::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);

QPainter p(this);

p.setRenderHint(QPainter::SmoothPixmapTransform);
Expand Down Expand Up @@ -116,7 +118,8 @@ void BleImageProcess::paintEvent(QPaintEvent *event)
}
qimage = QImage((uchar*)image.data, image.width, image.height, QImage::Format_RGB888);

p.drawImage(pair.rect, qimage);
p.drawPixmap(pair.rect, QPixmap::fromImage(qimage));
// p.drawImage(pair.rect, qimage);
}

if (m_activePair && m_activePair->rect.isValid()) {
Expand Down Expand Up @@ -274,6 +277,8 @@ void BleImageProcess::keyPressEvent(QKeyEvent *e)

void BleImageProcess::focusOutEvent(QFocusEvent *e)
{
Q_UNUSED(e);

m_activePair = NULL;
}

Expand Down Expand Up @@ -313,7 +318,6 @@ void BleImageProcess::onUpBtnClicked()

QRect &r = m_activePair->rect;
if (r.isValid()) {
int x = r.x();
int y = r.y();
r.moveTop(y - 1);
}
Expand Down
3 changes: 2 additions & 1 deletion trunk/src/BleRtmpMuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ RtmpAU::RtmpAU(const string &url)
RTMP_Init(m_pRtmp);
m_pRtmp->m_bUseNagle = TRUE;

m_pRtmp->Link.flashVer.av_val = "FMLE/3.0 (compatible; FMSc/1.0)";
const char *av_val = "FMLE/3.0 (compatible; FMSc/1.0)";
m_pRtmp->Link.flashVer.av_val = const_cast<char *> (av_val);
m_pRtmp->Link.flashVer.av_len = (int)strlen(m_pRtmp->Link.flashVer.av_val);

m_pRtmp->m_outChunkSize = 4096;//RTMP_DEFAULT_CHUNKSIZE;//
Expand Down
18 changes: 9 additions & 9 deletions trunk/src/BleTimestampBulider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "BleUtil.hpp"

static qint64 growTimestamp(qint64 & timestamp, int internal, qint64 & otherTimestamp)
static double growTimestamp(double & timestamp, float internal, double & otherTimestamp)
{
if (timestamp <= otherTimestamp) {
while (timestamp <= otherTimestamp) {
if (timestamp < otherTimestamp) {
while (timestamp < otherTimestamp) {
timestamp += internal;
}
} else {
Expand All @@ -39,10 +39,10 @@ static qint64 growTimestamp(qint64 & timestamp, int internal, qint64 & otherTime
}

BleTimestampBulider::BleTimestampBulider()
: m_videoInternal(50)
, m_audiInternal(23)
, m_videoTimestamp(0)
, m_audioTimestamp(0)
: m_videoInternal(66.66666666666667) // default 15fps
, m_audiInternal(23.2199546485261) // default aac 44100Hz
, m_videoTimestamp(0.00)
, m_audioTimestamp(0.00)
{
}

Expand All @@ -56,14 +56,14 @@ void BleTimestampBulider::setAudioCaptureInternal(int internal)
m_audiInternal = internal;
}

qint64 BleTimestampBulider::addVideoFrame()
double BleTimestampBulider::addVideoFrame()
{
BleAutoLocker(m_mutex);

return growTimestamp(m_videoTimestamp, m_videoInternal, m_audioTimestamp);;
}

qint64 BleTimestampBulider::addAudioFrame()
double BleTimestampBulider::addAudioFrame()
{
BleAutoLocker(m_mutex);

Expand Down
12 changes: 6 additions & 6 deletions trunk/src/BleTimestampBulider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ class BleTimestampBulider
void setVideoCaptureInternal(int internal);
void setAudioCaptureInternal(int internal);

qint64 addVideoFrame();
qint64 addAudioFrame();
double addVideoFrame();
double addAudioFrame();

private:
QMutex m_mutex;

int m_videoInternal;
int m_audiInternal;
float m_videoInternal;
float m_audiInternal;

qint64 m_videoTimestamp;
qint64 m_audioTimestamp;
double m_videoTimestamp;
double m_audioTimestamp;
};

#endif // BLETIMESTAMPBULIDER_HPP
4 changes: 2 additions & 2 deletions trunk/src/BleX264Encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ int BleX264Encoder::init()
QString tuneName = option->option("tune", "x264").toString();
QString profileName = option->option("profile", "x264").toString();
int fps = option->option("fps", "encoder").toInt();
int bps = option->option("bitrate", "encoder").toInt();
int kbps = option->option("bitrate", "encoder").toInt();

QSize wh = option->option("res", "encoder").toSize();
int width = wh.width();
int height = wh.height();

int maxBitRate = bps;
int maxBitRate = kbps;
int bufferSize = maxBitRate;
bool bUseCBR = (option->option("BitrateMode", "x264").toString() == "CBR");
int quality = option->option("quality", "x264").toInt();
Expand Down
10 changes: 5 additions & 5 deletions trunk/src/core/mstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void MStream::writeString(const char *data, int size)
int MStream::read1Bytes(mint8 &var)
{
int ret = E_SUCCESS;
if (left() < sizeof(var)) {
if (left() < (int)sizeof(var)) {
return E_SPACE_NOT_ENOUGH;
}

Expand Down Expand Up @@ -159,7 +159,7 @@ int MStream::read4Bytes(mint32 &var)
int MStream::read8Bytes(double &var)
{
int ret = E_SUCCESS;
if (left() < sizeof(var)) {
if (left() < (int)sizeof(var)) {
return E_SPACE_NOT_ENOUGH;
}

Expand All @@ -179,7 +179,7 @@ int MStream::read8Bytes(double &var)
int MStream::readString(mint16 len, MString &var)
{
int ret = E_SUCCESS;
if (left() < (muint32)len) {
if (left() < (int)len) {
return E_SPACE_NOT_ENOUGH;
}

Expand All @@ -198,7 +198,7 @@ int MStream::skip(int len)
{
int temp = m_pos;
temp += len;
if (temp >= size() || temp < 0) {
if (temp >= (int)size() || temp < 0) {
return E_STREAM_SKIP_ERROR;
}
m_pos = temp;
Expand All @@ -213,7 +213,7 @@ void MStream::reset()

bool MStream::end()
{
return m_pos == size();
return m_pos == (int)size();
}

int MStream::pos()
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/gui/RecSkinWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void RecSkinWidget::onCloseNum(int num,const QString &fileName)
{
return;
}
RecSkinPushButton *tmpButton;
RecSkinPushButton *tmpButton = NULL;
if(nowPixNum == num)
emit currentPixmap(oneFileName,onePix,oneColor);
else
Expand Down

0 comments on commit a895b40

Please sign in to comment.