root/OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.hpp @ 9861

Revision 9861, 2.2 kB (checked in by robert, 5 years ago)

Removed boost reference and cleaned up debug output

RevLine 
[9816]1
2#ifndef HEADER_GUARD_OSGFFMPEG_FFMPEG_DECODER_AUDIO_H
3#define HEADER_GUARD_OSGFFMPEG_FFMPEG_DECODER_AUDIO_H
4
5#include <OpenThreads/Thread>
6
7#include "FFmpegClocks.hpp"
8#include "FFmpegPacket.hpp"
9
[9827]10#include <osg/AudioStream>
11
[9818]12#include "BoundedMessageQueue.hpp"
[9816]13
14
[9818]15
[9827]16
[9816]17namespace osgFFmpeg {
18
19
20
21class FFmpegDecoderAudio : public OpenThreads::Thread
22{
23public:
24
25    typedef BoundedMessageQueue<FFmpegPacket> PacketQueue;
26    typedef void (* PublishFunc) (const FFmpegDecoderAudio & decoder, void * user_data);
27
28    FFmpegDecoderAudio(PacketQueue & packets, FFmpegClocks & clocks);
29    ~FFmpegDecoderAudio();
30
31    void open(AVStream * stream);
32    virtual void run();
33
[9847]34    void setAudioSink(osg::ref_ptr<osg::AudioSink> audio_sink);
[9816]35    void fillBuffer(void * buffer, size_t size);
36
37    bool validContext() const;
38    int frequency() const;
39    int nbChannels() const;
[9827]40    osg::AudioStream::SampleFormat sampleFormat() const;
[9816]41
42private:
43
[9847]44    typedef osg::ref_ptr<osg::AudioSink> SinkPtr;
[9816]45    typedef std::vector<uint8_t> Buffer;
46
47    void decodeLoop();
48    void adjustBufferEndTps(size_t buffer_size);
49    size_t decodeFrame(void * buffer, size_t size);
50
51
52    PacketQueue &        m_packets;
53    FFmpegClocks &        m_clocks;
54    AVStream *            m_stream;
55    AVCodecContext *    m_context;
56    FFmpegPacket        m_packet;
57    const uint8_t *        m_packet_data;
58    int                    m_bytes_remaining;
59
60    Buffer                m_audio_buffer;
61    size_t                m_audio_buf_size;
62    size_t                m_audio_buf_index;
63
64    int                    m_frequency;
65    int                    m_nb_channels;
[9827]66    osg::AudioStream::SampleFormat    m_sample_format;
[9816]67
68    SinkPtr                m_audio_sink;
69
70    bool                m_end_of_stream;
71    volatile bool        m_exit;
72};
73
74
75
76
77
78inline bool FFmpegDecoderAudio::validContext() const
79{
80    return m_context != 0;
81}
82
83
84inline int FFmpegDecoderAudio::frequency() const
85{
86    return m_frequency;
87}
88
89
90inline int FFmpegDecoderAudio::nbChannels() const
91{
92    return m_nb_channels;
93}
94
95
[9827]96inline osg::AudioStream::SampleFormat FFmpegDecoderAudio::sampleFormat() const
[9816]97{
98    return m_sample_format;
99}
100
101
102
103} // namespace osgFFmpeg
104
105
106
107#endif // HEADER_GUARD_OSGFFMPEG_FFMPEG_DECODER_AUDIO_H
Note: See TracBrowser for help on using the browser.