AudioClipWorkflow.h 3.31 KB
Newer Older
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*****************************************************************************
 * AudioClipWorkflow.h : Clip workflow. Will extract a single frame from a VLCMedia
 *****************************************************************************
 * 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.
 *****************************************************************************/

#ifndef AUDIOCLIPWORKFLOW_H
#define AUDIOCLIPWORKFLOW_H

#include "ClipWorkflow.h"
27
#include "StackedBuffer.hpp"
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
28 29 30 31

class   AudioClipWorkflow : public ClipWorkflow
{
    public:
32 33 34 35
        struct  AudioSample
        {
            unsigned char*  buff;
            size_t          size;
36 37
            unsigned int    nbSample;
            unsigned int    nbChannels;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
38
            qint64          ptsDiff;
39
            uint32_t        debugId;
40
        };
41 42 43 44 45 46 47 48 49 50
        class   StackedBuffer : public ::StackedBuffer<AudioSample*>
        {
            public:
                StackedBuffer( AudioSample* lvf, AudioClipWorkflow* poolHandler,
                                    bool mustBeReleased = true);
                virtual void        release();
            private:
                AudioClipWorkflow*  m_poolHandler;
        };

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
51 52 53 54
        AudioClipWorkflow( Clip* clip );
        ~AudioClipWorkflow();
        void*                   getLockCallback();
        void*                   getUnlockCallback();
55
        virtual void*           getOutput( ClipWorkflow::GetMode mode );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
56

57
    protected:
58
        virtual uint32_t        getNbComputedBuffers() const;
59
        virtual uint32_t        getMaxComputedBuffers() const;
60
        void                    flushComputedBuffers();
61

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
62
    private:
63 64 65 66 67
        void                    releaseBuffer( AudioSample* sample );

    private:
        QQueue<AudioSample*>        m_computedBuffers;
        QQueue<AudioSample*>        m_availableBuffers;
68
        void                        initVlcOutput();
69
        AudioSample*                createBuffer( size_t size );
70 71 72 73 74
        static void                 lock( AudioClipWorkflow* clipWorkflow, uint8_t** pcm_buffer , unsigned int size );
        static void                 unlock( AudioClipWorkflow* clipWorkflow, uint8_t* pcm_buffer,
                                            unsigned int channels, unsigned int rate,
                                            unsigned int nb_samples, unsigned int bits_per_sample,
                                            unsigned int size, qint64 pts );
75 76

        //FIXME: this is totally random powered ! Please adjust with a value that does make sense...
77
        static const uint32_t   nbBuffers = 1024;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
78 79 80
};

#endif // AUDIOCLIPWORKFLOW_H