source: trunk/doc/src/snippets/phonon/samplebackend/main.cpp

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:BSD$
10** You may use this file under the terms of the BSD license as follows:
11**
12** "Redistribution and use in source and binary forms, with or without
13** modification, are permitted provided that the following conditions are
14** met:
15** * Redistributions of source code must retain the above copyright
16** notice, this list of conditions and the following disclaimer.
17** * Redistributions in binary form must reproduce the above copyright
18** notice, this list of conditions and the following disclaimer in
19** the documentation and/or other materials provided with the
20** distribution.
21** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22** the names of its contributors may be used to endorse or promote
23** products derived from this software without specific prior written
24** permission.
25**
26** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41//! [snippet]
42QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args)
43{
44 switch (c) {
45 case MediaObjectClass:
46 return new MediaObject(parent);
47 case VolumeFaderEffectClass:
48 return new VolumeFaderEffect(parent);
49 case AudioOutputClass:
50 return new AudioOutput(parent);
51 case AudioDataOutputClass:
52 return new AudioDataOutput(parent);
53 case VisualizationClass:
54 return new Visualization(parent);
55 case VideoDataOutputClass:
56 return new VideoDataOutput(parent);
57 case EffectClass:
58 return new Effect(args[0].toInt(), parent);
59 case VideoWidgetClass:
60 return new VideoWidget(qobject_cast<QWidget *>(parent));
61 }
62 return 0;
63}
64
65QSet<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const
66{
67 QSet<int> set;
68 switch(type)
69 {
70 case Phonon::AudioOutputDeviceType:
71 // use AudioDeviceEnumerator to list ALSA and OSS devices
72 set << 10000 << 10001;
73 break;
74 case Phonon::AudioCaptureDeviceType:
75 set << 20000 << 20001;
76 break;
77 case Phonon::VideoOutputDeviceType:
78 break;
79 case Phonon::VideoCaptureDeviceType:
80 set << 30000 << 30001;
81 break;
82 case Phonon::VisualizationType:
83 case Phonon::AudioCodecType:
84 case Phonon::VideoCodecType:
85 case Phonon::ContainerFormatType:
86 break;
87 case Phonon::EffectType:
88 set << 0x7F000001;
89 break;
90 }
91 return set;
92}
93
94QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const
95{
96 QHash<QByteArray, QVariant> ret;
97 switch (type) {
98 case Phonon::AudioOutputDeviceType:
99 switch (index) {
100 case 10000:
101 ret.insert("name", QLatin1String("internal Soundcard"));
102 break;
103 case 10001:
104 ret.insert("name", QLatin1String("USB Headset"));
105 ret.insert("icon", KIcon("usb-headset"));
106 ret.insert("available", false);
107 break;
108 }
109 break;
110 case Phonon::AudioCaptureDeviceType:
111 switch (index) {
112 case 20000:
113 ret.insert("name", QLatin1String("Soundcard"));
114 ret.insert("description", QLatin1String("first description"));
115 break;
116 case 20001:
117 ret.insert("name", QLatin1String("DV"));
118 ret.insert("description", QLatin1String("second description"));
119 break;
120 }
121 break;
122 case Phonon::VideoOutputDeviceType:
123 break;
124 case Phonon::VideoCaptureDeviceType:
125 switch (index) {
126 case 30000:
127 ret.insert("name", QLatin1String("USB Webcam"));
128 ret.insert("description", QLatin1String("first description"));
129 break;
130 case 30001:
131 ret.insert("name", QLatin1String("DV"));
132 ret.insert("description", QLatin1String("second description"));
133 break;
134 }
135 break;
136 case Phonon::VisualizationType:
137 break;
138 case Phonon::AudioCodecType:
139 break;
140 case Phonon::VideoCodecType:
141 break;
142 case Phonon::ContainerFormatType:
143 break;
144 case Phonon::EffectType:
145 switch (index) {
146 case 0x7F000001:
147 ret.insert("name", QLatin1String("Delay"));
148 ret.insert("description", QLatin1String("Simple delay effect with time, feedback and level controls."));
149 break;
150 }
151 break;
152 }
153 return ret;
154}
155//! [snippet]
Note: See TracBrowser for help on using the repository browser.