| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU Lesser General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
| 21 | ** packaging of this file. Please review the following information to | 
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
| 24 | ** | 
| 25 | ** GNU General Public License Usage | 
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
| 31 | ** included in the packaging of this file. Please review the following | 
| 32 | ** information to ensure the GNU General Public License requirements will | 
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
| 35 | ** | 
| 36 | ** $QT_END_LICENSE$ | 
| 37 | ** | 
| 38 | ****************************************************************************/ | 
| 39 |  | 
| 40 | #include "qmediaencodersettings.h" | 
| 41 |  | 
| 42 | QT_BEGIN_NAMESPACE | 
| 43 |  | 
| 44 | static void qRegisterEncoderSettingsMetaTypes() | 
| 45 | { | 
| 46 |     qRegisterMetaType<QAudioEncoderSettings>(); | 
| 47 |     qRegisterMetaType<QVideoEncoderSettings>(); | 
| 48 |     qRegisterMetaType<QImageEncoderSettings>(); | 
| 49 | } | 
| 50 |  | 
| 51 | Q_CONSTRUCTOR_FUNCTION(qRegisterEncoderSettingsMetaTypes) | 
| 52 |  | 
| 53 |  | 
| 54 | class QAudioEncoderSettingsPrivate  : public QSharedData | 
| 55 | { | 
| 56 | public: | 
| 57 |     QAudioEncoderSettingsPrivate() : | 
| 58 |         isNull(true), | 
| 59 |         encodingMode(QMultimedia::ConstantQualityEncoding), | 
| 60 |         bitrate(-1), | 
| 61 |         sampleRate(-1), | 
| 62 |         channels(-1), | 
| 63 |         quality(QMultimedia::NormalQuality) | 
| 64 |     { | 
| 65 |     } | 
| 66 |  | 
| 67 |     QAudioEncoderSettingsPrivate(const QAudioEncoderSettingsPrivate &other): | 
| 68 |         QSharedData(other), | 
| 69 |         isNull(other.isNull), | 
| 70 |         encodingMode(other.encodingMode), | 
| 71 |         codec(other.codec), | 
| 72 |         bitrate(other.bitrate), | 
| 73 |         sampleRate(other.sampleRate), | 
| 74 |         channels(other.channels), | 
| 75 |         quality(other.quality), | 
| 76 |         encodingOptions(other.encodingOptions) | 
| 77 |     { | 
| 78 |     } | 
| 79 |  | 
| 80 |     bool isNull; | 
| 81 |     QMultimedia::EncodingMode encodingMode; | 
| 82 |     QString codec; | 
| 83 |     int bitrate; | 
| 84 |     int sampleRate; | 
| 85 |     int channels; | 
| 86 |     QMultimedia::EncodingQuality quality; | 
| 87 |     QVariantMap encodingOptions; | 
| 88 |  | 
| 89 | private: | 
| 90 |     QAudioEncoderSettingsPrivate& operator=(const QAudioEncoderSettingsPrivate &other); | 
| 91 | }; | 
| 92 |  | 
| 93 | /*! | 
| 94 |     \class QAudioEncoderSettings | 
| 95 |  | 
| 96 |     \brief The QAudioEncoderSettings class provides a set of audio encoder settings. | 
| 97 |  | 
| 98 |     \inmodule QtMultimedia | 
| 99 |     \ingroup multimedia | 
| 100 |     \ingroup multimedia_recording | 
| 101 |  | 
| 102 |     A audio encoder settings object is used to specify the audio encoder | 
| 103 |     settings used by QMediaRecorder.  Audio encoder settings are selected by | 
| 104 |     constructing a QAudioEncoderSettings object, setting the desired properties | 
| 105 |     and then passing it to a QMediaRecorder instance using the | 
| 106 |     QMediaRecorder::setEncodingSettings() function. | 
| 107 |  | 
| 108 |     \snippet multimedia-snippets/media.cpp Audio encoder settings | 
| 109 |  | 
| 110 |     \sa QMediaRecorder, QAudioEncoderSettingsControl | 
| 111 | */ | 
| 112 |  | 
| 113 | /*! | 
| 114 |     Construct a null audio encoder settings object. | 
| 115 | */ | 
| 116 | QAudioEncoderSettings::QAudioEncoderSettings() | 
| 117 |     :d(new QAudioEncoderSettingsPrivate) | 
| 118 | { | 
| 119 | } | 
| 120 |  | 
| 121 | /*! | 
| 122 |     Constructs a copy of the audio encoder settings object \a other. | 
| 123 | */ | 
| 124 |  | 
| 125 | QAudioEncoderSettings::QAudioEncoderSettings(const QAudioEncoderSettings& other) | 
| 126 |     :d(other.d) | 
| 127 | { | 
| 128 | } | 
| 129 |  | 
| 130 | /*! | 
| 131 |     Destroys an audio encoder settings object. | 
| 132 | */ | 
| 133 |  | 
| 134 | QAudioEncoderSettings::~QAudioEncoderSettings() | 
| 135 | { | 
| 136 | } | 
| 137 |  | 
| 138 | /*! | 
| 139 |     Assigns the value of \a other to an audio encoder settings object. | 
| 140 | */ | 
| 141 |  | 
| 142 | QAudioEncoderSettings& QAudioEncoderSettings::operator=(const QAudioEncoderSettings &other) | 
| 143 | { | 
| 144 |     d = other.d; | 
| 145 |     return *this; | 
| 146 | } | 
| 147 |  | 
| 148 | /*! | 
| 149 |     Determines if \a other is of equal value to an audio encoder settings | 
| 150 |     object. | 
| 151 |  | 
| 152 |     Returns true if the settings objects are of equal value, and false if they | 
| 153 |     are not of equal value. | 
| 154 | */ | 
| 155 |  | 
| 156 | bool QAudioEncoderSettings::operator==(const QAudioEncoderSettings &other) const | 
| 157 | { | 
| 158 |     return (d == other.d) || | 
| 159 |            (d->isNull == other.d->isNull && | 
| 160 |             d->encodingMode == other.d->encodingMode && | 
| 161 |             d->bitrate == other.d->bitrate && | 
| 162 |             d->sampleRate == other.d->sampleRate && | 
| 163 |             d->channels == other.d->channels && | 
| 164 |             d->quality == other.d->quality && | 
| 165 |             d->codec == other.d->codec && | 
| 166 |             d->encodingOptions == other.d->encodingOptions); | 
| 167 | } | 
| 168 |  | 
| 169 | /*! | 
| 170 |     Determines if \a other is of equal value to an audio encoder settings | 
| 171 |     object. | 
| 172 |  | 
| 173 |     Returns true if the settings objects are not of equal value, and true if | 
| 174 |     they are of equal value. | 
| 175 | */ | 
| 176 |  | 
| 177 | bool QAudioEncoderSettings::operator!=(const QAudioEncoderSettings &other) const | 
| 178 | { | 
| 179 |     return !(*this == other); | 
| 180 | } | 
| 181 |  | 
| 182 | /*! | 
| 183 |     Identifies if an audio settings object is initialized. | 
| 184 |  | 
| 185 |     Returns true if the settings object is null, and false if it is not. | 
| 186 | */ | 
| 187 |  | 
| 188 | bool QAudioEncoderSettings::isNull() const | 
| 189 | { | 
| 190 |     return d->isNull; | 
| 191 | } | 
| 192 |  | 
| 193 | /*! | 
| 194 |     Returns the audio encoding mode. | 
| 195 |  | 
| 196 |     \sa QMultimedia::EncodingMode | 
| 197 | */ | 
| 198 | QMultimedia::EncodingMode QAudioEncoderSettings::encodingMode() const | 
| 199 | { | 
| 200 |     return d->encodingMode; | 
| 201 | } | 
| 202 |  | 
| 203 | /*! | 
| 204 |     Sets the audio encoding \a mode setting. | 
| 205 |  | 
| 206 |     If QMultimedia::ConstantQualityEncoding is set, the quality | 
| 207 |     encoding parameter is used and bit rate is ignored, | 
| 208 |     otherwise the bitrate is used. | 
| 209 |  | 
| 210 |     The audio codec, channels count and sample rate settings are used in all | 
| 211 |     the encoding modes. | 
| 212 |  | 
| 213 |     \sa encodingMode(), QMultimedia::EncodingMode | 
| 214 | */ | 
| 215 | void QAudioEncoderSettings::setEncodingMode(QMultimedia::EncodingMode mode) | 
| 216 | { | 
| 217 |     d->encodingMode = mode; | 
| 218 | } | 
| 219 |  | 
| 220 | /*! | 
| 221 |     Returns the audio codec. | 
| 222 | */ | 
| 223 | QString QAudioEncoderSettings::codec() const | 
| 224 | { | 
| 225 |     return d->codec; | 
| 226 | } | 
| 227 |  | 
| 228 | /*! | 
| 229 |     Sets the audio \a codec. | 
| 230 | */ | 
| 231 | void QAudioEncoderSettings::setCodec(const QString& codec) | 
| 232 | { | 
| 233 |     d->isNull = false; | 
| 234 |     d->codec = codec; | 
| 235 | } | 
| 236 |  | 
| 237 | /*! | 
| 238 |     Returns the bit rate of the compressed audio stream in bits per second. | 
| 239 | */ | 
| 240 | int QAudioEncoderSettings::bitRate() const | 
| 241 | { | 
| 242 |     return d->bitrate; | 
| 243 | } | 
| 244 |  | 
| 245 | /*! | 
| 246 |     Returns the number of audio channels. | 
| 247 | */ | 
| 248 | int QAudioEncoderSettings::channelCount() const | 
| 249 | { | 
| 250 |     return d->channels; | 
| 251 | } | 
| 252 |  | 
| 253 | /*! | 
| 254 |     Sets the number of audio \a channels. | 
| 255 |  | 
| 256 |     A value of -1 indicates the encoder should make an optimal choice based on | 
| 257 |     what is available from the audio source and the limitations of the codec. | 
| 258 | */ | 
| 259 | void QAudioEncoderSettings::setChannelCount(int channels) | 
| 260 | { | 
| 261 |     d->isNull = false; | 
| 262 |     d->channels = channels; | 
| 263 | } | 
| 264 |  | 
| 265 | /*! | 
| 266 |     Sets the audio bit \a rate in bits per second. | 
| 267 | */ | 
| 268 | void QAudioEncoderSettings::setBitRate(int rate) | 
| 269 | { | 
| 270 |     d->isNull = false; | 
| 271 |     d->bitrate = rate; | 
| 272 | } | 
| 273 |  | 
| 274 | /*! | 
| 275 |     Returns the audio sample rate in Hz. | 
| 276 | */ | 
| 277 | int QAudioEncoderSettings::sampleRate() const | 
| 278 | { | 
| 279 |     return d->sampleRate; | 
| 280 | } | 
| 281 |  | 
| 282 | /*! | 
| 283 |     Sets the audio sample \a rate in Hz. | 
| 284 |  | 
| 285 |     A value of -1 indicates the encoder should make an optimal choice based on what is avaialbe | 
| 286 |     from the audio source and the limitations of the codec. | 
| 287 |   */ | 
| 288 | void QAudioEncoderSettings::setSampleRate(int rate) | 
| 289 | { | 
| 290 |     d->isNull = false; | 
| 291 |     d->sampleRate = rate; | 
| 292 | } | 
| 293 |  | 
| 294 | /*! | 
| 295 |     Returns the audio encoding quality. | 
| 296 | */ | 
| 297 |  | 
| 298 | QMultimedia::EncodingQuality QAudioEncoderSettings::quality() const | 
| 299 | { | 
| 300 |     return d->quality; | 
| 301 | } | 
| 302 |  | 
| 303 | /*! | 
| 304 |     Set the audio encoding \a quality. | 
| 305 |  | 
| 306 |     Setting the audio quality parameter allows backend to choose the balanced | 
| 307 |     set of encoding parameters to achieve the desired quality level. | 
| 308 |  | 
| 309 |     The \a quality settings parameter is only used in the | 
| 310 |     \l {QMultimedia::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}. | 
| 311 | */ | 
| 312 | void QAudioEncoderSettings::setQuality(QMultimedia::EncodingQuality quality) | 
| 313 | { | 
| 314 |     d->isNull = false; | 
| 315 |     d->quality = quality; | 
| 316 | } | 
| 317 |  | 
| 318 | /*! | 
| 319 |     Returns the value of encoding \a option. | 
| 320 |  | 
| 321 |     \sa setEncodingOption(), encodingOptions() | 
| 322 | */ | 
| 323 | QVariant QAudioEncoderSettings::encodingOption(const QString &option) const | 
| 324 | { | 
| 325 |     return d->encodingOptions.value(akey: option); | 
| 326 | } | 
| 327 |  | 
| 328 | /*! | 
| 329 |     Returns the all the encoding options as QVariantMap. | 
| 330 |  | 
| 331 |     \sa encodingOption(), setEncodingOptions() | 
| 332 | */ | 
| 333 | QVariantMap QAudioEncoderSettings::encodingOptions() const | 
| 334 | { | 
| 335 |     return d->encodingOptions; | 
| 336 | } | 
| 337 |  | 
| 338 | /*! | 
| 339 |     Set the encoding \a option to \a value. | 
| 340 |  | 
| 341 |     The supported set and meaning of encoding options are | 
| 342 |     system and selected codec specific. | 
| 343 |  | 
| 344 |     \sa encodingOption(), setEncodingOptions() | 
| 345 | */ | 
| 346 | void QAudioEncoderSettings::setEncodingOption(const QString &option, const QVariant &value) | 
| 347 | { | 
| 348 |     d->isNull = false; | 
| 349 |     if (value.isNull()) | 
| 350 |         d->encodingOptions.remove(akey: option); | 
| 351 |     else | 
| 352 |         d->encodingOptions.insert(akey: option, avalue: value); | 
| 353 | } | 
| 354 |  | 
| 355 | /*! | 
| 356 |     Replace all the encoding options with \a options. | 
| 357 |  | 
| 358 |     The supported set and meaning of encoding options are | 
| 359 |     system and selected codec specific. | 
| 360 |  | 
| 361 |     \sa encodingOption(), setEncodingOption() | 
| 362 | */ | 
| 363 | void QAudioEncoderSettings::setEncodingOptions(const QVariantMap &options) | 
| 364 | { | 
| 365 |     d->isNull = false; | 
| 366 |     d->encodingOptions = options; | 
| 367 | } | 
| 368 |  | 
| 369 | class QVideoEncoderSettingsPrivate  : public QSharedData | 
| 370 | { | 
| 371 | public: | 
| 372 |     QVideoEncoderSettingsPrivate() : | 
| 373 |         isNull(true), | 
| 374 |         encodingMode(QMultimedia::ConstantQualityEncoding), | 
| 375 |         bitrate(-1), | 
| 376 |         frameRate(0), | 
| 377 |         quality(QMultimedia::NormalQuality) | 
| 378 |     { | 
| 379 |     } | 
| 380 |  | 
| 381 |     QVideoEncoderSettingsPrivate(const QVideoEncoderSettingsPrivate &other): | 
| 382 |         QSharedData(other), | 
| 383 |         isNull(other.isNull), | 
| 384 |         encodingMode(other.encodingMode), | 
| 385 |         codec(other.codec), | 
| 386 |         bitrate(other.bitrate), | 
| 387 |         resolution(other.resolution), | 
| 388 |         frameRate(other.frameRate), | 
| 389 |         quality(other.quality), | 
| 390 |         encodingOptions(other.encodingOptions) | 
| 391 |     { | 
| 392 |     } | 
| 393 |  | 
| 394 |     bool isNull; | 
| 395 |     QMultimedia::EncodingMode encodingMode; | 
| 396 |     QString codec; | 
| 397 |     int bitrate; | 
| 398 |     QSize resolution; | 
| 399 |     qreal frameRate; | 
| 400 |     QMultimedia::EncodingQuality quality; | 
| 401 |     QVariantMap encodingOptions; | 
| 402 |  | 
| 403 | private: | 
| 404 |     QVideoEncoderSettingsPrivate& operator=(const QVideoEncoderSettingsPrivate &other); | 
| 405 | }; | 
| 406 |  | 
| 407 | /*! | 
| 408 |     \class QVideoEncoderSettings | 
| 409 |  | 
| 410 |     \brief The QVideoEncoderSettings class provides a set of video encoder settings. | 
| 411 |  | 
| 412 |     \inmodule QtMultimedia | 
| 413 |     \ingroup multimedia | 
| 414 |     \ingroup multimedia_recording | 
| 415 |  | 
| 416 |     A video encoder settings object is used to specify the video encoder | 
| 417 |     settings used by QMediaRecorder.  Video encoder settings are selected by | 
| 418 |     constructing a QVideoEncoderSettings object, setting the desired properties | 
| 419 |     and then passing it to a QMediaRecorder instance using the | 
| 420 |     QMediaRecorder::setEncodingSettings() function. | 
| 421 |  | 
| 422 |     \snippet multimedia-snippets/media.cpp Video encoder settings | 
| 423 |  | 
| 424 |     \sa QMediaRecorder, QVideoEncoderSettingsControl | 
| 425 | */ | 
| 426 |  | 
| 427 | /*! | 
| 428 |     Constructs a null video encoder settings object. | 
| 429 | */ | 
| 430 |  | 
| 431 | QVideoEncoderSettings::QVideoEncoderSettings() | 
| 432 |     :d(new QVideoEncoderSettingsPrivate) | 
| 433 | { | 
| 434 | } | 
| 435 |  | 
| 436 | /*! | 
| 437 |     Constructs a copy of the video encoder settings object \a other. | 
| 438 | */ | 
| 439 |  | 
| 440 | QVideoEncoderSettings::QVideoEncoderSettings(const QVideoEncoderSettings& other) | 
| 441 |     :d(other.d) | 
| 442 | { | 
| 443 | } | 
| 444 |  | 
| 445 | /*! | 
| 446 |     Destroys a video encoder settings object. | 
| 447 | */ | 
| 448 |  | 
| 449 | QVideoEncoderSettings::~QVideoEncoderSettings() | 
| 450 | { | 
| 451 | } | 
| 452 |  | 
| 453 | /*! | 
| 454 |     Assigns the value of \a other to a video encoder settings object. | 
| 455 | */ | 
| 456 | QVideoEncoderSettings &QVideoEncoderSettings::operator=(const QVideoEncoderSettings &other) | 
| 457 | { | 
| 458 |     d = other.d; | 
| 459 |     return *this; | 
| 460 | } | 
| 461 |  | 
| 462 | /*! | 
| 463 |     Determines if \a other is of equal value to a video encoder settings object. | 
| 464 |  | 
| 465 |     Returns true if the settings objects are of equal value, and false if they | 
| 466 |     are not of equal value. | 
| 467 | */ | 
| 468 | bool QVideoEncoderSettings::operator==(const QVideoEncoderSettings &other) const | 
| 469 | { | 
| 470 |     return (d == other.d) || | 
| 471 |            (d->isNull == other.d->isNull && | 
| 472 |             d->encodingMode == other.d->encodingMode && | 
| 473 |             d->bitrate == other.d->bitrate && | 
| 474 |             d->quality == other.d->quality && | 
| 475 |             d->codec == other.d->codec && | 
| 476 |             d->resolution == other.d->resolution && | 
| 477 |             qFuzzyCompare(p1: d->frameRate, p2: other.d->frameRate) && | 
| 478 |             d->encodingOptions == other.d->encodingOptions); | 
| 479 | } | 
| 480 |  | 
| 481 | /*! | 
| 482 |     Determines if \a other is of equal value to a video encoder settings object. | 
| 483 |  | 
| 484 |     Returns true if the settings objects are not of equal value, and false if | 
| 485 |     they are of equal value. | 
| 486 | */ | 
| 487 | bool QVideoEncoderSettings::operator!=(const QVideoEncoderSettings &other) const | 
| 488 | { | 
| 489 |     return !(*this == other); | 
| 490 | } | 
| 491 |  | 
| 492 | /*! | 
| 493 |     Identifies if a video encoder settings object is uninitalized. | 
| 494 |  | 
| 495 |     Returns true if the settings are null, and false if they are not. | 
| 496 | */ | 
| 497 | bool QVideoEncoderSettings::isNull() const | 
| 498 | { | 
| 499 |     return d->isNull; | 
| 500 | } | 
| 501 |  | 
| 502 | /*! | 
| 503 |     Returns the video encoding mode. | 
| 504 |  | 
| 505 |     \sa QMultimedia::EncodingMode | 
| 506 | */ | 
| 507 | QMultimedia::EncodingMode QVideoEncoderSettings::encodingMode() const | 
| 508 | { | 
| 509 |     return d->encodingMode; | 
| 510 | } | 
| 511 |  | 
| 512 | /*! | 
| 513 |     Sets the video encoding \a mode. | 
| 514 |  | 
| 515 |     If QMultimedia::ConstantQualityEncoding is set, | 
| 516 |     the quality encoding parameter is used and bit rate is ignored, | 
| 517 |     otherwise the bitrate is used. | 
| 518 |  | 
| 519 |     The rest of encoding settings are respected regardless of encoding mode. | 
| 520 |  | 
| 521 |     \sa QMultimedia::EncodingMode | 
| 522 | */ | 
| 523 | void QVideoEncoderSettings::setEncodingMode(QMultimedia::EncodingMode mode) | 
| 524 | { | 
| 525 |     d->isNull = false; | 
| 526 |     d->encodingMode = mode; | 
| 527 | } | 
| 528 |  | 
| 529 | /*! | 
| 530 |     Returns the video codec. | 
| 531 | */ | 
| 532 |  | 
| 533 | QString QVideoEncoderSettings::codec() const | 
| 534 | { | 
| 535 |     return d->codec; | 
| 536 | } | 
| 537 |  | 
| 538 | /*! | 
| 539 |     Sets the video \a codec. | 
| 540 | */ | 
| 541 | void QVideoEncoderSettings::setCodec(const QString& codec) | 
| 542 | { | 
| 543 |     d->isNull = false; | 
| 544 |     d->codec = codec; | 
| 545 | } | 
| 546 |  | 
| 547 | /*! | 
| 548 |     Returns bit rate of the encoded video stream in bits per second. | 
| 549 | */ | 
| 550 | int QVideoEncoderSettings::bitRate() const | 
| 551 | { | 
| 552 |     return d->bitrate; | 
| 553 | } | 
| 554 |  | 
| 555 | /*! | 
| 556 |     Sets the bit rate of the encoded video stream to \a value. | 
| 557 | */ | 
| 558 |  | 
| 559 | void QVideoEncoderSettings::setBitRate(int value) | 
| 560 | { | 
| 561 |     d->isNull = false; | 
| 562 |     d->bitrate = value; | 
| 563 | } | 
| 564 |  | 
| 565 | /*! | 
| 566 |     Returns the video frame rate. | 
| 567 | */ | 
| 568 | qreal QVideoEncoderSettings::frameRate() const | 
| 569 | { | 
| 570 |     return d->frameRate; | 
| 571 | } | 
| 572 |  | 
| 573 | /*! | 
| 574 |     \fn QVideoEncoderSettings::setFrameRate(qreal rate) | 
| 575 |  | 
| 576 |     Sets the video frame \a rate. | 
| 577 |  | 
| 578 |     A value of 0 indicates the encoder should make an optimal choice based on what is available | 
| 579 |     from the video source and the limitations of the codec. | 
| 580 | */ | 
| 581 |  | 
| 582 | void QVideoEncoderSettings::setFrameRate(qreal rate) | 
| 583 | { | 
| 584 |     d->isNull = false; | 
| 585 |     d->frameRate = rate; | 
| 586 | } | 
| 587 |  | 
| 588 | /*! | 
| 589 |     Returns the resolution of the encoded video. | 
| 590 | */ | 
| 591 |  | 
| 592 | QSize QVideoEncoderSettings::resolution() const | 
| 593 | { | 
| 594 |     return d->resolution; | 
| 595 | } | 
| 596 |  | 
| 597 | /*! | 
| 598 |     Sets the \a resolution of the encoded video. | 
| 599 |  | 
| 600 |     An empty QSize indicates the encoder should make an optimal choice based on | 
| 601 |     what is available from the video source and the limitations of the codec. | 
| 602 | */ | 
| 603 |  | 
| 604 | void QVideoEncoderSettings::setResolution(const QSize &resolution) | 
| 605 | { | 
| 606 |     d->isNull = false; | 
| 607 |     d->resolution = resolution; | 
| 608 | } | 
| 609 |  | 
| 610 | /*! | 
| 611 |     Sets the \a width and \a height of the resolution of the encoded video. | 
| 612 |  | 
| 613 |     \overload | 
| 614 | */ | 
| 615 |  | 
| 616 | void QVideoEncoderSettings::setResolution(int width, int height) | 
| 617 | { | 
| 618 |     d->isNull = false; | 
| 619 |     d->resolution = QSize(width, height); | 
| 620 | } | 
| 621 |  | 
| 622 | /*! | 
| 623 |     Returns the video encoding quality. | 
| 624 | */ | 
| 625 |  | 
| 626 | QMultimedia::EncodingQuality QVideoEncoderSettings::quality() const | 
| 627 | { | 
| 628 |     return d->quality; | 
| 629 | } | 
| 630 |  | 
| 631 | /*! | 
| 632 |     Sets the video encoding \a quality. | 
| 633 |  | 
| 634 |     Setting the video quality parameter allows backend to choose the balanced | 
| 635 |     set of encoding parameters to achieve the desired quality level. | 
| 636 |  | 
| 637 |     The \a quality settings parameter is only used in the | 
| 638 |     \l {QMultimedia::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}. | 
| 639 |     The \a quality settings parameter is only used in the \l | 
| 640 |     {QMultimedia::ConstantQualityEncoding}{constant quality} | 
| 641 |     \l{encodingMode()}{encoding mode}. | 
| 642 | */ | 
| 643 |  | 
| 644 | void QVideoEncoderSettings::setQuality(QMultimedia::EncodingQuality quality) | 
| 645 | { | 
| 646 |     d->isNull = false; | 
| 647 |     d->quality = quality; | 
| 648 | } | 
| 649 |  | 
| 650 | /*! | 
| 651 |     Returns the value of encoding \a option. | 
| 652 |  | 
| 653 |     \sa setEncodingOption(), encodingOptions() | 
| 654 | */ | 
| 655 | QVariant QVideoEncoderSettings::encodingOption(const QString &option) const | 
| 656 | { | 
| 657 |     return d->encodingOptions.value(akey: option); | 
| 658 | } | 
| 659 |  | 
| 660 | /*! | 
| 661 |     Returns the all the encoding options as QVariantMap. | 
| 662 |  | 
| 663 |     \sa encodingOption(), setEncodingOptions() | 
| 664 | */ | 
| 665 | QVariantMap QVideoEncoderSettings::encodingOptions() const | 
| 666 | { | 
| 667 |     return d->encodingOptions; | 
| 668 | } | 
| 669 |  | 
| 670 | /*! | 
| 671 |     Set the encoding \a option \a value. | 
| 672 |  | 
| 673 |     The supported set and meaning of encoding options are | 
| 674 |     system and selected codec specific. | 
| 675 |  | 
| 676 |     \sa encodingOption(), setEncodingOptions() | 
| 677 | */ | 
| 678 | void QVideoEncoderSettings::setEncodingOption(const QString &option, const QVariant &value) | 
| 679 | { | 
| 680 |     d->isNull = false; | 
| 681 |     if (value.isNull()) | 
| 682 |         d->encodingOptions.remove(akey: option); | 
| 683 |     else | 
| 684 |         d->encodingOptions.insert(akey: option, avalue: value); | 
| 685 | } | 
| 686 |  | 
| 687 | /*! | 
| 688 |     Replace all the encoding options with \a options. | 
| 689 |  | 
| 690 |     The supported set and meaning of encoding options are | 
| 691 |     system and selected codec specific. | 
| 692 |  | 
| 693 |     \sa encodingOption(), setEncodingOption() | 
| 694 | */ | 
| 695 | void QVideoEncoderSettings::setEncodingOptions(const QVariantMap &options) | 
| 696 | { | 
| 697 |     d->isNull = false; | 
| 698 |     d->encodingOptions = options; | 
| 699 | } | 
| 700 |  | 
| 701 |  | 
| 702 | class QImageEncoderSettingsPrivate  : public QSharedData | 
| 703 | { | 
| 704 | public: | 
| 705 |     QImageEncoderSettingsPrivate() : | 
| 706 |         isNull(true), | 
| 707 |         quality(QMultimedia::NormalQuality) | 
| 708 |     { | 
| 709 |     } | 
| 710 |  | 
| 711 |     QImageEncoderSettingsPrivate(const QImageEncoderSettingsPrivate &other): | 
| 712 |         QSharedData(other), | 
| 713 |         isNull(other.isNull), | 
| 714 |         codec(other.codec), | 
| 715 |         resolution(other.resolution), | 
| 716 |         quality(other.quality), | 
| 717 |         encodingOptions(other.encodingOptions) | 
| 718 |     { | 
| 719 |     } | 
| 720 |  | 
| 721 |     bool isNull; | 
| 722 |     QString codec; | 
| 723 |     QSize resolution; | 
| 724 |     QMultimedia::EncodingQuality quality; | 
| 725 |     QVariantMap encodingOptions; | 
| 726 |  | 
| 727 | private: | 
| 728 |     QImageEncoderSettingsPrivate& operator=(const QImageEncoderSettingsPrivate &other); | 
| 729 | }; | 
| 730 |  | 
| 731 | /*! | 
| 732 |     \class QImageEncoderSettings | 
| 733 |  | 
| 734 |  | 
| 735 |     \brief The QImageEncoderSettings class provides a set of image encoder | 
| 736 |     settings. | 
| 737 |  | 
| 738 |     \inmodule QtMultimedia | 
| 739 |     \ingroup multimedia | 
| 740 |     \ingroup multimedia_camera | 
| 741 |  | 
| 742 |     A image encoder settings object is used to specify the image encoder | 
| 743 |     settings used by QCameraImageCapture.  Image encoder settings are selected | 
| 744 |     by constructing a QImageEncoderSettings object, setting the desired | 
| 745 |     properties and then passing it to a QCameraImageCapture instance using the | 
| 746 |     QCameraImageCapture::setImageSettings() function. | 
| 747 |  | 
| 748 |     \snippet multimedia-snippets/media.cpp Image encoder settings | 
| 749 |  | 
| 750 |     \sa QImageEncoderControl | 
| 751 | */ | 
| 752 |  | 
| 753 | /*! | 
| 754 |     Constructs a null image encoder settings object. | 
| 755 | */ | 
| 756 |  | 
| 757 | QImageEncoderSettings::QImageEncoderSettings() | 
| 758 |     :d(new QImageEncoderSettingsPrivate) | 
| 759 | { | 
| 760 | } | 
| 761 |  | 
| 762 | /*! | 
| 763 |     Constructs a copy of the image encoder settings object \a other. | 
| 764 | */ | 
| 765 |  | 
| 766 | QImageEncoderSettings::QImageEncoderSettings(const QImageEncoderSettings& other) | 
| 767 |     :d(other.d) | 
| 768 | { | 
| 769 | } | 
| 770 |  | 
| 771 | /*! | 
| 772 |     Destroys a image encoder settings object. | 
| 773 | */ | 
| 774 |  | 
| 775 | QImageEncoderSettings::~QImageEncoderSettings() | 
| 776 | { | 
| 777 | } | 
| 778 |  | 
| 779 | /*! | 
| 780 |     Assigns the value of \a other to a image encoder settings object. | 
| 781 | */ | 
| 782 | QImageEncoderSettings &QImageEncoderSettings::operator=(const QImageEncoderSettings &other) | 
| 783 | { | 
| 784 |     d = other.d; | 
| 785 |     return *this; | 
| 786 | } | 
| 787 |  | 
| 788 | /*! | 
| 789 |     Determines if \a other is of equal value to a image encoder settings | 
| 790 |     object. | 
| 791 |  | 
| 792 |     Returns true if the settings objects are of equal value, and false if they | 
| 793 |     are not of equal value. | 
| 794 | */ | 
| 795 | bool QImageEncoderSettings::operator==(const QImageEncoderSettings &other) const | 
| 796 | { | 
| 797 |     return (d == other.d) || | 
| 798 |            (d->isNull == other.d->isNull && | 
| 799 |             d->quality == other.d->quality && | 
| 800 |             d->codec == other.d->codec && | 
| 801 |             d->resolution == other.d->resolution && | 
| 802 |             d->encodingOptions == other.d->encodingOptions); | 
| 803 |  | 
| 804 | } | 
| 805 |  | 
| 806 | /*! | 
| 807 |     Determines if \a other is of equal value to a image encoder settings | 
| 808 |     object. | 
| 809 |  | 
| 810 |     Returns true if the settings objects are not of equal value, and false if | 
| 811 |     they are of equal value. | 
| 812 | */ | 
| 813 | bool QImageEncoderSettings::operator!=(const QImageEncoderSettings &other) const | 
| 814 | { | 
| 815 |     return !(*this == other); | 
| 816 | } | 
| 817 |  | 
| 818 | /*! | 
| 819 |     Identifies if a image encoder settings object is uninitalized. | 
| 820 |  | 
| 821 |     Returns true if the settings are null, and false if they are not. | 
| 822 | */ | 
| 823 | bool QImageEncoderSettings::isNull() const | 
| 824 | { | 
| 825 |     return d->isNull; | 
| 826 | } | 
| 827 |  | 
| 828 | /*! | 
| 829 |     Returns the image codec. | 
| 830 | */ | 
| 831 |  | 
| 832 | QString QImageEncoderSettings::codec() const | 
| 833 | { | 
| 834 |     return d->codec; | 
| 835 | } | 
| 836 |  | 
| 837 | /*! | 
| 838 |     Sets the image \a codec. | 
| 839 | */ | 
| 840 | void QImageEncoderSettings::setCodec(const QString& codec) | 
| 841 | { | 
| 842 |     d->isNull = false; | 
| 843 |     d->codec = codec; | 
| 844 | } | 
| 845 |  | 
| 846 | /*! | 
| 847 |     Returns the resolution of the encoded image. | 
| 848 | */ | 
| 849 |  | 
| 850 | QSize QImageEncoderSettings::resolution() const | 
| 851 | { | 
| 852 |     return d->resolution; | 
| 853 | } | 
| 854 |  | 
| 855 | /*! | 
| 856 |     Sets the \a resolution of the encoded image. | 
| 857 |  | 
| 858 |     An empty QSize indicates the encoder should make an optimal choice based on | 
| 859 |     what is available from the image source and the limitations of the codec. | 
| 860 | */ | 
| 861 |  | 
| 862 | void QImageEncoderSettings::setResolution(const QSize &resolution) | 
| 863 | { | 
| 864 |     d->isNull = false; | 
| 865 |     d->resolution = resolution; | 
| 866 | } | 
| 867 |  | 
| 868 | /*! | 
| 869 |     Sets the \a width and \a height of the resolution of the encoded image. | 
| 870 |  | 
| 871 |     \overload | 
| 872 | */ | 
| 873 |  | 
| 874 | void QImageEncoderSettings::setResolution(int width, int height) | 
| 875 | { | 
| 876 |     d->isNull = false; | 
| 877 |     d->resolution = QSize(width, height); | 
| 878 | } | 
| 879 |  | 
| 880 | /*! | 
| 881 |     Returns the image encoding quality. | 
| 882 | */ | 
| 883 |  | 
| 884 | QMultimedia::EncodingQuality QImageEncoderSettings::quality() const | 
| 885 | { | 
| 886 |     return d->quality; | 
| 887 | } | 
| 888 |  | 
| 889 | /*! | 
| 890 |     Sets the image encoding \a quality. | 
| 891 | */ | 
| 892 |  | 
| 893 | void QImageEncoderSettings::setQuality(QMultimedia::EncodingQuality quality) | 
| 894 | { | 
| 895 |     d->isNull = false; | 
| 896 |     d->quality = quality; | 
| 897 | } | 
| 898 |  | 
| 899 | /*! | 
| 900 |     Returns the value of encoding \a option. | 
| 901 |  | 
| 902 |     \sa setEncodingOption(), encodingOptions() | 
| 903 | */ | 
| 904 | QVariant QImageEncoderSettings::encodingOption(const QString &option) const | 
| 905 | { | 
| 906 |     return d->encodingOptions.value(akey: option); | 
| 907 | } | 
| 908 |  | 
| 909 | /*! | 
| 910 |     Returns the all the encoding options as QVariantMap. | 
| 911 |  | 
| 912 |     \sa encodingOption(), setEncodingOptions() | 
| 913 | */ | 
| 914 | QVariantMap QImageEncoderSettings::encodingOptions() const | 
| 915 | { | 
| 916 |     return d->encodingOptions; | 
| 917 | } | 
| 918 |  | 
| 919 | /*! | 
| 920 |     Set the encoding \a option \a value. | 
| 921 |  | 
| 922 |     The supported set and meaning of encoding options are | 
| 923 |     system and selected codec specific. | 
| 924 |  | 
| 925 |     \sa encodingOption(), setEncodingOptions() | 
| 926 | */ | 
| 927 | void QImageEncoderSettings::setEncodingOption(const QString &option, const QVariant &value) | 
| 928 | { | 
| 929 |     d->isNull = false; | 
| 930 |     if (value.isNull()) | 
| 931 |         d->encodingOptions.remove(akey: option); | 
| 932 |     else | 
| 933 |         d->encodingOptions.insert(akey: option, avalue: value); | 
| 934 | } | 
| 935 |  | 
| 936 | /*! | 
| 937 |     Replace all the encoding options with \a options. | 
| 938 |  | 
| 939 |     The supported set and meaning of encoding options are | 
| 940 |     system and selected codec specific. | 
| 941 |  | 
| 942 |     \sa encodingOption(), setEncodingOption() | 
| 943 | */ | 
| 944 | void QImageEncoderSettings::setEncodingOptions(const QVariantMap &options) | 
| 945 | { | 
| 946 |     d->isNull = false; | 
| 947 |     d->encodingOptions = options; | 
| 948 | } | 
| 949 |  | 
| 950 |  | 
| 951 | QT_END_NAMESPACE | 
| 952 |  | 
| 953 |  |