Skip to content

Commit

Permalink
misc. copyright, format .etc
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Oct 31, 2012
1 parent d2c18c5 commit 0def632
Show file tree
Hide file tree
Showing 42 changed files with 1,433 additions and 227 deletions.
674 changes: 674 additions & 0 deletions gpl-3.0.txt

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/AVClock.cpp
Original file line number Diff line number Diff line change
@@ -1,17 1,17 @@
/******************************************************************************
AVClock.cpp: description
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012 Wang Bin <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
Expand Down
20 changes: 19 additions & 1 deletion src/AVDecoder.cpp
Original file line number Diff line number Diff line change
@@ -1,3 1,21 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012 Wang Bin <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <QtAV/AVDecoder.h>
#include <private/AVDecoder_p.h>

Expand Down Expand Up @@ -42,4 60,4 @@ QByteArray AVDecoder::data() const
return d_ptr->decoded;
}

}
} //namespace QtAV
20 changes: 19 additions & 1 deletion src/AVDemuxThread.cpp
Original file line number Diff line number Diff line change
@@ -1,3 1,21 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012 Wang Bin <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <QtAV/AVDemuxThread.h>
#include <QtAV/AVDemuxer.h>
#include <QtAV/Packet.h>
Expand Down Expand Up @@ -81,4 99,4 @@ void AVDemuxThread::run()
qDebug("Demux thread stops running....");
}

}
} //namespace QtAV
71 changes: 50 additions & 21 deletions src/AVDemuxer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 1,21 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012 Wang Bin <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <QtAV/AVDemuxer.h>
#ifdef __cplusplus
extern "C" {
Expand All @@ -13,6 31,7 @@ extern "C" {
namespace QtAV {
AVDemuxer::AVDemuxer(const QString& fileName, QObject *parent)
:QObject(parent),eof(false),pkt(new Packet()),stream_idx(-1)
,audio_stream(-2),video_stream(-2),subtitle_stream(-2)
,_is_input(true),format_context(0),a_codec_context(0),v_codec_context(0)
,_file_name(fileName)
{
Expand All @@ -36,7 55,7 @@ AVDemuxer::~AVDemuxer()

bool AVDemuxer::readFrame()
{
static AVPacket packet;
AVPacket packet;
int ret = av_read_frame(format_context, &packet); //0: ok, <0: error/end

if (ret != 0) {
Expand Down Expand Up @@ -274,12 293,11 @@ bool AVDemuxer::isInput() const

int AVDemuxer::audioStream() const
{
static int audio_stream = -2; //-2: not parsed, -1 not found.
if (audio_stream != -2)
if (audio_stream != -2) //-2: not parsed, -1 not found.
return audio_stream;
audio_stream = -1;
for(unsigned int i=0; i<format_context->nb_streams; i) {
if(format_context->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO) {
if(format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
audio_stream = i;
break;
}
Expand All @@ -289,19 307,32 @@ int AVDemuxer::audioStream() const

int AVDemuxer::videoStream() const
{
static int video_stream = -2; //-2: not parsed, -1 not found.
if (video_stream != -2)
if (video_stream != -2) //-2: not parsed, -1 not found.
return video_stream;
video_stream = -1;
for(unsigned int i=0; i<format_context->nb_streams; i) {
if(format_context->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
if(format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
video_stream = i;
break;
}
}
return video_stream;
}

int AVDemuxer::subtitleStream() const
{
if (subtitle_stream != -2) //-2: not parsed, -1 not found.
return subtitle_stream;
subtitle_stream = -1;
for(unsigned int i=0; i<format_context->nb_streams; i) {
if(format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
subtitle_stream = i;
break;
}
}
return subtitle_stream;
}

int AVDemuxer::width() const
{
return videoCodecContext()->width;
Expand Down Expand Up @@ -357,15 388,13 @@ QString AVDemuxer::videoCodecLongName() const

bool AVDemuxer::findAVCodec()
{
static int video_stream = -2; //-2: not parsed, -1 not found.
static int audio_stream = -2; //-2: not parsed, -1 not found.
if (video_stream != -2 && audio_stream != -2)
return (video_stream != -1) && (audio_stream != -1);
video_stream = -1;
audio_stream = -1;
for(unsigned int i=0; i<format_context->nb_streams; i) {
if(format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO
&& video_stream < 0) {
if (video_stream != -2 && audio_stream != -2 && subtitle_stream != -2)
return (video_stream != -1) && (audio_stream != -1) && (subtitle_stream != -1);
video_stream = audio_stream = subtitle_stream = -1;
AVMediaType type = AVMEDIA_TYPE_UNKNOWN;
for (unsigned int i=0; i<format_context->nb_streams; i) {
type = format_context->streams[i]->codec->codec_type;
if (type == AVMEDIA_TYPE_VIDEO && video_stream < 0) {
video_stream = i;
v_codec_context = format_context->streams[video_stream]->codec;
//if !vaapi
Expand All @@ -375,13 404,13 @@ bool AVDemuxer::findAVCodec()
} else {
//v_codec_context->lowres = lowres;
}
}
if(format_context->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO
&& audio_stream < 0) {
} else if (type == AVMEDIA_TYPE_AUDIO && audio_stream < 0) {
audio_stream = i;
a_codec_context = format_context->streams[audio_stream]->codec;
} else if (type == AVMEDIA_TYPE_SUBTITLE && subtitle_stream < 0) {
subtitle_stream = i;
}
if (audio_stream >=0 && video_stream >= 0)
if (audio_stream >=0 && video_stream >= 0 && subtitle_stream >= 0)
return true;
}
return false;
Expand All @@ -395,4 424,4 @@ QString AVDemuxer::formatName(AVFormatContext *ctx, bool longName) const
return longName ? ctx->oformat->long_name : ctx->oformat->name;
}

}
} //namespace QtAV
20 changes: 19 additions & 1 deletion src/AVOutput.cpp
Original file line number Diff line number Diff line change
@@ -1,3 1,21 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012 Wang Bin <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <QtAV/AVOutput.h>
#include <private/AVOutput_p.h>

Expand Down Expand Up @@ -30,4 48,4 @@ void AVOutput::bindDecoder(AVDecoder *dec)
d_ptr->dec = dec;
}

}
} //namespace QtAV
35 changes: 26 additions & 9 deletions src/AVPlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 1,21 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012 Wang Bin <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <QtAV/AVPlayer.h>

#include <qevent.h>
Expand All @@ -21,15 39,14 @@
extern "C"
{
#endif //__cplusplus
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavcodec/avcodec.h"
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#ifdef __cplusplus
}
#endif //__cplusplus


namespace QtAV {

AVPlayer::AVPlayer(QObject *parent) :
QObject(parent),renderer(0),audio(0)
{
Expand Down Expand Up @@ -117,7 134,7 @@ bool AVPlayer::play(const QString& path)
// return false;
AVStream *m_v_stream = formatCtx->streams[videoStream];
qDebug("[AVFormatContext::duration = %lld]", demuxer.duration());
qDebug("[AVStream::start_time = %lld]", m_v_stream->start_time);
qDebug("[AVStream::start_time = %lld]", m_v_stream->start_time);
qDebug("[AVCodecContext::time_base = %d, %d, %.2f %.2f]", vCodecCtx->time_base.num, vCodecCtx->time_base.den
,1.0 * vCodecCtx->time_base.num / vCodecCtx->time_base.den
,1.0 / (1.0 * vCodecCtx->time_base.num / vCodecCtx->time_base.den));
Expand Down Expand Up @@ -149,9 166,9 @@ void AVPlayer::timerEvent(QTimerEvent* e)
{
if (e->timerId() != avTimerId)
return;
static AVPacket packet;
static int videoStream = demuxer.videoStream();
static int audioStream = demuxer.audioStream();
AVPacket packet;
int videoStream = demuxer.videoStream();
int audioStream = demuxer.audioStream();
while (av_read_frame(formatCtx, &packet) >=0 ) {
Packet pkt;
pkt.data = QByteArray((const char*)packet.data, packet.size);
Expand Down Expand Up @@ -191,4 208,4 @@ void AVPlayer::timerEvent(QTimerEvent* e)
}
}

}
} //namespace QtAV
21 changes: 19 additions & 2 deletions src/AVThread.cpp
Original file line number Diff line number Diff line change
@@ -1,3 1,21 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012 Wang Bin <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <QtAV/AVThread.h>
#include <private/AVThread_p.h>

Expand Down Expand Up @@ -63,5 81,4 @@ AVOutput* AVThread::output() const
return d_ptr->writer;
}

}

} //namespace QtAV
Loading

0 comments on commit 0def632

Please sign in to comment.