Commit b060a25c authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Adding the first basics for streams handling

parent 0f1f4754
......@@ -40,6 +40,7 @@ Clip::Clip( Clip* creator, float begin, float end ) : m_parent( creator->getPare
Clip::Clip( Media* parent, float begin, float end ) : m_parent( parent ), m_begin( begin ), m_end( end )
{
Q_ASSERT( parent->getInputType() == Media::File || ( begin == .0f && end == .0f ) );
init();
}
......@@ -81,12 +82,20 @@ qint64 Clip::getLengthSecond() const
void Clip::computeLength()
{
unsigned int fps = m_parent->getFps();
if ( fps < 0.1f )
fps = FPS;
qint64 nbMs = (qint64)( ( m_end - m_begin ) * (float)m_parent->getLength() );
m_lengthSeconds = nbMs / 1000;
m_length = (nbMs / 1000) * fps;
if ( m_parent->getInputType() == Media::File )
{
unsigned int fps = m_parent->getFps();
if ( fps < 0.1f )
fps = FPS;
qint64 nbMs = (qint64)( ( m_end - m_begin ) * (float)m_parent->getLength() );
m_lengthSeconds = nbMs / 1000;
m_length = (nbMs / 1000) * fps;
}
else
{
m_length = 0;
m_lengthSeconds = 0;
}
}
const QUuid& Clip::getUuid() const
......
......@@ -33,18 +33,33 @@ QPixmap* Media::defaultSnapshot = NULL;
const QString Media::VideoExtensions = "*.mov *.avi *.mkv *.mpg *.mpeg *.wmv *.mp4";
const QString Media::ImageExtensions = "*.gif *.png *.jpg";
const QString Media::AudioExtensions = "*.mp3 *.oga *.flac *.aac *.wav";
const QString Media::streamPrefix = "stream://";
Media::Media( const QString& filePath )
: m_vlcMedia( NULL ), m_snapshot( NULL ), m_length( 0 ),
m_width( 0 ), m_height( 0 )
: m_vlcMedia( NULL ),
m_snapshot( NULL ),
m_fileInfo( NULL ),
m_length( 0 ),
m_width( 0 ),
m_height( 0 )
{
m_uuid = QUuid::createUuid();
m_fileInfo = new QFileInfo( filePath );
setFileType();
if ( m_fileType == Media::Video || m_fileType == Media::Audio )
m_mrl = "file:///" + m_fileInfo->absoluteFilePath();
if ( filePath.startsWith( Media::streamPrefix ) == false )
{
m_inputType = Media::File;
m_fileInfo = new QFileInfo( filePath );
setFileType();
if ( m_fileType == Media::Video || m_fileType == Media::Audio )
m_mrl = "file:///" + m_fileInfo->absoluteFilePath();
else
m_mrl = "fake:///" + m_fileInfo->absoluteFilePath();
}
else
m_mrl = "fake:///" + m_fileInfo->absoluteFilePath();
{
m_inputType = Media::Stream;
m_mrl = filePath.right( filePath.length() - streamPrefix.length() );
}
m_vlcMedia = new LibVLCpp::Media( m_mrl );
}
......@@ -54,7 +69,8 @@ Media::~Media()
delete m_vlcMedia;
if ( m_snapshot )
delete m_snapshot;
delete m_fileInfo;
if ( m_fileInfo )
delete m_fileInfo;
}
void Media::setFileType()
......@@ -70,15 +86,6 @@ void Media::setFileType()
qDebug() << "What the hell is this extension ? And how did you loaded it ?!";
}
void Media::loadMedia( const QString& mrl )
{
if ( m_vlcMedia )
delete m_vlcMedia;
m_mrl = mrl;
m_vlcMedia = new LibVLCpp::Media( mrl );
}
void Media::flushVolatileParameters()
{
QString defaultValue;
......@@ -207,3 +214,8 @@ void Media::emitMetaDataComputed()
emit metaDataComputed();
emit metaDataComputed( this );
}
Media::InputType Media::getInputType() const
{
return m_inputType;
}
......@@ -63,16 +63,20 @@ public:
* \enum fType
* \brief enum to determine file type
*/
enum FileType
enum FileType
{
Audio,
Video,
Image
};
enum InputType
{
File,
Stream
};
Media( const QString& filePath );
virtual ~Media();
void loadMedia( const QString& mrl );
/**
* \brief This method adds a parameter that will stay constant though the whole life of this media (unless it is explicitely overided), even if it is cloned.
*/
......@@ -117,6 +121,8 @@ public:
static const QString VideoExtensions;
static const QString AudioExtensions;
static const QString ImageExtensions;
InputType getInputType() const;
static const QString streamPrefix;
void initAudioData( void* datas, unsigned int* freq, unsigned int* nbChannels, unsigned int* fourCCFormat, unsigned int* frameSize );
void addAudioFrame( void* datas, unsigned char* buffer, size_t buffSize, unsigned int nbSample );
......@@ -146,6 +152,7 @@ protected:
int* m_audioSpectrum;
audioData m_audioData;
FileType m_fileType;
InputType m_inputType;
signals:
void metaDataComputed();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment