|
|
|
@ -67,11 +67,6 @@ void Stream::deInit()
|
|
|
|
avformat_network_deinit(); // ignore failure
|
|
|
|
avformat_network_deinit(); // ignore failure
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Stream::setDecoder(Decoder *decoder)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_decoder = decoder;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static quint32 bufferRead32be(quint8 *buf)
|
|
|
|
static quint32 bufferRead32be(quint8 *buf)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return static_cast<quint32>((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
|
|
|
|
return static_cast<quint32>((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
|
|
|
|
@ -84,11 +79,6 @@ static quint64 bufferRead64be(quint8 *buf)
|
|
|
|
return (static_cast<quint64>(msb) << 32) | lsb;
|
|
|
|
return (static_cast<quint64>(msb) << 32) | lsb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Stream::setRecoder(Recorder *recorder)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_recorder = recorder;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qint32 Stream::recvData(quint8 *buf, qint32 bufSize)
|
|
|
|
qint32 Stream::recvData(quint8 *buf, qint32 bufSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!buf || !m_recvData) {
|
|
|
|
if (!buf || !m_recvData) {
|
|
|
|
@ -110,9 +100,6 @@ bool Stream::startDecode()
|
|
|
|
|
|
|
|
|
|
|
|
void Stream::stopDecode()
|
|
|
|
void Stream::stopDecode()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_decoder) {
|
|
|
|
|
|
|
|
m_decoder->interrupt();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wait();
|
|
|
|
wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -136,23 +123,6 @@ void Stream::run()
|
|
|
|
goto runQuit;
|
|
|
|
goto runQuit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_decoder && !m_decoder->open(codec)) {
|
|
|
|
|
|
|
|
qCritical("Could not open m_decoder");
|
|
|
|
|
|
|
|
goto runQuit;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_recorder) {
|
|
|
|
|
|
|
|
if (!m_recorder->open(codec)) {
|
|
|
|
|
|
|
|
qCritical("Could not open recorder");
|
|
|
|
|
|
|
|
goto runQuit;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!m_recorder->startRecorder()) {
|
|
|
|
|
|
|
|
qCritical("Could not start recorder");
|
|
|
|
|
|
|
|
goto runQuit;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_parser = av_parser_init(AV_CODEC_ID_H264);
|
|
|
|
m_parser = av_parser_init(AV_CODEC_ID_H264);
|
|
|
|
if (!m_parser) {
|
|
|
|
if (!m_parser) {
|
|
|
|
qCritical("Could not initialize parser");
|
|
|
|
qCritical("Could not initialize parser");
|
|
|
|
@ -188,16 +158,6 @@ void Stream::run()
|
|
|
|
av_parser_close(m_parser);
|
|
|
|
av_parser_close(m_parser);
|
|
|
|
|
|
|
|
|
|
|
|
runQuit:
|
|
|
|
runQuit:
|
|
|
|
if (m_recorder) {
|
|
|
|
|
|
|
|
if (m_recorder->isRunning()) {
|
|
|
|
|
|
|
|
m_recorder->stopRecorder();
|
|
|
|
|
|
|
|
m_recorder->wait();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_recorder->close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_decoder) {
|
|
|
|
|
|
|
|
m_decoder->close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_codecCtx) {
|
|
|
|
if (m_codecCtx) {
|
|
|
|
avcodec_free_context(&m_codecCtx);
|
|
|
|
avcodec_free_context(&m_codecCtx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -305,10 +265,7 @@ bool Stream::pushPacket(AVPacket *packet)
|
|
|
|
|
|
|
|
|
|
|
|
bool Stream::processConfigPacket(AVPacket *packet)
|
|
|
|
bool Stream::processConfigPacket(AVPacket *packet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_recorder && !m_recorder->push(packet)) {
|
|
|
|
emit getConfigFrame(packet);
|
|
|
|
qCritical("Could not send config packet to recorder");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -340,18 +297,7 @@ bool Stream::parse(AVPacket *packet)
|
|
|
|
|
|
|
|
|
|
|
|
bool Stream::processFrame(AVPacket *packet)
|
|
|
|
bool Stream::processFrame(AVPacket *packet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_decoder && !m_decoder->push(packet)) {
|
|
|
|
packet->dts = packet->pts;
|
|
|
|
return false;
|
|
|
|
emit getFrame(packet);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_recorder) {
|
|
|
|
|
|
|
|
packet->dts = packet->pts;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!m_recorder->push(packet)) {
|
|
|
|
|
|
|
|
qCritical("Could not send packet to recorder");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|