VLCMedia.cpp 2.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*****************************************************************************
 * VLCMedia.cpp: Binding for libvlc_media
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
 *
 * 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.
 *****************************************************************************/

23
#include <QtDebug>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
24
25
26
27
28
#include <cassert>
#include "VLCMedia.h"

using namespace LibVLCpp;

29
Media::Media( const QString& filename )
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
30
    : m_pixelBuffer( NULL )
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
31
{
32
    m_internalPtr = libvlc_media_new( *(LibVLCpp::Instance::getInstance()), filename.toLocal8Bit(), m_ex );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
33
    CheckVlcppException(m_ex);
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
34
35
36
37
}

Media::~Media()
{
Ludovic Fauvet's avatar
Ludovic Fauvet committed
38
    libvlc_media_release( m_internalPtr );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
39
40
}

Ludovic Fauvet's avatar
Ludovic Fauvet committed
41
void                    Media::addOption( const char* opt )
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
42
{
43
    libvlc_media_add_option_flag( m_internalPtr, opt, libvlc_media_option_trusted, m_ex);
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
44
    CheckVlcppException(m_ex);
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
45
46
}

Ludovic Fauvet's avatar
Ludovic Fauvet committed
47
void                    Media::setLockCallback( Media::lockCallback callback )
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
48
49
{
    char    param[64];
50
    sprintf( param, ":sout-smem-video-prerender-callback=%lld", (qint64)(intptr_t)callback );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
51
    addOption(param);
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
52
53
}

Ludovic Fauvet's avatar
Ludovic Fauvet committed
54
void                    Media::setUnlockCallback( Media::unlockCallback callback )
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
55
56
{
    char    param[64];
57
    sprintf( param, ":sout-smem-video-postrender-callback=%lld", (qint64)(intptr_t)callback );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
58
    addOption( param );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
59
60
}

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
61
void                    Media::setDataCtx( void* dataCtx )
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
62
63
{
    char    param[64];
64

65
    sprintf( param, ":sout-smem-video-data=%lld", (qint64)(intptr_t)dataCtx );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
66
    addOption( param );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
67
68
69
70
}

void                    Media::outputInVmem()
{
Ludovic Fauvet's avatar
Ludovic Fauvet committed
71
    addOption( ":vout=vmem" );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
72
73
74
75
76
77
}

void                    Media::outputInWindow()
{
//    this->addOption();
}
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
78

Ludovic Fauvet's avatar
Ludovic Fauvet committed
79
void                    Media::setPixelBuffer( uchar* buffer )
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
80
{
Ludovic Fauvet's avatar
Ludovic Fauvet committed
81
    m_pixelBuffer = buffer;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
82
83
84
85
}

uchar*                  Media::getPixelBuffer()
{
Ludovic Fauvet's avatar
Ludovic Fauvet committed
86
    return m_pixelBuffer;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
87
}