Skip to content

Commit

Permalink
Audio and video works
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Oct 29, 2012
1 parent bf5aa85 commit 4583eb5
Show file tree
Hide file tree
Showing 44 changed files with 2,578 additions and 4 deletions.
68 changes: 68 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
CVS
.#*

.hg
.hgignore

bin
obj
TestResults
*.pbxuser
*.perspectivev3
.DS_Store

*.old
*.log
*.out
*.cache

*.deb

*.git.old*
Makefile*
*.*pro*.user*
*.[oa]
*.so*
*.dll
*.lib
*.exp
*.exe
*.out

#vc files
*.def
*.dep
*.idb
*.layout
*.manifest
*.ncb
*.obj
*.pdb
*.suo
*.user
*.tlh
*.tli


#intel compiler
*.ilk

#dirs
.moc
.rcc
.obj
/bin*
/lib*
Debug
Release
*.Debug
*.Release

*.fuse*

#qt
*.prl
*moc_*
*.moc
*qrc_res.cpp

11 changes: 11 additions & 0 deletions QtAV.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = libqtav test

libqtav.file = src/libQtAV.pro
test.file = test/tst_QtAV.pro
test.depends += libqtav

OTHER_FILES += README


4 changes: 0 additions & 4 deletions README.md

This file was deleted.

164 changes: 164 additions & 0 deletions common.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# qmake common template pri file
# Copyright (C) 2011 Wang Bin <[email protected]>
# Shanghai, China.
#
# 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 2 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

isEmpty(COMMON_PRI_INCLUDED): { #begin COMMON_PRI_INCLUDED

CONFIG += profile
#profiling, -pg is not supported for msvc
debug:!*msvc*:profile {
QMAKE_CXXFLAGS_DEBUG += -pg
QMAKE_LFLAGS_DEBUG += -pg
QMAKE_CXXFLAGS_DEBUG = $$unique(QMAKE_CXXFLAGS_DEBUG)
QMAKE_LFLAGS_DEBUG = $$unique(QMAKE_LFLAGS_DEBUG)
}

#$$[TARGET_PLATFORM]
#$$[QT_ARCH] #windows symbian windowsce arm
_OS =
_ARCH =
_EXTRA =

unix {
_OS = _unix
*linux*: _OS = _linux
*maemo* {
_OS = _maemo
*maemo5*:_OS = _maemo5
*maemo6*:_OS = _maemo6
}
*meego*: _OS = _meego
!isEmpty(MEEGO_EDITION): _OS = _$$MEEGO_EDITION
} else:wince* {
_OS = _wince
} else:win32 { #true for wince
_OS = _win32
} else:macx {
_OS = _macx
}

#*arm*: _ARCH = $${_ARCH}_arm
contains(QT_ARCH, arm.*) {
_ARCH = $${_ARCH}_$${QT_ARCH}
}
*64: _ARCH = $${_ARCH}_x64
*llvm*: _EXTRA = _llvm
#*msvc*:

win32-msvc* {
#Don't warn about sprintf, fopen etc being 'unsafe'
DEFINES += _CRT_SECURE_NO_WARNINGS
}

#################################functions#########################################
defineReplace(cleanPath) {
win32:1 ~= s|\\\\|/|g
contains(1, ^/.*):pfx = /
else:pfx =
segs = $$split(1, /)
out =
for(seg, segs) {
equals(seg, ..):out = $$member(out, 0, -2)
else:!equals(seg, .):out += $$seg
}
return($$join(out, /, $$pfx))
}

#Acts like qtLibraryTarget. From qtcreator.pri
defineReplace(qtLibName) {
#TEMPLATE += fakelib
#LIB_FULLNAME = $$qtLibraryTarget($$1)
#TEMPLATE -= fakelib
unset(LIBRARY_NAME)
LIBRARY_NAME = $$1
CONFIG(debug, debug|release) {
!debug_and_release|build_pass {
mac:RET = $$member(LIBRARY_NAME, 0)_debug
else:win32:RET = $$member(LIBRARY_NAME, 0)d
}
}
isEmpty(RET):RET = $$LIBRARY_NAME
!win32: return($$RET)

isEmpty(2): VERSION_EXT = $$VERSION
else: VERSION_EXT = $$2
!isEmpty(VERSION_EXT) {
VERSION_EXT = $$section(VERSION_EXT, ., 0, 0)
isEqual(VERSION_EXT, 0):unset(VERSION_EXT)
}
RET = $${RET}$${VERSION_EXT}
unset(VERSION_EXT)
return($$RET)
}


#fakelib
defineReplace(qtStaticLib) {
unset(LIB_FULLNAME)
LIB_FULLNAME = $$qtLibName($$1, $$2)
*msvc*: LIB_FULLNAME = $$member(LIB_FULLNAME, 0).lib
else: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).a
return($$LIB_FULLNAME)
}

defineReplace(qtSharedLib) {
unset(LIB_FULLNAME)
LIB_FULLNAME = $$qtLibName($$1, $$2)
win32: LIB_FULLNAME = $$member(LIB_FULLNAME, 0).dll
else {
macx|ios: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).$${QMAKE_EXTENSION_SHLIB} #default_post.prf
else: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).so
}
return($$LIB_FULLNAME)
}

defineReplace(qtLongName) {
unset(LONG_NAME)
LONG_NAME = $$1$${_OS}$${_ARCH}$${_EXTRA}
return($$LONG_NAME)
}

##############################paths####################################
#TRANSLATIONS += i18n/$${TARGET}_zh-cn.ts i18n/$${TARGET}_zh_CN.ts

#for Qt2, Qt3 which does not have QT_VERSION. Qt4: $$[QT_VERSION]
MOC_DIR = $$BUILD_DIR/.moc/$${QT_VERSION}
RCC_DIR = $$BUILD_DIR/.rcc/$${QT_VERSION}
UI_DIR = $$BUILD_DIR/.ui/$${QT_VERSION}
#obj is platform dependent
OBJECTS_DIR = $$qtLongName($$BUILD_DIR/.obj/$$TARGET)

isEqual(TEMPLATE, app) {
DESTDIR = $$BUILD_DIR/bin
TARGET = $$qtLongName($$TARGET)
EXE_EXT =
win32: EXE_EXT = .exe
CONFIG(release, debug|release): !isEmpty(QMAKE_STRIP): QMAKE_POST_LINK = -$$QMAKE_STRIP $$DESTDIR/$${TARGET}$${EXE_EXT} #.exe in win
}
else: DESTDIR = $$qtLongName($$BUILD_DIR/lib)

!build_pass:message(target: $$DESTDIR/$$TARGET)

COMMON_PRI_INCLUDED = 1

} #end COMMON_PRI_INCLUDED
#before target name changed
#TRANSLATIONS += i18n/$${TARGET}_zh-cn.ts #i18n/$${TARGET}_zh_CN.ts



44 changes: 44 additions & 0 deletions src/AVDecoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <QtAV/AVDecoder.h>

namespace QtAV {
AVDecoder::AVDecoder()
:codec_ctx(0),frame_(0)
{
}

AVDecoder::~AVDecoder()
{
}

void AVDecoder::setCodecContext(AVCodecContext *codecCtx)
{
codec_ctx = codecCtx;
}

AVCodecContext* AVDecoder::codecContext() const
{
return codec_ctx;
}

void AVDecoder::setFrame(AVFrame *frame)
{
frame_ = frame;
}

AVFrame* AVDecoder::frame() const
{
return frame_;
}

bool AVDecoder::decode(const QByteArray &encoded)
{
decoded = encoded;
return true;
}

QByteArray AVDecoder::data() const
{
return decoded;
}

}
15 changes: 15 additions & 0 deletions src/AVDemuxThread.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <QtAV/AVDemuxThread.h>

namespace QtAV {
AVDemuxThread::AVDemuxThread(QObject *parent) :
QThread(parent)
{
}


void AVDemuxThread::run()
{
//demuxer->read()
//enqueue()
}
}
62 changes: 62 additions & 0 deletions src/AVDemuxer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <QtAV/AVDemuxer.h>
#ifdef __cplusplus
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
#endif //__cplusplus

#include <QtAV/QAVPacket.h>

namespace QtAV {
AVDemuxer::AVDemuxer()
:formatCtx(0)
{
}


bool AVDemuxer::readPacket(QAVPacket *packet, int stream)
{
AVPacket pkt;
int ret = av_read_frame(formatCtx, &pkt);

if (ret == AVERROR(EAGAIN))
return true;
else if (ret)
return false;
/* idx = pkt.stream_index;
if (idx >= _streams.count())
{
loadStreams();
if ( idx >= _streams.count() )
return false;
}
*/
packet->data = QByteArray((const char *)pkt.data, pkt.size);
#if 0
AVStream *&stream = ( AVStream *& )_streams[ idx ];

//TODO: seek by byte?
if (pkt.dts == AV_NOPTS_VALUE && pkt.pts != AV_NOPTS_VALUE)
packet->pts = pkt.pts;
else if (pkt.dts != AV_NOPTS_VALUE)
packet->pts = pkt.dts;
if (packet->pts < 0.)
packet->pts = 0.;
packet->pts *= av_q2d(stream->time_base);
if (packet->pts && packet->pts - start_time >= 0.0 )
packet->pts -= start_time;

if (stream->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
&& ( pkt.flags & AV_PKT_FLAG_KEY )
&& pkt.convergence_duration != AV_NOPTS_VALUE)
packet->duration = pkt.convergence_duration * av_q2d(stream->time_base);
else if (pkt.duration > 0)
packet->duration = pkt.duration * av_q2d(stream->time_base);
else
packet->duration = 0.;
#endif
return true;
}

}
Loading

0 comments on commit 4583eb5

Please sign in to comment.