~ubuntu-branches/ubuntu/feisty/kdetv/feisty

« back to all changes in this revision

Viewing changes to kdetv/plugins/video/v4l2/kdetv_grabber.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-09-17 23:25:16 UTC
  • Revision ID: james.westby@ubuntu.com-20050917232516-9wdsn3ckagbqieh8
Tags: upstream-0.8.8
ImportĀ upstreamĀ versionĀ 0.8.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
/***************************************************************************
 
3
                           kdetv_grabber.h
 
4
                           ---------------
 
5
    begin                : Thu Oct 27 2004
 
6
    copyright            : (C) 2004 by Dirk Ziegelmeier
 
7
    email                : dziegel@gmx.de
 
8
***************************************************************************/
 
9
 
 
10
/*
 
11
 * This library is free software; you can redistribute it and/or
 
12
 * modify it under the terms of the GNU Library General Public
 
13
 * License as published by the Free Software Foundation; either
 
14
 * version 2 of the License, or (at your option) any later version.
 
15
 *
 
16
 * This library is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
 * Library General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU Library General Public License
 
22
 * along with this library; see the file COPYING.LIB.  If not, write to
 
23
 * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
 
24
 * Boston, MA 02110-1301, USA.
 
25
 */
 
26
 
 
27
#ifndef __KDETV_V4L2GRABBER_H
 
28
#define __KDETV_V4L2GRABBER_H
 
29
 
 
30
#include <qobject.h>
 
31
#include <qthread.h>
 
32
#include <qmutex.h>
 
33
#include <qsize.h>
 
34
 
 
35
#include "kdetvvideo/kdetvimage.h"
 
36
 
 
37
class QVideoStream;
 
38
class V4L2Dev;
 
39
class KdetvImageFilterContext;
 
40
class KdetvImagePool;
 
41
class KdetvImageFilter;
 
42
class KdetvFormatConversionFilter;
 
43
 
 
44
// History: four fields
 
45
#define V4L2GRABBER_CONTEXT_HISTORY 4
 
46
 
 
47
/*
 
48
 * The field images need to be "faked" from progessive images.
 
49
 * The algorithm is simple, but the last two fields must not be
 
50
 * accessed. Depending on the order, the image with buffer may be
 
51
 * deleted while it's corresponding fake field image is still queued.
 
52
 */
 
53
#define V4L2GRABBER_HISTORY V4L2GRABBER_CONTEXT_HISTORY+2
 
54
 
 
55
 
 
56
class V4L2Grabber : public QObject, public QThread
 
57
{
 
58
public:
 
59
        V4L2Grabber(QObject *owner, V4L2Dev *dev, QVideoStream* vs, KdetvImage::ImageFormat fmt);
 
60
        virtual ~V4L2Grabber();
 
61
 
 
62
        virtual void run();
 
63
        void stop() { _stop = true; }
 
64
    QMutex& mutex() { return _devMutex; }
 
65
 
 
66
    int _fieldTime;
 
67
    KdetvImage::ImageType _mostRecentField;
 
68
    bool _fullFrameRate;
 
69
    KdetvImageFilter* _flt;
 
70
    KdetvFormatConversionFilter* _fmtConv;
 
71
 
 
72
private:
 
73
        QObject *_owner;
 
74
        V4L2Dev *_d;
 
75
        volatile bool _stop;
 
76
        QVideoStream* _vs; 
 
77
    QMutex _devMutex;
 
78
    QSize _inputSize;
 
79
    KdetvImage::ImageFormat _fmt; 
 
80
    KdetvImagePool* _poolWithBuffer;
 
81
    KdetvImagePool* _poolWithoutBuffer;
 
82
    KdetvImageFilterContext* _ctx;
 
83
    KdetvSharedImage* _images[V4L2GRABBER_HISTORY];
 
84
};
 
85
 
 
86
class V4L2ErrorEvent : public QEvent
 
87
{
 
88
public:
 
89
    V4L2ErrorEvent(const QString& msg)
 
90
        : QEvent(QEvent::User),
 
91
          _msg(msg)
 
92
    {
 
93
    }
 
94
 
 
95
    ~V4L2ErrorEvent()
 
96
    {
 
97
    }
 
98
 
 
99
    QString _msg;
 
100
};
 
101
 
 
102
 
 
103
struct V4L2GrabberLocker
 
104
{
 
105
    V4L2GrabberLocker(V4L2Grabber* g)
 
106
        : _g(g) 
 
107
    {
 
108
        if (_g)
 
109
            _g->mutex().lock();
 
110
    }
 
111
 
 
112
    ~V4L2GrabberLocker()
 
113
    {
 
114
        if (_g)
 
115
            _g->mutex().unlock();
 
116
    }
 
117
 
 
118
    V4L2Grabber* _g;
 
119
};
 
120
 
 
121
#endif
 
122